Changeset View
Changeset View
Standalone View
Standalone View
duchain/declarationbuilder.cpp
Show All 14 Lines | 1 | /* This file is part of KDevelop | |||
---|---|---|---|---|---|
15 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 15 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
16 | Boston, MA 02110-1301, USA. | 16 | Boston, MA 02110-1301, USA. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | #include "declarationbuilder.h" | 19 | #include "declarationbuilder.h" | ||
20 | 20 | | |||
21 | #include <QByteArray> | 21 | #include <QByteArray> | ||
22 | 22 | | |||
23 | #include <ktexteditor/smartrange.h> | | |||
24 | #include <ktexteditor/smartinterface.h> | | |||
25 | | ||||
26 | #include "editorintegrator.h" | 23 | #include "editorintegrator.h" | ||
27 | #include "identifiercompiler.h" | 24 | #include "identifiercompiler.h" | ||
28 | #include <language/duchain/functiondeclaration.h> | 25 | #include <language/duchain/functiondeclaration.h> | ||
29 | #include <language/duchain/aliasdeclaration.h> | 26 | #include <language/duchain/aliasdeclaration.h> | ||
30 | #include "parsesession.h" | 27 | #include "parsesession.h" | ||
31 | #include "classdeclaration.h" | 28 | #include "classdeclaration.h" | ||
32 | #include <language/duchain/namespacealiasdeclaration.h> | 29 | #include <language/duchain/namespacealiasdeclaration.h> | ||
33 | #include "helpers.h" | 30 | #include "helpers.h" | ||
Show All 14 Lines | |||||
48 | void DeclarationBuilder::closeDeclaration() | 45 | void DeclarationBuilder::closeDeclaration() | ||
49 | { | 46 | { | ||
50 | if (currentDeclaration()) { | 47 | if (currentDeclaration()) { | ||
51 | DUChainWriteLocker lock(DUChain::lock()); | 48 | DUChainWriteLocker lock(DUChain::lock()); | ||
52 | 49 | | |||
53 | if (lastType()) { | 50 | if (lastType()) { | ||
54 | 51 | | |||
55 | AbstractType::Ptr type = lastType(); | 52 | AbstractType::Ptr type = lastType(); | ||
56 | IdentifiedType* idType = dynamic_cast<IdentifiedType*>(type.unsafeData()); | 53 | IdentifiedType* idType = dynamic_cast<IdentifiedType*>(type.data()); | ||
57 | 54 | | |||
58 | //When the given type has no declaration yet, assume we are declaring it now. | 55 | //When the given type has no declaration yet, assume we are declaring it now. | ||
59 | //If the type is a delayed type, it is a searched type, and not a declared one, so don't set the declaration then. | 56 | //If the type is a delayed type, it is a searched type, and not a declared one, so don't set the declaration then. | ||
60 | if( idType && !idType->declarationId().isValid() /*&& !delayed*/ ) { | 57 | if( idType && !idType->declarationId().isValid() /*&& !delayed*/ ) { | ||
61 | idType->setDeclaration( currentDeclaration() ); | 58 | idType->setDeclaration( currentDeclaration() ); | ||
62 | } | 59 | } | ||
63 | } | 60 | } | ||
64 | 61 | | |||
65 | currentDeclaration()->setType(lastType()); | 62 | currentDeclaration()->setType(lastType()); | ||
66 | } | 63 | } | ||
67 | 64 | | |||
68 | eventuallyAssignInternalContext(); | 65 | eventuallyAssignInternalContext(); | ||
69 | 66 | | |||
70 | //kDebug() << "Declaration closed:" << currentDeclaration()->identifier(); | 67 | //qDebug() << "Declaration closed:" << currentDeclaration()->identifier(); | ||
71 | 68 | | |||
72 | DeclarationBuilderBase::closeDeclaration(); | 69 | DeclarationBuilderBase::closeDeclaration(); | ||
73 | } | 70 | } | ||
74 | 71 | | |||
75 | void DeclarationBuilder::visitClassDeclaration(ClassDeclarationAst * node) | 72 | void DeclarationBuilder::visitClassDeclaration(ClassDeclarationAst * node) | ||
76 | { | 73 | { | ||
77 | ClassDeclaration* newClass = openDefinition<ClassDeclaration>(node->className, node); | 74 | ClassDeclaration* newClass = openDefinition<ClassDeclaration>(node->className, node); | ||
78 | 75 | | |||
79 | newClass->setAccessPolicy(parseAccessPolicy(node->modifiers)); | 76 | newClass->setAccessPolicy(parseAccessPolicy(node->modifiers)); | ||
80 | newClass->setClassType(ClassDeclarationData::Class); | 77 | newClass->setClassType(ClassDeclarationData::Class); | ||
81 | newClass->setStorageSpecifiers(parseModifiers(node->modifiers)); | 78 | newClass->setStorageSpecifiers(parseModifiers(node->modifiers)); | ||
82 | newClass->setKind(Declaration::Type); | 79 | newClass->setKind(Declaration::Type); | ||
83 | 80 | | |||
84 | DeclarationBuilderBase::visitClassDeclaration(node); | 81 | DeclarationBuilderBase::visitClassDeclaration(node); | ||
85 | 82 | | |||
86 | // Provide java.lang.Object inheritance where it is not specified | 83 | // Provide java.lang.Object inheritance where it is not specified | ||
87 | DUChainWriteLocker lock(DUChain::lock()); | 84 | DUChainWriteLocker lock(DUChain::lock()); | ||
88 | //TODO : only count objects, not interfaces, in this check | 85 | //TODO : only count objects, not interfaces, in this check | ||
89 | if (buildCompleteTypes() && newClass->baseClassesSize() == 0) { | 86 | if (buildCompleteTypes() && newClass->baseClassesSize() == 0) { | ||
90 | static QualifiedIdentifier javaLangObject("java::lang::Object"); | 87 | static QualifiedIdentifier javaLangObject("java::lang::Object"); | ||
91 | if (newClass->qualifiedIdentifier() != javaLangObject) { | 88 | if (newClass->qualifiedIdentifier() != javaLangObject) { | ||
92 | QList<Declaration*> declarations = currentContext()->findDeclarations(javaLangObject, currentContext()->range().end, AbstractType::Ptr(), currentContext()->topContext()); | 89 | QList<Declaration*> declarations = currentContext()->findDeclarations(javaLangObject, currentContext()->range().end, AbstractType::Ptr(), currentContext()->topContext()); | ||
93 | if (declarations.count() >= 1) { | 90 | if (declarations.count() >= 1) { | ||
94 | if (declarations.count() > 1) { | 91 | if (declarations.count() > 1) { | ||
95 | kDebug() << "Found mulitple declarations for" << javaLangObject.toStringList().join("."); | 92 | qDebug() << "Found mulitple declarations for" << javaLangObject.toStringList().join("."); | ||
96 | } | 93 | } | ||
97 | BaseClassInstance instance; | 94 | BaseClassInstance instance; | ||
98 | { | 95 | { | ||
99 | // TODO check that type is a class | 96 | // TODO check that type is a class | ||
100 | instance.baseClass = declarations.at(0)->indexedType(); | 97 | instance.baseClass = declarations.at(0)->indexedType(); | ||
101 | Q_ASSERT(dynamic_cast<IdentifiedType*>(instance.baseClass.abstractType().unsafeData())->declaration(currentContext()->topContext())); | 98 | Q_ASSERT(dynamic_cast<IdentifiedType*>(instance.baseClass.abstractType().data())->declaration(currentContext()->topContext())); | ||
102 | newClass->addBaseClass(instance); | 99 | newClass->addBaseClass(instance); | ||
103 | } | 100 | } | ||
104 | addBaseType(instance); | 101 | addBaseType(instance); | ||
105 | } else { | 102 | } else { | ||
106 | kDebug() << "Couldn't find declaration for java.lang.Object"; | 103 | qDebug() << "Couldn't find declaration for java.lang.Object"; | ||
107 | } | 104 | } | ||
108 | } | 105 | } | ||
109 | } | 106 | } | ||
110 | closeDeclaration(); | 107 | closeDeclaration(); | ||
111 | } | 108 | } | ||
112 | 109 | | |||
113 | void DeclarationBuilder::classContextOpened(KDevelop::DUContext* context) | 110 | void DeclarationBuilder::classContextOpened(KDevelop::DUContext* context) | ||
114 | { | 111 | { | ||
Show All 14 Lines | 123 | { | |||
129 | if (buildCompleteTypes()) { | 126 | if (buildCompleteTypes()) { | ||
130 | BaseClassInstance instance; | 127 | BaseClassInstance instance; | ||
131 | { | 128 | { | ||
132 | DUChainWriteLocker lock(DUChain::lock()); | 129 | DUChainWriteLocker lock(DUChain::lock()); | ||
133 | ClassDeclaration* currentClass = dynamic_cast<ClassDeclaration*>(currentDeclaration()); | 130 | ClassDeclaration* currentClass = dynamic_cast<ClassDeclaration*>(currentDeclaration()); | ||
134 | if (currentClass) { | 131 | if (currentClass) { | ||
135 | // TODO check that type is a class | 132 | // TODO check that type is a class | ||
136 | instance.baseClass = lastType()->indexed(); | 133 | instance.baseClass = lastType()->indexed(); | ||
137 | kDebug() << "adding base class type, valid? " << instance.baseClass.isValid(); | 134 | qDebug() << "adding base class type, valid? " << instance.baseClass.isValid(); | ||
138 | 135 | | |||
139 | if (instance.baseClass.abstractType()) | 136 | if (instance.baseClass.abstractType()) | ||
140 | kDebug() << "type " << instance.baseClass.abstractType()->toString(); | 137 | qDebug() << "type " << instance.baseClass.abstractType()->toString(); | ||
141 | else | 138 | else | ||
142 | kDebug() << "null type"; | 139 | qDebug() << "null type"; | ||
143 | 140 | | |||
144 | if (instance.baseClass.isValid()) | 141 | if (instance.baseClass.isValid()) | ||
145 | currentClass->addBaseClass(instance); | 142 | currentClass->addBaseClass(instance); | ||
146 | else | 143 | else | ||
147 | kDebug() << "extends-specifier without class type (invalid parsed type)"; | 144 | qDebug() << "extends-specifier without class type (invalid parsed type)"; | ||
148 | 145 | | |||
149 | } else { | 146 | } else { | ||
150 | kDebug() << "extends-specifier without class type"; | 147 | qDebug() << "extends-specifier without class type"; | ||
151 | } | 148 | } | ||
152 | } | 149 | } | ||
153 | addBaseType(instance); | 150 | addBaseType(instance); | ||
154 | } | 151 | } | ||
155 | } | 152 | } | ||
156 | 153 | | |||
157 | void DeclarationBuilder::visitImplementsClause(java::ImplementsClauseAst* node) | 154 | void DeclarationBuilder::visitImplementsClause(java::ImplementsClauseAst* node) | ||
158 | { | 155 | { | ||
Show All 14 Lines | 168 | if (m_inImplementsClause) { | |||
173 | { | 170 | { | ||
174 | DUChainWriteLocker lock(DUChain::lock()); | 171 | DUChainWriteLocker lock(DUChain::lock()); | ||
175 | ClassDeclaration* currentClass = dynamic_cast<ClassDeclaration*>(currentDeclaration()); | 172 | ClassDeclaration* currentClass = dynamic_cast<ClassDeclaration*>(currentDeclaration()); | ||
176 | if(currentClass) { | 173 | if(currentClass) { | ||
177 | // TODO check that type is an interface | 174 | // TODO check that type is an interface | ||
178 | instance.baseClass = lastType()->indexed(); | 175 | instance.baseClass = lastType()->indexed(); | ||
179 | currentClass->addBaseClass(instance); | 176 | currentClass->addBaseClass(instance); | ||
180 | }else{ | 177 | }else{ | ||
181 | kWarning() << "implements specifier without interface type"; | 178 | qWarning() << "implements specifier without interface type"; | ||
182 | } | 179 | } | ||
183 | } | 180 | } | ||
184 | addBaseType(instance); | 181 | addBaseType(instance); | ||
185 | } | 182 | } | ||
186 | } | 183 | } | ||
187 | } | 184 | } | ||
188 | 185 | | |||
189 | void DeclarationBuilder::visitInterfaceDeclaration(InterfaceDeclarationAst * node) | 186 | void DeclarationBuilder::visitInterfaceDeclaration(InterfaceDeclarationAst * node) | ||
Show All 19 Lines | 205 | if (node->modifiers) { | |||
209 | Declaration::AccessPolicy access = parseAccessPolicy(node->modifiers); | 206 | Declaration::AccessPolicy access = parseAccessPolicy(node->modifiers); | ||
210 | 207 | | |||
211 | // Default public access for interface methods | 208 | // Default public access for interface methods | ||
212 | if (access == Declaration::DefaultAccess) | 209 | if (access == Declaration::DefaultAccess) | ||
213 | access = Declaration::Public; | 210 | access = Declaration::Public; | ||
214 | 211 | | |||
215 | newMethod->setAccessPolicy(access); | 212 | newMethod->setAccessPolicy(access); | ||
216 | 213 | | |||
217 | newMethod->setStorageSpecifiers(parseModifiers(node->modifiers)); | 214 | newMethod->setStorageSpecifiers(ClassMemberDeclaration::StorageSpecifiers(static_cast<ClassDeclaration::StorageSpecifiers::Int>(parseModifiers(node->modifiers)))); | ||
218 | } | 215 | } | ||
219 | 216 | | |||
220 | DeclarationBuilderBase::visitInterfaceMethodDeclaration(node); | 217 | DeclarationBuilderBase::visitInterfaceMethodDeclaration(node); | ||
221 | 218 | | |||
222 | closeDeclaration(); | 219 | closeDeclaration(); | ||
223 | } | 220 | } | ||
224 | 221 | | |||
225 | void DeclarationBuilder::visitEnumDeclaration(java::EnumDeclarationAst* node) | 222 | void DeclarationBuilder::visitEnumDeclaration(java::EnumDeclarationAst* node) | ||
Show All 36 Lines | 255 | { | |||
262 | 259 | | |||
263 | closeDeclaration(); | 260 | closeDeclaration(); | ||
264 | } | 261 | } | ||
265 | 262 | | |||
266 | void DeclarationBuilder::visitMethodDeclaration(MethodDeclarationAst * node) | 263 | void DeclarationBuilder::visitMethodDeclaration(MethodDeclarationAst * node) | ||
267 | { | 264 | { | ||
268 | ClassFunctionDeclaration* newMethod = openDefinition<ClassFunctionDeclaration>(node->methodName, node); | 265 | ClassFunctionDeclaration* newMethod = openDefinition<ClassFunctionDeclaration>(node->methodName, node); | ||
269 | newMethod->setAccessPolicy(parseAccessPolicy(node->modifiers)); | 266 | newMethod->setAccessPolicy(parseAccessPolicy(node->modifiers)); | ||
270 | newMethod->setStorageSpecifiers(parseModifiers(node->modifiers)); | 267 | newMethod->setStorageSpecifiers(ClassMemberDeclaration::StorageSpecifiers(static_cast<ClassDeclaration::StorageSpecifiers::Int>(parseModifiers(node->modifiers)))); | ||
271 | 268 | | |||
272 | DeclarationBuilderBase::visitMethodDeclaration(node); | 269 | DeclarationBuilderBase::visitMethodDeclaration(node); | ||
273 | 270 | | |||
274 | closeDeclaration(); | 271 | closeDeclaration(); | ||
275 | } | 272 | } | ||
276 | 273 | | |||
277 | void DeclarationBuilder::visitVariableDeclarationData(java::VariableDeclarationDataAst* node) | 274 | void DeclarationBuilder::visitVariableDeclarationData(java::VariableDeclarationDataAst* node) | ||
278 | { | 275 | { | ||
279 | m_currentVariableModifiers = parseModifiers(node->modifiers); | 276 | m_currentVariableModifiers = parseModifiers(node->modifiers); | ||
280 | 277 | | |||
281 | DeclarationBuilderBase::visitVariableDeclarationData(node); | 278 | DeclarationBuilderBase::visitVariableDeclarationData(node); | ||
282 | 279 | | |||
283 | m_currentVariableModifiers = 0; | 280 | m_currentVariableModifiers = 0; | ||
284 | } | 281 | } | ||
285 | 282 | | |||
286 | void DeclarationBuilder::visitVariableDeclarator(VariableDeclaratorAst * node) | 283 | void DeclarationBuilder::visitVariableDeclarator(VariableDeclaratorAst * node) | ||
287 | { | 284 | { | ||
288 | if (currentContext()->type() == DUContext::Class) { | 285 | if (currentContext()->type() == DUContext::Class) { | ||
289 | ClassMemberDeclaration* classMember = openDefinition<ClassMemberDeclaration>(node->variableName, node); | 286 | ClassMemberDeclaration* classMember = openDefinition<ClassMemberDeclaration>(node->variableName, node); | ||
290 | classMember->setStorageSpecifiers(m_currentVariableModifiers); | 287 | classMember->setStorageSpecifiers(ClassMemberDeclaration::StorageSpecifiers(static_cast<ClassDeclaration::StorageSpecifiers::Int>(m_currentVariableModifiers))); | ||
291 | classMember->setKind(Declaration::Instance); | 288 | classMember->setKind(Declaration::Instance); | ||
292 | classMember->setAbstractType(lastType()); | 289 | classMember->setAbstractType(lastType()); | ||
293 | } else { | 290 | } else { | ||
294 | Declaration* variableDeclaration = openDefinition<Declaration>(node->variableName, node); | 291 | Declaration* variableDeclaration = openDefinition<Declaration>(node->variableName, node); | ||
295 | variableDeclaration->setKind(Declaration::Instance); | 292 | variableDeclaration->setKind(Declaration::Instance); | ||
296 | variableDeclaration->setAbstractType(lastType()); | 293 | variableDeclaration->setAbstractType(lastType()); | ||
297 | #if 0 // Porting -- Declaration::final property got removed | 294 | #if 0 // Porting -- Declaration::final property got removed | ||
298 | variableDeclaration->setFinal(m_currentVariableModifiers & ClassMemberDeclaration::FinalSpecifier); | 295 | variableDeclaration->setFinal(m_currentVariableModifiers & ClassMemberDeclaration::FinalSpecifier); | ||
Show All 34 Lines | |||||
333 | } | 330 | } | ||
334 | 331 | | |||
335 | void DeclarationBuilder::visitImportDeclaration(ImportDeclarationAst* node) | 332 | void DeclarationBuilder::visitImportDeclaration(ImportDeclarationAst* node) | ||
336 | { | 333 | { | ||
337 | if (!m_defaultImportCreated) { | 334 | if (!m_defaultImportCreated) { | ||
338 | Q_ASSERT(javaLang.count() == 3); | 335 | Q_ASSERT(javaLang.count() == 3); | ||
339 | 336 | | |||
340 | DUChainWriteLocker lock(DUChain::lock()); | 337 | DUChainWriteLocker lock(DUChain::lock()); | ||
341 | NamespaceAliasDeclaration* decl = openDeclaration<NamespaceAliasDeclaration>(QualifiedIdentifier(globalImportIdentifier()), RangeInRevision()); | 338 | NamespaceAliasDeclaration* decl = openDeclaration<NamespaceAliasDeclaration>(globalImportIdentifier(), RangeInRevision()); | ||
342 | decl->setImportIdentifier(javaLang); | 339 | decl->setImportIdentifier(javaLang); | ||
343 | decl->setKind(Declaration::Import); | 340 | decl->setKind(Declaration::Import); | ||
344 | closeDeclaration(); | 341 | closeDeclaration(); | ||
345 | m_defaultImportCreated = true; | 342 | m_defaultImportCreated = true; | ||
346 | } | 343 | } | ||
347 | 344 | | |||
348 | if (node && node->identifierName && node->identifierName->nameSequence) { | 345 | if (node && node->identifierName && node->identifierName->nameSequence) { | ||
349 | QualifiedIdentifier import = identifierForNode(node->identifierName->nameSequence); | 346 | QualifiedIdentifier import = identifierForNode(node->identifierName->nameSequence); | ||
Show All 9 Lines | 347 | if (node->identifierName->hasStar) { | |||
359 | // Ignore imports of java.lang.*, it's auto-imported. | 356 | // Ignore imports of java.lang.*, it's auto-imported. | ||
360 | if (import == javaLang) | 357 | if (import == javaLang) | ||
361 | return; | 358 | return; | ||
362 | } | 359 | } | ||
363 | 360 | | |||
364 | ///@todo only use the last name component as range | 361 | ///@todo only use the last name component as range | ||
365 | { | 362 | { | ||
366 | DUChainWriteLocker lock(DUChain::lock()); | 363 | DUChainWriteLocker lock(DUChain::lock()); | ||
367 | NamespaceAliasDeclaration* decl = openDeclaration<NamespaceAliasDeclaration>(QualifiedIdentifier(node->staticImport ? Identifier(globalStaticImportIdentifier) : globalImportIdentifier()), editorFindRange(node->identifierName, node->identifierName)); | 364 | NamespaceAliasDeclaration* decl = openDeclaration<NamespaceAliasDeclaration>(node->staticImport ? Identifier(globalStaticImportIdentifier) : globalImportIdentifier(), editorFindRange(node->identifierName, node->identifierName)); | ||
368 | decl->setImportIdentifier(import); | 365 | decl->setImportIdentifier(import); | ||
369 | } | 366 | } | ||
370 | 367 | | |||
371 | closeDeclaration(); | 368 | closeDeclaration(); | ||
372 | } | 369 | } | ||
373 | } | 370 | } | ||
374 | 371 | | |||
375 | void DeclarationBuilder::visitPackageDeclaration(java::PackageDeclarationAst* node) | 372 | void DeclarationBuilder::visitPackageDeclaration(java::PackageDeclarationAst* node) | ||
376 | { | 373 | { | ||
377 | if (node && node->packageName) { | 374 | if (node && node->packageName) { | ||
378 | // Use this to import other items from the package | 375 | // Use this to import other items from the package | ||
379 | QualifiedIdentifier id = identifierForNode(node->packageName); | 376 | QualifiedIdentifier id = identifierForNode(node->packageName); | ||
380 | KDevelop::RangeInRevision range = editorFindRange(node->packageName, node->packageName); | 377 | KDevelop::RangeInRevision range = editorFindRange(node->packageName, node->packageName); | ||
381 | 378 | | |||
382 | { | 379 | { | ||
383 | DUChainWriteLocker lock(DUChain::lock()); | 380 | DUChainWriteLocker lock(DUChain::lock()); | ||
384 | NamespaceAliasDeclaration* decl = openDeclaration<NamespaceAliasDeclaration>(QualifiedIdentifier(globalImportIdentifier()), range); | 381 | NamespaceAliasDeclaration* decl = openDeclaration<NamespaceAliasDeclaration>(globalImportIdentifier(), range); | ||
385 | QualifiedIdentifier id2 = id; | 382 | QualifiedIdentifier id2 = id; | ||
386 | id2.push(Identifier("*")); | 383 | id2.push(Identifier("*")); | ||
387 | decl->setImportIdentifier(id2); | 384 | decl->setImportIdentifier(id2); | ||
388 | decl->setContext(currentContext()->topContext()); | 385 | decl->setContext(currentContext()->topContext()); | ||
389 | decl->setKind(Declaration::NamespaceAlias); | 386 | decl->setKind(Declaration::NamespaceAlias); | ||
390 | closeDeclaration(); | 387 | closeDeclaration(); | ||
391 | 388 | | |||
392 | // Some crazy issue with just passing the whole QI? | 389 | // Some crazy issue with just passing the whole QI? | ||
393 | openDeclaration<Declaration>(QualifiedIdentifier(id.last()), range); | 390 | openDeclaration<Declaration>(id.last(), range); | ||
394 | } | 391 | } | ||
395 | 392 | | |||
396 | DeclarationBuilderBase::visitPackageDeclaration(node); | 393 | DeclarationBuilderBase::visitPackageDeclaration(node); | ||
397 | 394 | | |||
398 | DUChainWriteLocker lock(DUChain::lock()); | 395 | DUChainWriteLocker lock(DUChain::lock()); | ||
399 | currentDeclaration()->setKind(KDevelop::Declaration::Namespace); | 396 | currentDeclaration()->setKind(KDevelop::Declaration::Namespace); | ||
400 | closeDeclaration(); | 397 | closeDeclaration(); | ||
401 | } | 398 | } | ||
Show All 10 Lines | 403 | if (node) { | |||
412 | 409 | | |||
413 | if (node->modifiers & ModifierPrivate) | 410 | if (node->modifiers & ModifierPrivate) | ||
414 | return Declaration::Private; | 411 | return Declaration::Private; | ||
415 | } | 412 | } | ||
416 | 413 | | |||
417 | return Declaration::DefaultAccess; | 414 | return Declaration::DefaultAccess; | ||
418 | } | 415 | } | ||
419 | 416 | | |||
420 | ClassMemberDeclaration::StorageSpecifiers DeclarationBuilder::parseModifiers(java::OptionalModifiersAst* node) | 417 | ClassDeclaration::StorageSpecifiers DeclarationBuilder::parseModifiers(java::OptionalModifiersAst* node) | ||
421 | { | 418 | { | ||
422 | ClassMemberDeclaration::StorageSpecifiers ret; | 419 | ClassDeclaration::StorageSpecifiers ret; | ||
423 | 420 | | |||
424 | if (node) { | 421 | if (node) { | ||
425 | if (node->modifiers & ModifierFinal) | 422 | if (node->modifiers & ModifierFinal) | ||
426 | ret |= ClassMemberDeclaration::FinalSpecifier; | 423 | ret |= ClassDeclaration::FinalSpecifier; | ||
427 | if (node->modifiers & ModifierAbstract) | 424 | if (node->modifiers & ModifierAbstract) | ||
428 | ret |= ClassMemberDeclaration::AbstractSpecifier; | 425 | ret |= ClassDeclaration::AbstractSpecifier; | ||
429 | if (node->modifiers & ModifierStrictFP) | 426 | if (node->modifiers & ModifierStrictFP) | ||
430 | ret |= ClassMemberDeclaration::StrictFPSpecifier; | 427 | ret |= ClassDeclaration::StrictFPSpecifier; | ||
431 | if (node->modifiers & ModifierSynchronized) | 428 | if (node->modifiers & ModifierSynchronized) | ||
432 | ret |= ClassMemberDeclaration::SynchronizedSpecifier; | 429 | ret |= ClassDeclaration::SynchronizedSpecifier; | ||
433 | if (node->modifiers & ModifierStatic) | 430 | if (node->modifiers & ModifierStatic) | ||
434 | ret |= ClassMemberDeclaration::StaticSpecifier; | 431 | ret |= ClassDeclaration::StaticSpecifier; | ||
435 | if (node->modifiers & ModifierNative) | 432 | if (node->modifiers & ModifierNative) | ||
436 | ret |= ClassMemberDeclaration::NativeSpecifier; | 433 | ret |= ClassDeclaration::NativeSpecifier; | ||
437 | //ModifierTransient = 1 << 4, | 434 | //ModifierTransient = 1 << 4, | ||
438 | //ModifierVolatile = 1 << 9, | 435 | //ModifierVolatile = 1 << 9, | ||
439 | } | 436 | } | ||
440 | 437 | | |||
441 | return ret; | 438 | return ret; | ||
442 | } | 439 | } | ||
443 | 440 | | |||
444 | void DeclarationBuilder::classTypeOpened(AbstractType::Ptr type) | 441 | void DeclarationBuilder::classTypeOpened(AbstractType::Ptr type) | ||
445 | { | 442 | { | ||
446 | //We override this so we can get the class-declaration into a usable state(with filled type) earlier | 443 | //We override this so we can get the class-declaration into a usable state(with filled type) earlier | ||
447 | DUChainWriteLocker lock(DUChain::lock()); | 444 | DUChainWriteLocker lock(DUChain::lock()); | ||
448 | 445 | | |||
449 | IdentifiedType* idType = dynamic_cast<IdentifiedType*>(type.unsafeData()); | 446 | IdentifiedType* idType = dynamic_cast<IdentifiedType*>(type.data()); | ||
450 | 447 | | |||
451 | if( idType && !idType->declarationId().isValid() ) //When the given type has no declaration yet, assume we are declaring it now | 448 | if( idType && !idType->declarationId().isValid() ) //When the given type has no declaration yet, assume we are declaring it now | ||
452 | idType->setDeclaration( currentDeclaration() ); | 449 | idType->setDeclaration( currentDeclaration() ); | ||
453 | 450 | | |||
454 | currentDeclaration()->setType(type); | 451 | currentDeclaration()->setType(type); | ||
455 | } | 452 | } | ||
456 | 453 | | |||
457 | } | 454 | } |