forked from qt-creator/qt-creator
QmlJS: Add semantic highlighting.
Change-Id: If9293244075cff1a52801b50cdbb77248ecd21ea Reviewed-on: http://codereview.qt.nokia.com/3310 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
@@ -442,7 +442,7 @@ bool CheckSymbols::visit(NamespaceAST *ast)
|
||||
if (! tok.generated()) {
|
||||
unsigned line, column;
|
||||
getTokenStartPosition(ast->identifier_token, &line, &column);
|
||||
Use use(line, column, tok.length());
|
||||
Use use(line, column, tok.length(), SemanticInfo::TypeUse);
|
||||
addUse(use);
|
||||
}
|
||||
}
|
||||
@@ -457,7 +457,7 @@ bool CheckSymbols::visit(UsingDirectiveAST *)
|
||||
|
||||
bool CheckSymbols::visit(EnumeratorAST *ast)
|
||||
{
|
||||
addUse(ast->identifier_token, Use::Static);
|
||||
addUse(ast->identifier_token, SemanticInfo::StaticUse);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -469,7 +469,7 @@ bool CheckSymbols::visit(SimpleDeclarationAST *ast)
|
||||
if (NameAST *declId = declaratorId(ast->declarator_list->value)) {
|
||||
if (Function *funTy = decl->type()->asFunctionType()) {
|
||||
if (funTy->isVirtual()) {
|
||||
addUse(declId, Use::VirtualMethod);
|
||||
addUse(declId, SemanticInfo::VirtualMethodUse);
|
||||
} else if (maybeVirtualMethod(decl->name())) {
|
||||
addVirtualMethod(_context.lookup(decl->name(), decl->enclosingScope()), declId, funTy->argumentCount());
|
||||
}
|
||||
@@ -490,7 +490,7 @@ bool CheckSymbols::visit(ElaboratedTypeSpecifierAST *ast)
|
||||
{
|
||||
accept(ast->attribute_list);
|
||||
accept(ast->name);
|
||||
addUse(ast->name, Use::Type);
|
||||
addUse(ast->name, SemanticInfo::TypeUse);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -643,7 +643,7 @@ void CheckSymbols::checkName(NameAST *ast, Scope *scope)
|
||||
if (ast->asDestructorName() != 0) {
|
||||
Class *klass = scope->asClass();
|
||||
if (hasVirtualDestructor(_context.lookupType(klass)))
|
||||
addUse(ast, Use::VirtualMethod);
|
||||
addUse(ast, SemanticInfo::VirtualMethodUse);
|
||||
} else if (maybeType(ast->name) || maybeStatic(ast->name)) {
|
||||
const QList<LookupItem> candidates = _context.lookup(ast->name, scope);
|
||||
addTypeOrStatic(candidates, ast);
|
||||
@@ -693,7 +693,7 @@ bool CheckSymbols::visit(QualifiedNameAST *ast)
|
||||
if (NameAST *class_or_namespace_name = nested_name_specifier->class_or_namespace_name) {
|
||||
if (TemplateIdAST *template_id = class_or_namespace_name->asTemplateId()) {
|
||||
if (template_id->template_token) {
|
||||
addUse(template_id, Use::Type);
|
||||
addUse(template_id, SemanticInfo::TypeUse);
|
||||
binding = 0; // there's no way we can find a binding.
|
||||
}
|
||||
|
||||
@@ -714,7 +714,7 @@ bool CheckSymbols::visit(QualifiedNameAST *ast)
|
||||
if (binding && ast->unqualified_name) {
|
||||
if (ast->unqualified_name->asDestructorName() != 0) {
|
||||
if (hasVirtualDestructor(binding))
|
||||
addUse(ast->unqualified_name, Use::VirtualMethod);
|
||||
addUse(ast->unqualified_name, SemanticInfo::VirtualMethodUse);
|
||||
} else {
|
||||
addTypeOrStatic(binding->find(ast->unqualified_name->name), ast->unqualified_name);
|
||||
}
|
||||
@@ -729,7 +729,7 @@ bool CheckSymbols::visit(QualifiedNameAST *ast)
|
||||
|
||||
bool CheckSymbols::visit(TypenameTypeParameterAST *ast)
|
||||
{
|
||||
addUse(ast->name, Use::Type);
|
||||
addUse(ast->name, SemanticInfo::TypeUse);
|
||||
accept(ast->type_id);
|
||||
return false;
|
||||
}
|
||||
@@ -737,7 +737,7 @@ bool CheckSymbols::visit(TypenameTypeParameterAST *ast)
|
||||
bool CheckSymbols::visit(TemplateTypeParameterAST *ast)
|
||||
{
|
||||
accept(ast->template_parameter_list);
|
||||
addUse(ast->name, Use::Type);
|
||||
addUse(ast->name, SemanticInfo::TypeUse);
|
||||
accept(ast->type_id);
|
||||
return false;
|
||||
}
|
||||
@@ -775,7 +775,7 @@ bool CheckSymbols::visit(FunctionDefinitionAST *ast)
|
||||
declId = q->unqualified_name;
|
||||
|
||||
if (fun->isVirtual()) {
|
||||
addUse(declId, Use::VirtualMethod);
|
||||
addUse(declId, SemanticInfo::VirtualMethodUse);
|
||||
} else if (maybeVirtualMethod(fun->name())) {
|
||||
addVirtualMethod(_context.lookup(fun->name(), fun->enclosingScope()), declId, fun->argumentCount());
|
||||
}
|
||||
@@ -798,7 +798,7 @@ bool CheckSymbols::visit(FunctionDefinitionAST *ast)
|
||||
return false;
|
||||
}
|
||||
|
||||
void CheckSymbols::addUse(NameAST *ast, Use::Kind kind)
|
||||
void CheckSymbols::addUse(NameAST *ast, UseKind kind)
|
||||
{
|
||||
if (! ast)
|
||||
return;
|
||||
@@ -822,7 +822,7 @@ void CheckSymbols::addUse(NameAST *ast, Use::Kind kind)
|
||||
addUse(startToken, kind);
|
||||
}
|
||||
|
||||
void CheckSymbols::addUse(unsigned tokenIndex, Use::Kind kind)
|
||||
void CheckSymbols::addUse(unsigned tokenIndex, UseKind kind)
|
||||
{
|
||||
if (! tokenIndex)
|
||||
return;
|
||||
@@ -871,7 +871,7 @@ void CheckSymbols::addType(ClassOrNamespace *b, NameAST *ast)
|
||||
unsigned line, column;
|
||||
getTokenStartPosition(startToken, &line, &column);
|
||||
const unsigned length = tok.length();
|
||||
const Use use(line, column, length, Use::Type);
|
||||
const Use use(line, column, length, SemanticInfo::TypeUse);
|
||||
addUse(use);
|
||||
//qDebug() << "added use" << oo(ast->name) << line << column << length;
|
||||
}
|
||||
@@ -913,10 +913,10 @@ void CheckSymbols::addTypeOrStatic(const QList<LookupItem> &candidates, NameAST
|
||||
getTokenStartPosition(startToken, &line, &column);
|
||||
const unsigned length = tok.length();
|
||||
|
||||
Use::Kind kind = Use::Type;
|
||||
UseKind kind = SemanticInfo::TypeUse;
|
||||
|
||||
if (c->enclosingEnum() != 0)
|
||||
kind = Use::Static;
|
||||
kind = SemanticInfo::StaticUse;
|
||||
|
||||
const Use use(line, column, length, kind);
|
||||
addUse(use);
|
||||
@@ -951,7 +951,7 @@ void CheckSymbols::addClassMember(const QList<LookupItem> &candidates, NameAST *
|
||||
getTokenStartPosition(startToken, &line, &column);
|
||||
const unsigned length = tok.length();
|
||||
|
||||
const Use use(line, column, length, Use::Field);
|
||||
const Use use(line, column, length, SemanticInfo::FieldUse);
|
||||
addUse(use);
|
||||
break;
|
||||
}
|
||||
@@ -976,7 +976,7 @@ void CheckSymbols::addStatic(const QList<LookupItem> &candidates, NameAST *ast)
|
||||
getTokenStartPosition(startToken, &line, &column);
|
||||
const unsigned length = tok.length();
|
||||
|
||||
const Use use(line, column, length, Use::Static);
|
||||
const Use use(line, column, length, SemanticInfo::StaticUse);
|
||||
addUse(use);
|
||||
//qDebug() << "added use" << oo(ast->name) << line << column << length;
|
||||
break;
|
||||
@@ -1015,7 +1015,7 @@ void CheckSymbols::addVirtualMethod(const QList<LookupItem> &candidates, NameAST
|
||||
getTokenStartPosition(startToken, &line, &column);
|
||||
const unsigned length = tok.length();
|
||||
|
||||
const Use use(line, column, length, Use::VirtualMethod);
|
||||
const Use use(line, column, length, SemanticInfo::VirtualMethodUse);
|
||||
addUse(use);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user