11/* ****************************************************************************
22 * Copyright (c) 2007 Piyush verma <piyush.verma@gmail.com> *
3- * Copyright 2007 Andreas Pakulat <apaku@gmx.de> *
3+ * Copyright 2007 Andreas Pakulat <apaku@gmx.de> *
4+ * Copyright 2010 Sven Brauch <svenbrauch@googlemail.com> *
45 * *
56 * Permission is hereby granted, free of charge, to any person obtaining *
67 * a copy of this software and associated documentation files (the *
3940#include < language/duchain/types/unsuretype.h>
4041#include < language/duchain/builders/abstracttypebuilder.h>
4142
43+ #include " contextbuilder.h"
44+
4245#include " pythoneditorintegrator.h"
4346#include " QtGlobal"
4447
@@ -115,9 +118,16 @@ Declaration* DeclarationBuilder::visitVariableDeclaration(Identifier* node, Ast*
115118 dec->setType (IntegralType::Ptr (new IntegralType (IntegralType::TypeMixed)));
116119 }
117120 else kDebug () << " Not updating existing declaration for " << node->value ;
121+ // dec->setType<>();
118122 return dec;
119123}
120124
125+ void DeclarationBuilder::visitExceptionHandler (ExceptionHandlerAst* node)
126+ {
127+ if ( node->name ) visitVariableDeclaration (node->name ); // except Error as <vardecl>
128+ Python::AstDefaultVisitor::visitExceptionHandler (node);
129+ }
130+
121131void DeclarationBuilder::visitFor (ForAst* node)
122132{
123133 if ( node->target ->astType == Ast::NameAstType ) visitVariableDeclaration (node->target );
@@ -131,10 +141,14 @@ void DeclarationBuilder::visitFor(ForAst* node)
131141
132142void DeclarationBuilder::visitImport (ImportAst* node)
133143{
134- Python::AstDefaultVisitor ::visitImport (node);
144+ Python::ContextBuilder ::visitImport (node);
135145 foreach ( AliasAst* name, node->names ) {
146+ TopDUContextPointer contextptr = contextsForModules.value (name->asName ? name->asName ->identifier ->value : name->name ->value );
147+ kDebug () << " Chain for document: " << contextptr;
148+ m_importContextsForImportStatement.push (contextptr);
136149 if ( name->asName ) visitVariableDeclaration (name->asName );
137150 else visitVariableDeclaration (name->name );
151+ m_importContextsForImportStatement.clear ();
138152 }
139153}
140154
@@ -230,6 +244,17 @@ void DeclarationBuilder::visitLambda( LambdaAst* node )
230244// closeDeclaration();
231245}
232246
247+ void DeclarationBuilder::visitCall (CallAst* node)
248+ {
249+ foreach ( ExpressionAst* currentArgument, node->arguments ) {
250+ NameAst* realArgument = dynamic_cast <NameAst*>(currentArgument);
251+ if ( realArgument ) {
252+ visitVariableDeclaration (realArgument); // some_func(<arg1>, <arg2>)
253+ }
254+ }
255+ Python::AstDefaultVisitor::visitCall (node);
256+ }
257+
233258void DeclarationBuilder::visitArguments ( ArgumentsAst* node )
234259{
235260 AbstractFunctionDeclaration* function = dynamic_cast <AbstractFunctionDeclaration*>(currentDeclaration ());
0 commit comments