forked from qt-creator/qt-creator
		
	Clang: Fix built-in's ExtractFunction action
Since
  Clang: Provide highlighting for identifier under cursor
  commit ca72c29462
the LocalUseMap, used for some refactoring actions, was not updated
anymore. Fall back to the built-in implementation for the LocalUseMap
because it contains pointers to built-in AST that clang obviously can't
provide.
Task-number: QTCREATORBUG-18607
Change-Id: I08762fe457835d4d83aca719febcb3497ee9696b
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
			
			
This commit is contained in:
		| @@ -47,7 +47,6 @@ using namespace CPlusPlus; | ||||
| using SemanticUses = QList<CppTools::SemanticInfo::Use>; | ||||
|  | ||||
| namespace CppTools { | ||||
| namespace Internal { | ||||
| namespace { | ||||
|  | ||||
| CursorInfo::Range toRange(const SemanticInfo::Use &use) | ||||
| @@ -186,7 +185,8 @@ private: | ||||
|     { | ||||
|         CursorInfo result; | ||||
|  | ||||
|         const CppTools::SemanticInfo::LocalUseMap localUses = findLocalUses(); | ||||
|         const CppTools::SemanticInfo::LocalUseMap localUses | ||||
|                 = BuiltinCursorInfo::findLocalUses(m_document, m_line, m_column); | ||||
|         result.localUses = localUses; | ||||
|         splitLocalUses(localUses, &result.useRanges, &result.unusedVariablesRanges); | ||||
|  | ||||
| @@ -200,16 +200,6 @@ private: | ||||
|         return result; // OK, result.unusedVariablesRanges will be passed on | ||||
|     } | ||||
|  | ||||
|     CppTools::SemanticInfo::LocalUseMap findLocalUses() const | ||||
|     { | ||||
|         AST *ast = m_document->translationUnit()->ast(); | ||||
|         FunctionDefinitionUnderCursor functionDefinitionUnderCursor(m_document->translationUnit()); | ||||
|         DeclarationAST *declaration = functionDefinitionUnderCursor(ast, | ||||
|                                                                     static_cast<unsigned>(m_line), | ||||
|                                                                     static_cast<unsigned>(m_column)); | ||||
|         return CppTools::LocalSymbols(m_document, declaration).uses; | ||||
|     } | ||||
|  | ||||
|     void splitLocalUses(const CppTools::SemanticInfo::LocalUseMap &uses, | ||||
|                         CursorInfo::Ranges *rangesForLocalVariableUnderCursor, | ||||
|                         CursorInfo::Ranges *rangesForLocalUnusedVariables) const | ||||
| @@ -365,5 +355,15 @@ QFuture<CursorInfo> BuiltinCursorInfo::run(const CursorInfoParams &cursorInfoPar | ||||
|     return Utils::runAsync(&FindUses::find, document, snapshot, line, column, scope, expression); | ||||
| } | ||||
|  | ||||
| } // namespace Internal | ||||
| CppTools::SemanticInfo::LocalUseMap | ||||
| BuiltinCursorInfo::findLocalUses(const Document::Ptr &document, int line, int column) | ||||
| { | ||||
|     AST *ast = document->translationUnit()->ast(); | ||||
|     FunctionDefinitionUnderCursor functionDefinitionUnderCursor(document->translationUnit()); | ||||
|     DeclarationAST *declaration = functionDefinitionUnderCursor(ast, | ||||
|                                                                 static_cast<unsigned>(line), | ||||
|                                                                 static_cast<unsigned>(column)); | ||||
|     return CppTools::LocalSymbols(document, declaration).uses; | ||||
| } | ||||
|  | ||||
| } // namespace CppTools | ||||
|   | ||||
| @@ -26,17 +26,21 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "cppcursorinfo.h" | ||||
| #include "cpptools_global.h" | ||||
|  | ||||
| #include <cplusplus/CppDocument.h> | ||||
|  | ||||
| #include <QFuture> | ||||
|  | ||||
| namespace CppTools { | ||||
| namespace Internal { | ||||
|  | ||||
| class BuiltinCursorInfo | ||||
| class CPPTOOLS_EXPORT BuiltinCursorInfo | ||||
| { | ||||
| public: | ||||
|     static QFuture<CursorInfo> run(const CursorInfoParams ¶ms); | ||||
|  | ||||
|     static CppTools::SemanticInfo::LocalUseMap | ||||
|     findLocalUses(const CPlusPlus::Document::Ptr &document, int line, int column); | ||||
| }; | ||||
|  | ||||
| } // namespace Internal | ||||
| } // namespace CppTools | ||||
|   | ||||
| @@ -257,7 +257,7 @@ bool BuiltinEditorDocumentProcessor::isParserRunning() const | ||||
| QFuture<CursorInfo> | ||||
| BuiltinEditorDocumentProcessor::cursorInfo(const CursorInfoParams ¶ms) | ||||
| { | ||||
|     return Internal::BuiltinCursorInfo::run(params); | ||||
|     return BuiltinCursorInfo::run(params); | ||||
| } | ||||
|  | ||||
| void BuiltinEditorDocumentProcessor::onParserFinished(CPlusPlus::Document::Ptr document, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user