[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdevelop/projectmanagers/cmake
From: Aleix Pol Gonzalez <aleixpol () gmail ! com>
Date: 2009-03-02 22:05:43
Message-ID: 1236031543.940202.11757.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 934375 by apol:
First documentation integration version for CMake support.
M +4 -2 CMakeLists.txt
A cmakedocumentation.cpp [License: GPL (v2+)]
A cmakedocumentation.h [License: GPL (v2+)]
M +59 -26 cmakemanager.cpp
M +5 -5 cmakemanager.h
A cmakenavigationwidget.cpp [License: GPL (v2+)]
A cmakenavigationwidget.h [License: GPL (v2+)]
M +23 -0 cmakeutils.cpp
M +4 -0 cmakeutils.h
M +24 -11 tests/cmakeduchaintest.cpp
--- trunk/KDE/kdevelop/projectmanagers/cmake/CMakeLists.txt #934374:934375
@@ -10,7 +10,7 @@
# the debug visitor prints out the Ast for the CMakeLists.txt file.
#add_definitions( -DCMAKEDEBUGVISITOR )
-add_definitions( -DKDE_DEFAULT_DEBUG_AREA=9032 )
+add_definitions( -DKDE_DEFAULT_DEBUG_AREA=9042 )
set( cmakecommon_SRCS
parser/cmListFileLexer.c
@@ -31,7 +31,9 @@
cmakebuilddirchooser.ui
)
-set( cmakemanager_SRCS
+set( cmakemanager_SRCS
+ cmakenavigationwidget.cpp
+ cmakedocumentation.cpp
cmakemodelitems.cpp
cmakemanager.cpp
cmakehighlighting.cpp
--- trunk/KDE/kdevelop/projectmanagers/cmake/cmakemanager.cpp #934374:934375
@@ -1,7 +1,7 @@
/* KDevelop CMake Support
*
* Copyright 2006 Matt Rogers <mattr@kde.org>
- * Copyright 2007-2008 Aleix Pol <aleixpol@gmail.com>
+ * Copyright 2007-2009 Aleix Pol <aleixpol@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -63,7 +63,9 @@
#include "applychangeswidget.h"
#include "cmakeconfig.h"
+#include "cmakedocumentation.h"
#include "cmakemodelitems.h"
+#include "cmakenavigationwidget.h"
#include "cmakehighlighting.h"
#include "cmakecachereader.h"
#include "cmakeastvisitor.h"
@@ -90,28 +92,6 @@
namespace {
-QString executeProcess(const QString& execName, const QStringList& \
args=QStringList())
-{
- kDebug(9042) << "Executing:" << execName << "::" << args /*<< "into" << \
*m_vars*/;
-
- KProcess p;
- p.setOutputChannelMode(KProcess::MergedChannels);
- p.setProgram(execName, args);
- p.start();
-
- if(!p.waitForFinished())
- {
- kDebug() << "failed to execute:" << execName;
- }
-
- QByteArray b = p.readAllStandardOutput();
- QString t;
- t.prepend(b.trimmed());
- kDebug(9042) << "executed" << execName << "<" << t;
-
- return t;
-}
-
QString fetchBuildDir(KDevelop::IProject* project)
{
Q_ASSERT(project);
@@ -203,9 +183,9 @@
cmakeInitScripts << "CMakeUnixFindMake.cmake";
#endif
cmakeInitScripts << "CMakeDetermineSystem.cmake";
+ cmakeInitScripts << "CMakeSystemSpecificInformation.cmake";
cmakeInitScripts << "CMakeDetermineCCompiler.cmake";
cmakeInitScripts << "CMakeDetermineCXXCompiler.cmake";
- cmakeInitScripts << "CMakeSystemSpecificInformation.cmake";
m_varsDef.insert("CMAKE_MODULE_PATH", m_modulePathDef);
@@ -223,11 +203,14 @@
m_varsDef.insert("CMAKE_HOST_APPLE", QStringList("1"));
#endif
+ m_doc=new CMakeDocumentation(cmakeCmd);
kDebug(9042) << "modPath" << m_varsDef.value("CMAKE_MODULE_PATH") << \
m_modulePathDef; }
CMakeProjectManager::~CMakeProjectManager()
-{}
+{
+ delete m_doc;
+}
KUrl CMakeProjectManager::buildDirectory(const KDevelop::ProjectBaseItem *item) \
const {
@@ -715,7 +698,7 @@
QString ret;
KUrl bin(guessCMakeShare(cmakeBin));
- QString version=executeProcess(cmakeBin, QStringList("--version"));
+ QString version=CMake::executeProcess(cmakeBin, QStringList("--version"));
QRegExp rx("[a-z* ]*([0-9.]*)-[0-9]*");
rx.indexIn(version);
QString versionNumber = rx.capturedTexts()[1];
@@ -1165,4 +1148,54 @@
return ret;
}
+QWidget* CMakeProjectManager::specialLanguageObjectNavigationWidget(const KUrl& url, \
const KDevelop::SimpleCursor& position) +{
+ KDevelop::TopDUContextPointer top= \
TopDUContextPointer(KDevelop::DUChain::self()->chainForDocument(url)); + \
Declaration *decl=0; + QString htmlDoc;
+ if(top)
+ {
+ int useAt=top->findUseAt(position);
+ if(useAt>=0)
+ {
+ Use u=top->uses()[useAt];
+ decl=u.usedDeclaration(top->topContext());
+ }
+ }
+
+ if(decl)
+ {
+ QString id=decl->identifier().toString();
+ QString desc=m_doc->description(decl);
+ if(desc.isEmpty()) {
+ CMakeNavigationWidget* doc=new CMakeNavigationWidget(top, decl);
+ return doc;
+ } else {
+ CMakeNavigationWidget* doc=new CMakeNavigationWidget(top, id, desc);
+ return doc;
+ }
+ }
+ else
+ {
+ const IDocument* d=ICore::self()->documentController()->documentForUrl(url);
+ const KTextEditor::Document* e=d->textDocument();
+ KTextEditor::Cursor start=position.textCursor(), end=position.textCursor(), \
step(0,1); + for(QChar i=e->character(start); i.isLetter() || i=='_'; \
i=e->character(start-=step)) + {}
+ start+=step;
+
+ for(QChar i=e->character(end); i.isLetter() || i=='_'; \
i=e->character(end+=step)) + {}
+
+ QString id=e->text(KTextEditor::Range(start, end));
+ QString desc=m_doc->description(id);
+ if(!desc.isEmpty())
+ {
+ CMakeNavigationWidget* doc=new CMakeNavigationWidget(top, id, desc);
+ return doc;
+ }
+ }
+ return 0;
+}
+
#include "cmakemanager.moc"
--- trunk/KDE/kdevelop/projectmanagers/cmake/cmakemanager.h #934374:934375
@@ -1,7 +1,7 @@
/* KDevelop CMake Support
*
* Copyright 2006 Matt Rogers <mattr@kde.org>
- * Copyright 2007-2008 Aleix Pol <aleixpol@gmail.com>
+ * Copyright 2007-2009 Aleix Pol <aleixpol@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -38,6 +38,7 @@
class QDir;
class QObject;
class CMakeHighlighting;
+class CMakeDocumentation;
namespace KDevelop
{
@@ -103,12 +104,10 @@
//LanguageSupport
virtual QString name() const;
-
virtual KDevelop::ParseJob *createParseJob(const KUrl &url);
-
virtual KDevelop::ILanguage *language();
-
virtual const KDevelop::ICodeHighlighting* codeHighlighting() const;
+ virtual QWidget* specialLanguageObjectNavigationWidget(const KUrl& url, const \
KDevelop::SimpleCursor& position);
public slots:
void dirtyFile(const QString& file);
@@ -127,7 +126,8 @@
KDevelop::ReferencedTopDUContext includeScript(const QString& File, \
KDevelop::IProject * project,
KDevelop::ReferencedTopDUContext \
parent);
-
+
+ CMakeDocumentation* m_doc;
VariableMap m_varsDef;
QStringList m_modulePathDef;
QMap<KDevelop::IProject*, QStringList> m_modulePathPerProject;
--- trunk/KDE/kdevelop/projectmanagers/cmake/cmakeutils.cpp #934374:934375
@@ -29,6 +29,7 @@
#include <kparts/mainwindow.h>
#include <kdialog.h>
#include <kdebug.h>
+#include <kprocess.h>
#include <kstandarddirs.h>
#include <project/projectmodel.h>
@@ -139,5 +140,27 @@
cmakeGrp.sync();
}
+QString executeProcess(const QString& execName, const QStringList& args)
+{
+ kDebug(9042) << "Executing:" << execName << "::" << args /*<< "into" << \
*m_vars*/; +
+ KProcess p;
+ p.setOutputChannelMode(KProcess::MergedChannels);
+ p.setProgram(execName, args);
+ p.start();
+
+ if(!p.waitForFinished())
+ {
+ kDebug() << "failed to execute:" << execName;
+ }
+
+ QByteArray b = p.readAllStandardOutput();
+ QString t;
+ t.prepend(b.trimmed());
+ kDebug(9042) << "executed" << execName << "<" << t;
+
+ return t;
}
+}
+
--- trunk/KDE/kdevelop/projectmanagers/cmake/cmakeutils.h #934374:934375
@@ -22,6 +22,7 @@
#define CMAKEUTILS_H
#include "cmakeexport.h"
+#include <QStringList>
namespace KDevelop
{
@@ -83,6 +84,9 @@
* Sets the current build dir for the given project.
*/
KDEVCMAKECOMMON_EXPORT void setCurrentBuildDir( KDevelop::IProject* project, \
const KUrl& url ); +
+ /** Runs the process specified by @p execName with @p args */
+ KDEVCMAKECOMMON_EXPORT QString executeProcess(const QString& execName, const \
QStringList& args=QStringList()); }
#endif
--- trunk/KDE/kdevelop/projectmanagers/cmake/tests/cmakeduchaintest.cpp \
#934374:934375 @@ -106,10 +106,10 @@
// v.setModulePath();
v.walk(code, 0);
- DUChainWriteLocker lock(DUChain::lock());
- TopDUContext* ctx=v.context();
+ ReferencedTopDUContext ctx=v.context();
QVERIFY(ctx);
+ DUChainWriteLocker lock(DUChain::lock());
QVector<Declaration*> declarations=ctx->localDeclarations();
/*for(int i=0; i<declarations.count(); i++)
{
@@ -127,9 +127,9 @@
{
if(declarations[i]->range()==sr)
found=true;
- else
- qDebug() << "diff " << declarations[i]->range().start.column << \
declarations[i]->range().end.column
- << declarations[i]->range().end.line;
+// else
+// qDebug() << "diff " << declarations[i]->range().start.column << \
declarations[i]->range().end.column +// << \
declarations[i]->range().end.line; }
if(!found)
qDebug() << "doesn't exist " << sr.start.column << sr.end.column;
@@ -173,6 +173,13 @@
QTest::newRow("conditional") << input[3] << QStringList("var")
<< (QList<SimpleRange>() << SimpleRange(1,3, 1,3+3) << SimpleRange(3,6, \
3,6+3)); +
+ QTest::newRow("included_macro") <<
+ "set(CMAKE_MODULE_PATH .)\n"
+ "include(included)\n"
+ "mymacro(33)\nmessage(STATUS 33)\n"
+ << QStringList("CMAKE_MODULE_PATH")
+ << (QList<SimpleRange>() << SimpleRange(2,0, 2,0+7));
}
void CMakeDUChainTest::testUses()
@@ -203,7 +210,11 @@
}
ReferencedTopDUContext m_fakeContext=new \
TopDUContext(IndexedString(file.fileName()), SimpleRange(0,0, endl, endc));
- QString inputIncluded="set(avalue 33)\n";
+ QString inputIncluded=
+ "set(avalue 33)\n"
+ "macro(mymacro kk)\n"
+ "message(STATUS hello ${kk})\n"
+ "endmacro(mymacro)\n";
QFile includedFile("included.cmake");
QVERIFY(includedFile.open(QIODevice::WriteOnly | QIODevice::Text));
@@ -236,7 +247,7 @@
// if(decls.count() != declarations.count())
// {
-// for(int i=0; i<decls.count(); i++) {
+// for(int i=0; i<declarations.count(); i++) {
// qDebug() << "decl" << declarations[i]->toString();
// }
// }
@@ -257,14 +268,16 @@
QCOMPARE(ctx->usesCount(), uses.count());
for(int i=0; i<ctx->usesCount(); i++)
{
- qDebug() << "use" << i << ctx->uses()[i].m_range.textRange() << \
uses[i].textRange()
- << \
ctx->usedDeclarationForIndex(ctx->uses()[i].m_declarationIndex)->identifier().toString();
- QCOMPARE(uses[i], ctx->uses()[i].m_range);
+ Use u=ctx->uses()[i];
+ qDebug() << "use" << i << u.m_range.textRange() << uses[i].textRange()
+ << u.usedDeclaration(ctx)->toString();
+ QCOMPARE(uses[i], u.m_range);
}
+
+ DUChain::self()->removeDocumentChain(m_fakeContext);
includedFile.remove();
file.remove();
- DUChain::self()->removeDocumentChain(m_fakeContext);
}
#include "cmakeduchaintest.moc"
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic