@@ -67,28 +67,6 @@ DeclarationBuilder:: ~DeclarationBuilder()
6767{
6868}
6969
70- // This is not used anywhere and causes build errors, so... bye.
71- /*
72- template<class DeclarationType>
73- DeclarationType* DeclarationBuilder::specialDeclaration( KTextEditor::SmartRange* smartRange,
74- const KDevelop::SimpleRange& range )
75- {
76- DeclarationType* ret = new DeclarationType( m_editor->currentUrl(), range, currentContext() );
77- ret->setSmartRange( smartRange );
78- return ret;
79- }
80-
81- template<class DeclarationType>
82- DeclarationType* DeclarationBuilder::specialDeclaration( KTextEditor::SmartRange* smartRange,
83- const KDevelop::SimpleRange& range,
84- int scope )
85- {
86- DeclarationType* ret = new DeclarationType( m_editor->currentUrl(), range, currentContext() );
87- ret->setSmartRange( smartRange );
88- return ret;
89- }
90- */
91-
9270void DeclarationBuilder::closeDeclaration ()
9371{
9472 if ( lastContext () )
@@ -102,47 +80,47 @@ void DeclarationBuilder::closeDeclaration()
10280 DeclarationBuilderBase::closeDeclaration ();
10381}
10482
105- void DeclarationBuilder::visitIdentifierTarget (IdentifierTargetAst* node)
106- {
107- Python::AstDefaultVisitor::visitIdentifierTarget (node);
108-
109- QList<Declaration*> existingLocalDeclarations;
110-
111- {
112- DUChainWriteLocker lock ( DUChain::lock () );
113- RangeInRevision range = editorFindRange (node, node);
114- CursorInRevision stopSearching = range.start ;
115- QualifiedIdentifier id = identifierForNode (node->identifier );
116- existingLocalDeclarations = currentContext ()->findLocalDeclarations (id.last (), stopSearching);
117- }
118-
119- if ( ! existingLocalDeclarations.length () ) {
120- Declaration *dec = openDeclaration<Declaration>( node->identifier , node);
121- closeDeclaration ();
122- {
123- DUChainWriteLocker lock (DUChain::lock ());
124- dec->setType (IntegralType::Ptr (new IntegralType (IntegralType::TypeMixed)));
125- }
126- }
127- else {
128- kDebug () << " Declaration does already exist, not updating" << node->identifier ->identifier .toAscii ();
129- }
130- }
83+ // void DeclarationBuilder::visitIdentifierTarget(IdentifierTargetAst* node)
84+ // {
85+ // Python::AstDefaultVisitor::visitIdentifierTarget(node);
86+ //
87+ // QList<Declaration*> existingLocalDeclarations;
88+ //
89+ // {
90+ // DUChainWriteLocker lock( DUChain::lock() );
91+ // RangeInRevision range = editorFindRange(node, node);
92+ // CursorInRevision stopSearching = range.start;
93+ // QualifiedIdentifier id = identifierForNode(node->identifier);
94+ // existingLocalDeclarations = currentContext()->findLocalDeclarations(id.last(), stopSearching);
95+ // }
96+ //
97+ // if ( ! existingLocalDeclarations.length() ) {
98+ // Declaration *dec = openDeclaration<Declaration>( node->identifier, node);
99+ // closeDeclaration();
100+ // {
101+ // DUChainWriteLocker lock(DUChain::lock());
102+ // dec->setType(IntegralType::Ptr(new IntegralType(IntegralType::TypeMixed)));
103+ // }
104+ // }
105+ // else {
106+ // kDebug() << "Declaration does already exist, not updating" << node->identifier->identifier.toAscii();
107+ // }
108+ // }
131109
132110
133111void DeclarationBuilder::visitClassDefinition ( ClassDefinitionAst* node )
134112{
135113 kDebug () << " opening class definition" ;
136114 ContextBuilder::visitClassDefinition ( node );
137- openDeclaration<Declaration>( node->className , node );
115+ openDeclaration<Declaration>( node->name , node );
138116 eventuallyAssignInternalContext ();
139117 closeDeclaration ();
140118}
141119
142120void DeclarationBuilder::visitFunctionDefinition ( FunctionDefinitionAst* node )
143121{
144122 kDebug () << " opening function definition" ;
145- FunctionDeclaration* dec = openDeclaration<FunctionDeclaration>( node->functionName , node );
123+ FunctionDeclaration* dec = openDeclaration<FunctionDeclaration>( node->name , node );
146124
147125 FunctionType::Ptr type (new FunctionType);
148126
@@ -165,45 +143,46 @@ void DeclarationBuilder::visitLambda( LambdaAst* node )
165143// closeDeclaration();
166144}
167145
168- void DeclarationBuilder::visitDefaultParameter ( DefaultParameterAst * node )
146+ void DeclarationBuilder::visitArguments ( ArgumentsAst * node )
169147{
170- ContextBuilder::visitDefaultParameter ( node );
171- // AbstractFunctionDeclaration* function = currentDeclaration<AbstractFunctionDeclaration>();
172- AbstractFunctionDeclaration* function = dynamic_cast <AbstractFunctionDeclaration*>(currentDeclaration ());
173-
174- if ( function )
175- {
176- if ( node->value )
177- {
178- // Not sure what to do here, C++ simply adds the source code as default parameter, but that doesn't sound sane...
179- }
180- // simple case, we have an identifier parameter
181- if ( node->name ->astType == Ast::IdentifierParameterPartAst )
182- {
183- function->addDefaultParameter (IndexedString (" foo" ));
184- kDebug () << function->defaultParametersSize ();
185-
186- Q_ASSERT (hasCurrentType ());
187- FunctionType::Ptr type = currentType<FunctionType>();
188- Q_ASSERT (type);
189-
190- kDebug () << type->toString ();
191-
192- // create a variable definition
193- IdentifierParameterPartAst* identifierNode = dynamic_cast <IdentifierParameterPartAst*>(node->name );
194- Declaration* dec = openDeclaration<Declaration>( identifierNode->name , node);
195- {
196- DUChainWriteLocker lock (DUChain::lock ());
197- dec->setType (IntegralType::Ptr (new IntegralType (IntegralType::TypeMixed)));
198- type->addArgument (dec->abstractType ());
199- }
200- closeDeclaration ();
201-
202- } else if ( node->name ->astType == Ast::ListParameterPartAst )
203- {
204- // complex case, a sublist, what to do??
205- }
206- }
148+ AstDefaultVisitor::visitArguments (node);
149+ // ContextBuilder::visitDefaultParameter( node );
150+ // // AbstractFunctionDeclaration* function = currentDeclaration<AbstractFunctionDeclaration>();
151+ // AbstractFunctionDeclaration* function = dynamic_cast<AbstractFunctionDeclaration*>(currentDeclaration());
152+ //
153+ // if( function )
154+ // {
155+ // if( node->value )
156+ // {
157+ // //Not sure what to do here, C++ simply adds the source code as default parameter, but that doesn't sound sane...
158+ // }
159+ // //simple case, we have an identifier parameter
160+ // if( node->name->astType == Ast::IdentifierParameterPartAst )
161+ // {
162+ // function->addDefaultParameter(IndexedString("foo"));
163+ // kDebug() << function->defaultParametersSize();
164+ //
165+ // Q_ASSERT(hasCurrentType());
166+ // FunctionType::Ptr type = currentType<FunctionType>();
167+ // Q_ASSERT(type);
168+ //
169+ // kDebug() << type->toString();
170+ //
171+ // // create a variable definition
172+ // IdentifierParameterPartAst* identifierNode = dynamic_cast<IdentifierParameterPartAst*>(node->name);
173+ // Declaration* dec = openDeclaration<Declaration>( identifierNode->name, node);
174+ // {
175+ // DUChainWriteLocker lock(DUChain::lock());
176+ // dec->setType(IntegralType::Ptr(new IntegralType(IntegralType::TypeMixed)));
177+ // type->addArgument(dec->abstractType());
178+ // }
179+ // closeDeclaration();
180+ //
181+ // } else if( node->name->astType == Ast::ListParameterPartAst )
182+ // {
183+ // //complex case, a sublist, what to do??
184+ // }
185+ // }
207186}
208187
209188}
0 commit comments