[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdevelop/plugins/managers/cmake
From: Aleix Pol Gonzalez <aleixpol () gmail ! com>
Date: 2008-11-30 21:27:40
Message-ID: 1228080460.313840.29063.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 891002 by apol:
improved the cmake highlighting. now the uses are highlighted
M +59 -13 cmakehighlighting.cpp
M +5 -2 cmakehighlighting.h
M +1 -1 parser/cmakelistsparser.cpp
--- trunk/KDE/kdevelop/plugins/managers/cmake/cmakehighlighting.cpp #891001:891002
@@ -24,6 +24,8 @@
#include "cmakehighlighting.h"
#include <ktexteditor/smartrange.h>
+#include <ktexteditor/smartinterface.h>
+#include <ktexteditor/document.h>
#include <language/duchain/topducontext.h>
#include <language/duchain/declaration.h>
@@ -34,6 +36,8 @@
using namespace KTextEditor;
using namespace KDevelop;
+#define LOCK_SMART(range) KTextEditor::SmartInterface* iface = \
dynamic_cast<KTextEditor::SmartInterface*>(range->document()); QMutexLocker \
lock(iface ? iface->smartMutex() : 0); +
CMakeHighlighting::CMakeHighlighting( QObject * parent )
: QObject(parent)
{
@@ -43,40 +47,65 @@
{
}
-KTextEditor::Attribute::Ptr CMakeHighlighting::attributeForType( Types type, \
Contexts context ) const +KTextEditor::Attribute::Ptr \
CMakeHighlighting::attributeForType( Types type, Contexts ctx) const {
KTextEditor::Attribute::Ptr a;
- a = m_definitionAttributes[type];
+ switch (ctx)
+ {
+ case DefinitionContext:
+ a = m_definitionAttributes[type];
+ break;
+
+ case DeclarationContext:
+ a = m_declarationAttributes[type];
+ break;
+
+ case ReferenceContext:
+ a = m_referenceAttributes[type];
+ break;
+ }
+
if (!a)
{
a = KTextEditor::Attribute::Ptr(new KTextEditor::Attribute());
a->setBackgroundFillWhitespace(true);
- m_definitionAttributes.insert(type, a);
+
+ QColor c;
switch (type)
{
case NamespaceType:
- a->setBackground(QColor(Qt::green).light(170));
+ c=QColor(Qt::green);
break;
case ClassType:
- a->setBackground(QColor(Qt::blue).light(175));
+ c=QColor(Qt::blue);
break;
case FunctionType:
- a->setBackground(QColor(Qt::green).light(175));
+ c=QColor(Qt::green);
break;
case FunctionVariableType:
- a->setBackground(QColor(Qt::blue).light(175));
+ c=QColor(Qt::blue);
break;
case NamespaceVariableType:
- a->setBackground(QColor(Qt::red).light(175));
+ c=QColor(Qt::red);
break;
case ClassVariableType:
- a->setBackground(QColor(Qt::green).light(165));
+ c=QColor(Qt::green);
break;
default:
- a->setBackground(QColor(Qt::green).light(175));
+ c=QColor(Qt::green);
break;
}
- a->setFontBold();
+ if(ctx==ReferenceContext)
+ {
+ a->setForeground(c.dark());
+ m_referenceAttributes.insert(type, a);
+ }
+ else
+ {
+ a->setBackground(c.light(170));
+ a->setFontBold();
+ m_definitionAttributes.insert(type, a);
+ }
}
return a;
}
@@ -112,7 +141,12 @@
}
kDebug() << "Highlighting declarations:" << context->localDeclarations();
foreach (Declaration* dec, context->localDeclarations())
+ {
highlightDeclaration(dec);
+ }
+
+ highlightUses(context);
+
kDebug() << "Highlighting child contexts:" << context->childContexts();
foreach (DUContext* child, context->childContexts())
highlightDUChain(child);
@@ -121,7 +155,7 @@
CMakeHighlighting::Types CMakeHighlighting::typeForDeclaration(Declaration * dec) \
const {
- Types type;
+ Types type=ErrorVariableType;
switch (dec->context()->type())
{
case DUContext::Class:
@@ -145,8 +179,20 @@
range->setAttribute(attributeForType(typeForDeclaration(declaration), \
DeclarationContext)); }
-void CMakeHighlighting::highlightUses(KDevelop::DUContext* ) const
+void CMakeHighlighting::highlightUses(KDevelop::DUContext* context) const
{
+ for(int i=0; i<context->usesCount(); i++)
+ {
+ if (SmartRange* range = context->useSmartRange(i)) {
+ Types type = ErrorVariableType;
+ Declaration* decl = \
context->topContext()->usedDeclarationForIndex(context->uses()[i].m_declarationIndex);
+ if (decl)
+ type = typeForDeclaration(decl);
+
+ LOCK_SMART(range);
+ range->setAttribute(attributeForType(type, ReferenceContext));
+ }
+ }
}
#include "cmakehighlighting.moc"
--- trunk/KDE/kdevelop/plugins/managers/cmake/cmakehighlighting.h #891001:891002
@@ -54,13 +54,15 @@
NamespaceType,
FunctionVariableType,
ClassVariableType,
- NamespaceVariableType
+ NamespaceVariableType,
+ ErrorVariableType
};
enum Contexts
{
DefinitionContext,
DeclarationContext,
- NamespaceContext
+ NamespaceContext,
+ ReferenceContext
};
CMakeHighlighting(QObject* parent);
virtual ~CMakeHighlighting();
@@ -79,6 +81,7 @@
mutable QHash<Types, KTextEditor::Attribute::Ptr> m_definitionAttributes;
mutable QHash<Types, KTextEditor::Attribute::Ptr> m_declarationAttributes;
+ mutable QHash<Types, KTextEditor::Attribute::Ptr> m_referenceAttributes;
};
#endif
--- trunk/KDE/kdevelop/plugins/managers/cmake/parser/cmakelistsparser.cpp \
#891001:891002 @@ -370,7 +370,7 @@
}
else if(token->type == cmListFileLexer_Token_ArgumentQuoted)
{
- CMakeFunctionArgument a( token->text, true, fileName, token->line, \
token->column ); + CMakeFunctionArgument a( token->text, true, fileName, \
token->line, token->column+1 ); func.arguments << a;
}
else if(token->type != cmListFileLexer_Token_Newline)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic