Changeset View
Changeset View
Standalone View
Standalone View
duchain/contextbuilder.cpp
Show All 13 Lines | 1 | /* This file is part of KDevelop | |||
---|---|---|---|---|---|
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to | ||
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301, USA. | 17 | Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "contextbuilder.h" | 20 | #include "contextbuilder.h" | ||
21 | 21 | | |||
22 | #include <KDebug> | 22 | #include <QDebug> | ||
23 | #include <ktexteditor/smartrange.h> | | |||
24 | 23 | | |||
25 | #include <language/duchain/duchain.h> | 24 | #include <language/duchain/duchain.h> | ||
26 | #include <language/duchain/topducontext.h> | 25 | #include <language/duchain/topducontext.h> | ||
27 | #include <language/duchain/duchainlock.h> | 26 | #include <language/duchain/duchainlock.h> | ||
28 | 27 | | |||
29 | #include "parsesession.h" | 28 | #include "parsesession.h" | ||
30 | #include "editorintegrator.h" | 29 | #include "editorintegrator.h" | ||
31 | #include "identifiercompiler.h" | 30 | #include "identifiercompiler.h" | ||
▲ Show 20 Lines • Show All 368 Lines • ▼ Show 20 Line(s) | 398 | { | |||
400 | DUChainReadLocker lock(DUChain::lock()); | 399 | DUChainReadLocker lock(DUChain::lock()); | ||
401 | packageDeclarations = packageContext->findLocalDeclarations(id.last()); | 400 | packageDeclarations = packageContext->findLocalDeclarations(id.last()); | ||
402 | if (id.isEmpty()) | 401 | if (id.isEmpty()) | ||
403 | { | 402 | { | ||
404 | Q_ASSERT(packageDeclarations.isEmpty()); | 403 | Q_ASSERT(packageDeclarations.isEmpty()); | ||
405 | } | 404 | } | ||
406 | else if (packageDeclarations.count() != 1) | 405 | else if (packageDeclarations.count() != 1) | ||
407 | { | 406 | { | ||
408 | kWarning() << "Package declaration expected, found " << packageDeclarations.count() << "declarations of" << id.last().toString(); | 407 | qWarning() << "Package declaration expected, found " << packageDeclarations.count() << "declarations of" << id.last().toString(); | ||
409 | } | 408 | } | ||
410 | } | 409 | } | ||
411 | 410 | | |||
412 | openContext(node, DUContext::Namespace, id); | 411 | openContext(node, DUContext::Namespace, id); | ||
413 | 412 | | |||
414 | if (!packageDeclarations.isEmpty()) { | 413 | if (!packageDeclarations.isEmpty()) { | ||
415 | DUChainWriteLocker lock(DUChain::lock()); | 414 | DUChainWriteLocker lock(DUChain::lock()); | ||
416 | packageDeclarations.first()->setInternalContext(currentContext()); | 415 | packageDeclarations.first()->setInternalContext(currentContext()); | ||
417 | } | 416 | } | ||
418 | 417 | | |||
419 | visitNodeList(node->typeDeclarationSequence); | 418 | visitNodeList(node->typeDeclarationSequence); | ||
420 | 419 | | |||
421 | closeContext(); | 420 | closeContext(); | ||
422 | } | 421 | } | ||
423 | 422 | | |||
424 | void ContextBuilder::addBaseType(BaseClassInstance base) | 423 | void ContextBuilder::addBaseType(BaseClassInstance base) | ||
425 | { | 424 | { | ||
426 | DUChainWriteLocker lock(DUChain::lock()); | 425 | DUChainWriteLocker lock(DUChain::lock()); | ||
427 | 426 | | |||
428 | //addImportedContexts(); //Make sure the template-contexts are imported first, before any parent-class contexts. | 427 | //addImportedContexts(); //Make sure the template-contexts are imported first, before any parent-class contexts. | ||
429 | 428 | | |||
430 | if (currentContext()->type() != DUContext::Class) { | 429 | if (currentContext()->type() != DUContext::Class) { | ||
431 | kDebug() << "Tried to add base class to a non-class context!"; | 430 | qDebug() << "Tried to add base class to a non-class context!"; | ||
432 | return; | 431 | return; | ||
433 | } | 432 | } | ||
434 | 433 | | |||
435 | AbstractType::Ptr baseClass = base.baseClass.abstractType(); | 434 | AbstractType::Ptr baseClass = base.baseClass.abstractType(); | ||
436 | IdentifiedType* idType = dynamic_cast<IdentifiedType*>(baseClass.unsafeData()); | 435 | IdentifiedType* idType = dynamic_cast<IdentifiedType*>(baseClass.data()); | ||
437 | Declaration* idDecl = 0; | 436 | Declaration* idDecl = 0; | ||
438 | if (idType) { | 437 | if (idType) { | ||
439 | idDecl = idType->declaration(currentContext()->topContext()); | 438 | idDecl = idType->declaration(currentContext()->topContext()); | ||
440 | if (!idDecl) { | 439 | if (!idDecl) { | ||
441 | kDebug() << "No declaration provided by base class type " << idType->qualifiedIdentifier().toStringList().join("."); | 440 | qDebug() << "No declaration provided by base class type " << idType->qualifiedIdentifier().toStringList().join("."); | ||
442 | return; | 441 | return; | ||
443 | } | 442 | } | ||
444 | } else { | 443 | } else { | ||
445 | kDebug() << "Tried to add base class which is a null type!"; | 444 | qDebug() << "Tried to add base class which is a null type!"; | ||
446 | return; | 445 | return; | ||
447 | } | 446 | } | ||
448 | 447 | | |||
449 | if( idDecl->logicalInternalContext(0) ) { | 448 | if( idDecl->logicalInternalContext(0) ) { | ||
450 | currentContext()->addImportedParentContext( idDecl->logicalInternalContext(0) ); | 449 | currentContext()->addImportedParentContext( idDecl->logicalInternalContext(0) ); | ||
451 | } else { | 450 | } else { | ||
452 | kDebug() << "No internal context provided for " << idDecl->toString(); | 451 | qDebug() << "No internal context provided for " << idDecl->toString(); | ||
453 | } | 452 | } | ||
454 | } | 453 | } | ||
455 | 454 | | |||
456 | void ContextBuilder::classContextOpened(KDevelop::DUContext* context) | 455 | void ContextBuilder::classContextOpened(KDevelop::DUContext* context) | ||
457 | { | 456 | { | ||
458 | Q_UNUSED(context); | 457 | Q_UNUSED(context); | ||
459 | } | 458 | } | ||
460 | 459 | | |||
461 | void ContextBuilder::visitImportDeclaration(java::ImportDeclarationAst* node) | 460 | void ContextBuilder::visitImportDeclaration(java::ImportDeclarationAst* node) | ||
462 | { | 461 | { | ||
463 | if (node) | 462 | if (node) | ||
464 | DefaultVisitor::visitImportDeclaration(node); | 463 | DefaultVisitor::visitImportDeclaration(node); | ||
465 | } | 464 | } | ||
466 | 465 | | |||
467 | } | 466 | } |