Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. "Multiple parse contexts" in Qt creator

"Multiple parse contexts" in Qt creator

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
qt creatorcreator warning
7 Posts 4 Posters 19.8k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    koahnig
    wrote on last edited by
    #1

    Not sure what is meant here:
    0_1503840310552_c66c496e-3d80-4907-ae00-715afbba0d87-image.png

    This comes from Qt creator latest version 4.3.1 on windows 10,in case it matters.

    I am at a loss what I can do to get rid of it. Obviously, I can use "Do Not Show Again" which is on the right of the message, but I prefer to know, what I am ignoring.

    What are possible causes?

    Vote the answer(s) that helped you to solve your issue(s)

    1 Reply Last reply
    1
    • aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Most likely you have multiple (Sub-)projects containg this file. Depending on the parse context, different defines may be active that influence the parsing of this file

      Qt has to stay free or it will die.

      1 Reply Last reply
      3
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by kshegunov
        #3

        Hi
        Do you use sessions?
        https://bugreports.qt.io/browse/QTCREATORBUG-18521

        Anyway, its not clear from source what is being checked

        CppTools::BaseEditorDocumentProcessor *CppEditorDocument::processor()
        {
          ...
                    const bool isAmbiguous = info.hints & ProjectPartInfo::IsAmbiguousMatch;
                    const bool isProjectFile = info.hints & ProjectPartInfo::IsFromProjectMatch;
                    showHideInfoBarAboutMultipleParseContexts(isAmbiguous && isProjectFile); // this shows msg
        

        The IsFromProjectMatch flag is set here
        cppprojectpartchooser.cpp

                // Hints
                if (m_info.projectParts.size() > 1)
                    m_info.hints |= ProjectPartInfo::IsAmbiguousMatch;
                if (prioritized.first().priority > 1000)
                    m_info.hints |= ProjectPartInfo::IsPreferredMatch;
                if (areProjectPartsFromDependencies)
                    m_info.hints |= ProjectPartInfo::IsFromDependenciesMatch;
                else
                    m_info.hints |= ProjectPartInfo::IsFromProjectMatch;
        

        so it seems to be related to sort / classify files depending on origin but didnt really see the meaning of
        multiple contexts.

        update: yep, as @aha_1980 says, sub projects might trigger this , it seems from the code.

        [Added code tags ~kshegunov]

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          Thanks guys.

          Yes, I am using subprojects.
          Yes, I am using sessions.

          Within the session I have/had a couple of projects which I have also put into a subdirs project,which is also open.

          Apparently the message is an one time display, because it does not vanish after:

          • closing the duplicates
          • changing to another file

          I was using a search over all projects with some text. That might have triggered the message.
          I guess for the first time, it might make sense for a file. However, when switching to another file, the meaning is lost, because the message refers to "this file".

          The description of the bug report does not really fit my case.

          How can I choose a prefered one then?

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          1
          • aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by
            #5

            you can select the active parse context with drop down box (3) from http://doc.qt.io/qtcreator/creator-coding-navigating.html

            Qt has to stay free or it will die.

            K P 2 Replies Last reply
            4
            • aha_1980A aha_1980

              you can select the active parse context with drop down box (3) from http://doc.qt.io/qtcreator/creator-coding-navigating.html

              K Offline
              K Offline
              koahnig
              wrote on last edited by
              #6

              @aha_1980

              Thanks for link. That is exactly what I was looking for.

              As a side note, the dropdown box is not always visible. I had realized that there was something, but could not really make it out. In addition the content was not obviously related to my issue. Probably, I have seen the box the first time in that context.
              IMHO the warning text is ambigious, which causes confusion. However, rather than just complaining about it, which is always easy, I cannot offer an alternative text.

              Vote the answer(s) that helped you to solve your issue(s)

              1 Reply Last reply
              1
              • aha_1980A aha_1980

                you can select the active parse context with drop down box (3) from http://doc.qt.io/qtcreator/creator-coding-navigating.html

                P Offline
                P Offline
                paulf
                wrote on last edited by
                #7

                @aha_1980

                No subprojects. No sessions. Choosing C++ from the Parse Contect drop down does nothing.

                From what I can tell the reason that this is badly broken is that the GUI only lets you choose between C and C++ to resolve "parse contexts". Looking at the source "ProjectPart" has the following fields, and it is totally opaque from the GUI as to why a file has more than one of these ProjectParts

                public:
                ProjectExplorer::Project *project = nullptr;

                QString displayName;
                
                QString projectFile;
                int projectFileLine = -1;
                int projectFileColumn = -1;
                QString callGroupId;
                
                // Versions, features and extensions
                ::Utils::Language language = ::Utils::Language::Cxx;
                ::Utils::LanguageVersion languageVersion = ::Utils::LanguageVersion::LatestCxx;
                ::Utils::LanguageExtensions languageExtensions = ::Utils::LanguageExtension::None;
                CPlusPlus::LanguageFeatures languageFeatures;
                ::Utils::QtVersion qtVersion = ::Utils::QtVersion::Unknown;
                
                // Files
                ProjectFiles files;
                QStringList includedFiles;
                QStringList precompiledHeaders;
                ProjectExplorer::HeaderPaths headerPaths;
                QString projectConfigFile; // Generic Project Manager only
                
                // Macros
                ProjectExplorer::Macros projectMacros;
                ProjectExplorer::Macros toolChainMacros;
                
                // Build system
                QString buildSystemTarget;
                ProjectExplorer::BuildTargetType buildTargetType = ProjectExplorer::BuildTargetType::Unknown;
                bool selectedForBuilding = true;
                
                // ToolChain
                Utils::Id toolchainType;
                bool isMsvc2015Toolchain = false;
                QString toolChainTargetTriple;
                ToolChainWordWidth toolChainWordWidth = WordWidth32Bit;
                ::Utils::FilePath toolChainInstallDir;
                ::Utils::WarningFlags warningFlags = ::Utils::WarningFlags::Default;
                
                // Misc
                QStringList extraCodeModelFlags;
                QStringList compilerFlags;
                
                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved