[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdev-php] /: Adapt to KDevplatform changes.
From:       Milian Wolff <mail () milianw ! de>
Date:       2012-10-24 23:44:43
Message-ID: 20121024234443.613ACA6078 () git ! kde ! org
[Download RAW message or body]

Git commit 71ecdd288d623893e9990d170b84cfee17ecf5f4 by Milian Wolff.
Committed on 25/10/2012 at 01:37.
Pushed by mwolff into branch 'master'.

Adapt to KDevplatform changes.

Reuse common code and use IndexedString instead of KUrl in some places.

M  +5    -13   phplanguagesupport.cpp
M  +2    -3    phplanguagesupport.h
M  +12   -38   phpparsejob.cpp
M  +2    -3    phpparsejob.h

http://commits.kde.org/kdev-php/71ecdd288d623893e9990d170b84cfee17ecf5f4

diff --git a/phplanguagesupport.cpp b/phplanguagesupport.cpp
index eb76b5c..7879fa1 100644
--- a/phplanguagesupport.cpp
+++ b/phplanguagesupport.cpp
@@ -68,8 +68,6 @@ K_EXPORT_PLUGIN(KDevPhpSupportFactory(
 namespace Php
 {
 
-LanguageSupport* LanguageSupport::m_self = 0;
-
 LanguageSupport::LanguageSupport(QObject* parent, const QVariantList& /*args*/)
         : KDevelop::IPlugin(KDevPhpSupportFactory::componentData(), parent),
         KDevelop::ILanguageSupport(), m_internalFunctionsLoaded(false)
@@ -79,8 +77,6 @@ LanguageSupport::LanguageSupport(QObject* parent, const \
QVariantList& /*args*/)  
     KDEV_USE_EXTENSION_INTERFACE(KDevelop::ILanguageSupport)
 
-    m_self = this;
-
     m_highlighting = new Php::Highlighting(this);
 
     CodeCompletionModel* ccModel = new CodeCompletionModel(this);
@@ -94,7 +90,8 @@ LanguageSupport::~LanguageSupport()
     ILanguage* lang = language();
     if ( lang ) {
         lang->parseLock()->lockForWrite();
-        m_self = 0; //By locking the parse-mutexes, we make sure that parse- and \
preprocess-jobs get a chance to finish in a good state +        //By locking the \
parse-mutexes, we make sure that parse- and preprocess-jobs +        //get a chance \
to finish in a good state  lang->parseLock()->unlock();
     }
 }
@@ -106,7 +103,7 @@ void LanguageSupport::updateInternalFunctions()
     DUChain::self()->updateContextForUrl(internalFunctionFile(), \
KDevelop::TopDUContext::AllDeclarationsAndContexts, this, -10);  }
 
-void LanguageSupport::updateReady( IndexedString url, ReferencedTopDUContext \
topContext ) +void LanguageSupport::updateReady( const IndexedString& url, const \
ReferencedTopDUContext& topContext )  {
     Q_ASSERT(url == internalFunctionFile());
     Q_UNUSED(topContext);
@@ -127,9 +124,9 @@ QReadWriteLock* LanguageSupport::internalFunctionsLock()
     return &m_internalFunctionsLock;
 }
 
-KDevelop::ParseJob *LanguageSupport::createParseJob(const KUrl &url)
+KDevelop::ParseJob *LanguageSupport::createParseJob(const IndexedString &url)
 {
-    return new ParseJob(url);
+    return new ParseJob(url, this);
 }
 
 QString LanguageSupport::name() const
@@ -147,11 +144,6 @@ KDevelop::ICodeHighlighting* LanguageSupport::codeHighlighting() \
const  return m_highlighting;
 }
 
