See More

/***************************************************************************** * Copyright (c) 2007 Piyush verma * * Copyright 2007 Andreas Pakulat * * * * Permission is hereby granted, free of charge, to any person obtaining * * a copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, sublicense, and/or sell copies of the Software, and to * * permit persons to whom the Software is furnished to do so, subject to * * the following conditions: * * * * The above copyright notice and this permission notice shall be * * included in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * *****************************************************************************/ #ifndef CONTEXTBUILDER_H #define CONTEXTBUILDER_H #include "astdefaultvisitor.h" #include #include #include #include "pythonduchainexport.h" using namespace KDevelop; namespace Python { class PythonEditorIntegrator; class ParseSession; typedef KDevelop::AbstractContextBuilder ContextBuilderBase; class KDEVPYTHONDUCHAIN_EXPORT ContextBuilder: public ContextBuilderBase, public Python::AstDefaultVisitor { public: void setEditor(PythonEditorIntegrator* editor); void setEditor(ParseSession* session); protected: PythonEditorIntegrator* editor() const; virtual void startVisiting( Ast* node ); virtual void setContextOnNode( Ast* node, KDevelop::DUContext* context ); virtual KDevelop::DUContext* contextFromNode( Ast* node ); virtual KDevelop::RangeInRevision editorFindRange( Ast* fromNode, Ast* toNode ); virtual KDevelop::QualifiedIdentifier identifierForNode( Identifier* node ); void addImportedContexts(); virtual void visitFunctionDefinition( FunctionDefinitionAst* ); virtual void visitClassDefinition( ClassDefinitionAst* ); virtual void visitFor( ForAst* node ); virtual void visitWith( WithAst* node ); virtual void visitWhile( WhileAst* node ); virtual void visitIf( IfAst* node ); virtual void visitArguments(ArgumentsAst* node); static PythonEditorIntegrator* m_editor; TopDUContext* newTopContext(const RangeInRevision& range, ParsingEnvironmentFile* file); template void visitNodeList( const QList& l ) { typename QList::ConstIterator it, end = l.end(); for ( it = l.begin(); it != end; ++it ) { visitNode(( *it ) ); } } bool m_mapAst; ReferencedTopDUContext m_topContext; private: void openContextForStatementList( const QList& ); QList<:ducontext> m_importedParentContexts; }; } #endif