Fixed more build errors and bugs · mcanes/kdevelop-python@6907049 · GitHub
Skip to content

Commit 6907049

Browse files
committed
Fixed more build errors and bugs
1 parent dbf2e61 commit 6907049

12 files changed

Lines changed: 91 additions & 20 deletions

‎duchain/contextbuilder.cpp‎

Lines changed: 13 additions & 1 deletion

‎duchain/contextbuilder.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828

2929
#include <language/duchain/builders/abstractcontextbuilder.h>
3030
#include <language/editor/rangeinrevision.h>
31+
#include <language/duchain/topducontext.h>
3132

3233
#include "pythonduchainexport.h"
3334

35+
using namespace KDevelop;
3436

3537
namespace Python
3638
{
@@ -66,6 +68,8 @@ class KDEVPYTHONDUCHAIN_EXPORT ContextBuilder: public ContextBuilderBase, public
6668
virtual void visitTry( TryAst* node );
6769

6870
PythonEditorIntegrator *m_editor;
71+
72+
TopDUContext* newTopContext(const RangeInRevision& range, ParsingEnvironmentFile* file);
6973

7074
template <typename T> void visitNodeList( const QList<T*>& l )
7175
{

‎duchain/declarationbuilder.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ void DeclarationBuilder::closeDeclaration()
105105
void DeclarationBuilder::visitIdentifierTarget(IdentifierTargetAst* node)
106106
{
107107
Python::AstDefaultVisitor::visitIdentifierTarget(node);
108+
108109
openDeclaration<Declaration>( node->identifier, node);
109110
closeDeclaration();
110111
}

‎duchain/pythoneditorintegrator.cpp‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,40 @@ PythonEditorIntegrator::~PythonEditorIntegrator()
4343
{
4444
}
4545

46-
Cursor PythonEditorIntegrator::findPosition( Ast* node , Edge edge ) const
46+
ParseSession* PythonEditorIntegrator::parseSession() const
47+
{
48+
return m_session;
49+
}
50+
51+
void PythonEditorIntegrator::setParseSession(ParseSession* session)
52+
{
53+
m_session = session;
54+
}
55+
56+
57+
CursorInRevision PythonEditorIntegrator::findPosition( Ast* node , Edge edge ) const
4758
{
4859
if ( edge == BackEdge )
4960
{
5061
// Apparently KTE expects a range to go until _after_ the last character that should be included
5162
// however the parser calculates endCol as the index _before_ the last included character, so adjust here
52-
return Cursor( node->endLine, node->endCol+1 );
63+
return CursorInRevision( node->endLine, node->endCol+1 );
5364
}else
5465
{
55-
return Cursor( node->startLine, node->startCol );
66+
return CursorInRevision( node->startLine, node->startCol );
5667
}
5768
}
5869

59-
Range PythonEditorIntegrator::findRange( Ast * node, RangeEdge edge )
70+
RangeInRevision PythonEditorIntegrator::findRange( Ast * node, RangeEdge edge )
6071
{
6172
Q_UNUSED( edge );
6273
kDebug() << "Finding Range ==================";
63-
return Range( findPosition( node, FrontEdge ), findPosition( node, BackEdge ) );
74+
return RangeInRevision( findPosition( node, FrontEdge ), findPosition( node, BackEdge ) );
6475
}
6576

66-
Range PythonEditorIntegrator::findRange( Ast* from, Ast* to )
77+
RangeInRevision PythonEditorIntegrator::findRange( Ast* from, Ast* to )
6778
{
68-
return Range( findPosition( from, FrontEdge ), findPosition( to, BackEdge ) );
79+
return RangeInRevision( findPosition( from, FrontEdge ), findPosition( to, BackEdge ) );
6980
}
7081

7182
}

‎duchain/pythoneditorintegrator.h‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "pythonduchainexport.h"
2727
#include <language/editor/documentrange.h>
2828
#include <language/editor/documentrangeobject.h>
29+
#include "parsesession.h"
2930

3031
namespace Python
3132
{
@@ -38,6 +39,9 @@ class KDEVPYTHONDUCHAIN_EXPORT PythonEditorIntegrator
3839
public:
3940
PythonEditorIntegrator();
4041
~PythonEditorIntegrator();
42+
43+
ParseSession* parseSession() const;
44+
void setParseSession(ParseSession* session);
4145

4246
enum Edge {
4347
FrontEdge,
@@ -49,12 +53,13 @@ class KDEVPYTHONDUCHAIN_EXPORT PythonEditorIntegrator
4953
OuterEdge
5054
};
5155

52-
KTextEditor::Cursor findPosition( Ast* node, Edge edge = BackEdge ) const;
56+
CursorInRevision findPosition( Python::Ast* node, Python::PythonEditorIntegrator::Edge edge = BackEdge ) const;
5357

54-
KTextEditor::Range findRange( Ast* node, RangeEdge = OuterEdge );
55-
KTextEditor::Range findRange( Ast* from, Python::Ast* to );
58+
RangeInRevision findRange( Python::Ast* node, Python::PythonEditorIntegrator::RangeEdge edge = OuterEdge );
59+
RangeInRevision findRange( Python::Ast* from, Python::Ast* to );
5660

5761
private:
62+
ParseSession* m_session;
5863
};
5964

6065
}

‎kdevpythonsupport.desktop‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ GenericName[x-test]=xxPython Supportxx
7474
ServiceTypes=KDevelop/Plugin
7575
Icon=source
7676
X-KDE-Library=kdevpythonlanguagesupport
77-
X-KDevelop-Version=10
77+
X-KDevelop-Version=11
7878
X-KDevelop-Language=Python
7979
X-KDevelop-Args=PYTHON
8080
X-KDevelop-Interfaces=ILanguageSupport

‎parser/CMakeLists.txt‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,19 @@ set( parser_SRCS
3838
#add_subdirectory(tests)
3939

4040
kde4_add_library( kdev4pythonparser SHARED ${parser_SRCS} ${parser_STAT_SRCS} )
41-
target_link_libraries( kdev4pythonparser ${KDE4_KDECORE_LIBS} )
41+
target_link_libraries(
42+
kdev4pythonparser
43+
${KDE4_KDECORE_LIBS}
44+
${KDEVPLATFORM_LANGUAGE_LIBRARIES}
45+
)
4246

4347
kde4_add_executable( python-parser main.cpp )
4448

45-
target_link_libraries(python-parser ${QT_QTCORE_LIBRARY} kdev4pythonparser)
49+
target_link_libraries(
50+
python-parser
51+
${QT_QTCORE_LIBRARY}
52+
kdev4pythonparser
53+
)
4654

4755
install(TARGETS python-parser ${INSTALL_TARGETS_DEFAULT_ARGS})
4856
install(TARGETS kdev4pythonparser DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS})

‎parser/parsesession.cpp‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#include <kdebug.h>
2626

2727
#include "pythondriver.h"
28+
#include <language/duchain/indexedstring.h>
29+
30+
using namespace KDevelop;
2831

2932
namespace Python
3033
{
@@ -36,6 +39,17 @@ ParseSession::~ParseSession()
3639
{
3740
}
3841

42+
void ParseSession::setCurrentDocument(IndexedString filename)
43+
{
44+
m_currentDocument = filename;
45+
}
46+
47+
IndexedString ParseSession::currentDocument()
48+
{
49+
return m_currentDocument;
50+
}
51+
52+
3953
QString ParseSession::contents() const
4054
{
4155
return m_contents;

‎parser/parsesession.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#define PYTHON_PARSESESSION_H
2626
#include <QtCore/QString>
2727
#include "parserexport.h"
28+
#include <language/duchain/indexedstring.h>
29+
30+
using namespace KDevelop;
2831

2932
namespace Python
3033
{
@@ -39,10 +42,14 @@ class KDEVPYTHONPARSER_EXPORT ParseSession
3942

4043
void setContents( const QString& contents );
4144
QString contents() const;
45+
46+
void setCurrentDocument(IndexedString filename);
47+
IndexedString currentDocument();
4248

4349
bool parse( Python::CodeAst** );
4450
private:
4551
QString m_contents;
52+
IndexedString m_currentDocument;
4653

4754
};
4855

‎pythonlanguagesupport.cpp‎

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)