diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,16 +1,17 @@ project(java) -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.10) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${java_SOURCE_DIR}/cmake) +find_package (ECM 5.28.0 REQUIRED CONFIG) +set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) -find_package(KDE4 REQUIRED) -include (KDE4Defaults) -include (MacroLibrary) -include (MacroOptionalAddSubdirectory) +include(KDEInstallDirs) +include(KDECMakeSettings) +include(GenerateExportHeader) -find_package(KDevPlatform REQUIRED) +find_package(KF5 REQUIRED COMPONENTS Archive) +find_package(KDevPlatform REQUIRED) find_package(KDevelop-PG-Qt REQUIRED) include_directories(${KDEVPGQT_INCLUDE_DIR}) @@ -26,19 +27,11 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} - ${KDE4_INCLUDES} - ${KDE4_INCLUDE_DIR}/threadweaver - ${KDE4_INCLUDE_DIR}/kdevelop-pg-qt - ${CMAKE_CURRENT_SOURCE_DIR}/parser - ${CMAKE_CURRENT_BINARY_DIR}/parser - ${KDEVPLATFORM_INCLUDE_DIR} ) ########### next target ############### -add_definitions( ${QT_DEFINITIONS} ${KDE4_DEFINITIONS} -DKDE_DEFAULT_DEBUG_AREA=9013 ) - set(kdevjavalanguagesupport_PART_SRCS javalanguagesupport.cpp parsejob.cpp @@ -48,24 +41,17 @@ completion/context.cpp completion/model.cpp completion/helpers.cpp + + $ +) + +kdevplatform_add_plugin(kdevjavalanguagesupport JSON kdevjavasupport.json SOURCES + ${kdevjavalanguagesupport_PART_SRCS} ) -kde4_add_plugin(kdevjavalanguagesupport ${kdevjavalanguagesupport_PART_SRCS}) target_link_libraries(kdevjavalanguagesupport - ${KDE4_KTEXTEDITOR_LIBS} - ${KDEVPLATFORM_INTERFACES_LIBRARIES} - ${KDEVPLATFORM_PROJECT_LIBRARIES} - ${KDE4_THREADWEAVER_LIBRARIES} - ${KDEVPLATFORM_LANGUAGE_LIBRARIES} - ${KDE4_KDEUI_LIBS} + KF5::ThreadWeaver + KF5::Archive kdev4javaparser kdevjavaduchain ) - -install(TARGETS kdevjavalanguagesupport DESTINATION ${PLUGIN_INSTALL_DIR}) - - -########### install files ############### - -configure_file(kdevjavasupport.desktop.cmake ${CMAKE_CURRENT_BINARY_DIR}/kdevjavasupport.desktop) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kdevjavasupport.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/cmake/FindKDevPlatform.cmake b/cmake/FindKDevPlatform.cmake deleted file mode 100644 --- a/cmake/FindKDevPlatform.cmake +++ /dev/null @@ -1,46 +0,0 @@ -# -# Find the KDevelop Platform modules and sets various variables accordingly -# -# Example usage of this module: -# find_package(KDevPlatform 1.0.0 REQUIRED) -# -# The version number and REQUIRED flag are optional. You can set CMAKE_PREFIX_PATH -# variable to help it find the required files and directories - -# KDEVPLATFORM_FOUND - set to TRUE if the platform was found and the version is compatible FALSE otherwise -# -# KDEVPLATFORM_VERSION - The version number of kdevplatform -# KDEVPLATFORM_VERSION_MAJOR - The major version number of kdevplatform -# KDEVPLATFORM_VERSION_MINOR - The minor version number of kdevplatform -# KDEVPLATFORM_VERSION_PATCH - The patch version number of kdevplatform -# KDEVPLATFORM_INCLUDE_DIR - include dir of the platform, for example /usr/include/kdevplatform -# KDEVPLATFORM_INTERFACES_LIBRARIES - interfaces module library -# KDEVPLATFORM_LANGUAGE_LIBRARIES - language module library -# KDEVPLATFORM_OUTPUTVIEW_LIBRARIES - outputview module library -# KDEVPLATFORM_PROJECT_LIBRARIES - project module library -# KDEVPLATFORM_SUBLIME_LIBRARIES - sublime module library -# KDEVPLATFORM_SHELL_LIBRARIES - shell module library -# KDEVPLATFORM_TESTS_LIBRARIES - library to write tests for plugins, -# contains some useful tools and a way to replace parts of Core -# classes with custom implementations -# KDEVPLATFORM_UTIL_LIBRARIES - util module library -# KDEVPLATFORM_VCS_LIBRARIES - vcs module library -# KDEVPLATFORM_SOURCEFORMATTER_LIBRARIES - source formatter library -# KDEVPLATFORM_DEBUGGER_LIBRARIES - debugger module library -# -# The following macros are added (from KDevPlatformMacros.cmake): -# -# KDEVPLATFORM_ADD_APP_TEMPLATES( template1 ... templateN ) -# Use this to get packaged template archives for the given templates. -# Parameters should be the directories containing the templates. -# -# Copyright 2007 Andreas Pakulat -# Redistribution and use is allowed according to the terms of the BSD license. - -set(_KDevPlatform_FIND_QUIETLY ${KDevPlatform_FIND_QUIETLY}) -find_package( KDevPlatform ${KDevPlatform_FIND_VERSION} NO_MODULE ) -set(KDevPlatform_FIND_QUIETLY ${_KDevPlatform_FIND_QUIETLY}) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(KDevPlatform DEFAULT_MSG KDevPlatform_CONFIG ) - diff --git a/completion/context.h b/completion/context.h --- a/completion/context.h +++ b/completion/context.h @@ -22,10 +22,9 @@ #include -#include +#include #include -#include #include "items.h" @@ -39,16 +38,16 @@ class AbstractType; class CompletionTreeItem; - typedef KSharedPtr CompletionTreeItemPointer; + using CompletionTreeItemPointer = QExplicitlySharedDataPointer; } namespace java { /** * This class is responsible for finding out what kind of completion is needed, what expression should be evaluated for the container-class of the completion, what conversion will be applied to the result of the completion, etc. * */ class CodeCompletionContext : public KDevelop::CodeCompletionContext { public: - typedef KSharedPtr Ptr; + typedef QExplicitlySharedDataPointer Ptr; /** * @param firstContext should be true for a context that has no parent. Such a context will never be a function-call context. @@ -64,7 +63,7 @@ virtual QList completionItems(bool& abort, bool fullCompletion = true); void standardAccessCompletionItems(/*const KDevelop::CursorInRevision& position,*/ QList& items); - + bool isValidPosition() const; /** diff --git a/completion/context.cpp b/completion/context.cpp --- a/completion/context.cpp +++ b/completion/context.cpp @@ -77,23 +77,23 @@ CodeCompletionContext::CodeCompletionContext(DUContextPointer context, const QString& text, const QString& followingText, const KDevelop::CursorInRevision& position, int depth, const QStringList& knownArgumentExpressions, int line) : KDevelop::CodeCompletionContext(context, text, position, depth) - , m_memberAccessOperation(NoMemberAccess), m_followingText( followingText ), + , m_memberAccessOperation(NoMemberAccess), m_followingText( followingText ), m_knownArgumentExpressions( knownArgumentExpressions) { #warning What to do with knownArgumentExpressions ? m_valid = isValidPosition(); if( !m_valid ) { - kDebug() << "position not valid for code-completion" ; + qDebug() << "position not valid for code-completion" ; return; } - ifDebug( kDebug() << "non-processed text: " << m_text; ) + ifDebug( qDebug() << "non-processed text: " << m_text; ) // m_text = Utils::clearComments( m_text ); // m_text = Utils::clearStrings( m_text ); // m_text = Utils::stripFinalWhitespace( m_text ); - ifDebug( kDebug() << "processed text: " << m_text; ) + ifDebug( qDebug() << "processed text: " << m_text; ) ///@todo template-parameters @@ -128,7 +128,7 @@ * When the left and right part are only separated by a whitespace, * expressionAt returns both sides * */ - + } CodeCompletionContext::~CodeCompletionContext() { @@ -160,7 +160,7 @@ } else { standardAccessCompletionItems(items); - kDebug() << "Found declarations:" << items.count(); + qDebug() << "Found declarations:" << items.count(); } return items; @@ -177,7 +177,7 @@ typeIsConst = true; }*/ - QList decls = m_duContext->allDeclarations(m_duContext->type() == DUContext::Class ? m_duContext->range().end : m_position, m_duContext->topContext()); + QVector decls = m_duContext->allDeclarations(m_duContext->type() == DUContext::Class ? m_duContext->range().end : m_position, m_duContext->topContext()); QList moreDecls; @@ -207,27 +207,27 @@ // TODO static-filter moreDecls << top->findDeclarations(alias->importIdentifier()); - kDebug() << "Found imported packages to retrieve declarations from:"; + qDebug() << "Found imported packages to retrieve declarations from:"; foreach(const QualifiedIdentifier &package, packages) { QList importedContextDecls = m_duContext->findDeclarations( package ); - kDebug() << package.toStringList().join(".") << "context declarations found: " << importedContextDecls.count(); + qDebug() << package.toStringList().join(".") << "context declarations found: " << importedContextDecls.count(); foreach(Declaration* contextDecl, importedContextDecls) { if(contextDecl->kind() != Declaration::Namespace || !contextDecl->internalContext()) continue; DUContext* context = contextDecl->internalContext(); /*if(context->range().contains(m_duContext->range())) { - kDebug() << "Ignoring same context " << context << m_duContext; + qDebug() << "Ignoring same context " << context << m_duContext; continue; //If the context surrounds the current one, the declarations are visible through allDeclarations(..). }*/ foreach(Declaration* decl, context->localDeclarations()) if(filterDeclaration(decl)) { - kDebug() << "Adding declaration" << decl << decl->toString(); + qDebug() << "Adding declaration" << decl << decl->toString(); moreDecls << decl; } else { - kDebug() << "Filtered out declaration" << decl; + qDebug() << "Filtered out declaration" << decl; } } } @@ -294,7 +294,7 @@ PointerType::Ptr thisPointer(new PointerType()); thisPointer->setModifiers(AbstractType::ConstModifier); thisPointer->setBaseType(classType); - KSharedPtr item( new TypeConversionCompletionItem("this", thisPointer->indexed(), 0, KSharedPtr (this)) ); + QExplicitlySharedDataPointer item( new TypeConversionCompletionItem("this", thisPointer->indexed(), 0, QExplicitlySharedDataPointer (this)) ); item->setPrefix(thisPointer->toString()); QList lst; lst += CompletionTreeItemPointer(item.data()); @@ -308,7 +308,7 @@ #ifndef TEST_COMPLETION MissingIncludeCompletionModel::self().startWithExpression(m_duContext, QString(), m_followingText.trimmed()); #endif -// kDebug() << QString("added %1 missing-includes for %2").arg(items.count()-oldItemCount).arg(totalExpression); +// qDebug() << QString("added %1 missing-includes for %2").arg(items.count()-oldItemCount).arg(totalExpression); // } eventuallyAddGroup(i18n("C++ Builtin"), 800, keywordCompletionItems()); @@ -323,9 +323,9 @@ if (dynamic_cast(decl)) return false; - if (decl->kind() == DUContext::Namespace) + if (decl->kind() == Declaration::Kind::Namespace) return false; - + //if(m_onlyShowTypes && decl->kind() != Declaration::Type && decl->kind() != Declaration::Namespace) //return false; diff --git a/completion/helpers.cpp b/completion/helpers.cpp --- a/completion/helpers.cpp +++ b/completion/helpers.cpp @@ -41,10 +41,10 @@ QString createArgumentList(const NormalDeclarationCompletionItem& item, QList* highlighting, bool includeDefaultParams, bool noShortening ) { QString ret; - + Declaration* dec(item.declaration().data()); if (!dec) { - kDebug() << "No declaration for item"; + qDebug() << "No declaration for item"; return ret; } @@ -62,19 +62,19 @@ AbstractFunctionDeclaration* decl = dynamic_cast(dec); if (!decl) { - kDebug() << "Declaration is not a subclass of AbstractFunctionDeclaration" << dec->toString(); + qDebug() << "Declaration is not a subclass of AbstractFunctionDeclaration" << dec->toString(); } - + FunctionType::Ptr functionType = dec->type(); if (!functionType) { - kDebug() << "Type is not a function type" << dec->abstractType()->toString(); + qDebug() << "Type is not a function type" << dec->abstractType()->toString(); } - + if (functionType && decl) { QVector parameters; - if( DUChainUtils::getArgumentContext(dec) ) - parameters = DUChainUtils::getArgumentContext(dec)->localDeclarations(top); + if( DUChainUtils::argumentContext(dec) ) + parameters = DUChainUtils::argumentContext(dec)->localDeclarations(top); // QStringList defaultParams = decl->defaultParameters(); diff --git a/completion/items.h b/completion/items.h --- a/completion/items.h +++ b/completion/items.h @@ -29,16 +29,15 @@ class QModelIndex; namespace java { - //A completion item used for completion of normal declarations while normal code-completion class NormalDeclarationCompletionItem : public KDevelop::NormalDeclarationCompletionItem { public: - NormalDeclarationCompletionItem(KDevelop::DeclarationPointer decl = KDevelop::DeclarationPointer(), KSharedPtr context=KSharedPtr(), int _inheritanceDepth = 0); + NormalDeclarationCompletionItem(KDevelop::DeclarationPointer decl = KDevelop::DeclarationPointer(), QExplicitlySharedDataPointer context=QExplicitlySharedDataPointer(), int _inheritanceDepth = 0); virtual QVariant data(const QModelIndex& index, int role, const KDevelop::CodeCompletionModel* model) const; protected: - virtual void executed(KTextEditor::Document* document, const KTextEditor::Range& word); + virtual void executed(KTextEditor::View* document, const KTextEditor::Range& word); virtual QString shortenedTypeString(KDevelop::DeclarationPointer decl, int desiredTypeLength) const; }; diff --git a/completion/items.cpp b/completion/items.cpp --- a/completion/items.cpp +++ b/completion/items.cpp @@ -22,8 +22,6 @@ #include "items.h" -#include - #include #include #include @@ -42,12 +40,12 @@ namespace java { -NormalDeclarationCompletionItem::NormalDeclarationCompletionItem(KDevelop::DeclarationPointer decl, KSharedPtr< KDevelop::CodeCompletionContext > context, int _inheritanceDepth) +NormalDeclarationCompletionItem::NormalDeclarationCompletionItem(KDevelop::DeclarationPointer decl, QExplicitlySharedDataPointer< KDevelop::CodeCompletionContext > context, int _inheritanceDepth) : KDevelop::NormalDeclarationCompletionItem(decl, context, _inheritanceDepth) { } -void NormalDeclarationCompletionItem::executed(KTextEditor::Document* document, const KTextEditor::Range& word) +void NormalDeclarationCompletionItem::executed(KTextEditor::View* document, const KTextEditor::Range& word) { if( m_declaration && dynamic_cast(m_declaration.data()) ) { //Do some intelligent stuff for functions with the parens: @@ -59,7 +57,7 @@ { DUChainReadLocker lock(DUChain::lock(), 500); if(!lock.locked()) { - kDebug() << "Failed to lock the du-chain in time"; + qDebug() << "Failed to lock the du-chain in time"; return QVariant(); } @@ -107,7 +105,7 @@ if (FunctionType::Ptr functionType = m_declaration->type()) return createArgumentList(*this, 0); break; - + case CodeCompletionModel::Postfix: if (FunctionType::Ptr functionType = m_declaration->type()) { // TODO print throws declarations diff --git a/completion/model.h b/completion/model.h --- a/completion/model.h +++ b/completion/model.h @@ -27,7 +27,6 @@ #include #include #include -#include #include #include "context.h" @@ -43,9 +42,9 @@ protected: virtual KDevelop::CodeCompletionWorker* createCompletionWorker(); - + private: - KSharedPtr m_completionContext; + QExplicitlySharedDataPointer m_completionContext; }; } diff --git a/completion/model.cpp b/completion/model.cpp --- a/completion/model.cpp +++ b/completion/model.cpp @@ -27,11 +27,8 @@ #include #include #include -#include #include #include -#include -#include #include @@ -69,4 +66,3 @@ } -#include "model.moc" diff --git a/completion/worker.cpp b/completion/worker.cpp --- a/completion/worker.cpp +++ b/completion/worker.cpp @@ -22,11 +22,8 @@ #include "worker.h" -#include - #include #include -#include #include #include diff --git a/duchain/CMakeLists.txt b/duchain/CMakeLists.txt --- a/duchain/CMakeLists.txt +++ b/duchain/CMakeLists.txt @@ -23,19 +23,11 @@ ${CMAKE_CURRENT_SOURCE_DIR}/../parser ${CMAKE_CURRENT_BINARY_DIR}/../parser ${CMAKE_CURRENT_BINARY_DIR} - ${KDE4_INCLUDES} - ${KDEVPLATFORM_INCLUDE_DIR} ) -kde4_add_library(kdevjavaduchain SHARED ${kdevjavaduchain_SRCS} ) +add_library(kdevjavaduchain SHARED ${kdevjavaduchain_SRCS} ) +generate_export_header(kdevjavaduchain BASE_NAME javaduchain EXPORT_MACRO_NAME KDEVJAVADUCHAIN_EXPORT) target_link_libraries(kdevjavaduchain - ${QT_QTDESIGNER_LIBRARY} - ${KDE4_KTEXTEDITOR_LIBS} - ${KDEVPLATFORM_INTERFACES_LIBRARIES} - ${KDEVPLATFORM_PROJECT_LIBRARIES} - ${KDE4_THREADWEAVER_LIBRARIES} - ${KDEVPLATFORM_LANGUAGE_LIBRARIES} - ${KDE4_KDEUI_LIBS} kdev4javaparser ) diff --git a/duchain/abstractexpressionvisitor.h b/duchain/abstractexpressionvisitor.h --- a/duchain/abstractexpressionvisitor.h +++ b/duchain/abstractexpressionvisitor.h @@ -152,14 +152,14 @@ /** Called when there is a problem, with a string for that problem. * The default-implementation dumps all relevant information to - * kDebug. + * qDebug. * @param node the node the problem is about * @param str a string that describes the problem */ virtual void problem( T* node, const QString& str ) { #ifdef DUMP_PROBLEMS - kDebug() << "Problem:" << str; + qDebug() << "Problem:" << str; #endif } diff --git a/duchain/classdeclaration.h b/duchain/classdeclaration.h --- a/duchain/classdeclaration.h +++ b/duchain/classdeclaration.h @@ -26,7 +26,7 @@ #include #include -#include "javaduchainexport.h" +#include "javaduchain_export.h" namespace KDevelop { class QualifiedIdentifier; @@ -80,11 +80,29 @@ class KDEVJAVADUCHAIN_EXPORT ClassDeclaration : public KDevelop::ClassMemberDeclaration { public: + ClassDeclaration(const ClassDeclaration& rhs); ClassDeclaration(ClassDeclarationData& data); ClassDeclaration(const KDevelop::RangeInRevision& range, KDevelop::DUContext* context); ~ClassDeclaration(); + enum StorageSpecifier { + StaticSpecifier = 0x1 /**< indicates static member */, + AutoSpecifier = 0x2 /**< indicates automatic determination of member access */, + FriendSpecifier = 0x4 /**< indicates friend member */, + ExternSpecifier = 0x8 /**< indicates external declaration */, + RegisterSpecifier = 0x10 /**< indicates register */, + MutableSpecifier = 0x20 /**< indicates a mutable member */, + FinalSpecifier = 0x40 /**< indicates a final declaration */, + NativeSpecifier = 0x80, + SynchronizedSpecifier = 0x100, + StrictFPSpecifier = 0x200, + AbstractSpecifier = 0x400 + }; + Q_DECLARE_FLAGS(StorageSpecifiers, StorageSpecifier) + + void setStorageSpecifiers(StorageSpecifiers specifiers); + void clearBaseClasses(); ///Count of base-classes uint baseClassesSize() const; @@ -112,6 +130,13 @@ private: virtual KDevelop::Declaration* clonePrivate() const; DUCHAIN_DECLARE_DATA(ClassDeclaration) + + bool m_isFinal = false; + bool m_isNative = false; + bool m_isSynchronized = false; + bool m_isStrictFP = false; + bool m_isAbstract = false; + }; } diff --git a/duchain/classdeclaration.cpp b/duchain/classdeclaration.cpp --- a/duchain/classdeclaration.cpp +++ b/duchain/classdeclaration.cpp @@ -45,6 +45,17 @@ REGISTER_DUCHAIN_ITEM(ClassDeclaration); + +void ClassDeclaration::setStorageSpecifiers(StorageSpecifiers specifiers) +{ + ClassMemberDeclaration::setStorageSpecifiers(ClassMemberDeclaration::StorageSpecifiers(static_cast(specifiers))); + this->m_isFinal = specifiers & FinalSpecifier; + this->m_isSynchronized = specifiers & SynchronizedSpecifier; + this->m_isNative = specifiers & NativeSpecifier; + this->m_isStrictFP = specifiers & StrictFPSpecifier; + this->m_isAbstract = specifiers & AbstractSpecifier; +} + void ClassDeclaration::clearBaseClasses() { d_func_dynamic()->baseClassesList().clear(); } diff --git a/duchain/contextbuilder.h b/duchain/contextbuilder.h --- a/duchain/contextbuilder.h +++ b/duchain/contextbuilder.h @@ -25,7 +25,7 @@ #include #include "classdeclaration.h" -#include "javaduchainexport.h" +#include "javaduchain_export.h" class JavaLanguageSupport; @@ -81,7 +81,7 @@ KDevelop::QualifiedIdentifier identifierForNode(ClassOrInterfaceTypeNameAst* id); void unresolvedIdentifier(KDevelop::DUContextPointer context, KDevelop::QualifiedIdentifier id); - + // Visitors template void visitNodeList(const KDevPG::ListNode* list) diff --git a/duchain/contextbuilder.cpp b/duchain/contextbuilder.cpp --- a/duchain/contextbuilder.cpp +++ b/duchain/contextbuilder.cpp @@ -19,8 +19,7 @@ #include "contextbuilder.h" -#include -#include +#include #include #include @@ -64,7 +63,7 @@ bool ContextBuilder::identifiersRemainUnresolved() const { DUChainReadLocker lock(DUChain::lock()); - + foreach (const ContextID& cid, m_unresolvedIDs) { // Weirdness if the context has been deleted if (!cid.first) @@ -243,7 +242,7 @@ QualifiedIdentifier id = identifierForNode(node->enumName); openContext(node->body, DUContext::Class, id); classContextOpened(currentContext()); - + DefaultVisitor::visitEnumDeclaration(node); closeContext(); @@ -388,7 +387,7 @@ openedExtraContext = true; } } - + if (node->packageDeclaration) visitPackageDeclaration(node->packageDeclaration); @@ -405,7 +404,7 @@ } else if (packageDeclarations.count() != 1) { - kWarning() << "Package declaration expected, found " << packageDeclarations.count() << "declarations of" << id.last().toString(); + qWarning() << "Package declaration expected, found " << packageDeclarations.count() << "declarations of" << id.last().toString(); } } @@ -428,28 +427,28 @@ //addImportedContexts(); //Make sure the template-contexts are imported first, before any parent-class contexts. if (currentContext()->type() != DUContext::Class) { - kDebug() << "Tried to add base class to a non-class context!"; + qDebug() << "Tried to add base class to a non-class context!"; return; } AbstractType::Ptr baseClass = base.baseClass.abstractType(); - IdentifiedType* idType = dynamic_cast(baseClass.unsafeData()); + IdentifiedType* idType = dynamic_cast(baseClass.data()); Declaration* idDecl = 0; if (idType) { idDecl = idType->declaration(currentContext()->topContext()); if (!idDecl) { - kDebug() << "No declaration provided by base class type " << idType->qualifiedIdentifier().toStringList().join("."); + qDebug() << "No declaration provided by base class type " << idType->qualifiedIdentifier().toStringList().join("."); return; } } else { - kDebug() << "Tried to add base class which is a null type!"; + qDebug() << "Tried to add base class which is a null type!"; return; } - + if( idDecl->logicalInternalContext(0) ) { currentContext()->addImportedParentContext( idDecl->logicalInternalContext(0) ); } else { - kDebug() << "No internal context provided for " << idDecl->toString(); + qDebug() << "No internal context provided for " << idDecl->toString(); } } diff --git a/duchain/declarationbuilder.h b/duchain/declarationbuilder.h --- a/duchain/declarationbuilder.h +++ b/duchain/declarationbuilder.h @@ -21,7 +21,7 @@ #include "typebuilder.h" #include -#include "javaduchainexport.h" +#include "javaduchain_export.h" namespace java { @@ -60,14 +60,14 @@ virtual void visitEnumConstant(java::EnumConstantAst* node); KDevelop::Declaration::AccessPolicy parseAccessPolicy(OptionalModifiersAst* node); - KDevelop::ClassMemberDeclaration::StorageSpecifiers parseModifiers(OptionalModifiersAst* node); + ClassDeclaration::StorageSpecifiers parseModifiers(OptionalModifiersAst* node); private: bool m_defaultImportCreated; bool m_inImplementsClause; KDevelop::QualifiedIdentifier javaLang; - KDevelop::ClassMemberDeclaration::StorageSpecifiers m_currentVariableModifiers; + ClassDeclaration::StorageSpecifiers m_currentVariableModifiers; }; } diff --git a/duchain/declarationbuilder.cpp b/duchain/declarationbuilder.cpp --- a/duchain/declarationbuilder.cpp +++ b/duchain/declarationbuilder.cpp @@ -20,9 +20,6 @@ #include -#include -#include - #include "editorintegrator.h" #include "identifiercompiler.h" #include @@ -53,27 +50,27 @@ if (lastType()) { AbstractType::Ptr type = lastType(); - IdentifiedType* idType = dynamic_cast(type.unsafeData()); + IdentifiedType* idType = dynamic_cast(type.data()); //When the given type has no declaration yet, assume we are declaring it now. //If the type is a delayed type, it is a searched type, and not a declared one, so don't set the declaration then. if( idType && !idType->declarationId().isValid() /*&& !delayed*/ ) { idType->setDeclaration( currentDeclaration() ); } } - + currentDeclaration()->setType(lastType()); } eventuallyAssignInternalContext(); - //kDebug() << "Declaration closed:" << currentDeclaration()->identifier(); + //qDebug() << "Declaration closed:" << currentDeclaration()->identifier(); DeclarationBuilderBase::closeDeclaration(); } void DeclarationBuilder::visitClassDeclaration(ClassDeclarationAst * node) -{ +{ ClassDeclaration* newClass = openDefinition(node->className, node); newClass->setAccessPolicy(parseAccessPolicy(node->modifiers)); @@ -92,18 +89,18 @@ QList declarations = currentContext()->findDeclarations(javaLangObject, currentContext()->range().end, AbstractType::Ptr(), currentContext()->topContext()); if (declarations.count() >= 1) { if (declarations.count() > 1) { - kDebug() << "Found mulitple declarations for" << javaLangObject.toStringList().join("."); + qDebug() << "Found mulitple declarations for" << javaLangObject.toStringList().join("."); } BaseClassInstance instance; { // TODO check that type is a class instance.baseClass = declarations.at(0)->indexedType(); - Q_ASSERT(dynamic_cast(instance.baseClass.abstractType().unsafeData())->declaration(currentContext()->topContext())); + Q_ASSERT(dynamic_cast(instance.baseClass.abstractType().data())->declaration(currentContext()->topContext())); newClass->addBaseClass(instance); } addBaseType(instance); } else { - kDebug() << "Couldn't find declaration for java.lang.Object"; + qDebug() << "Couldn't find declaration for java.lang.Object"; } } } @@ -117,7 +114,7 @@ Q_ASSERT(context->type() == KDevelop::DUContext::Class); currentDeclaration()->setInternalContext(context); } - + DeclarationBuilderBase::classContextOpened(context); } @@ -134,20 +131,20 @@ if (currentClass) { // TODO check that type is a class instance.baseClass = lastType()->indexed(); - kDebug() << "adding base class type, valid? " << instance.baseClass.isValid(); + qDebug() << "adding base class type, valid? " << instance.baseClass.isValid(); if (instance.baseClass.abstractType()) - kDebug() << "type " << instance.baseClass.abstractType()->toString(); + qDebug() << "type " << instance.baseClass.abstractType()->toString(); else - kDebug() << "null type"; + qDebug() << "null type"; if (instance.baseClass.isValid()) currentClass->addBaseClass(instance); else - kDebug() << "extends-specifier without class type (invalid parsed type)"; + qDebug() << "extends-specifier without class type (invalid parsed type)"; } else { - kDebug() << "extends-specifier without class type"; + qDebug() << "extends-specifier without class type"; } } addBaseType(instance); @@ -162,7 +159,7 @@ m_inImplementsClause = false; } - + void DeclarationBuilder::visitClassOrInterfaceTypeName(ClassOrInterfaceTypeNameAst *node) { DeclarationBuilderBase::visitClassOrInterfaceTypeName(node); @@ -178,7 +175,7 @@ instance.baseClass = lastType()->indexed(); currentClass->addBaseClass(instance); }else{ - kWarning() << "implements specifier without interface type"; + qWarning() << "implements specifier without interface type"; } } addBaseType(instance); @@ -214,7 +211,7 @@ newMethod->setAccessPolicy(access); - newMethod->setStorageSpecifiers(parseModifiers(node->modifiers)); + newMethod->setStorageSpecifiers(ClassMemberDeclaration::StorageSpecifiers(static_cast(parseModifiers(node->modifiers)))); } DeclarationBuilderBase::visitInterfaceMethodDeclaration(node); @@ -267,7 +264,7 @@ { ClassFunctionDeclaration* newMethod = openDefinition(node->methodName, node); newMethod->setAccessPolicy(parseAccessPolicy(node->modifiers)); - newMethod->setStorageSpecifiers(parseModifiers(node->modifiers)); + newMethod->setStorageSpecifiers(ClassMemberDeclaration::StorageSpecifiers(static_cast(parseModifiers(node->modifiers)))); DeclarationBuilderBase::visitMethodDeclaration(node); @@ -287,7 +284,7 @@ { if (currentContext()->type() == DUContext::Class) { ClassMemberDeclaration* classMember = openDefinition(node->variableName, node); - classMember->setStorageSpecifiers(m_currentVariableModifiers); + classMember->setStorageSpecifiers(ClassMemberDeclaration::StorageSpecifiers(static_cast(m_currentVariableModifiers))); classMember->setKind(Declaration::Instance); classMember->setAbstractType(lastType()); } else { @@ -338,7 +335,7 @@ Q_ASSERT(javaLang.count() == 3); DUChainWriteLocker lock(DUChain::lock()); - NamespaceAliasDeclaration* decl = openDeclaration(QualifiedIdentifier(globalImportIdentifier()), RangeInRevision()); + NamespaceAliasDeclaration* decl = openDeclaration(globalImportIdentifier(), RangeInRevision()); decl->setImportIdentifier(javaLang); decl->setKind(Declaration::Import); closeDeclaration(); @@ -364,7 +361,7 @@ ///@todo only use the last name component as range { DUChainWriteLocker lock(DUChain::lock()); - NamespaceAliasDeclaration* decl = openDeclaration(QualifiedIdentifier(node->staticImport ? Identifier(globalStaticImportIdentifier) : globalImportIdentifier()), editorFindRange(node->identifierName, node->identifierName)); + NamespaceAliasDeclaration* decl = openDeclaration(node->staticImport ? Identifier(globalStaticImportIdentifier) : globalImportIdentifier(), editorFindRange(node->identifierName, node->identifierName)); decl->setImportIdentifier(import); } @@ -381,16 +378,16 @@ { DUChainWriteLocker lock(DUChain::lock()); - NamespaceAliasDeclaration* decl = openDeclaration(QualifiedIdentifier(globalImportIdentifier()), range); + NamespaceAliasDeclaration* decl = openDeclaration(globalImportIdentifier(), range); QualifiedIdentifier id2 = id; id2.push(Identifier("*")); decl->setImportIdentifier(id2); decl->setContext(currentContext()->topContext()); decl->setKind(Declaration::NamespaceAlias); closeDeclaration(); // Some crazy issue with just passing the whole QI? - openDeclaration(QualifiedIdentifier(id.last()), range); + openDeclaration(id.last(), range); } DeclarationBuilderBase::visitPackageDeclaration(node); @@ -417,23 +414,23 @@ return Declaration::DefaultAccess; } -ClassMemberDeclaration::StorageSpecifiers DeclarationBuilder::parseModifiers(java::OptionalModifiersAst* node) +ClassDeclaration::StorageSpecifiers DeclarationBuilder::parseModifiers(java::OptionalModifiersAst* node) { - ClassMemberDeclaration::StorageSpecifiers ret; + ClassDeclaration::StorageSpecifiers ret; if (node) { if (node->modifiers & ModifierFinal) - ret |= ClassMemberDeclaration::FinalSpecifier; + ret |= ClassDeclaration::FinalSpecifier; if (node->modifiers & ModifierAbstract) - ret |= ClassMemberDeclaration::AbstractSpecifier; + ret |= ClassDeclaration::AbstractSpecifier; if (node->modifiers & ModifierStrictFP) - ret |= ClassMemberDeclaration::StrictFPSpecifier; + ret |= ClassDeclaration::StrictFPSpecifier; if (node->modifiers & ModifierSynchronized) - ret |= ClassMemberDeclaration::SynchronizedSpecifier; + ret |= ClassDeclaration::SynchronizedSpecifier; if (node->modifiers & ModifierStatic) - ret |= ClassMemberDeclaration::StaticSpecifier; + ret |= ClassDeclaration::StaticSpecifier; if (node->modifiers & ModifierNative) - ret |= ClassMemberDeclaration::NativeSpecifier; + ret |= ClassDeclaration::NativeSpecifier; //ModifierTransient = 1 << 4, //ModifierVolatile = 1 << 9, } @@ -446,7 +443,7 @@ //We override this so we can get the class-declaration into a usable state(with filled type) earlier DUChainWriteLocker lock(DUChain::lock()); - IdentifiedType* idType = dynamic_cast(type.unsafeData()); + IdentifiedType* idType = dynamic_cast(type.data()); if( idType && !idType->declarationId().isValid() ) //When the given type has no declaration yet, assume we are declaring it now idType->setDeclaration( currentDeclaration() ); diff --git a/duchain/dumpchain.h b/duchain/dumpchain.h --- a/duchain/dumpchain.h +++ b/duchain/dumpchain.h @@ -22,7 +22,7 @@ #include "javadefaultvisitor.h" -#include "javaduchainexport.h" +#include "javaduchain_export.h" namespace KDevelop { diff --git a/duchain/dumpchain.cpp b/duchain/dumpchain.cpp --- a/duchain/dumpchain.cpp +++ b/duchain/dumpchain.cpp @@ -21,8 +21,8 @@ #include #include +#include -#include #include #include @@ -205,11 +205,11 @@ if( !nodeText.isEmpty() ) nodeText = "\"" + nodeText + "\""; - kDebug() << indentation << "\\" << names[node->kind - 1000] + qDebug() << indentation << "\\" << names[node->kind - 1000] << "[" << node->startToken << m_editor->findPosition(node->startToken, EditorIntegrator::FrontEdge) << ", " << node->endToken << m_editor->findPosition(node->endToken, EditorIntegrator::BackEdge) << "]" << nodeText << endl; } else { - kDebug() << indentation << "\\" << names[node->kind - 1000] + qDebug() << indentation << "\\" << names[node->kind - 1000] << "[" << node->startToken << "," << node->endToken << "]" << endl; } } @@ -220,11 +220,11 @@ if (node) { if (m_editor) { - kDebug() << indentation << "/" << names[node->kind - 1000] + qDebug() << indentation << "/" << names[node->kind - 1000] << "[(" << node->endToken << ") "/*<< m_editor->findPosition(node->startToken, EditorIntegrator::FrontEdge) << ", "*/ << m_editor->findPosition(node->endToken, EditorIntegrator::FrontEdge) << "]" << endl; } else { - kDebug() << indentation << "/" << names[node->kind - 1000] + qDebug() << indentation << "/" << names[node->kind - 1000] << "[" << node->startToken << "," << node->endToken << ']' << endl; } } @@ -237,18 +237,18 @@ void DumpChain::dump( DUContext * context, bool imported ) { - kDebug() << QString(indent * 2, ' ') << (imported ? "==import==> Context " : "New Context ") << context << "\"" << context->localScopeIdentifier() << "\" [" << context->scopeIdentifier() << "]" << context->range() << " " << (dynamic_cast(context) ? "top-context" : ""); + qDebug() << QString(indent * 2, ' ') << (imported ? "==import==> Context " : "New Context ") << context << "\"" << context->localScopeIdentifier() << "\" [" << context->scopeIdentifier() << "]" << context->range() << " " << (dynamic_cast(context) ? "top-context" : ""); if( !context ) return; if (!imported) { foreach (Declaration* dec, context->localDeclarations()) { - kDebug() << QString((indent+1) * 2, ' ') << "Declaration: " << dec->toString() << /*(idType ? (" (type-identity: " + idType->identifier().toString() + ")") : QString()) <<*/ " [" << dec->qualifiedIdentifier() << "]" << dec << "(internal ctx" << dec->internalContext() << ")" << dec->range() << "," << (dec->isDefinition() ? "definition, " : "declaration, ") << dec->uses().count() << "use(s)," << (dec->inSymbolTable() ? " in symbol table" : " not in symbol table"); - QMap > uses = dec->uses(); - for(QMap >::const_iterator it = uses.begin(); it != uses.end(); ++it) { - kDebug() << QString((indent+2) * 2, ' ') << "File:" << it.key().str(); + qDebug() << QString((indent+1) * 2, ' ') << "Declaration: " << dec->toString() << /*(idType ? (" (type-identity: " + idType->identifier().toString() + ")") : QString()) <<*/ " [" << dec->qualifiedIdentifier() << "]" << dec << "(internal ctx" << dec->internalContext() << ")" << dec->range() << "," << (dec->isDefinition() ? "definition, " : "declaration, ") << dec->uses().count() << "use(s)," << (dec->inSymbolTable() ? " in symbol table" : " not in symbol table"); + QMap > uses = dec->uses(); + for(QMap >::const_iterator it = uses.begin(); it != uses.end(); ++it) { + qDebug() << QString((indent+2) * 2, ' ') << "File:" << it.key().str(); foreach (const RangeInRevision& range, *it) - kDebug() << QString((indent+2) * 2+1, ' ') << "Use:" << range; + qDebug() << QString((indent+2) * 2+1, ' ') << "Use:" << range; } } } diff --git a/duchain/editorintegrator.h b/duchain/editorintegrator.h --- a/duchain/editorintegrator.h +++ b/duchain/editorintegrator.h @@ -23,7 +23,7 @@ #include "kdev-pg-token-stream.h" -#include "javaduchainexport.h" +#include "javaduchain_export.h" namespace java { diff --git a/duchain/editorintegrator.cpp b/duchain/editorintegrator.cpp --- a/duchain/editorintegrator.cpp +++ b/duchain/editorintegrator.cpp @@ -19,9 +19,6 @@ #include "editorintegrator.h" #include -#include -#include - #include #include "javaast.h" diff --git a/duchain/expressionvisitor.cpp b/duchain/expressionvisitor.cpp --- a/duchain/expressionvisitor.cpp +++ b/duchain/expressionvisitor.cpp @@ -91,9 +91,9 @@ if (useDecl) useNode = node; else - kDebug() << classType->toString() << "unable to return its declaration."; + qDebug() << classType->toString() << "unable to return its declaration."; } else { - kDebug() << id.toString() << "cannot be found as a class or interface type name."; + qDebug() << id.toString() << "cannot be found as a class or interface type name."; } if (useNode) @@ -122,8 +122,8 @@ if (decl->abstractType() ) { ///@todo only functions may have multiple declarations here - //ifDebug( if( dec.count() > 1 ) kDebug() << id.toString() << "was found" << dec.count() << "times" ) - //kDebug() << "found for" << id.toString() << ":" << decl->toString() << "type:" << decl->abstractType()->toString() << "context:" << decl->context(); + //ifDebug( if( dec.count() > 1 ) qDebug() << id.toString() << "was found" << dec.count() << "times" ) + //qDebug() << "found for" << id.toString() << ":" << decl->toString() << "type:" << decl->abstractType()->toString() << "context:" << decl->context(); openedType = decl->abstractType(); setLastType(decl->abstractType()); break; @@ -194,15 +194,15 @@ DUChainReadLocker lock(DUChain::lock()); StructureType::Ptr classType = lastInstance().declaration->type(); if (!classType) { - kDebug() << "Type of last instance " << lastInstance().declaration->toString() << "was not a structure."; + qDebug() << "Type of last instance " << lastInstance().declaration->toString() << "was not a structure."; return; } searchContext = classType->internalContext(topContext()); if (!searchContext) { - kDebug() << "could not find internal context for the structure type of the class to be searched"; + qDebug() << "could not find internal context for the structure type of the class to be searched"; return; } - kDebug() << "Looking for function" << id << "in" << searchContext->scopeIdentifier(true); + qDebug() << "Looking for function" << id << "in" << searchContext->scopeIdentifier(true); } QList parameters; @@ -215,7 +215,7 @@ visitNode(__it->element); // TODO determine l-value-ness if required if (lastType()) { - kDebug() << "Parameter" << lastType()->toString(); + qDebug() << "Parameter" << lastType()->toString(); parameters.append(OverloadResolver::Parameter(lastType(), false)); } @@ -227,19 +227,19 @@ DUChainReadLocker lock(DUChain::lock()); OverloadResolver resolver(searchContext); - //kDebug() << "Parameter count:" << parameters.count(); + //qDebug() << "Parameter count:" << parameters.count(); useDecl = resolver.resolve(OverloadResolver::ParameterList(parameters), id); if (useDecl) useNode = node->methodName; - kDebug() << "result" << (useDecl ? useDecl->toString() : "null declaration") << useNode; + qDebug() << "result" << (useDecl ? useDecl->toString() : "null declaration") << useNode; } if (useNode) usingDeclaration(useNode, useDecl); } else { - kDebug() << "No declaration for the last instance on which to invoke a method"; + qDebug() << "No declaration for the last instance on which to invoke a method"; } } @@ -283,7 +283,7 @@ useDecl = decls.first(); useNode = node->simpleNameAccess; } - //kDebug() << currentContext()->localScopeIdentifier().toString() << id << start << decls.count() << useDecl << useNode; + //qDebug() << currentContext()->localScopeIdentifier().toString() << id << start << decls.count() << useDecl << useNode; } if (node->superAccess) { @@ -331,10 +331,10 @@ } } } else { - kWarning() << "Internal context for declaration" << lastInstance().declaration->toString() << "was null."; + qWarning() << "Internal context for declaration" << lastInstance().declaration->toString() << "was null."; } } else { - kWarning() << "No last instance for primary selector at" << editor()->findRange(node->simpleNameAccess->name, node->simpleNameAccess->name); + qWarning() << "No last instance for primary selector at" << editor()->findRange(node->simpleNameAccess->name, node->simpleNameAccess->name); } } } diff --git a/duchain/helpers.h b/duchain/helpers.h --- a/duchain/helpers.h +++ b/duchain/helpers.h @@ -4,15 +4,15 @@ #include #include #include -#include +#include using namespace KDevelop; namespace java { static KDevelop::ReferencedTopDUContext allJavaContext() { - static IndexedString global(KUrl("java://all")); + static IndexedString global(QUrl("java://all")); DUChainReadLocker lock; ReferencedTopDUContext top = DUChain::self()->chainForDocument(global); if ( ! top ) { diff --git a/duchain/identifiercompiler.cpp b/duchain/identifiercompiler.cpp --- a/duchain/identifiercompiler.cpp +++ b/duchain/identifiercompiler.cpp @@ -25,8 +25,6 @@ #include "parsesession.h" //#include "tokens.h" -#include - using namespace KDevelop; using namespace java; diff --git a/duchain/javaduchainexport.h b/duchain/javaduchainexport.h deleted file mode 100644 --- a/duchain/javaduchainexport.h +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************** - * This file is part of KDevelop * - * Copyright 2014 Sven Brauch * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Library General Public License as * - * published by the Free Software Foundation; either version 2 of the * - * License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef JAVADUCHAINEXPORT_H -#define JAVADUCHAINEXPORT_H - -/* needed for KDE_EXPORT macros */ -#include - -#ifndef KDEVJAVADUCHAIN_EXPORT -# ifdef MAKE_KDEVJAVADUCHAIN_LIB -# define KDEVJAVADUCHAIN_EXPORT KDE_EXPORT -# else -# define KDEVJAVADUCHAIN_EXPORT KDE_IMPORT -# endif -#endif - -#endif - diff --git a/duchain/overloadresolver.cpp b/duchain/overloadresolver.cpp --- a/duchain/overloadresolver.cpp +++ b/duchain/overloadresolver.cpp @@ -20,7 +20,7 @@ #include "overloadresolver.h" #include #include -#include +#include #include #include #include @@ -30,7 +30,7 @@ #include "viablefunctions.h" namespace java { - + using namespace KDevelop; OverloadResolver::OverloadResolver( DUContextPointer context, bool forceIsInstance ) : m_context(context), m_topContext(context->topContext()), m_worstConversionRank(NoMatch), m_forceIsInstance(forceIsInstance) { @@ -217,7 +217,7 @@ FunctionType::Ptr functionType = declaration->type(); if(!functionType) { - kDebug(9007) << "Template function has no function type"; + qDebug(9007) << "Template function has no function type"; return declaration; } @@ -289,9 +289,9 @@ return 1; if(!argumentType || !parameterType) return 0; - - ifDebugOverloadResolution( kDebug() << "matching" << argumentType->toString() << "to" << parameterType->toString(); ) - + + ifDebugOverloadResolution( qDebug() << "matching" << argumentType->toString() << "to" << parameterType->toString(); ) + if(instantiatedTypes.isEmpty()) return 1; @@ -317,7 +317,7 @@ if( argumentPointer && parameterPointer && ((argumentPointer->modifiers() & AbstractType::ConstModifier) == (parameterPointer->modifiers() & AbstractType::ConstModifier)) ) return incrementIfSuccessful( matchParameterTypes( argumentPointer->baseType(), parameterPointer->baseType(), instantiatedTypes, keepValue ) ); - + /*if(CppTemplateParameterType::Ptr templateParam = parameterType.cast()) { ///@todo Allow template-parameters with even more template-parameters declared //Directly assign argumentType to the template parameter @@ -327,43 +327,43 @@ if(instantiatedTypes[id].isNull()) { instantiatedTypes[id] = argumentType; return 1; - }else if(instantiatedTypes[id]->equals(argumentType.unsafeData())) { + }else if(instantiatedTypes[id]->equals(argumentType.data())) { return 1; }else{ //Mismatch, another type was already assigned return 0; } } }*/ - + ///Match assigned template-parameters, for example when matching QList to QList, assign int to T. - const IdentifiedType* identifiedArgument = dynamic_cast(argumentType.unsafeData()); - const IdentifiedType* identifiedParameter = dynamic_cast(parameterType.unsafeData()); - + const IdentifiedType* identifiedArgument = dynamic_cast(argumentType.data()); + const IdentifiedType* identifiedParameter = dynamic_cast(parameterType.data()); + if( identifiedArgument && identifiedParameter ) { //TemplateDeclaration* argumentTemplateDeclaration = dynamic_cast(identifiedArgument->declaration(m_topContext.data())); //TemplateDeclaration* parameterTemplateDeclaration = dynamic_cast(identifiedParameter->declaration(m_topContext.data())); //if(!argumentTemplateDeclaration || !parameterTemplateDeclaration) return 1; - + /*if(argumentTemplateDeclaration->instantiatedFrom() == parameterTemplateDeclaration->instantiatedFrom() && argumentTemplateDeclaration->instantiatedFrom()) { InstantiationInformation argumentInstantiatedWith = argumentTemplateDeclaration->instantiatedWith().information(); InstantiationInformation parameterInstantiatedWith = parameterTemplateDeclaration->instantiatedWith().information(); - + if(argumentInstantiatedWith.templateParametersSize() != parameterInstantiatedWith.templateParametersSize()) return 0; - + uint matchDepth = 1; - + for(uint a = 0; a < argumentInstantiatedWith.templateParametersSize(); ++a) { uint localMatchDepth = matchParameterTypes(argumentInstantiatedWith.templateParameters()[a].abstractType(), parameterInstantiatedWith.templateParameters()[a].abstractType(), instantiatedTypes, keepValue); if(!localMatchDepth) return 0; matchDepth += localMatchDepth; } - + return matchDepth; }*/ } @@ -374,7 +374,7 @@ AbstractType::Ptr getContainerType(AbstractType::Ptr type, int depth, TopDUContext* topContext) { for(int a = 0; a < depth; a++) { AbstractType::Ptr real = TypeUtils::realType(type, topContext); - IdentifiedType* idType = dynamic_cast(real.unsafeData()); + IdentifiedType* idType = dynamic_cast(real.data()); if(!idType) return AbstractType::Ptr(); @@ -391,14 +391,14 @@ uint OverloadResolver::matchParameterTypes(AbstractType::Ptr argumentType, const IndexedTypeIdentifier& parameterType, QMap& instantiatedTypes, bool keepValue) const { - ifDebugOverloadResolution( kDebug() << "1 matching" << argumentType->toString() << "to" << parameterType.toString() << parameterType.pointerDepth(); ) + ifDebugOverloadResolution( qDebug() << "1 matching" << argumentType->toString() << "to" << parameterType.toString() << parameterType.pointerDepth(); ) if(!argumentType) return 1; if(instantiatedTypes.isEmpty()) return 1; - + QualifiedIdentifier parameterQid(parameterType.identifier().identifier()); - + if(parameterQid.isEmpty()) return 1; @@ -439,7 +439,7 @@ matchDepth += localDepth; } #endif - + return matchDepth; } diff --git a/duchain/tests/CMakeLists.txt b/duchain/tests/CMakeLists.txt --- a/duchain/tests/CMakeLists.txt +++ b/duchain/tests/CMakeLists.txt @@ -1,14 +1,19 @@ + +include(ECMAddTests) + include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} - ${KDE4_INCLUDES} - ${KDEVPLATFORM_INCLUDE_DIR} ) -kde4_add_unit_test(javaduchaintest javaduchaintest.cpp) +add_executable(javaduchaintest javaduchaintest.cpp) +add_test(javaduchaintest javaduchaintest) +ecm_mark_as_test(javaduchaintest) + target_link_libraries(javaduchaintest kdevjavaduchain - ${QT_QTTEST_LIBRARY} - ${KDEVPLATFORM_TESTS_LIBRARIES} -) \ No newline at end of file + KDevPlatformLanguage + KDevPlatformTests + Qt5::Test +) diff --git a/duchain/tests/javaduchaintest.cpp b/duchain/tests/javaduchaintest.cpp --- a/duchain/tests/javaduchaintest.cpp +++ b/duchain/tests/javaduchaintest.cpp @@ -30,8 +30,8 @@ #include #include -#include -#include +#include +#include QTEST_MAIN(JavaDUChainTest); @@ -199,6 +199,4 @@ QTest::newRow("function_call") << "public class Foo {\npublic static void main() {\nfunc();\n}\nvoid func() {\n}\n}" << QStringList{"func"}; } -#include "javaduchaintest.moc" - // kate: space-indent on; indent-width 4 diff --git a/duchain/topducontext.cpp b/duchain/topducontext.cpp --- a/duchain/topducontext.cpp +++ b/duchain/topducontext.cpp @@ -22,7 +22,6 @@ #include #include #include - #include #include "helpers.h" @@ -52,7 +51,7 @@ void operator() (Declaration* declaration) { #ifdef DEBUG_SEARCH - kDebug() << "accepting" << element->qualifiedIdentifier().toString(); + qDebug() << "accepting" << element->qualifiedIdentifier().toString(); #endif if (check(declaration)) { target.append(declaration); @@ -77,25 +76,27 @@ FindDeclarationsAcceptor accept(ret, check); #ifdef DEBUG_SEARCH2 - FOREACH_ARRAY(SearchItem::Ptr idTree, identifiers) + for (const SearchItem::Ptr &idTree : identifiers) + { foreach(const QualifiedIdentifier &id, idTree->toList()) - kDebug() << "findDeclarationsInternal" << id.toString(); + qDebug() << "findDeclarationsInternal" << id.toString(); + } bool nextEmpty = identifier->hasNext() ? identifier->next.isEmpty() : true; - kDebug() << "Do direct search? hasNext" << identifier->hasNext() << " isEmpty " << nextEmpty; + qDebug() << "Do direct search? hasNext" << identifier->hasNext() << " isEmpty " << nextEmpty; #endif - + if (identifier->hasNext() && !identifier->next.isEmpty()) { // This is a qualified identifier, do a direct lookup only SearchItem::PtrList directLookup; directLookup.append(identifier); findJavaDeclarationsInternal(directLookup, accept, false); #ifdef DEBUG_SEARCH2 - kDebug() << "Found directly " << ret.count(); + qDebug() << "Found directly " << ret.count(); #endif return true; } - + SearchItem::PtrList singleTypeImports; SearchItem::PtrList typeImportsOnDemand; SearchItem::PtrList singleStaticImports; @@ -127,97 +128,106 @@ } #ifdef DEBUG_SEARCH - FOREACH_ARRAY(SearchItem::Ptr idTree, singleTypeImports) + for (const SearchItem::Ptr &idTree : singleTypeImports) + { foreach(const QualifiedIdentifier &id, idTree->toList()) - kDebug() << "Single type imported: " << id.toString(); + qDebug() << "Single type imported: " << id.toString(); + } - FOREACH_ARRAY(SearchItem::Ptr idTree, typeImportsOnDemand) + for (const SearchItem::Ptr &idTree : typeImportsOnDemand) + { foreach(const QualifiedIdentifier &id, idTree->toList()) - kDebug() << "Type import on demand: " << id.toString(); + qDebug() << "Type import on demand: " << id.toString(); + } - FOREACH_ARRAY(SearchItem::Ptr idTree, singleStaticImports) + for (const SearchItem::Ptr &idTree : singleStaticImports) + { foreach(const QualifiedIdentifier &id, idTree->toList()) - kDebug() << "Single static imported: " << id.toString(); + qDebug() << "Single static imported: " << id.toString(); + } - FOREACH_ARRAY(SearchItem::Ptr idTree, staticImportsOnDemand) + for (const SearchItem::Ptr &idTree : staticImportsOnDemand) + { foreach(const QualifiedIdentifier &id, idTree->toList()) - kDebug() << "Statics imported on demand: " << id.toString(); + qDebug() << "Statics imported on demand: " << id.toString(); + } #endif ///The actual scopes are found within applyAliases, and each complete qualified identifier is given to FindDeclarationsAcceptor. ///That stores the found declaration to the output. findJavaDeclarationsInternal(singleTypeImports, accept, false); if (foundEnough(ret, flags)) { #ifdef DEBUG_SEARCH2 - kDebug() << "Found from single type" << ret.count(); + qDebug() << "Found from single type" << ret.count(); #endif return true; } findJavaDeclarationsInternal(singleStaticImports, accept, true); if (foundEnough(ret, flags)) { #ifdef DEBUG_SEARCH2 - kDebug() << "Found from single static" << ret.count(); + qDebug() << "Found from single static" << ret.count(); #endif return true; } findJavaDeclarationsInternal(typeImportsOnDemand, accept, false); if (foundEnough(ret, flags)) { #ifdef DEBUG_SEARCH2 - kDebug() << "Found from type on demand" << ret.count(); + qDebug() << "Found from type on demand" << ret.count(); #endif return true; } findJavaDeclarationsInternal(staticImportsOnDemand, accept, true); if (foundEnough(ret, flags)) { #ifdef DEBUG_SEARCH2 - kDebug() << "Found from static on demand" << ret.count(); + qDebug() << "Found from static on demand" << ret.count(); #endif return true; } #ifdef DEBUG_SEARCH2 - kDebug() << "None found" << ret.count(); + qDebug() << "None found" << ret.count(); #endif return true; } template void TopDUContext::findJavaDeclarationsInternal( const SearchItem::PtrList& identifiers, Acceptor& accept, bool staticOnly ) const { - FOREACH_ARRAY(SearchItem::Ptr identifier, identifiers) { + for (SearchItem::Ptr identifier : identifiers) + { QualifiedIdentifier id(identifier->identifier); while (identifier->hasNext()) { identifier = *identifier->next.data(); id.push(identifier->identifier); } #ifdef DEBUG_SEARCH2 - kDebug() << "checking" << id.toString(); + qDebug() << "checking" << id.toString(); #endif if(!id.isEmpty()) { - PersistentSymbolTable::FilteredDeclarationIterator filter = PersistentSymbolTable::self().getFilteredDeclarations(id, recursiveImportIndices()); + PersistentSymbolTable::FilteredDeclarationIterator filter = PersistentSymbolTable::self().filteredDeclarations(id, recursiveImportIndices()); if (filter) { for(; filter; ++filter) { const IndexedDeclaration iDecl = *filter; Declaration* aliasDecl = iDecl.data(); #ifdef DEBUG_SEARCH2 - kDebug() << "Found declaration" << aliasDecl; + qDebug() << "Found declaration" << aliasDecl; #endif if(!aliasDecl) continue; if(aliasDecl->identifier() != id.last()) { //Since we have retrieved the aliases by hash only, we still need to compare the name #ifdef DEBUG_SEARCH2 - kDebug() << "Dumped as not the same identifier" << aliasDecl->identifier().toString() << id.last().toString(); + qDebug() << "Dumped as not the same identifier" << aliasDecl->identifier().toString() << id.last().toString(); #endif continue; } @@ -227,21 +237,21 @@ // TODO check logic here if (staticOnly && (!classMemberDecl || !classMemberDecl->isStatic())) { #ifdef DEBUG_SEARCH2 - kDebug() << "Dumped as not static where search requested static only" << aliasDecl->identifier().toString(); + qDebug() << "Dumped as not static where search requested static only" << aliasDecl->identifier().toString(); #endif continue; } #ifdef DEBUG_SEARCH2 - kDebug() << "Trying to accept" << aliasDecl->identifier().toString(); + qDebug() << "Trying to accept" << aliasDecl->identifier().toString(); #endif accept(aliasDecl); } } } #ifdef DEBUG_SEARCH2 - kDebug() << "Finished" << id.toString(); + qDebug() << "Finished" << id.toString(); #endif } } diff --git a/duchain/typebuilder.h b/duchain/typebuilder.h --- a/duchain/typebuilder.h +++ b/duchain/typebuilder.h @@ -24,7 +24,7 @@ #include #include -#include "javaduchainexport.h" +#include "javaduchain_export.h" namespace java { diff --git a/duchain/typebuilder.cpp b/duchain/typebuilder.cpp --- a/duchain/typebuilder.cpp +++ b/duchain/typebuilder.cpp @@ -258,7 +258,7 @@ if (buildCompleteTypes() && openTypeFromName(m_currentIdentifier, node, true)) { { //DUChainReadLocker lock(DUChain::lock()); - //kDebug() << "Searching for type " << m_currentIdentifier.toStringList().join(".") << ", found " << currentAbstractType()->toString(); + //qDebug() << "Searching for type " << m_currentIdentifier.toStringList().join(".") << ", found " << currentAbstractType()->toString(); } closeType(); } else { diff --git a/duchain/typeconversion.cpp b/duchain/typeconversion.cpp --- a/duchain/typeconversion.cpp +++ b/duchain/typeconversion.cpp @@ -39,7 +39,7 @@ struct ImplicitConversionParams { IndexedType from, to; bool fromLValue, noUserDefinedConversion; - + bool operator==(const ImplicitConversionParams& rhs) const { return from == rhs.from && to == rhs.to && fromLValue == rhs.fromLValue && noUserDefinedConversion == rhs.noUserDefinedConversion; } @@ -125,28 +125,28 @@ m_baseConversionLevels = 0; int conv = 0; - + ImplicitConversionParams params; params.from = _from; params.to = _to; params.fromLValue = fromLValue; params.noUserDefinedConversion = noUserDefinedConversion; - + if(m_cache) { QHash::const_iterator it = m_cache->m_implicitConversionResults.constFind(params); if(it != m_cache->m_implicitConversionResults.constEnd()) return *it; } - + AbstractType::Ptr to = unAliasedType(_to.abstractType()); AbstractType::Ptr from = unAliasedType(_from.abstractType()); - + if( !from || !to ) { problem( from, to, "one type is invalid" ); goto ready; }else{ - - //kDebug(9007) << "Checking conversion from " << from->toString() << " to " << to->toString(); + + //qDebug(9007) << "Checking conversion from " << from->toString() << " to " << to->toString(); ReferenceType::Ptr fromReference = from.cast(); if( fromReference ) fromLValue = true; @@ -210,17 +210,17 @@ conv = tempConv; } } - + if( (tempConv = ellipsisConversion(from, to)) && tempConv > conv ) conv = tempConv; } } ready: - + if(m_cache) m_cache->m_implicitConversionResults.insert(params, conv); - + return conv; } @@ -246,48 +246,48 @@ ConversionRank worseRank( ConversionRank rank1, ConversionRank rank2 ) { return rank1 > rank2 ? rank2 : rank1; } - + ConversionRank TypeConversion::pointerConversion( PointerType::Ptr from, PointerType::Ptr to ) { - + //We can convert non-const -> const, but not const -> non-const // if(to->modifiers() & AbstractType::ConstModifier || !(from->modifiers()& AbstractType::ConstModifier)) { if(!from || !to) return NoMatch; - + AbstractType::Ptr nextFrom = unAliasedType(from->baseType()); AbstractType::Ptr nextTo = unAliasedType(to->baseType()); if(!nextTo || !nextFrom) return NoMatch; if((nextFrom->modifiers() & AbstractType::ConstModifier) && !(nextTo->modifiers() & AbstractType::ConstModifier)) return NoMatch; //Cannot convert const -> non-const - + PointerType::Ptr pointerFrom = nextFrom.cast(); PointerType::Ptr pointerTo = nextTo.cast(); if(pointerFrom && pointerTo) return pointerConversion(pointerFrom, pointerTo); - + StructureType::Ptr fromClass = nextFrom.cast(); StructureType::Ptr toClass = nextTo.cast(); if( toClass && fromClass ) if(toClass->modifiers() & AbstractType::ConstModifier || !(fromClass->modifiers()& AbstractType::ConstModifier)) if( isPublicBaseClass( fromClass, toClass, m_topContext, &m_baseConversionLevels ) ) return ((toClass->modifiers() & AbstractType::ConstModifier) != (fromClass->modifiers() & AbstractType::ConstModifier)) ? Conversion : ExactMatch; - + bool changed = false; //Change the constness matches, so they are equal if compatible if(nextTo->modifiers() & AbstractType::ConstModifier) { nextFrom->setModifiers(nextFrom->modifiers() | AbstractType::ConstModifier); changed = true; } - + if(identityConversion(nextFrom, nextTo)) return changed ? Conversion : ExactMatch; - + // } - + return NoMatch; } @@ -333,22 +333,22 @@ if(!from || !to) return NoMatch; - + ConversionRank bestRank = NoMatch; ///Try lvalue-transformation category if( (categories & LValueTransformationCategory) ) { bool constRef = false; if( isReferenceType(from) ) { ///Transform lvalue to rvalue. Iso c++ draft 4.1 modeled roughly - + AbstractType::Ptr fromNonConstant = realType(from, m_topContext)->indexed().abstractType(); //When copying, the type becomes non-constant if(fromNonConstant && fromNonConstant->modifiers() & AbstractType::ConstModifier) fromNonConstant->setModifiers(fromNonConstant->modifiers() & ~(AbstractType::ConstModifier)); - + ConversionRank ret = standardConversion( fromNonConstant, to, removeCategories(categories,LValueTransformationCategory), maxCategories-1 ); maximizeRank( bestRank, ret ); }else if( ArrayType::Ptr array = realType(from, m_topContext, &constRef).cast() ) { //realType(from) is used here so reference-to-array can be transformed to a pointer. This does not exactly follow the standard I think, check that. @@ -383,7 +383,7 @@ // if( categories & QualificationAdjustmentCategory ) { // PointerType::Ptr pnt = from.cast(); -// +// // ///@todo iso c++ 4.4.2 etc: pointer to member // } @@ -492,10 +492,10 @@ } bool TypeConversion::identityConversion( AbstractType::Ptr from, AbstractType::Ptr to ) { - + from = TypeUtils::unAliasedType(from); to = TypeUtils::unAliasedType(to); - + if( !from && !to ) return true; else if( !from || !to ) @@ -505,7 +505,7 @@ if(from.cast() && typeid(*to) == typeid(IntegralType)) return true; - return from->equals(to.unsafeData()); + return from->equals(to.data()); } void TypeConversion::problem( AbstractType::Ptr from, AbstractType::Ptr to, const QString& desc ) { @@ -599,4 +599,4 @@ return NoMatch; } -} \ No newline at end of file +} diff --git a/duchain/typeutils.cpp b/duchain/typeutils.cpp --- a/duchain/typeutils.cpp +++ b/duchain/typeutils.cpp @@ -44,7 +44,7 @@ } if(base) base->setModifiers(base->modifiers() | hadModifiers); - + ref = base.cast(); alias = base.cast(); } @@ -62,7 +62,7 @@ base = ref->baseType(); if(base) base->setModifiers(base->modifiers() | hadModifiers); - + ref = base.cast(); } @@ -187,10 +187,10 @@ Declaration* klassDecl = klass->declaration(topContext); DUContext* context = klassDecl ? klassDecl->internalContext() : 0; if( !context || !context->owner() || !context->owner() ) { -// kDebug(9007) << "Tried to get constructors of a class without context"; +// qDebug(9007) << "Tried to get constructors of a class without context"; return; } - + Identifier id(context->owner()->identifier()); id.clearTemplateIdentifiers(); @@ -218,9 +218,9 @@ KDevelop::AbstractType::Ptr matchingClassPointer(const KDevelop::AbstractType::Ptr& matchTo, const KDevelop::AbstractType::Ptr& actual, const KDevelop::TopDUContext* topContext) { java::TypeConversion conversion(topContext); - + StructureType::Ptr actualStructure = realType(actual, topContext).cast(); - + if(actualStructure) { DUContext* internal = actualStructure->internalContext(topContext); if(internal) { @@ -235,14 +235,14 @@ } } } - + return actual; } Declaration* getDeclaration( const AbstractType::Ptr& type, TopDUContext* top ) { if( !type) return 0; - const IdentifiedType* idType = dynamic_cast(type.unsafeData()); + const IdentifiedType* idType = dynamic_cast(type.data()); if( idType ) { return idType->declaration(top); } else { @@ -252,7 +252,7 @@ AbstractType::Ptr decreasePointerDepth(AbstractType::Ptr type, TopDUContext* top, bool useOperator) { type = realType(type, top); - + if( PointerType::Ptr pt = type.cast() ) { //Dereference @@ -285,7 +285,7 @@ AbstractType::Ptr removeConstants(AbstractType::Ptr type) { if(ConstantIntegralType::Ptr integral = type.cast()) return AbstractType::Ptr(new IntegralType(*integral)); - + return type; } } diff --git a/duchain/usebuilder.h b/duchain/usebuilder.h --- a/duchain/usebuilder.h +++ b/duchain/usebuilder.h @@ -22,7 +22,7 @@ #include #include "expressionvisitor.h" -#include "javaduchainexport.h" +#include "javaduchain_export.h" namespace java { diff --git a/duchain/usebuilder.cpp b/duchain/usebuilder.cpp --- a/duchain/usebuilder.cpp +++ b/duchain/usebuilder.cpp @@ -75,8 +75,8 @@ if (end_token == qint64()) end_token = node->endToken; - kDebug() << "New use" << editor()->findRange(start_token, end_token) << " declaration" << decl.data() << decl->toString(); - m_builder->newUse(node, editor()->findRange(start_token, end_token), decl); + qDebug() << "New use" << editor()->findRange(start_token, end_token) << " declaration" << decl.data() << decl->toString(); + m_builder->newUse(editor()->findRange(start_token, end_token), decl); } } diff --git a/duchain/viablefunctions.cpp b/duchain/viablefunctions.cpp --- a/duchain/viablefunctions.cpp +++ b/duchain/viablefunctions.cpp @@ -60,11 +60,11 @@ uint functionArgumentCount = m_type->indexedArgumentsSize(); if( params.parameters.size() + m_funDecl->defaultParametersSize() < functionArgumentCount && !partial ) { - //kDebug() << "Not enough parameters + default-parameters"; + //qDebug() << "Not enough parameters + default-parameters"; return; //Not enough parameters + default-parameters } if( params.parameters.size() > functionArgumentCount ) { - //kDebug() << "Too many parameters" << params.parameters.size() << "gt" << functionArgumentCount; + //qDebug() << "Too many parameters" << params.parameters.size() << "gt" << functionArgumentCount; return; //Too many parameters } diff --git a/javalanguagesupport.h b/javalanguagesupport.h --- a/javalanguagesupport.h +++ b/javalanguagesupport.h @@ -53,29 +53,32 @@ JavaLanguageSupport( QObject* parent, const QVariantList& args = QVariantList() ); virtual ~JavaLanguageSupport(); - virtual QString name() const; + virtual QString name() const override; - virtual KDevelop::ParseJob *createParseJob(const KDevelop::IndexedString& url); - virtual KDevelop::ILanguage *language(); - virtual KDevelop::ICodeHighlighting* codeHighlighting() const; + virtual KDevelop::ParseJob *createParseJob(const KDevelop::IndexedString& url) override; + virtual KDevelop::ILanguageSupport *language(); + virtual KDevelop::ICodeHighlighting* codeHighlighting() const override; + + KDevelop::ConfigPage* configPage(int number, QWidget *parent) override; + int configPages() const override; static JavaLanguageSupport* self(); QMutex* javaSourceZipMutex() const; KZip* javaSourceZip() const; private Q_SLOTS: void slotJavaSourceEntries(KIO::Job* job, KIO::UDSEntryList entries); - + private: void scheduleInternalSources(); KDevelop::CodeHighlighting* m_highlighting; KDevelop::ReferencedTopDUContext m_allJavaContext; - KUrl m_javaSourceUrl; + QUrl m_javaSourceUrl; QMutex* m_javaSourceZipMutex; mutable KZip* m_javaSourceZip; - + static JavaLanguageSupport* s_self; }; diff --git a/javalanguagesupport.cpp b/javalanguagesupport.cpp --- a/javalanguagesupport.cpp +++ b/javalanguagesupport.cpp @@ -22,14 +22,10 @@ #include -#include -#include -#include -#include -#include +#include -#include -#include +#include +#include #include #include @@ -41,52 +37,48 @@ #include #include "parsejob.h" +#include "settings/javapreferences.h" #include #include #include "completion/model.h" #include #include -#include #include #include #include -#include #include #include using namespace java; -K_PLUGIN_FACTORY(KDevJavaSupportFactory, registerPlugin(); ) -K_EXPORT_PLUGIN(KDevJavaSupportFactory("kdevjavasupport")) +K_PLUGIN_FACTORY_WITH_JSON(KDevJavaSupportFactory, "kdevjavasupport.json", registerPlugin(); ) JavaLanguageSupport* JavaLanguageSupport::s_self = 0; JavaLanguageSupport::JavaLanguageSupport( QObject* parent, const QVariantList& /*args*/ ) - : KDevelop::IPlugin( KDevJavaSupportFactory::componentData(), parent ) + : KDevelop::IPlugin(QStringLiteral("kdevjavasupport"), parent ) , KDevelop::ILanguageSupport() , m_allJavaContext(0) , m_javaSourceZipMutex(new QMutex()) , m_javaSourceZip(0) { s_self = this; - - KDEV_USE_EXTENSION_INTERFACE( KDevelop::ILanguageSupport ) m_highlighting = new KDevelop::CodeHighlighting( this ); CodeCompletionModel* ccModel = new CodeCompletionModel(this); new KDevelop::CodeCompletion( this, ccModel, name() ); scheduleInternalSources(); - kDebug() << "Java support loaded"; + qDebug() << "Java support loaded"; } JavaLanguageSupport::~JavaLanguageSupport() { - KDevelop::ILanguage* lang = language(); + KDevelop::ILanguageSupport* lang = language(); if (lang) { lang->parseLock()->lockForWrite(); s_self = 0; //By locking the parse-mutexes, we make sure that parse- and preprocess-jobs get a chance to finish in a good state @@ -112,55 +104,61 @@ return "Java"; } -KDevelop::ILanguage * JavaLanguageSupport::language() +KDevelop::ILanguageSupport * JavaLanguageSupport::language() { return core()->languageController()->language(name()); } void JavaLanguageSupport::scheduleInternalSources() { - KConfigGroup config(KGlobal::config(), "Java Support"); - m_javaSourceUrl = config.readEntry("Java Source Zip", KUrl()); + KConfigGroup config(KSharedConfig::openConfig(), "Java Support"); + m_javaSourceUrl = config.readEntry("Java Source Zip", QUrl()); - if (m_javaSourceUrl.protocol() == "file") { + if (m_javaSourceUrl.scheme() == "file") { // KIO method - replace with KZip method if you can understand the KArchive API QFileInfo info(m_javaSourceUrl.path()); if (info.exists() && info.isReadable() && info.isFile()) { m_javaSourceZip = new KZip(m_javaSourceUrl.path()); if (!m_javaSourceZip->open(QIODevice::ReadOnly)) { - kDebug() << "error, could not open zip file"<< m_javaSourceUrl <<"for reading."; + qDebug() << "error, could not open zip file"<< m_javaSourceUrl <<"for reading."; return; } - m_javaSourceUrl.setProtocol("zip"); - m_javaSourceUrl.adjustPath(KUrl::AddTrailingSlash); + m_javaSourceUrl.setScheme("zip"); + + QString path = m_javaSourceUrl.path(); + if (path.length() > 0 && path.back() != QLatin1Char('/')) { + m_javaSourceUrl.setPath(path + QLatin1Char('/')); + } + KIO::ListJob* list = KIO::listRecursive(m_javaSourceUrl, KIO::DefaultFlags, false); connect(list, SIGNAL(entries(KIO::Job*,KIO::UDSEntryList)), SLOT(slotJavaSourceEntries(KIO::Job*,KIO::UDSEntryList))); list->start(); } else { - kDebug() << m_javaSourceUrl << "error, file doesn't exist or is not readable"; + qDebug() << m_javaSourceUrl << "error, file doesn't exist or is not readable"; } } else { - kDebug() << m_javaSourceUrl << "error, non file protocol url"; + qDebug() << m_javaSourceUrl << "error, non file protocol url"; } } void JavaLanguageSupport::slotJavaSourceEntries(KIO::Job* job, KIO::UDSEntryList entries) { Q_UNUSED(job); - + foreach (KIO::UDSEntry entry, entries) { - KUrl url = m_javaSourceUrl; - url.addPath(entry.stringValue(KIO::UDSEntry::UDS_NAME)); + QUrl url = m_javaSourceUrl; + url = url.adjusted(QUrl::StripTrailingSlash); + url.setPath(url.path() + '/' + (entry.stringValue(KIO::UDSEntry::UDS_NAME))); if (!entry.isDir() && !entry.isLink()) { - kDebug() << "Found" << url << "in the java source zip, scheduled for parsing"; + qDebug() << "Found" << url << "in the java source zip, scheduled for parsing"; KDevelop::ICore::self()->languageController()->backgroundParser()->addDocument(KDevelop::IndexedString(url), KDevelop::TopDUContext::SimplifiedVisibleDeclarationsAndContexts); } } } KZip* JavaLanguageSupport::javaSourceZip() const -{ +{ return m_javaSourceZip; } @@ -175,6 +173,17 @@ return m_highlighting; } +KDevelop::ConfigPage* JavaLanguageSupport::configPage(int number, QWidget* parent) +{ + return number == 0 ? new JavaPreferences(parent) : nullptr; +} + +int JavaLanguageSupport::configPages() const +{ + return 1; +} + + #include "javalanguagesupport.moc" // kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on diff --git a/kdevjavasupport.desktop.cmake b/kdevjavasupport.desktop.cmake deleted file mode 100644 --- a/kdevjavasupport.desktop.cmake +++ /dev/null @@ -1,100 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Type=Service -Exec=blubb -Comment=Java Language Support -Comment[ast]=Sofitu de llinguax Java -Comment[bg]=Поддръжка на езика Java -Comment[bs]=Podrška za jezik Java -Comment[ca]=Implementació de llenguatge Java -Comment[ca@valencia]=Implementació de llenguatge Java -Comment[de]=Sprachunterstützung für Java -Comment[el]=Υποστήριξη γλώσσας Java -Comment[en_GB]=Java Language Support -Comment[es]=Implementación de lenguaje Java -Comment[et]=Java keele toetus -Comment[fi]=Java-kielituki -Comment[fr]=Prise en charge du langage Java -Comment[ga]=Tacaíocht Java -Comment[gl]=Soporte de Java -Comment[hne]=जावा भाखा समर्थन -Comment[hu]=Java nyelvi támogatás -Comment[it]=Supporto per il linguaggio Java -Comment[ja]=Java 言語のサポート -Comment[nds]=Ünnerstütten för Java -Comment[nl]=Ondersteuning voor de Java-taal -Comment[pa]=ਜਾਵਾ ਲੈਗੂਇਜ਼ ਸਹਿਯੋਗ -Comment[pl]=Obsługa języka Java -Comment[pt]=Suporte para a Linguagem Java -Comment[pt_BR]=Suporte à linguagem Java -Comment[sk]=Podpora jazyka Java -Comment[sv]=Stöd för språket Java -Comment[tr]=Java Dil Desteği -Comment[uk]=Підтримка мови Java -Comment[x-test]=xxJava Language Supportxx -Name=Java Support -Name[bg]=Поддръжка на Java -Name[bs]=Podrška za jezik Java -Name[ca]=Implementació Java -Name[ca@valencia]=Implementació Java -Name[de]=Unterstützung für Java -Name[en_GB]=Java Support -Name[es]=Implementación de Java -Name[et]=Java toetus -Name[fi]=Java-tuki -Name[fr]=Prise en charge de Java -Name[ga]=Tacaíocht Java -Name[gl]=Soporte de Java -Name[hu]=Java támogatás -Name[it]=Supporto per Java -Name[ja]=Java サポート -Name[nds]=Java-Ünnerstütten -Name[nl]=Ondersteuning voor Java -Name[pa]=ਜਾਵਾ ਸਹਿਯੋਗ -Name[pl]=Obsługa Java -Name[pt]=Suporte para Java -Name[pt_BR]=Suporte a Java -Name[sk]=Podpora Javy -Name[sv]=Java-stöd -Name[tr]=Java Desteği -Name[uk]=Підтримка Java -Name[x-test]=xxJava Supportxx -GenericName=Java Support -GenericName[bg]=Поддръжка на Java -GenericName[bs]=Podrška za jezik Java -GenericName[ca]=Implementació Java -GenericName[ca@valencia]=Implementació Java -GenericName[de]=Unterstützung für Java -GenericName[el]=Υποστήριξη Java -GenericName[en_GB]=Java Support -GenericName[es]=Implementación Java -GenericName[et]=Java toetus -GenericName[fi]=Java-tuki -GenericName[fr]=Prise en charge de Java -GenericName[ga]=Tacaíocht Java -GenericName[gl]=Soporte de Java -GenericName[hne]=जावा समर्थन -GenericName[hu]=Java támogatás -GenericName[it]=Supporto per Java -GenericName[ja]=Java サポート -GenericName[nds]=Java-Ünnerstütten -GenericName[nl]=Ondersteuning voor Java -GenericName[pa]=ਜਾਵਾ ਸਹਿਯੋਗ -GenericName[pl]=Obsługa Java -GenericName[pt]=Suporte para Java -GenericName[pt_BR]=Suporte a Java -GenericName[sk]=Podpora Javy -GenericName[sv]=Java-stöd -GenericName[tr]=Java Desteği -GenericName[uk]=Підтримка Java -GenericName[x-test]=xxJava Supportxx -ServiceTypes=KDevelop/Plugin -Icon=application-x-java -X-KDE-Library=kdevjavalanguagesupport -X-KDevelop-Version=@KDEV_PLUGIN_VERSION@ -X-KDevelop-Language=Java -X-KDevelop-Interfaces=ILanguageSupport -X-KDevelop-SupportedMimeTypes=text/x-java -X-KDE-PluginInfo-Name=kdevjavasupport -X-KDevelop-Mode=NoGUI -X-KDE-PluginInfo-Category=Language Support diff --git a/kdevjavasupport.json b/kdevjavasupport.json new file mode 100644 --- /dev/null +++ b/kdevjavasupport.json @@ -0,0 +1,76 @@ +{ + "KPlugin": { + "Category": "Language Support", + "Description": "Java Language Support", + "Description[ast]": "Sofitu de llinguax Java", + "Description[bg]": "Поддръжка на езика Java", + "Description[bs]": "Podrška za jezik Java", + "Description[ca@valencia]": "Implementació de llenguatge Java", + "Description[ca]": "Implementació de llenguatge Java", + "Description[de]": "Sprachunterstützung für Java", + "Description[el]": "Υποστήριξη γλώσσας Java", + "Description[en_GB]": "Java Language Support", + "Description[es]": "Implementación de lenguaje Java", + "Description[et]": "Java keele toetus", + "Description[fi]": "Java-kielituki", + "Description[fr]": "Prise en charge du langage Java", + "Description[ga]": "Tacaíocht Java", + "Description[gl]": "Soporte de Java", + "Description[hne]": "जावा भाखा समर्थन", + "Description[hu]": "Java nyelvi támogatás", + "Description[it]": "Supporto per il linguaggio Java", + "Description[ja]": "Java 言語のサポート", + "Description[nds]": "Ünnerstütten för Java", + "Description[nl]": "Ondersteuning voor de Java-taal", + "Description[pa]": "ਜਾਵਾ ਲੈਗੂਇਜ਼ ਸਹਿਯੋਗ", + "Description[pl]": "Obsługa języka Java", + "Description[pt]": "Suporte para a Linguagem Java", + "Description[pt_BR]": "Suporte à linguagem Java", + "Description[sk]": "Podpora jazyka Java", + "Description[sv]": "Stöd för språket Java", + "Description[tr]": "Java Dil Desteği", + "Description[uk]": "Підтримка мови Java", + "Description[x-test]": "xxJava Language Supportxx", + "Icon": "application-x-java", + "Id": "kdevjavasupport", + "License": "GPL", + "Name": "Java Support", + "Name[bg]": "Поддръжка на Java", + "Name[bs]": "Podrška za jezik Java", + "Name[ca@valencia]": "Implementació Java", + "Name[ca]": "Implementació Java", + "Name[de]": "Unterstützung für Java", + "Name[en_GB]": "Java Support", + "Name[es]": "Implementación de Java", + "Name[et]": "Java toetus", + "Name[fi]": "Java-tuki", + "Name[fr]": "Prise en charge de Java", + "Name[ga]": "Tacaíocht Java", + "Name[gl]": "Soporte de Java", + "Name[hu]": "Java támogatás", + "Name[it]": "Supporto per Java", + "Name[ja]": "Java サポート", + "Name[nds]": "Java-Ünnerstütten", + "Name[nl]": "Ondersteuning voor Java", + "Name[pa]": "ਜਾਵਾ ਸਹਿਯੋਗ", + "Name[pl]": "Obsługa Java", + "Name[pt]": "Suporte para Java", + "Name[pt_BR]": "Suporte a Java", + "Name[sk]": "Podpora Javy", + "Name[sv]": "Java-stöd", + "Name[tr]": "Java Desteği", + "Name[uk]": "Підтримка Java", + "Name[x-test]": "xxJava Supportxx", + "ServiceTypes": [ + "KDevelop/Plugin" + ] + }, + "X-KDevelop-Interfaces": [ + "ILanguageSupport" + ], + "X-KDevelop-Language": "Java", + "X-KDevelop-Mode": "NoGUI", + "X-KDevelop-SupportedMimeTypes": [ + "text/x-java" + ] +} diff --git a/parsejob.h b/parsejob.h --- a/parsejob.h +++ b/parsejob.h @@ -24,7 +24,7 @@ #ifndef JAVA_PARSEJOB_H #define JAVA_PARSEJOB_H -#include +#include #include // from the parser subdirectory diff --git a/parsejob.cpp b/parsejob.cpp --- a/parsejob.cpp +++ b/parsejob.cpp @@ -27,24 +27,19 @@ #include #include -#include "Thread.h" - #include #include #include #include - -#include -#include +#include #include "javalanguagesupport.h" // from the parser subdirectory #include #include #include -#include #include #include "parser/dumptree.h" @@ -60,7 +55,6 @@ #include #include #include -#include #include #include #include @@ -100,14 +94,14 @@ if ( abortRequested() ) return abortJob(); - KUrl fileUrl(document().str()); + QUrl fileUrl(document().str()); if ( !(minimumFeatures() & KDevelop::TopDUContext::ForceUpdate) ) { bool needsUpdate = true; KDevelop::DUChainReadLocker lock; ///TODO: this is hacky - we check for any env file for a zipped file and assume it's up2date /// updating a zip file won't trigger reparsing though... - bool isZipFile = fileUrl.protocol() == "zip"; + bool isZipFile = fileUrl.scheme() == "zip"; foreach(const KDevelop::ParsingEnvironmentFilePointer &file, KDevelop::DUChain::self()->allEnvironmentFiles(document())) { if (file->needsUpdate() && !(isZipFile && file->featuresSatisfied(minimumFeatures()))) { needsUpdate = true; @@ -117,7 +111,7 @@ } } if (!needsUpdate) { - kDebug() << "Already up to date" << document().str(); + qDebug() << "Already up to date" << document().str(); return; } } @@ -132,7 +126,7 @@ QReadLocker lock(java()->language()->parseLock()); - kDebug() << "===-- PARSING --===> " + qDebug() << "===-- PARSING --===> " << document().str() << " <== readFromDisk: " << m_readFromDisk << " size: " << m_session->size(); @@ -174,7 +168,7 @@ m_session->m_document = document(); java::EditorIntegrator editor(parseSession()); - //kDebug( ) << (contentContext ? "updating" : "building") << "duchain for" << parentJob()->document().str(); + //qDebug( ) << (contentContext ? "updating" : "building") << "duchain for" << parentJob()->document().str(); // TODO: use zip hash to find out if jdk/other source has changed when going for 2nd pass @@ -189,7 +183,7 @@ newFeatures = (KDevelop::TopDUContext::Features)(newFeatures | toUpdate->features()); if (newFeatures & KDevelop::TopDUContext::ForceUpdate) - kDebug() << "update enforced"; + qDebug() << "update enforced"; //Remove update-flags like 'Recursive' or 'ForceUpdate' newFeatures = static_cast(newFeatures & KDevelop::TopDUContext::AllDeclarationsContextsUsesAndAST); @@ -199,19 +193,19 @@ if (newFeatures == KDevelop::TopDUContext::SimplifiedVisibleDeclarationsAndContexts) { declarationBuilder.setOnlyComputeVisible(true); //Only visible declarations/contexts need to be built. declarationBuilder.setBuildCompleteTypes(false); - + } else if (newFeatures == KDevelop::TopDUContext::VisibleDeclarationsAndContexts) { declarationBuilder.setOnlyComputeVisible(true); //Only visible declarations/contexts need to be built. } - + KDevelop::TopDUContext* chain = declarationBuilder.build(document(), ast, toUpdate); setDuChain(chain); - + bool declarationsComplete = !declarationBuilder.hadUnresolvedIdentifiers(); - kDebug() << "Parsing with feature set: " << newFeatures << " complete:" <languageController()->backgroundParser()->addDocument(KDevelop::IndexedString(fileUrl), static_cast(newFeatures | KDevelop::TopDUContext::VisibleDeclarationsAndContexts), 10000); } else { // We haven't resolved all identifiers, but by now, we don't expect to - kDebug() << "Builder found unresolved identifiers when they should have been resolved! (if there was no coding error)"; + qDebug() << "Builder found unresolved identifiers when they should have been resolved! (if there was no coding error)"; declarationsComplete = true; } } } if (declarationsComplete && (newFeatures & KDevelop::TopDUContext::AllDeclarationsContextsAndUses) == KDevelop::TopDUContext::AllDeclarationsContextsAndUses) { - kDebug() << "Building uses"; + qDebug() << "Building uses"; UseBuilder useBuilder(&editor); useBuilder.buildUses(ast); } @@ -256,15 +250,13 @@ if (declarationsComplete && (newFeatures & KDevelop::TopDUContext::AllDeclarationsContextsAndUses) == KDevelop::TopDUContext::AllDeclarationsContextsAndUses) { DumpChain dump; dump.dump(ast, m_session); - + KDevelop::DUChainReadLocker duchainlock(KDevelop::DUChain::lock()); dump.dump(chain); } } } // end of namespace java -#include "parsejob.moc" - // kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on diff --git a/parser/CMakeLists.txt b/parser/CMakeLists.txt --- a/parser/CMakeLists.txt +++ b/parser/CMakeLists.txt @@ -1,9 +1,6 @@ include_directories( - ${KDE4_INCLUDES} - ${KDE4_INCLUDE_DIR}/kdevelop-pg-qt ${CMAKE_CURRENT_SOURCE_DIR} - ${KDEVPLATFORM_INCLUDE_DIR} # ${KDEVPLATFORM_INCLUDE_DIR}/interfaces # ${KDEVPLATFORM_INCLUDE_DIR}/editor # ${KDEVPLATFORM_INCLUDE_DIR}/project @@ -31,7 +28,7 @@ ${_kdevpgList} ) -find_package(Flex REQUIRED) +find_package(FLEX REQUIRED) # Copy javalexer.ll to the builddir, so that flex doesn't write out # absolute paths in the generated file when we pass them as arguments. @@ -73,7 +70,8 @@ # Note: This library doesn't follow API/ABI/BC rules and shouldn't have a SOVERSION # Its only purpose is to support the plugin without needing to add all source files # to the plugin target -kde4_add_library(kdev4javaparser SHARED ${kdevjavaparser_STAT_SRCS}) -target_link_libraries(kdev4javaparser ${KDE4_KDECORE_LIBS} ${KDE4_KTEXTEDITOR_LIBS} ${KDEVPLATFORM_LANGUAGE_LIBRARIES}) -install(TARGETS kdev4javaparser ${INSTALL_TARGETS_DEFAULT_ARGS} ) +add_library(kdev4javaparser SHARED ${kdevjavaparser_STAT_SRCS}) +generate_export_header(kdev4javaparser BASE_NAME javaparser EXPORT_MACRO_NAME KDEVJAVAPARSER_EXPORT) +target_link_libraries(kdev4javaparser KDev::Util) +install(TARGETS kdev4javaparser ${INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/parser/FlexLexer.h b/parser/FlexLexer.h deleted file mode 100644 --- a/parser/FlexLexer.h +++ /dev/null @@ -1,208 +0,0 @@ - -// -*-C++-*- -// FlexLexer.h -- define interfaces for lexical analyzer classes generated -// by flex - -// Copyright (c) 1993 The Regents of the University of California. -// All rights reserved. -// -// This code is derived from software contributed to Berkeley by -// Kent Williams and Tom Epperly. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: - -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. - -// Neither the name of the University nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. - -// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE. - -// This file defines FlexLexer, an abstract class which specifies the -// external interface provided to flex C++ lexer objects, and yyFlexLexer, -// which defines a particular lexer class. -// -// If you want to create multiple lexer classes, you use the -P flag -// to rename each yyFlexLexer to some other xxFlexLexer. You then -// include in your other sources once per lexer class: -// -// #undef yyFlexLexer -// #define yyFlexLexer xxFlexLexer -// #include -// -// #undef yyFlexLexer -// #define yyFlexLexer zzFlexLexer -// #include -// ... - -#ifndef __FLEX_LEXER_H -// Never included before - need to define base class. -#define __FLEX_LEXER_H - -#include -# ifndef FLEX_STD -# define FLEX_STD std:: -# endif - -extern "C++" { - -struct yy_buffer_state; -typedef int yy_state_type; - -class FlexLexer { -public: - virtual ~FlexLexer() { } - - const char* YYText() const { return yytext; } - int YYLeng() const { return yyleng; } - - virtual void - yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0; - virtual struct yy_buffer_state* - yy_create_buffer( FLEX_STD istream* s, int size ) = 0; - virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0; - virtual void yyrestart( FLEX_STD istream* s ) = 0; - - virtual int yylex() = 0; - - // Call yylex with new input/output sources. - int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 ) - { - switch_streams( new_in, new_out ); - return yylex(); - } - - // Switch to new input/output streams. A nil stream pointer - // indicates "keep the current one". - virtual void switch_streams( FLEX_STD istream* new_in = 0, - FLEX_STD ostream* new_out = 0 ) = 0; - - int lineno() const { return yylineno; } - - int debug() const { return yy_flex_debug; } - void set_debug( int flag ) { yy_flex_debug = flag; } - -protected: - char* yytext; - int yyleng; - int yylineno; // only maintained if you use %option yylineno - int yy_flex_debug; // only has effect with -d or "%option debug" -}; - -} -#endif - -#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce) -// Either this is the first time through (yyFlexLexerOnce not defined), -// or this is a repeated include to define a different flavor of -// yyFlexLexer, as discussed in the flex man page. -#define yyFlexLexerOnce - -extern "C++" { - -class yyFlexLexer : public FlexLexer { -public: - // arg_yyin and arg_yyout default to the cin and cout, but we - // only make that assignment when initializing in yylex(). - yyFlexLexer( FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0 ); - - virtual ~yyFlexLexer(); - - void yy_switch_to_buffer( struct yy_buffer_state* new_buffer ); - struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s, int size ); - void yy_delete_buffer( struct yy_buffer_state* b ); - void yyrestart( FLEX_STD istream* s ); - - void yypush_buffer_state( struct yy_buffer_state* new_buffer ); - void yypop_buffer_state(void); - -#ifndef yywrap -int yywrap(); -#endif - virtual int yylex(); - virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out ); - -protected: - virtual int LexerInput( char* buf, int max_size ); - virtual void LexerOutput( const char* buf, int size ); - virtual void LexerError( const char* msg ); - - void yyunput( int c, char* buf_ptr ); - int yyinput(); - - void yy_load_buffer_state(); - void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s ); - void yy_flush_buffer( struct yy_buffer_state* b ); - - int yy_start_stack_ptr; - int yy_start_stack_depth; - int* yy_start_stack; - - void yy_push_state( int new_state ); - void yy_pop_state(); - int yy_top_state(); - - yy_state_type yy_get_previous_state(); - yy_state_type yy_try_NUL_trans( yy_state_type current_state ); - int yy_get_next_buffer(); - - FLEX_STD istream* yyin; // input source for default LexerInput - FLEX_STD ostream* yyout; // output sink for default LexerOutput - - // yy_hold_char holds the character lost when yytext is formed. - char yy_hold_char; - - // Number of characters read into yy_ch_buf. - int yy_n_chars; - - // Points to current character in buffer. - char* yy_c_buf_p; - - int yy_init; // whether we need to initialize - int yy_start; // start state number - - // Flag which is used to allow yywrap()'s to do buffer switches - // instead of setting up a fresh yyin. A bit of a hack ... - int yy_did_buffer_switch_on_eof; - - - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */ - void yyensure_buffer_stack(void); - - // The following are not always needed, but may be depending - // on use of certain flex features (like REJECT or yymore()). - - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - yy_state_type* yy_state_buf; - yy_state_type* yy_state_ptr; - - char* yy_full_match; - int* yy_full_state; - int yy_full_lp; - - int yy_lp; - int yy_looking_for_trail_begin; - - int yy_more_flag; - int yy_more_len; - int yy_more_offset; - int yy_prev_more_offset; -}; - -} - -#endif diff --git a/parser/dumptree.cpp b/parser/dumptree.cpp --- a/parser/dumptree.cpp +++ b/parser/dumptree.cpp @@ -24,8 +24,7 @@ #include "kdev-pg-token-stream.h" #include - -#include +#include static char const * const names[] = { "additive_expression", @@ -184,16 +183,16 @@ } } if (node) { - kDebug() << QString(indent * 2, ' ').toLatin1().constData() << names[node->kind - 1000] + qDebug() << QString(indent * 2, ' ').toLatin1().constData() << names[node->kind - 1000] << "[" << node->startToken << "," << node->endToken << "]" << nodeText << endl; } ++indent; DefaultVisitor::visitNode(node); --indent; if (node) { - kDebug() << QString(indent * 2, ' ').toLatin1().constData() << names[node->kind - 1000]; + qDebug() << QString(indent * 2, ' ').toLatin1().constData() << names[node->kind - 1000]; } } diff --git a/parser/java.g b/parser/java.g --- a/parser/java.g +++ b/parser/java.g @@ -90,7 +90,7 @@ %parser_declaration_header "kdev-pg-list.h" %export_macro "KDEVJAVAPARSER_EXPORT" -%export_macro_header "javaparserexport.h" +%export_macro_header "javaparser_export.h" ------------------------------------------------------------ -- Enumeration types for additional AST members, diff --git a/parser/java_io.cpp b/parser/java_io.cpp --- a/parser/java_io.cpp +++ b/parser/java_io.cpp @@ -19,16 +19,16 @@ // This file is meant to be specific to the framework in which the parser // operates, and is likely to be adapted for different environments. -// Specifically, the error output might not always go to kDebug(), +// Specifically, the error output might not always go to qDebug(), // but will rather be placed as items inside some listbox. #include "javaparser.h" #include "javalexer.h" #include -#include +#include // void print_token_environment(java::Parser* parser); @@ -39,13 +39,13 @@ void Parser::reportProblem( Parser::ProblemType type, const QString& message ) { if (type == Error) { - kDebug() << "** ERROR:" << message; + qDebug() << "** ERROR:" << message; } else if (type == Warning) { - kDebug() << "** WARNING:" << message; + qDebug() << "** WARNING:" << message; } else if (type == Info) { - kDebug() << "** Info:" << message; + qDebug() << "** Info:" << message; } } diff --git a/parser/javalexer.h b/parser/javalexer.h --- a/parser/javalexer.h +++ b/parser/javalexer.h @@ -19,12 +19,12 @@ #include "javaparser.h" -#include "javaparserexport.h" +#include "javaparser_export.h" #include #ifndef DONT_INCLUDE_FLEXLEXER -#include "FlexLexer.h" +#include #endif // The YY_USER_ACTION macro is called whenever a token is found by Flex diff --git a/parser/javaparserexport.h b/parser/javaparserexport.h deleted file mode 100644 --- a/parser/javaparserexport.h +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************** - * This file is part of KDevelop * - * Copyright 2007 Andreas Pakulat * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Library General Public License as * - * published by the Free Software Foundation; either version 2 of the * - * License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef JAVAPARSEREXPORT_H -#define JAVAPARSEREXPORT_H - -/* needed for KDE_EXPORT macros */ -#include - -#ifndef KDEVJAVAPARSER_EXPORT -# ifdef MAKE_KDEVJAVAPARSER_LIB -# define KDEVJAVAPARSER_EXPORT KDE_EXPORT -# else -# define KDEVJAVAPARSER_EXPORT KDE_IMPORT -# endif -#endif - -#endif - diff --git a/parser/parsesession.h b/parser/parsesession.h --- a/parser/parsesession.h +++ b/parser/parsesession.h @@ -25,10 +25,10 @@ #include #include "javaparser.h" -#include "javaparserexport.h" -#include -#include +#include "javaparser_export.h" + +#include #include namespace java diff --git a/settings/CMakeLists.txt b/settings/CMakeLists.txt --- a/settings/CMakeLists.txt +++ b/settings/CMakeLists.txt @@ -1,8 +1,6 @@ include_directories( ${CMAKE_SOURCE_DIR} - ${KDE4_INCLUDES} - ${KDEVPLATFORM_INCLUDE_DIR} ) set( javasettings_cfg_SRCS @@ -13,15 +11,8 @@ javasettings.ui ) -kde4_add_ui_files( javasettings_cfg_SRCS ${javasettings_cfg_UI} ) -kde4_add_kcfg_files( javasettings_cfg_SRCS javaconfig.kcfgc ) -kde4_add_plugin( kcm_kdev_javasettings ${javasettings_cfg_SRCS} ) -target_link_libraries( kcm_kdev_javasettings ${KDE4_KUTILS_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${KDEVPLATFORM_INTERFACES_LIBRARIES} ) +ki18n_wrap_ui( javasettings_cfg_SRCS ${javasettings_cfg_UI} ) +kconfig_add_kcfg_files( javasettings_cfg_SRCS javaconfig.kcfgc ) +add_library(kdev_javasettings OBJECT ${javasettings_cfg_SRCS}) +target_link_libraries(kdev_javasettings KDev::Util) -install( TARGETS - kcm_kdev_javasettings - DESTINATION ${PLUGIN_INSTALL_DIR} ) - -install( FILES - kcm_kdev_javasettings.desktop - DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/settings/javapreferences.h b/settings/javapreferences.h --- a/settings/javapreferences.h +++ b/settings/javapreferences.h @@ -22,38 +22,28 @@ #ifndef KDEVJAVAPREFERENCES_H #define KDEVJAVAPREFERENCES_H -#include - -#include -#include +#include namespace Ui { class JavaSettings; } -namespace KDevelop -{ - -class JavaPreferences : public KCModule +class JavaPreferences : public KDevelop::ConfigPage { Q_OBJECT public: - JavaPreferences( QWidget *parent, const QVariantList &args ); + JavaPreferences(QWidget* parent); virtual ~JavaPreferences(); - virtual void save(); + QString name() const override; + QString fullName() const override; + QIcon icon() const override; - virtual KUrl localNonShareableFile() const - { - return KUrl::fromPath( - KStandardDirs::locate( "data", "kdevelop/data.kdev4" ) ); - } + KDevelop::ConfigPage::ConfigPageType configPageType() const override; private: - Ui::JavaSettings *preferencesDialog; - + QScopedPointer m_settings; }; -} #endif diff --git a/settings/javapreferences.cpp b/settings/javapreferences.cpp --- a/settings/javapreferences.cpp +++ b/settings/javapreferences.cpp @@ -19,50 +19,39 @@ */ #include "javapreferences.h" - -#include - -#include -#include - #include "javaconfig.h" +#include #include "ui_javasettings.h" -namespace KDevelop +JavaPreferences::JavaPreferences(QWidget* parent) + : ConfigPage(nullptr, JavaSettings::self(), parent) + , m_settings(new Ui::JavaSettings) { + m_settings->setupUi(this); +} -K_PLUGIN_FACTORY(JavaPreferencesFactory, registerPlugin();) -K_EXPORT_PLUGIN(JavaPreferencesFactory( KAboutData("kcm_kdev_bgsettings", "kdevplatform", ki18n("Java Support Settings"), "0.1"))) - +JavaPreferences::~JavaPreferences( ) +{} -JavaPreferences::JavaPreferences( QWidget *parent, const QVariantList &args ) - : KCModule( JavaPreferencesFactory::componentData(), parent, args ) +QString JavaPreferences::name() const { - - QVBoxLayout * l = new QVBoxLayout( this ); - QWidget* w = new QWidget; - preferencesDialog = new Ui::JavaSettings; - preferencesDialog->setupUi( w ); - - l->addWidget( w ); - - addConfig( JavaSettings::self(), w ); - - load(); + return i18n("Java Support"); } -JavaPreferences::~JavaPreferences( ) +QString JavaPreferences::fullName() const { - delete preferencesDialog; + return i18n("Configure Java Support settings"); } -void JavaPreferences::save() +QIcon JavaPreferences::icon() const { - KCModule::save(); + return QIcon::fromTheme(QStringLiteral("application-x-java")); } -} -#include "javapreferences.moc" +KDevelop::ConfigPage::ConfigPageType JavaPreferences::configPageType() const +{ + return ConfigPage::LanguageConfigPage; +} diff --git a/settings/javasettings.ui b/settings/javasettings.ui --- a/settings/javasettings.ui +++ b/settings/javasettings.ui @@ -44,7 +44,6 @@ KUrlRequester QFrame -
kurlrequester.h
diff --git a/settings/kcm_kdev_javasettings.desktop b/settings/kcm_kdev_javasettings.desktop deleted file mode 100644 --- a/settings/kcm_kdev_javasettings.desktop +++ /dev/null @@ -1,65 +0,0 @@ -[Desktop Entry] -Icon=java -Type=Service -ServiceTypes=KCModule - -X-KDE-ModuleType=Library -X-KDE-Library=kcm_kdev_javasettings -X-KDE-FactoryName=kcm_kdev_javasettings -X-KDE-ParentApp=kdevplatform -X-KDE-ParentComponents=kdevplatform -X-KDE-CfgDlgHierarchy=GENERAL - -Name=Java Support -Name[bg]=Поддръжка на Java -Name[bs]=Podrška za jezik Java -Name[ca]=Implementació Java -Name[ca@valencia]=Implementació Java -Name[de]=Unterstützung für Java -Name[en_GB]=Java Support -Name[es]=Implementación de Java -Name[et]=Java toetus -Name[fi]=Java-tuki -Name[fr]=Prise en charge de Java -Name[ga]=Tacaíocht Java -Name[gl]=Soporte de Java -Name[hu]=Java támogatás -Name[it]=Supporto per Java -Name[ja]=Java サポート -Name[nds]=Java-Ünnerstütten -Name[nl]=Ondersteuning voor Java -Name[pa]=ਜਾਵਾ ਸਹਿਯੋਗ -Name[pl]=Obsługa Java -Name[pt]=Suporte para Java -Name[pt_BR]=Suporte a Java -Name[sk]=Podpora Javy -Name[sv]=Java-stöd -Name[tr]=Java Desteği -Name[uk]=Підтримка Java -Name[x-test]=xxJava Supportxx -Comment=Configure Java Support settings -Comment[bg]=Настройки на поддръжката на Java -Comment[bs]=Konfiguriši podršku za jezik Java -Comment[ca]=Configura els arranjaments de la implementació de Java -Comment[ca@valencia]=Configura els arranjaments de la implementació de Java -Comment[de]=Unterstützung für Java einrichten -Comment[en_GB]=Configure Java Support settings -Comment[es]=Configurar las preferencias de la implementación Java -Comment[et]=Java toetuse seadistamine -Comment[fi]=Java-tuen asetukset -Comment[fr]=Configure les paramètres pour la prise en charge de Java -Comment[ga]=Cumraigh socruithe Tacaíocht Java -Comment[gl]=Configuración do soporte de Java -Comment[hu]=Java támogatás beállításainak módosítása -Comment[it]=Configura le impostazioni per il supporto Java -Comment[ja]=Java サポートを設定します -Comment[nds]=Java-Ünnerstütten instellen -Comment[nl]=Instellingen voor Java-ondersteuning configureren -Comment[pl]=Konfiguruj ustawienia obsługi Java -Comment[pt]=Configurar as opções do Suporte para Java -Comment[pt_BR]=Configurar as opções do suporte para Java -Comment[sk]=Nastaviť nastavenia podpory Javy -Comment[sv]=Anpassa inställningar av Java-stöd -Comment[tr]=Java Desteği ayarlarını yapılandır -Comment[uk]=Налаштувати параметри підтримки Java -Comment[x-test]=xxConfigure Java Support settingsxx