-LanguageSupport *LanguageSupport::self()
-{
-    return m_self;
-}
-
 QPair<QString, SimpleRange> LanguageSupport::wordUnderCursor(const KUrl& url, const \
SimpleCursor& position)  {
     KDevelop::IDocument* doc = core()->documentController()->documentForUrl(url);
diff --git a/phplanguagesupport.h b/phplanguagesupport.h
index 0996125..672bd54 100644
--- a/phplanguagesupport.h
+++ b/phplanguagesupport.h
@@ -91,7 +91,7 @@ public:
     /*Name Of the Language*/
     QString name() const;
     /*Parsejob used by background parser to parse given Url*/
-    KDevelop::ParseJob *createParseJob(const KUrl &url);
+    KDevelop::ParseJob *createParseJob(const KDevelop::IndexedString& url);
     /*the actual language object*/
     KDevelop::ILanguage *language();
 
@@ -117,14 +117,13 @@ public slots:
      *
      * \see loadedInternalFunctions
      */
-    void updateReady(KDevelop::IndexedString url, KDevelop::ReferencedTopDUContext \
topContext); +    void updateReady(const KDevelop::IndexedString& url, const \
KDevelop::ReferencedTopDUContext& topContext);  
 private slots:
     void updateInternalFunctions();
 
 private:
     KDevelop::CodeHighlighting* m_highlighting;
-    static LanguageSupport* m_self;
     bool m_internalFunctionsLoaded;
     QReadWriteLock m_internalFunctionsLock;
 
diff --git a/phpparsejob.cpp b/phpparsejob.cpp
index a46a9e4..682f04d 100644
--- a/phpparsejob.cpp
+++ b/phpparsejob.cpp
@@ -31,7 +31,6 @@
 #include <language/duchain/topducontext.h>
 #include <language/duchain/dumpchain.h>
 #include <interfaces/ilanguage.h>
-#include <language/highlighting/codehighlighting.h>
 #include <interfaces/icore.h>
 #include <interfaces/ilanguagecontroller.h>
 #include <language/backgroundparser/backgroundparser.h>
@@ -55,9 +54,9 @@ using namespace KDevelop;
 namespace Php
 {
 
-ParseJob::ParseJob(const KUrl &url)
-        : KDevelop::ParseJob(url)
-        , m_parentJob(0)
+ParseJob::ParseJob(const IndexedString& url, ILanguageSupport* languageSupport)
+: KDevelop::ParseJob(url, languageSupport)
+, m_parentJob(0)
 {
 }
 
@@ -65,16 +64,16 @@ ParseJob::~ParseJob()
 {
 }
 
-LanguageSupport *ParseJob::php() const
+LanguageSupport* ParseJob::php() const
 {
-    return LanguageSupport::self();
+    return dynamic_cast<LanguageSupport*>(languageSupport());
 }
 
 void ParseJob::run()
 {
-    if ( !php() ) {
-        return abortJob();
-    }
+    /// Indexed string for 'Php', identifies environment files from this language \
plugin +    static const IndexedString phpLangString("Php");
+
     // make sure we loaded the internal file already
     if ( !php()->internalFunctionsLoaded() && !m_parentJob && document() != \
                internalFunctionFile() ) {
         kDebug() << "waiting for internal function file to finish parsing";
@@ -83,28 +82,9 @@ void ParseJob::run()
 
     UrlParseLock urlLock(document());
 
-    if ( !(minimumFeatures() & TopDUContext::ForceUpdate || minimumFeatures() & \
                Resheduled) ) {
-        DUChainReadLocker lock(DUChain::lock());
-        static const IndexedString langString("Php");
-        foreach(const ParsingEnvironmentFilePointer &file, \
                DUChain::self()->allEnvironmentFiles(document())) {
-            if (file->language() != langString) {
-                continue;
-            }
-            if (!file->needsUpdate() && file->featuresSatisfied(minimumFeatures())) \
                {
-                kDebug() << "Already up to date" << document().str();
-                setDuChain(file->topContext());
-                if (php() && php()->codeHighlighting()
-                    && \
                ICore::self()->languageController()->backgroundParser()->trackerForUrl(document()))
                
-                {
-                    lock.unlock();
-                    php()->codeHighlighting()->highlightDUChain(duChain());
-                }
-                return;
-            }
-            break;
-        }
+    if (!(minimumFeatures() & Resheduled) && !isUpdateRequired(phpLangString)) {
+        return;
     }
-
     kDebug() << "parsing" << document().str();
 
     KDevelop::ProblemPointer p = readContents();
@@ -140,7 +120,7 @@ void ParseJob::run()
     newFeatures = static_cast<KDevelop::TopDUContext::Features>(newFeatures & \
KDevelop::TopDUContext::AllDeclarationsContextsUsesAndAST);  
     if (matched) {
-        if (abortRequested() || !php() || !php()->language()) {
+        if (abortRequested()) {
             return abortJob();
         }
 
@@ -206,11 +186,7 @@ void ParseJob::run()
             DUChain::self()->updateContextEnvironment( chain->topContext(), \
file.data() );  }
 
-        if (php() && php()->codeHighlighting()
-            && ICore::self()->languageController()->backgroundParser()->trackerForUrl(document()))
                
-        {
-            php()->codeHighlighting()->highlightDUChain(chain);
-        }
+        highlightDUChain();
     } else {
         ReferencedTopDUContext top;
         DUChainWriteLocker lock;
@@ -224,8 +200,6 @@ void ParseJob::run()
             top->clearProblems();
         } else {
             ParsingEnvironmentFile *file = new ParsingEnvironmentFile(document());
-            /// Indexed string for 'Php', identifies environment files from this \
                language plugin
-            static const IndexedString phpLangString("Php");
             file->setLanguage(phpLangString);
             top = new TopDUContext(document(), RangeInRevision(0, 0, INT_MAX, \
INT_MAX), file);  DUChain::self()->addDocumentChain(top);
diff --git a/phpparsejob.h b/phpparsejob.h
index 98e2b70..7f078bf 100644
--- a/phpparsejob.h
+++ b/phpparsejob.h
@@ -48,14 +48,13 @@ public:
         Resheduled = KDevelop::TopDUContext::LastFeature
     };
 
-    explicit ParseJob(const KUrl &url);
+    explicit ParseJob(const KDevelop::IndexedString& url, \
KDevelop::ILanguageSupport* LanguageSupport);  virtual ~ParseJob();
 
-    LanguageSupport* php() const;
-
     void setParentJob(ParseJob *job);
 
 protected:
+    LanguageSupport* php() const;
     virtual void run();
 
 private:


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic