forked from qt-creator/qt-creator
TextEditor: filepathify RefactoringChanges
Change-Id: Ie97e484bcdeaa0cb2f5d04b3c79ace55ff2e426c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -78,7 +78,8 @@ void ClangFixItOperation::perform()
|
||||
const QString filePath = i.key();
|
||||
const QVector<ClangBackEnd::FixItContainer> fixits = i.value();
|
||||
|
||||
RefactoringFilePtr refactoringFile = refactoringChanges.file(filePath);
|
||||
RefactoringFilePtr refactoringFile = refactoringChanges.file(
|
||||
Utils::FilePath::fromString(filePath));
|
||||
refactoringFiles.append(refactoringFile);
|
||||
|
||||
applyFixitsToFile(*refactoringFile, fixits);
|
||||
|
@@ -70,7 +70,7 @@ void ClangToolQuickFixOperation::perform()
|
||||
continue;
|
||||
TextEditor::RefactoringFilePtr &refactoringFile = refactoringFiles[step.location.filePath];
|
||||
if (refactoringFile.isNull())
|
||||
refactoringFile = changes.file(step.location.filePath);
|
||||
refactoringFile = changes.file(Utils::FilePath::fromString(step.location.filePath));
|
||||
Utils::ChangeSet changeSet = refactoringFile->changeSet();
|
||||
Range range = toRange(refactoringFile->document(), {step.ranges.first(), step.ranges.last()});
|
||||
changeSet.replace(range, step.message);
|
||||
|
@@ -1129,7 +1129,7 @@ void CppEditorWidget::onFunctionDeclDefLinkFound(QSharedPointer<FunctionDeclDefL
|
||||
abortDeclDefLink();
|
||||
d->m_declDefLink = link;
|
||||
IDocument *targetDocument = DocumentModel::documentForFilePath(
|
||||
FilePath::fromString(d->m_declDefLink->targetFile->fileName()));
|
||||
d->m_declDefLink->targetFile->filePath());
|
||||
if (textDocument() != targetDocument) {
|
||||
if (auto textDocument = qobject_cast<BaseTextDocument *>(targetDocument))
|
||||
connect(textDocument,
|
||||
@@ -1162,7 +1162,7 @@ void CppEditorWidget::abortDeclDefLink()
|
||||
return;
|
||||
|
||||
IDocument *targetDocument = DocumentModel::documentForFilePath(
|
||||
FilePath::fromString(d->m_declDefLink->targetFile->fileName()));
|
||||
d->m_declDefLink->targetFile->filePath());
|
||||
if (textDocument() != targetDocument) {
|
||||
if (auto textDocument = qobject_cast<BaseTextDocument *>(targetDocument))
|
||||
disconnect(textDocument,
|
||||
|
@@ -172,7 +172,8 @@ static QSharedPointer<FunctionDeclDefLink> findLinkHelper(QSharedPointer<Functio
|
||||
// parse the target file to get the linked decl/def
|
||||
const QString targetFileName = QString::fromUtf8(
|
||||
target->fileName(), target->fileNameLength());
|
||||
CppRefactoringFileConstPtr targetFile = changes.fileNoEditor(targetFileName);
|
||||
CppRefactoringFileConstPtr targetFile = changes.fileNoEditor(
|
||||
Utils::FilePath::fromString(targetFileName));
|
||||
if (!targetFile->isValid())
|
||||
return noResult;
|
||||
|
||||
@@ -220,7 +221,8 @@ void FunctionDeclDefLinkFinder::startFindLinkAt(
|
||||
|
||||
// find the start/end offsets
|
||||
CppRefactoringChanges refactoringChanges(snapshot);
|
||||
CppRefactoringFilePtr sourceFile = refactoringChanges.file(doc->fileName());
|
||||
CppRefactoringFilePtr sourceFile = refactoringChanges.file(
|
||||
Utils::FilePath::fromString(doc->fileName()));
|
||||
sourceFile->setCppDocument(doc);
|
||||
int start, end;
|
||||
declDefLinkStartEnd(sourceFile, parent, funcDecl, &start, &end);
|
||||
@@ -280,7 +282,7 @@ void FunctionDeclDefLink::apply(CppEditorWidget *editor, bool jumpToMatch)
|
||||
|
||||
// first verify the interesting region of the target file is unchanged
|
||||
CppRefactoringChanges refactoringChanges(snapshot);
|
||||
CppRefactoringFilePtr newTargetFile = refactoringChanges.file(targetFile->fileName());
|
||||
CppRefactoringFilePtr newTargetFile = refactoringChanges.file(targetFile->filePath());
|
||||
if (!newTargetFile->isValid())
|
||||
return;
|
||||
const int targetStart = newTargetFile->position(targetLine, targetColumn);
|
||||
|
@@ -786,8 +786,8 @@ public:
|
||||
printer.showTemplateParameters = true;
|
||||
Utils::ChangeSet headerChangeSet;
|
||||
const CppRefactoringChanges refactoring(snapshot());
|
||||
const QString filename = currentFile()->fileName();
|
||||
const CppRefactoringFilePtr headerFile = refactoring.file(filename);
|
||||
const Utils::FilePath filePath = currentFile()->filePath();
|
||||
const CppRefactoringFilePtr headerFile = refactoring.file(filePath);
|
||||
const LookupContext targetContext(headerFile->cppDocument(), snapshot());
|
||||
|
||||
const Class *targetClass = m_classAST->symbol;
|
||||
@@ -905,7 +905,8 @@ public:
|
||||
if (!clazz)
|
||||
return;
|
||||
|
||||
CppRefactoringFilePtr implementationFile = refactoring.file(m_cppFileName);
|
||||
CppRefactoringFilePtr implementationFile = refactoring.file(
|
||||
Utils::FilePath::fromString(m_cppFileName));
|
||||
Utils::ChangeSet implementationChangeSet;
|
||||
const int insertPos = qMax(0, implementationFile->document()->characterCount() - 1);
|
||||
|
||||
|
@@ -361,7 +361,7 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
|
||||
ChangeSet changes;
|
||||
if (negation) {
|
||||
@@ -455,7 +455,7 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
|
||||
ChangeSet changes;
|
||||
changes.flip(currentFile->range(binary->left_expression),
|
||||
@@ -544,7 +544,7 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
|
||||
ChangeSet changes;
|
||||
changes.replace(currentFile->range(pattern->binary_op_token), QLatin1String("||"));
|
||||
@@ -631,7 +631,7 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
|
||||
ChangeSet changes;
|
||||
|
||||
@@ -722,7 +722,7 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
|
||||
ChangeSet changes;
|
||||
|
||||
@@ -797,7 +797,7 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
|
||||
ChangeSet changes;
|
||||
|
||||
@@ -871,7 +871,7 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
|
||||
ChangeSet changes;
|
||||
|
||||
@@ -950,7 +950,7 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
|
||||
const Token binaryToken = currentFile->tokenAt(condition->binary_op_token);
|
||||
|
||||
@@ -1189,7 +1189,7 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
|
||||
ChangeSet changes;
|
||||
|
||||
@@ -1393,7 +1393,7 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
|
||||
ChangeSet changes;
|
||||
|
||||
@@ -1455,7 +1455,7 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
|
||||
ChangeSet changes;
|
||||
changes.replace(start, end, replacement);
|
||||
@@ -1614,7 +1614,7 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
|
||||
TypeOfExpression typeOfExpression;
|
||||
typeOfExpression.init(semanticInfo().doc, snapshot(), context().bindings());
|
||||
@@ -1712,7 +1712,7 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
|
||||
QString newName = m_isAllUpper ? m_name.toLower() : m_name;
|
||||
for (int i = 1; i < newName.length(); ++i) {
|
||||
@@ -1794,7 +1794,7 @@ AddIncludeForUndefinedIdentifierOp::AddIncludeForUndefinedIdentifierOp(
|
||||
void AddIncludeForUndefinedIdentifierOp::perform()
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr file = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr file = refactoring.file(filePath());
|
||||
|
||||
insertNewIncludeDirective(m_include, file, semanticInfo().doc);
|
||||
}
|
||||
@@ -1817,7 +1817,7 @@ void AddForwardDeclForUndefinedIdentifierOp::perform()
|
||||
const QStringList namespaces = parts.mid(0, parts.length() - 1);
|
||||
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr file = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr file = refactoring.file(filePath());
|
||||
|
||||
NSVisitor visitor(file.data(), namespaces, m_symbolPos);
|
||||
visitor.accept(file->cppDocument()->translationUnit()->ast());
|
||||
@@ -2164,7 +2164,7 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
|
||||
int targetEndPos = currentFile->endOf(m_targetParam);
|
||||
ChangeSet changes;
|
||||
@@ -2244,7 +2244,7 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
currentFile->setChangeSet(m_change);
|
||||
currentFile->apply();
|
||||
}
|
||||
@@ -2406,7 +2406,7 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
|
||||
ChangeSet changes;
|
||||
int start = currentFile->endOf(compoundStatement->lbrace_token);
|
||||
@@ -2548,7 +2548,8 @@ public:
|
||||
m_targetFileName, m_targetSymbol, m_xsSpec);
|
||||
QTC_ASSERT(loc.isValid(), return);
|
||||
|
||||
CppRefactoringFilePtr targetFile = refactoring.file(m_targetFileName);
|
||||
CppRefactoringFilePtr targetFile = refactoring.file(
|
||||
Utils::FilePath::fromString(m_targetFileName));
|
||||
int targetPosition1 = targetFile->position(loc.line(), loc.column());
|
||||
int targetPosition2 = qMax(0, targetFile->position(loc.line(), 1) - 1);
|
||||
|
||||
@@ -2730,7 +2731,8 @@ public:
|
||||
refactoring, targetFilePath);
|
||||
QTC_ASSERT(loc.isValid(), return);
|
||||
|
||||
CppRefactoringFilePtr targetFile = refactoring.file(loc.fileName());
|
||||
CppRefactoringFilePtr targetFile = refactoring.file(
|
||||
Utils::FilePath::fromString(loc.fileName()));
|
||||
Overview oo = CppCodeStyleSettings::currentProjectCodeStyleOverview();
|
||||
oo.showFunctionSignatures = true;
|
||||
oo.showReturnTypes = true;
|
||||
@@ -2792,7 +2794,7 @@ public:
|
||||
|
||||
// rewrite the function name
|
||||
if (nameIncludesOperatorName(decl->name())) {
|
||||
CppRefactoringFilePtr file = refactoring.file(op->filePath().toString());
|
||||
CppRefactoringFilePtr file = refactoring.file(op->filePath());
|
||||
const QString operatorNameText = file->textOf(declAST->core_declarator);
|
||||
oo.includeWhiteSpaceInOperatorName = operatorNameText.contains(QLatin1Char(' '));
|
||||
}
|
||||
@@ -2982,7 +2984,7 @@ private:
|
||||
filePath, m_class, InsertionPointLocator::Private);
|
||||
QTC_ASSERT(loc.isValid(), return);
|
||||
|
||||
CppRefactoringFilePtr targetFile = refactoring.file(filePath);
|
||||
CppRefactoringFilePtr targetFile = refactoring.file(Utils::FilePath::fromString(filePath));
|
||||
const int targetPosition1 = targetFile->position(loc.line(), loc.column());
|
||||
const int targetPosition2 = qMax(0, targetFile->position(loc.line(), 1) - 1);
|
||||
ChangeSet target;
|
||||
@@ -3312,7 +3314,8 @@ private:
|
||||
&changeSet.first, &changeSet.second);
|
||||
}
|
||||
for (auto it = changeSets.cbegin(); it != changeSets.cend(); ++it) {
|
||||
const CppRefactoringFilePtr file = refactoring.file(it.key());
|
||||
const CppRefactoringFilePtr file = refactoring.file(
|
||||
Utils::FilePath::fromString(it.key()));
|
||||
for (const ChangeSet::Range &r : it.value().second)
|
||||
file->appendIndentRange(r);
|
||||
file->setChangeSet(it.value().first);
|
||||
@@ -3438,14 +3441,14 @@ public:
|
||||
: m_operation(operation)
|
||||
, m_changes(m_operation->snapshot())
|
||||
, m_locator(m_changes)
|
||||
, m_headerFile(m_changes.file(fileName))
|
||||
, m_headerFile(m_changes.file(Utils::FilePath::fromString(fileName)))
|
||||
, m_sourceFile([&] {
|
||||
QString cppFileName = correspondingHeaderOrSource(fileName, &m_isHeaderHeaderFile);
|
||||
if (!m_isHeaderHeaderFile || !QFile::exists(cppFileName)) {
|
||||
// there is no "source" file
|
||||
return m_headerFile;
|
||||
} else {
|
||||
return m_changes.file(cppFileName);
|
||||
return m_changes.file(Utils::FilePath::fromString(cppFileName));
|
||||
}
|
||||
}())
|
||||
, m_class(clazz)
|
||||
@@ -3613,7 +3616,7 @@ protected:
|
||||
if (insertionPoint != m_headerInsertionPoints.end())
|
||||
return *insertionPoint;
|
||||
const InsertionLocation loc = m_locator.methodDeclarationInClass(
|
||||
m_headerFile->fileName(), m_class, spec,
|
||||
m_headerFile->filePath().toString(), m_class, spec,
|
||||
InsertionPointLocator::ForceAccessSpec::Yes);
|
||||
m_headerInsertionPoints.insert(spec, loc);
|
||||
return loc;
|
||||
@@ -3630,7 +3633,7 @@ protected:
|
||||
? NamespaceHandling::CreateMissing
|
||||
: NamespaceHandling::Ignore,
|
||||
m_changes,
|
||||
m_sourceFile->fileName(),
|
||||
m_sourceFile->filePath().toString(),
|
||||
insertedNamespaces);
|
||||
if (m_settings->addUsingNamespaceinCppFile()) {
|
||||
// check if we have to insert a using namespace ...
|
||||
@@ -3768,7 +3771,9 @@ public:
|
||||
|
||||
void perform() override
|
||||
{
|
||||
GetterSetterRefactoringHelper helper(this, currentFile()->fileName(), m_data.clazz);
|
||||
GetterSetterRefactoringHelper helper(this,
|
||||
currentFile()->filePath().toString(),
|
||||
m_data.clazz);
|
||||
helper.performGeneration(m_data, m_generateFlags);
|
||||
helper.applyChanges();
|
||||
}
|
||||
@@ -3945,11 +3950,12 @@ void GetterSetterRefactoringHelper::performGeneration(ExistingGetterSetterData d
|
||||
+ "()" + constSpec + "\n{\nreturn " + returnExpression + ";\n}";
|
||||
addSourceFileCode(code);
|
||||
} else if (getterLocation == CppQuickFixSettings::FunctionLocation::OutsideClass) {
|
||||
InsertionLocation loc = insertLocationForMethodDefinition(data.declarationSymbol,
|
||||
false,
|
||||
NamespaceHandling::Ignore,
|
||||
m_changes,
|
||||
m_headerFile->fileName());
|
||||
InsertionLocation loc
|
||||
= insertLocationForMethodDefinition(data.declarationSymbol,
|
||||
false,
|
||||
NamespaceHandling::Ignore,
|
||||
m_changes,
|
||||
m_headerFile->filePath().toString());
|
||||
const FullySpecifiedType returnType = getReturnTypeAt(m_headerFile, loc);
|
||||
const QString clazz = symbolAt(data.clazz, m_headerFile, loc);
|
||||
QString code = overview.prettyType(returnType, clazz + "::" + data.getterName)
|
||||
@@ -4020,11 +4026,12 @@ void GetterSetterRefactoringHelper::performGeneration(ExistingGetterSetterData d
|
||||
+ body;
|
||||
addSourceFileCode(code);
|
||||
} else if (setterLocation == CppQuickFixSettings::FunctionLocation::OutsideClass) {
|
||||
InsertionLocation loc = insertLocationForMethodDefinition(data.declarationSymbol,
|
||||
false,
|
||||
NamespaceHandling::Ignore,
|
||||
m_changes,
|
||||
m_headerFile->fileName());
|
||||
InsertionLocation loc
|
||||
= insertLocationForMethodDefinition(data.declarationSymbol,
|
||||
false,
|
||||
NamespaceHandling::Ignore,
|
||||
m_changes,
|
||||
m_headerFile->filePath().toString());
|
||||
|
||||
FullySpecifiedType newParameterType = typeAt(data.declarationSymbol->type(),
|
||||
data.clazz,
|
||||
@@ -4094,7 +4101,7 @@ void GetterSetterRefactoringHelper::performGeneration(ExistingGetterSetterData d
|
||||
false,
|
||||
NamespaceHandling::Ignore,
|
||||
m_changes,
|
||||
m_headerFile->fileName());
|
||||
m_headerFile->filePath().toString());
|
||||
const FullySpecifiedType type = typeAt(data.declarationSymbol->type(),
|
||||
data.clazz,
|
||||
m_headerFile,
|
||||
@@ -4665,7 +4672,7 @@ private:
|
||||
if (m_candidates.empty())
|
||||
return;
|
||||
GetterSetterRefactoringHelper helper(this,
|
||||
currentFile()->fileName(),
|
||||
currentFile()->filePath().toString(),
|
||||
m_candidates.front().data.clazz);
|
||||
for (MemberInfo &mi : m_candidates) {
|
||||
if (mi.requestedFlags != 0) {
|
||||
@@ -4744,7 +4751,7 @@ public:
|
||||
{
|
||||
QTC_ASSERT(!m_funcReturn || !m_relevantDecls.isEmpty(), return);
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
|
||||
ExtractFunctionOptions options;
|
||||
if (m_functionNameGetter)
|
||||
@@ -4850,7 +4857,7 @@ public:
|
||||
}
|
||||
funcDef.append(QLatin1String("\n}\n\n"));
|
||||
funcDef.replace(QChar::ParagraphSeparator, QLatin1String("\n"));
|
||||
funcDef.prepend(inlinePrefix(currentFile->fileName()));
|
||||
funcDef.prepend(inlinePrefix(currentFile->filePath().toString()));
|
||||
funcCall.append(QLatin1Char(';'));
|
||||
|
||||
// Get starting indentation from original code.
|
||||
@@ -4890,7 +4897,7 @@ public:
|
||||
const QString fileName = QLatin1String(matchingClass->fileName());
|
||||
const InsertionLocation &location =
|
||||
locator.methodDeclarationInClass(fileName, matchingClass, options.access);
|
||||
CppRefactoringFilePtr declFile = refactoring.file(fileName);
|
||||
CppRefactoringFilePtr declFile = refactoring.file(Utils::FilePath::fromString(fileName));
|
||||
change.clear();
|
||||
position = declFile->position(location.line(), location.column());
|
||||
change.insert(position, location.prefix() + funcDecl + location.suffix());
|
||||
@@ -5400,7 +5407,7 @@ public:
|
||||
declFileName = QString::fromUtf8(matchingClass->fileName(),
|
||||
matchingClass->fileNameLength());
|
||||
|
||||
result.file = refactoring.file(declFileName);
|
||||
result.file = refactoring.file(Utils::FilePath::fromString(declFileName));
|
||||
ASTPath astPath(result.file->cppDocument());
|
||||
const QList<AST *> path = astPath(s->line(), s->column());
|
||||
SimpleDeclarationAST *simpleDecl = nullptr;
|
||||
@@ -5423,7 +5430,7 @@ public:
|
||||
declFileName = correspondingHeaderOrSource(filePath().toString(), &isHeaderFile);
|
||||
if (!QFile::exists(declFileName))
|
||||
return FoundDeclaration();
|
||||
result.file = refactoring.file(declFileName);
|
||||
result.file = refactoring.file(Utils::FilePath::fromString(declFileName));
|
||||
if (!result.file)
|
||||
return FoundDeclaration();
|
||||
const LookupContext lc(result.file->cppDocument(), snapshot());
|
||||
@@ -5452,7 +5459,7 @@ public:
|
||||
FunctionDeclaratorAST *functionDeclaratorOfDefinition
|
||||
= functionDeclarator(m_functionDefinition);
|
||||
const CppRefactoringChanges refactoring(snapshot());
|
||||
const CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
const CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
deduceTypeNameOfLiteral(currentFile->cppDocument());
|
||||
|
||||
ChangeSet changes;
|
||||
@@ -5474,7 +5481,7 @@ public:
|
||||
appendFunctionParameter(functionDeclaratorOfDefinition, currentFile, &changes,
|
||||
!functionDeclaration.ast);
|
||||
if (functionDeclaration.ast) {
|
||||
if (currentFile->fileName() != functionDeclaration.file->fileName()) {
|
||||
if (currentFile->filePath() != functionDeclaration.file->filePath()) {
|
||||
ChangeSet declChanges;
|
||||
appendFunctionParameter(functionDeclaration.ast, functionDeclaration.file, &declChanges,
|
||||
true);
|
||||
@@ -5634,7 +5641,7 @@ public:
|
||||
, m_identifierAST(identifierAST)
|
||||
, m_symbol(symbol)
|
||||
, m_refactoring(snapshot())
|
||||
, m_file(m_refactoring.file(filePath().toString()))
|
||||
, m_file(m_refactoring.file(filePath()))
|
||||
, m_document(interface.semanticInfo().doc)
|
||||
{
|
||||
setDescription(
|
||||
@@ -6225,8 +6232,9 @@ public:
|
||||
const QString &fromFile, const QString &toFile)
|
||||
: m_operation(operation), m_type(type), m_changes(m_operation->snapshot())
|
||||
{
|
||||
m_fromFile = m_changes.file(fromFile);
|
||||
m_toFile = (m_type == MoveOutside) ? m_fromFile : m_changes.file(toFile);
|
||||
m_fromFile = m_changes.file(Utils::FilePath::fromString(fromFile));
|
||||
m_toFile = (m_type == MoveOutside) ? m_fromFile
|
||||
: m_changes.file(Utils::FilePath::fromString(toFile));
|
||||
}
|
||||
|
||||
void performMove(FunctionDefinitionAST *funcAST)
|
||||
@@ -6234,7 +6242,7 @@ public:
|
||||
// Determine file, insert position and scope
|
||||
InsertionLocation l = insertLocationForMethodDefinition(
|
||||
funcAST->symbol, false, NamespaceHandling::Ignore,
|
||||
m_changes, m_toFile->fileName());
|
||||
m_changes, m_toFile->filePath().toString());
|
||||
const QString prefix = l.prefix();
|
||||
const QString suffix = l.suffix();
|
||||
const int insertPos = m_toFile->position(l.line(), l.column());
|
||||
@@ -6242,7 +6250,7 @@ public:
|
||||
|
||||
// construct definition
|
||||
const QString funcDec = inlinePrefix(
|
||||
m_toFile->fileName(), [this] { return m_type == MoveOutside; })
|
||||
m_toFile->filePath().toString(), [this] { return m_type == MoveOutside; })
|
||||
+ definitionSignature(m_operation, funcAST, m_fromFile, m_toFile,
|
||||
scopeAtInsertPos);
|
||||
QString funcDef = prefix + funcDec;
|
||||
@@ -6495,8 +6503,8 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr fromFile = refactoring.file(m_fromFileName);
|
||||
CppRefactoringFilePtr toFile = refactoring.file(m_toFileName);
|
||||
CppRefactoringFilePtr fromFile = refactoring.file(Utils::FilePath::fromString(m_fromFileName));
|
||||
CppRefactoringFilePtr toFile = refactoring.file(Utils::FilePath::fromString(m_toFileName));
|
||||
|
||||
const QString wholeFunctionText = m_declarationText
|
||||
+ fromFile->textOf(fromFile->endOf(m_funcAST->declarator),
|
||||
@@ -6558,7 +6566,7 @@ void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
|
||||
return;
|
||||
|
||||
const CppRefactoringChanges refactoring(interface.snapshot());
|
||||
const CppRefactoringFilePtr defFile = refactoring.file(interface.filePath().toString());
|
||||
const CppRefactoringFilePtr defFile = refactoring.file(interface.filePath());
|
||||
const ChangeSet::Range defRange = defFile->range(completeDefAST);
|
||||
|
||||
// Determine declaration (file, range, text);
|
||||
@@ -6592,7 +6600,7 @@ void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
|
||||
declFileName = QString::fromUtf8(matchingClass->fileName(),
|
||||
matchingClass->fileNameLength());
|
||||
|
||||
const CppRefactoringFilePtr declFile = refactoring.file(declFileName);
|
||||
const CppRefactoringFilePtr declFile = refactoring.file(Utils::FilePath::fromString(declFileName));
|
||||
ASTPath astPath(declFile->cppDocument());
|
||||
const QList<AST *> path = astPath(s->line(), s->column());
|
||||
for (int idx = path.size() - 1; idx > 0; --idx) {
|
||||
@@ -6617,7 +6625,8 @@ void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
|
||||
if (isHeaderFile)
|
||||
return;
|
||||
|
||||
const CppRefactoringFilePtr declFile = refactoring.file(declFileName);
|
||||
const CppRefactoringFilePtr declFile = refactoring.file(
|
||||
Utils::FilePath::fromString(declFileName));
|
||||
const LookupContext lc(declFile->cppDocument(), interface.snapshot());
|
||||
const QList<LookupItem> candidates = lc.lookup(func->name(), matchingNamespace);
|
||||
for (const LookupItem &candidate : candidates) {
|
||||
@@ -6669,7 +6678,7 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr file = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr file = refactoring.file(filePath());
|
||||
|
||||
// Determine return type and new variable name
|
||||
TypeOfExpression typeOfExpression;
|
||||
@@ -6878,9 +6887,9 @@ public:
|
||||
{
|
||||
QTC_ASSERT(m_forAst, return);
|
||||
|
||||
const QString filename = currentFile()->fileName();
|
||||
const Utils::FilePath filePath = currentFile()->filePath();
|
||||
const CppRefactoringChanges refactoring(snapshot());
|
||||
const CppRefactoringFilePtr file = refactoring.file(filename);
|
||||
const CppRefactoringFilePtr file = refactoring.file(filePath);
|
||||
ChangeSet change;
|
||||
|
||||
// Optimize post (in|de)crement operator to pre (in|de)crement operator
|
||||
@@ -7134,7 +7143,7 @@ public:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
|
||||
const int startPos = currentFile->startOf(m_literal);
|
||||
const int endPos = currentFile->endOf(m_literal);
|
||||
@@ -7223,7 +7232,7 @@ private:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
currentFile->setChangeSet(m_changes);
|
||||
currentFile->apply();
|
||||
}
|
||||
@@ -7975,7 +7984,8 @@ private:
|
||||
while (!nodesWithProcessedParents.empty()) {
|
||||
Node &node = nodesWithProcessedParents.back();
|
||||
nodesWithProcessedParents.pop_back();
|
||||
CppRefactoringFilePtr file = refactoring.file(node.document->fileName());
|
||||
CppRefactoringFilePtr file = refactoring.file(
|
||||
Utils::FilePath::fromString(node.document->fileName()));
|
||||
const bool parentHasUsing = Utils::anyOf(node.includes, &Node::hasGlobalUsingDirective);
|
||||
const int startPos = parentHasUsing
|
||||
? 0
|
||||
@@ -7994,7 +8004,7 @@ private:
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
|
||||
if (m_removeAllAtGlobalScope) {
|
||||
removeAllUsingsAtGlobalScope(refactoring);
|
||||
} else if (refactorFile(currentFile,
|
||||
@@ -8047,7 +8057,8 @@ private:
|
||||
if (m_processed.contains(loc.first))
|
||||
continue;
|
||||
|
||||
CppRefactoringFilePtr file = refactoring.file(loc.first->fileName());
|
||||
CppRefactoringFilePtr file = refactoring.file(
|
||||
Utils::FilePath::fromString(loc.first->fileName()));
|
||||
const bool noGlobalUsing = refactorFile(file,
|
||||
refactoring.snapshot(),
|
||||
file->position(loc.second, 1));
|
||||
@@ -8866,7 +8877,7 @@ private:
|
||||
false,
|
||||
NamespaceHandling::Ignore,
|
||||
m_changes,
|
||||
m_headerFile->fileName(),
|
||||
m_headerFile->filePath().toString(),
|
||||
&insertedNamespaces);
|
||||
implFile = m_headerFile;
|
||||
implCode = symbolAt(m_class, m_headerFile, implLoc);
|
||||
@@ -8974,7 +8985,7 @@ private:
|
||||
}
|
||||
};
|
||||
GenerateConstructorRefactoringHelper helper(this,
|
||||
currentFile()->fileName(),
|
||||
currentFile()->filePath().toString(),
|
||||
m_classAST->symbol,
|
||||
m_classAST,
|
||||
accessSpec);
|
||||
|
@@ -1465,7 +1465,8 @@ void CppModelManager::renameIncludes(const QString &oldFileName, const QString &
|
||||
const TextEditor::RefactoringChanges changes;
|
||||
|
||||
foreach (Snapshot::IncludeLocation loc, snapshot().includeLocationsOfDocument(oldFileName)) {
|
||||
TextEditor::RefactoringFilePtr file = changes.file(loc.first->fileName());
|
||||
TextEditor::RefactoringFilePtr file = changes.file(
|
||||
Utils::FilePath::fromString(loc.first->fileName()));
|
||||
const QTextBlock &block = file->document()->findBlockByNumber(loc.second - 1);
|
||||
const int replaceStart = block.text().indexOf(oldFileInfo.fileName());
|
||||
if (replaceStart > -1) {
|
||||
|
@@ -47,13 +47,13 @@ namespace CppTools {
|
||||
|
||||
class CppRefactoringChangesData : public TextEditor::RefactoringChangesData
|
||||
{
|
||||
static std::unique_ptr<TextEditor::Indenter> createIndenter(const QString &fileName,
|
||||
static std::unique_ptr<TextEditor::Indenter> createIndenter(const Utils::FilePath &filePath,
|
||||
QTextDocument *textDocument)
|
||||
{
|
||||
TextEditor::ICodeStylePreferencesFactory *factory
|
||||
= TextEditor::TextEditorSettings::codeStyleFactory(CppTools::Constants::CPP_SETTINGS_ID);
|
||||
std::unique_ptr<TextEditor::Indenter> indenter(factory->createIndenter(textDocument));
|
||||
indenter->setFileName(Utils::FilePath::fromString(fileName));
|
||||
indenter->setFileName(filePath);
|
||||
return indenter;
|
||||
}
|
||||
|
||||
@@ -65,34 +65,36 @@ public:
|
||||
{}
|
||||
|
||||
void indentSelection(const QTextCursor &selection,
|
||||
const QString &fileName,
|
||||
const Utils::FilePath &filePath,
|
||||
const TextEditor::TextDocument *textDocument) const override
|
||||
{
|
||||
if (textDocument) { // use the indenter from the textDocument if there is one, can be ClangFormat
|
||||
textDocument->indenter()->indent(selection, QChar::Null, textDocument->tabSettings());
|
||||
} else {
|
||||
const auto &tabSettings = ProjectExplorer::actualTabSettings(fileName, textDocument);
|
||||
auto indenter = createIndenter(fileName, selection.document());
|
||||
const auto &tabSettings = ProjectExplorer::actualTabSettings(filePath.toString(),
|
||||
textDocument);
|
||||
auto indenter = createIndenter(filePath, selection.document());
|
||||
indenter->indent(selection, QChar::Null, tabSettings);
|
||||
}
|
||||
}
|
||||
|
||||
void reindentSelection(const QTextCursor &selection,
|
||||
const QString &fileName,
|
||||
const Utils::FilePath &filePath,
|
||||
const TextEditor::TextDocument *textDocument) const override
|
||||
{
|
||||
if (textDocument) { // use the indenter from the textDocument if there is one, can be ClangFormat
|
||||
textDocument->indenter()->reindent(selection, textDocument->tabSettings());
|
||||
} else {
|
||||
const auto &tabSettings = ProjectExplorer::actualTabSettings(fileName, textDocument);
|
||||
auto indenter = createIndenter(fileName, selection.document());
|
||||
const auto &tabSettings = ProjectExplorer::actualTabSettings(filePath.toString(),
|
||||
textDocument);
|
||||
auto indenter = createIndenter(filePath, selection.document());
|
||||
indenter->reindent(selection, tabSettings);
|
||||
}
|
||||
}
|
||||
|
||||
void fileChanged(const QString &fileName) override
|
||||
void fileChanged(const Utils::FilePath &filePath) override
|
||||
{
|
||||
m_modelManager->updateSourceFiles(QSet<QString>() << fileName);
|
||||
m_modelManager->updateSourceFiles({filePath.toString()});
|
||||
}
|
||||
|
||||
Snapshot m_snapshot;
|
||||
@@ -118,18 +120,19 @@ CppRefactoringFilePtr CppRefactoringChanges::file(TextEditor::TextEditorWidget *
|
||||
return result;
|
||||
}
|
||||
|
||||
CppRefactoringFilePtr CppRefactoringChanges::file(const QString &fileName) const
|
||||
CppRefactoringFilePtr CppRefactoringChanges::file(const Utils::FilePath &filePath) const
|
||||
{
|
||||
CppRefactoringFilePtr result(new CppRefactoringFile(fileName, m_data));
|
||||
CppRefactoringFilePtr result(new CppRefactoringFile(filePath, m_data));
|
||||
return result;
|
||||
}
|
||||
|
||||
CppRefactoringFileConstPtr CppRefactoringChanges::fileNoEditor(const QString &fileName) const
|
||||
CppRefactoringFileConstPtr CppRefactoringChanges::fileNoEditor(const Utils::FilePath &filePath) const
|
||||
{
|
||||
QTextDocument *document = nullptr;
|
||||
const QString fileName = filePath.toString();
|
||||
if (data()->m_workingCopy.contains(fileName))
|
||||
document = new QTextDocument(QString::fromUtf8(data()->m_workingCopy.source(fileName)));
|
||||
CppRefactoringFilePtr result(new CppRefactoringFile(document, fileName));
|
||||
CppRefactoringFilePtr result(new CppRefactoringFile(document, filePath));
|
||||
result->m_data = m_data;
|
||||
|
||||
return result;
|
||||
@@ -140,15 +143,15 @@ const Snapshot &CppRefactoringChanges::snapshot() const
|
||||
return data()->m_snapshot;
|
||||
}
|
||||
|
||||
CppRefactoringFile::CppRefactoringFile(const QString &fileName, const QSharedPointer<TextEditor::RefactoringChangesData> &data)
|
||||
: RefactoringFile(fileName, data)
|
||||
CppRefactoringFile::CppRefactoringFile(const Utils::FilePath &filePath, const QSharedPointer<TextEditor::RefactoringChangesData> &data)
|
||||
: RefactoringFile(filePath, data)
|
||||
{
|
||||
const Snapshot &snapshot = this->data()->m_snapshot;
|
||||
m_cppDocument = snapshot.document(fileName);
|
||||
m_cppDocument = snapshot.document(filePath.toString());
|
||||
}
|
||||
|
||||
CppRefactoringFile::CppRefactoringFile(QTextDocument *document, const QString &fileName)
|
||||
: RefactoringFile(document, fileName)
|
||||
CppRefactoringFile::CppRefactoringFile(QTextDocument *document, const Utils::FilePath &filePath)
|
||||
: RefactoringFile(document, filePath)
|
||||
{ }
|
||||
|
||||
CppRefactoringFile::CppRefactoringFile(TextEditor::TextEditorWidget *editor)
|
||||
@@ -160,7 +163,7 @@ Document::Ptr CppRefactoringFile::cppDocument() const
|
||||
if (!m_cppDocument || !m_cppDocument->translationUnit() ||
|
||||
!m_cppDocument->translationUnit()->ast()) {
|
||||
const QByteArray source = document()->toPlainText().toUtf8();
|
||||
const QString name = fileName();
|
||||
const QString name = filePath().toString();
|
||||
const Snapshot &snapshot = data()->m_snapshot;
|
||||
|
||||
m_cppDocument = snapshot.preprocessedDocument(source, name);
|
||||
|
@@ -67,8 +67,8 @@ public:
|
||||
QString textOf(const CPlusPlus::AST *ast) const;
|
||||
|
||||
protected:
|
||||
CppRefactoringFile(const QString &fileName, const QSharedPointer<TextEditor::RefactoringChangesData> &data);
|
||||
CppRefactoringFile(QTextDocument *document, const QString &fileName);
|
||||
CppRefactoringFile(const Utils::FilePath &filePath, const QSharedPointer<TextEditor::RefactoringChangesData> &data);
|
||||
CppRefactoringFile(QTextDocument *document, const Utils::FilePath &filePath);
|
||||
explicit CppRefactoringFile(TextEditor::TextEditorWidget *editor);
|
||||
|
||||
CppRefactoringChangesData *data() const;
|
||||
@@ -86,9 +86,9 @@ public:
|
||||
|
||||
static CppRefactoringFilePtr file(TextEditor::TextEditorWidget *editor,
|
||||
const CPlusPlus::Document::Ptr &document);
|
||||
CppRefactoringFilePtr file(const QString &fileName) const;
|
||||
CppRefactoringFilePtr file(const Utils::FilePath &filePath) const;
|
||||
// safe to use from non-gui threads
|
||||
CppRefactoringFileConstPtr fileNoEditor(const QString &fileName) const;
|
||||
CppRefactoringFileConstPtr fileNoEditor(const Utils::FilePath &filePath) const;
|
||||
|
||||
const CPlusPlus::Snapshot &snapshot() const;
|
||||
|
||||
|
@@ -276,7 +276,8 @@ InsertionLocation InsertionPointLocator::methodDeclarationInClass(
|
||||
AccessSpec xsSpec,
|
||||
ForceAccessSpec forceAccessSpec) const
|
||||
{
|
||||
const Document::Ptr doc = m_refactoringChanges.file(fileName)->cppDocument();
|
||||
const Document::Ptr doc = m_refactoringChanges.file(Utils::FilePath::fromString(fileName))
|
||||
->cppDocument();
|
||||
if (doc) {
|
||||
FindInClass find(doc->translationUnit(), clazz);
|
||||
ClassSpecifierAST *classAST = find();
|
||||
@@ -620,7 +621,8 @@ static InsertionLocation nextToSurroundingDefinitions(Symbol *declaration,
|
||||
targetDoc->translationUnit()->getPosition(definitionFunction->endOffset(), &line, &column);
|
||||
} else {
|
||||
// we don't have an offset to the start of the function definition, so we need to manually find it...
|
||||
CppRefactoringFilePtr targetFile = changes.file(QString::fromUtf8(definitionFunction->fileName()));
|
||||
CppRefactoringFilePtr targetFile = changes.file(
|
||||
Utils::FilePath::fromString(QString::fromUtf8(definitionFunction->fileName())));
|
||||
if (!targetFile->isValid())
|
||||
return noResult;
|
||||
|
||||
@@ -675,7 +677,8 @@ const QList<InsertionLocation> InsertionPointLocator::methodDefinition(
|
||||
target = candidate;
|
||||
}
|
||||
|
||||
CppRefactoringFilePtr targetFile = m_refactoringChanges.file(target);
|
||||
CppRefactoringFilePtr targetFile = m_refactoringChanges.file(
|
||||
Utils::FilePath::fromString(target));
|
||||
Document::Ptr doc = targetFile->cppDocument();
|
||||
if (doc.isNull())
|
||||
return result;
|
||||
@@ -783,7 +786,7 @@ InsertionLocation insertLocationForMethodDefinition(Symbol *symbol,
|
||||
{
|
||||
QTC_ASSERT(symbol, return InsertionLocation());
|
||||
|
||||
CppRefactoringFilePtr file = refactoring.file(fileName);
|
||||
CppRefactoringFilePtr file = refactoring.file(Utils::FilePath::fromString(fileName));
|
||||
QStringList requiredNamespaces;
|
||||
if (namespaceHandling == NamespaceHandling::CreateMissing) {
|
||||
requiredNamespaces = getNamespaceNames(symbol);
|
||||
|
@@ -97,7 +97,7 @@ bool applyTextEdits(const DocumentUri &uri, const QList<TextEdit> &edits)
|
||||
return true;
|
||||
RefactoringChanges changes;
|
||||
RefactoringFilePtr file;
|
||||
file = changes.file(uri.toFilePath().toString());
|
||||
file = changes.file(uri.toFilePath());
|
||||
file->setChangeSet(editsToChangeSet(edits, file->document()));
|
||||
return file->apply();
|
||||
}
|
||||
|
@@ -187,7 +187,8 @@ public:
|
||||
// stop if we can't create the new file
|
||||
const bool reindent = true;
|
||||
const bool openEditor = false;
|
||||
if (!refactoring.createFile(newFileName, newComponentSource, reindent, openEditor))
|
||||
const Utils::FilePath newFilePath = Utils::FilePath::fromString(newFileName);
|
||||
if (!refactoring.createFile(newFilePath, newComponentSource, reindent, openEditor))
|
||||
return;
|
||||
|
||||
if (path == QFileInfo(currentFileName).path()) {
|
||||
@@ -264,7 +265,7 @@ void performComponentFromObjectDef(const QString &fileName, QmlJS::AST::UiObject
|
||||
{
|
||||
QmlJSRefactoringChanges refactoring(QmlJS::ModelManagerInterface::instance(),
|
||||
QmlJS::ModelManagerInterface::instance()->snapshot());
|
||||
QmlJSRefactoringFilePtr current = refactoring.file(fileName);
|
||||
QmlJSRefactoringFilePtr current = refactoring.file(Utils::FilePath::fromString(fileName));
|
||||
|
||||
QmlJSQuickFixInterface interface;
|
||||
Operation operation(interface, objDef);
|
||||
|
@@ -56,7 +56,7 @@ void QmlJSQuickFixOperation::perform()
|
||||
{
|
||||
QmlJSRefactoringChanges refactoring(ModelManagerInterface::instance(),
|
||||
m_interface->semanticInfo().snapshot);
|
||||
QmlJSRefactoringFilePtr current = refactoring.file(fileName());
|
||||
QmlJSRefactoringFilePtr current = refactoring.file(Utils::FilePath::fromString(fileName()));
|
||||
|
||||
performChanges(current, refactoring);
|
||||
}
|
||||
|
@@ -880,7 +880,8 @@ void QmlOutlineModel::reparentNodes(QmlOutlineItem *targetItem, int row, QList<Q
|
||||
}
|
||||
|
||||
QmlJSRefactoringChanges refactoring(ModelManagerInterface::instance(), m_semanticInfo.snapshot);
|
||||
TextEditor::RefactoringFilePtr file = refactoring.file(m_semanticInfo.document->fileName());
|
||||
TextEditor::RefactoringFilePtr file = refactoring.file(
|
||||
Utils::FilePath::fromString(m_semanticInfo.document->fileName()));
|
||||
file->setChangeSet(changeSet);
|
||||
foreach (const Utils::ChangeSet::Range &range, changedRanges) {
|
||||
file->appendIndentRange(range);
|
||||
|
@@ -47,7 +47,7 @@ public:
|
||||
{}
|
||||
|
||||
void indentSelection(const QTextCursor &selection,
|
||||
const QString &fileName,
|
||||
const Utils::FilePath &filePath,
|
||||
const TextEditor::TextDocument *textDocument) const override
|
||||
{
|
||||
// ### shares code with QmlJSTextEditor::indent
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
const QTextBlock end = doc->findBlock(selection.selectionEnd()).next();
|
||||
|
||||
const TextEditor::TabSettings &tabSettings =
|
||||
ProjectExplorer::actualTabSettings(fileName, textDocument);
|
||||
ProjectExplorer::actualTabSettings(filePath.toString(), textDocument);
|
||||
CreatorCodeFormatter codeFormatter(tabSettings);
|
||||
codeFormatter.updateStateUntil(block);
|
||||
do {
|
||||
@@ -78,19 +78,19 @@ public:
|
||||
}
|
||||
|
||||
void reindentSelection(const QTextCursor &selection,
|
||||
const QString &fileName,
|
||||
const Utils::FilePath &filePath,
|
||||
const TextEditor::TextDocument *textDocument) const override
|
||||
{
|
||||
const TextEditor::TabSettings &tabSettings =
|
||||
ProjectExplorer::actualTabSettings(fileName, textDocument);
|
||||
ProjectExplorer::actualTabSettings(filePath.toString(), textDocument);
|
||||
|
||||
QmlJSEditor::Internal::Indenter indenter(selection.document());
|
||||
indenter.reindent(selection, tabSettings);
|
||||
}
|
||||
|
||||
void fileChanged(const QString &fileName) override
|
||||
void fileChanged(const Utils::FilePath &filePath) override
|
||||
{
|
||||
m_modelManager->updateSourceFiles(QStringList(fileName), true);
|
||||
m_modelManager->updateSourceFiles({filePath.toString()}, true);
|
||||
}
|
||||
|
||||
ModelManagerInterface *m_modelManager;
|
||||
@@ -103,9 +103,9 @@ QmlJSRefactoringChanges::QmlJSRefactoringChanges(ModelManagerInterface *modelMan
|
||||
{
|
||||
}
|
||||
|
||||
QmlJSRefactoringFilePtr QmlJSRefactoringChanges::file(const QString &fileName) const
|
||||
QmlJSRefactoringFilePtr QmlJSRefactoringChanges::file(const Utils::FilePath &filePath) const
|
||||
{
|
||||
return QmlJSRefactoringFilePtr(new QmlJSRefactoringFile(fileName, m_data));
|
||||
return QmlJSRefactoringFilePtr(new QmlJSRefactoringFile(filePath, m_data));
|
||||
}
|
||||
|
||||
QmlJSRefactoringFilePtr QmlJSRefactoringChanges::file(
|
||||
@@ -124,12 +124,13 @@ QmlJSRefactoringChangesData *QmlJSRefactoringChanges::data() const
|
||||
return static_cast<QmlJSRefactoringChangesData *>(m_data.data());
|
||||
}
|
||||
|
||||
QmlJSRefactoringFile::QmlJSRefactoringFile(const QString &fileName, const QSharedPointer<TextEditor::RefactoringChangesData> &data)
|
||||
: RefactoringFile(fileName, data)
|
||||
QmlJSRefactoringFile::QmlJSRefactoringFile(
|
||||
const Utils::FilePath &filePath, const QSharedPointer<TextEditor::RefactoringChangesData> &data)
|
||||
: RefactoringFile(filePath, data)
|
||||
{
|
||||
// the RefactoringFile is invalid if its not for a file with qml or js code
|
||||
if (ModelManagerInterface::guessLanguageOfFile(fileName) == Dialect::NoLanguage)
|
||||
m_fileName.clear();
|
||||
if (ModelManagerInterface::guessLanguageOfFile(filePath.toString()) == Dialect::NoLanguage)
|
||||
m_filePath.clear();
|
||||
}
|
||||
|
||||
QmlJSRefactoringFile::QmlJSRefactoringFile(TextEditor::TextEditorWidget *editor, Document::Ptr document)
|
||||
@@ -137,14 +138,14 @@ QmlJSRefactoringFile::QmlJSRefactoringFile(TextEditor::TextEditorWidget *editor,
|
||||
, m_qmljsDocument(document)
|
||||
{
|
||||
if (document)
|
||||
m_fileName = document->fileName();
|
||||
m_filePath = Utils::FilePath::fromString(document->fileName());
|
||||
}
|
||||
|
||||
Document::Ptr QmlJSRefactoringFile::qmljsDocument() const
|
||||
{
|
||||
if (!m_qmljsDocument) {
|
||||
const QString source = document()->toPlainText();
|
||||
const QString name = fileName();
|
||||
const QString name = filePath().toString();
|
||||
const Snapshot &snapshot = data()->m_snapshot;
|
||||
|
||||
Document::MutablePtr newDoc = snapshot.documentFromSource(source, name,
|
||||
|
@@ -56,7 +56,8 @@ public:
|
||||
bool isCursorOn(QmlJS::SourceLocation loc) const;
|
||||
|
||||
protected:
|
||||
QmlJSRefactoringFile(const QString &fileName, const QSharedPointer<TextEditor::RefactoringChangesData> &data);
|
||||
QmlJSRefactoringFile(const Utils::FilePath &filePath,
|
||||
const QSharedPointer<TextEditor::RefactoringChangesData> &data);
|
||||
QmlJSRefactoringFile(TextEditor::TextEditorWidget *editor, QmlJS::Document::Ptr document);
|
||||
|
||||
QmlJSRefactoringChangesData *data() const;
|
||||
@@ -76,7 +77,7 @@ public:
|
||||
|
||||
static QmlJSRefactoringFilePtr file(TextEditor::TextEditorWidget *editor,
|
||||
const QmlJS::Document::Ptr &document);
|
||||
QmlJSRefactoringFilePtr file(const QString &fileName) const;
|
||||
QmlJSRefactoringFilePtr file(const Utils::FilePath &filePath) const;
|
||||
|
||||
const QmlJS::Snapshot &snapshot() const;
|
||||
|
||||
|
@@ -519,7 +519,7 @@ QStringList BaseFileFind::replaceAll(const QString &text,
|
||||
const QList<SearchResultItem> changeItems = it.value();
|
||||
|
||||
ChangeSet changeSet;
|
||||
RefactoringFilePtr file = refactoring.file(fileName);
|
||||
RefactoringFilePtr file = refactoring.file(FilePath::fromString(fileName));
|
||||
QSet<QPair<int, int> > processed;
|
||||
for (const SearchResultItem &item : changeItems) {
|
||||
const QPair<int, int> &p = qMakePair(item.mainRange().begin.line,
|
||||
|
@@ -76,9 +76,12 @@ RefactoringSelections RefactoringChanges::rangesToSelections(QTextDocument *docu
|
||||
return selections;
|
||||
}
|
||||
|
||||
bool RefactoringChanges::createFile(const QString &fileName, const QString &contents, bool reindent, bool openEditor) const
|
||||
bool RefactoringChanges::createFile(const FilePath &filePath,
|
||||
const QString &contents,
|
||||
bool reindent,
|
||||
bool openEditor) const
|
||||
{
|
||||
if (QFile::exists(fileName))
|
||||
if (filePath.exists())
|
||||
return false;
|
||||
|
||||
// Create a text document for the new file:
|
||||
@@ -90,7 +93,7 @@ bool RefactoringChanges::createFile(const QString &fileName, const QString &cont
|
||||
// Reindent the contents:
|
||||
if (reindent) {
|
||||
cursor.select(QTextCursor::Document);
|
||||
m_data->indentSelection(cursor, fileName, nullptr);
|
||||
m_data->indentSelection(cursor, filePath, nullptr);
|
||||
}
|
||||
cursor.endEditBlock();
|
||||
|
||||
@@ -98,22 +101,22 @@ bool RefactoringChanges::createFile(const QString &fileName, const QString &cont
|
||||
TextFileFormat format;
|
||||
format.codec = EditorManager::defaultTextCodec();
|
||||
QString error;
|
||||
bool saveOk = format.writeFile(Utils::FilePath::fromString(fileName), document->toPlainText(), &error);
|
||||
bool saveOk = format.writeFile(filePath, document->toPlainText(), &error);
|
||||
delete document;
|
||||
if (!saveOk)
|
||||
return false;
|
||||
|
||||
m_data->fileChanged(fileName);
|
||||
m_data->fileChanged(filePath);
|
||||
|
||||
if (openEditor)
|
||||
RefactoringChanges::openEditor(fileName, /*bool activate =*/ false, -1, -1);
|
||||
RefactoringChanges::openEditor(filePath, /*bool activate =*/ false, -1, -1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RefactoringChanges::removeFile(const QString &fileName) const
|
||||
bool RefactoringChanges::removeFile(const FilePath &filePath) const
|
||||
{
|
||||
if (!QFile::exists(fileName))
|
||||
if (!filePath.exists())
|
||||
return false;
|
||||
|
||||
// ### implement!
|
||||
@@ -121,7 +124,10 @@ bool RefactoringChanges::removeFile(const QString &fileName) const
|
||||
return true;
|
||||
}
|
||||
|
||||
TextEditorWidget *RefactoringChanges::openEditor(const QString &fileName, bool activate, int line, int column)
|
||||
TextEditorWidget *RefactoringChanges::openEditor(const FilePath &filePath,
|
||||
bool activate,
|
||||
int line,
|
||||
int column)
|
||||
{
|
||||
EditorManager::OpenEditorFlags flags = EditorManager::IgnoreNavigationHistory;
|
||||
if (activate)
|
||||
@@ -132,7 +138,7 @@ TextEditorWidget *RefactoringChanges::openEditor(const QString &fileName, bool a
|
||||
// openEditorAt uses a 1-based line and a 0-based column!
|
||||
column -= 1;
|
||||
}
|
||||
IEditor *editor = EditorManager::openEditorAt(fileName, line, column, Id(), flags);
|
||||
IEditor *editor = EditorManager::openEditorAt(Link{filePath, line, column}, Id(), flags);
|
||||
|
||||
if (editor)
|
||||
return TextEditorWidget::fromEditor(editor);
|
||||
@@ -145,26 +151,27 @@ RefactoringFilePtr RefactoringChanges::file(TextEditorWidget *editor)
|
||||
return RefactoringFilePtr(new RefactoringFile(editor));
|
||||
}
|
||||
|
||||
RefactoringFilePtr RefactoringChanges::file(const QString &fileName) const
|
||||
RefactoringFilePtr RefactoringChanges::file(const FilePath &filePath) const
|
||||
{
|
||||
return RefactoringFilePtr(new RefactoringFile(fileName, m_data));
|
||||
return RefactoringFilePtr(new RefactoringFile(filePath, m_data));
|
||||
}
|
||||
|
||||
RefactoringFile::RefactoringFile(QTextDocument *document, const QString &fileName)
|
||||
: m_fileName(fileName)
|
||||
RefactoringFile::RefactoringFile(QTextDocument *document, const FilePath &filePath)
|
||||
: m_filePath(filePath)
|
||||
, m_document(document)
|
||||
{ }
|
||||
|
||||
RefactoringFile::RefactoringFile(TextEditorWidget *editor)
|
||||
: m_fileName(editor->textDocument()->filePath().toString())
|
||||
: m_filePath(editor->textDocument()->filePath())
|
||||
, m_editor(editor)
|
||||
{ }
|
||||
|
||||
RefactoringFile::RefactoringFile(const QString &fileName, const QSharedPointer<RefactoringChangesData> &data)
|
||||
: m_fileName(fileName)
|
||||
RefactoringFile::RefactoringFile(const FilePath &filePath,
|
||||
const QSharedPointer<RefactoringChangesData> &data)
|
||||
: m_filePath(filePath)
|
||||
, m_data(data)
|
||||
{
|
||||
QList<IEditor *> editors = DocumentModel::editorsForFilePath(Utils::FilePath::fromString(fileName));
|
||||
QList<IEditor *> editors = DocumentModel::editorsForFilePath(filePath);
|
||||
if (!editors.isEmpty()) {
|
||||
auto editorWidget = TextEditorWidget::fromEditor(editors.first());
|
||||
if (editorWidget && !editorWidget->isReadOnly())
|
||||
@@ -179,7 +186,7 @@ RefactoringFile::~RefactoringFile()
|
||||
|
||||
bool RefactoringFile::isValid() const
|
||||
{
|
||||
if (m_fileName.isEmpty())
|
||||
if (m_filePath.isEmpty())
|
||||
return false;
|
||||
return document();
|
||||
}
|
||||
@@ -195,17 +202,16 @@ QTextDocument *RefactoringFile::mutableDocument() const
|
||||
return m_editor->document();
|
||||
if (!m_document) {
|
||||
QString fileContents;
|
||||
if (!m_fileName.isEmpty()) {
|
||||
if (!m_filePath.isEmpty()) {
|
||||
QString error;
|
||||
QTextCodec *defaultCodec = EditorManager::defaultTextCodec();
|
||||
TextFileFormat::ReadResult result = TextFileFormat::readFile(FilePath::fromString(
|
||||
m_fileName),
|
||||
TextFileFormat::ReadResult result = TextFileFormat::readFile(m_filePath,
|
||||
defaultCodec,
|
||||
&fileContents,
|
||||
&m_textFileFormat,
|
||||
&error);
|
||||
if (result != TextFileFormat::ReadSuccess) {
|
||||
qWarning() << "Could not read " << m_fileName << ". Error: " << error;
|
||||
qWarning() << "Could not read " << m_filePath << ". Error: " << error;
|
||||
m_textFileFormat.codec = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -219,7 +225,7 @@ const QTextCursor RefactoringFile::cursor() const
|
||||
{
|
||||
if (m_editor)
|
||||
return m_editor->textCursor();
|
||||
if (!m_fileName.isEmpty()) {
|
||||
if (!m_filePath.isEmpty()) {
|
||||
if (QTextDocument *doc = mutableDocument())
|
||||
return QTextCursor(doc);
|
||||
}
|
||||
@@ -227,9 +233,9 @@ const QTextCursor RefactoringFile::cursor() const
|
||||
return QTextCursor();
|
||||
}
|
||||
|
||||
QString RefactoringFile::fileName() const
|
||||
FilePath RefactoringFile::filePath() const
|
||||
{
|
||||
return m_fileName;
|
||||
return m_filePath;
|
||||
}
|
||||
|
||||
TextEditorWidget *RefactoringFile::editor() const
|
||||
@@ -284,7 +290,7 @@ ChangeSet RefactoringFile::changeSet() const
|
||||
|
||||
void RefactoringFile::setChangeSet(const ChangeSet &changeSet)
|
||||
{
|
||||
if (m_fileName.isEmpty())
|
||||
if (m_filePath.isEmpty())
|
||||
return;
|
||||
|
||||
m_changes = changeSet;
|
||||
@@ -292,7 +298,7 @@ void RefactoringFile::setChangeSet(const ChangeSet &changeSet)
|
||||
|
||||
void RefactoringFile::appendIndentRange(const Range &range)
|
||||
{
|
||||
if (m_fileName.isEmpty())
|
||||
if (m_filePath.isEmpty())
|
||||
return;
|
||||
|
||||
m_indentRanges.append(range);
|
||||
@@ -300,7 +306,7 @@ void RefactoringFile::appendIndentRange(const Range &range)
|
||||
|
||||
void RefactoringFile::appendReindentRange(const Range &range)
|
||||
{
|
||||
if (m_fileName.isEmpty())
|
||||
if (m_filePath.isEmpty())
|
||||
return;
|
||||
|
||||
m_reindentRanges.append(range);
|
||||
@@ -316,8 +322,8 @@ void RefactoringFile::setOpenEditor(bool activate, int pos)
|
||||
bool RefactoringFile::apply()
|
||||
{
|
||||
// test file permissions
|
||||
if (!QFileInfo(fileName()).isWritable()) {
|
||||
ReadOnlyFilesDialog roDialog(FilePath::fromString(fileName()), ICore::dialogParent());
|
||||
if (!m_filePath.toFileInfo().isWritable()) {
|
||||
ReadOnlyFilesDialog roDialog(m_filePath, ICore::dialogParent());
|
||||
const QString &failDetailText = QApplication::translate("RefactoringFile::apply",
|
||||
"Refactoring cannot be applied.");
|
||||
roDialog.setShowFailWarning(true, failDetailText);
|
||||
@@ -326,11 +332,11 @@ bool RefactoringFile::apply()
|
||||
}
|
||||
|
||||
// open / activate / goto position
|
||||
if (m_openEditor && !m_fileName.isEmpty()) {
|
||||
if (m_openEditor && !m_filePath.isEmpty()) {
|
||||
int line = -1, column = -1;
|
||||
if (m_editorCursorPosition != -1)
|
||||
lineAndColumn(m_editorCursorPosition, &line, &column);
|
||||
m_editor = RefactoringChanges::openEditor(m_fileName, m_activateEditor, line, column);
|
||||
m_editor = RefactoringChanges::openEditor(m_filePath, m_activateEditor, line, column);
|
||||
m_openEditor = false;
|
||||
m_activateEditor = false;
|
||||
m_editorCursorPosition = -1;
|
||||
@@ -370,14 +376,15 @@ bool RefactoringFile::apply()
|
||||
|
||||
// if this document doesn't have an editor, write the result to a file
|
||||
if (!m_editor && m_textFileFormat.codec) {
|
||||
QTC_ASSERT(!m_fileName.isEmpty(), return false);
|
||||
QTC_ASSERT(!m_filePath.isEmpty(), return false);
|
||||
QString error;
|
||||
// suppress "file has changed" warnings if the file is open in a read-only editor
|
||||
Core::FileChangeBlocker block(m_fileName);
|
||||
if (!m_textFileFormat.writeFile(FilePath::fromString(m_fileName),
|
||||
Core::FileChangeBlocker block(m_filePath.toString());
|
||||
if (!m_textFileFormat.writeFile(m_filePath,
|
||||
doc->toPlainText(),
|
||||
&error)) {
|
||||
qWarning() << "Could not apply changes to" << m_fileName << ". Error: " << error;
|
||||
qWarning() << "Could not apply changes to" << m_filePath
|
||||
<< ". Error: " << error;
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
@@ -398,31 +405,35 @@ void RefactoringFile::indentOrReindent(const RefactoringSelections &ranges,
|
||||
QTextCursor selection(anchor);
|
||||
selection.setPosition(position.position(), QTextCursor::KeepAnchor);
|
||||
if (indent == Indent)
|
||||
m_data->indentSelection(selection, m_fileName, document);
|
||||
m_data->indentSelection(selection, m_filePath, document);
|
||||
else
|
||||
m_data->reindentSelection(selection, m_fileName, document);
|
||||
m_data->reindentSelection(selection, m_filePath, document);
|
||||
}
|
||||
}
|
||||
|
||||
void RefactoringFile::fileChanged()
|
||||
{
|
||||
if (!m_fileName.isEmpty())
|
||||
m_data->fileChanged(m_fileName);
|
||||
if (!m_filePath.isEmpty())
|
||||
m_data->fileChanged(m_filePath);
|
||||
}
|
||||
|
||||
RefactoringChangesData::~RefactoringChangesData() = default;
|
||||
|
||||
void RefactoringChangesData::indentSelection(const QTextCursor &, const QString &, const TextDocument *) const
|
||||
void RefactoringChangesData::indentSelection(const QTextCursor &,
|
||||
const FilePath &,
|
||||
const TextDocument *) const
|
||||
{
|
||||
qWarning() << Q_FUNC_INFO << "not implemented";
|
||||
}
|
||||
|
||||
void RefactoringChangesData::reindentSelection(const QTextCursor &, const QString &, const TextDocument *) const
|
||||
void RefactoringChangesData::reindentSelection(const QTextCursor &,
|
||||
const FilePath &,
|
||||
const TextDocument *) const
|
||||
{
|
||||
qWarning() << Q_FUNC_INFO << "not implemented";
|
||||
}
|
||||
|
||||
void RefactoringChangesData::fileChanged(const QString &)
|
||||
void RefactoringChangesData::fileChanged(const FilePath &)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -25,14 +25,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/changeset.h>
|
||||
#include <utils/textfileformat.h>
|
||||
#include <texteditor/texteditor_global.h>
|
||||
#include <utils/changeset.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/textfileformat.h>
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QSharedPointer>
|
||||
#include <QPair>
|
||||
#include <QSharedPointer>
|
||||
#include <QString>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QTextDocument;
|
||||
@@ -54,7 +55,6 @@ class TEXTEDITOR_EXPORT RefactoringFile
|
||||
public:
|
||||
using Range = Utils::ChangeSet::Range;
|
||||
|
||||
public:
|
||||
virtual ~RefactoringFile();
|
||||
|
||||
bool isValid() const;
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
const QTextDocument *document() const;
|
||||
// mustn't use the cursor to change the document
|
||||
const QTextCursor cursor() const;
|
||||
QString fileName() const;
|
||||
Utils::FilePath filePath() const;
|
||||
TextEditorWidget *editor() const;
|
||||
|
||||
// converts 1-based line and column into 0-based source offset
|
||||
@@ -84,10 +84,11 @@ public:
|
||||
protected:
|
||||
// users may only get const access to RefactoringFiles created through
|
||||
// this constructor, because it can't be used to apply changes
|
||||
RefactoringFile(QTextDocument *document, const QString &fileName);
|
||||
RefactoringFile(QTextDocument *document, const Utils::FilePath &filePath);
|
||||
|
||||
RefactoringFile(TextEditorWidget *editor);
|
||||
RefactoringFile(const QString &fileName, const QSharedPointer<RefactoringChangesData> &data);
|
||||
RefactoringFile(const Utils::FilePath &filePath,
|
||||
const QSharedPointer<RefactoringChangesData> &data);
|
||||
|
||||
QTextDocument *mutableDocument() const;
|
||||
// derived classes may want to clear language specific extra data
|
||||
@@ -96,8 +97,7 @@ protected:
|
||||
enum IndentType {Indent, Reindent};
|
||||
void indentOrReindent(const RefactoringSelections &ranges, IndentType indent);
|
||||
|
||||
protected:
|
||||
QString m_fileName;
|
||||
Utils::FilePath m_filePath;
|
||||
QSharedPointer<RefactoringChangesData> m_data;
|
||||
mutable Utils::TextFileFormat m_textFileFormat;
|
||||
mutable QTextDocument *m_document = nullptr;
|
||||
@@ -122,22 +122,27 @@ class TEXTEDITOR_EXPORT RefactoringChanges
|
||||
public:
|
||||
using Range = Utils::ChangeSet::Range;
|
||||
|
||||
public:
|
||||
RefactoringChanges();
|
||||
virtual ~RefactoringChanges();
|
||||
|
||||
static RefactoringFilePtr file(TextEditorWidget *editor);
|
||||
RefactoringFilePtr file(const QString &fileName) const;
|
||||
bool createFile(const QString &fileName, const QString &contents, bool reindent = true, bool openEditor = true) const;
|
||||
bool removeFile(const QString &fileName) const;
|
||||
RefactoringFilePtr file(const Utils::FilePath &filePath) const;
|
||||
bool createFile(const Utils::FilePath &filePath,
|
||||
const QString &contents,
|
||||
bool reindent = true,
|
||||
bool openEditor = true) const;
|
||||
bool removeFile(const Utils::FilePath &filePath) const;
|
||||
|
||||
protected:
|
||||
explicit RefactoringChanges(RefactoringChangesData *data);
|
||||
|
||||
static TextEditorWidget *openEditor(const QString &fileName, bool activate, int line, int column);
|
||||
static RefactoringSelections rangesToSelections(QTextDocument *document, const QList<Range> &ranges);
|
||||
static TextEditorWidget *openEditor(const Utils::FilePath &filePath,
|
||||
bool activate,
|
||||
int line,
|
||||
int column);
|
||||
static RefactoringSelections rangesToSelections(QTextDocument *document,
|
||||
const QList<Range> &ranges);
|
||||
|
||||
protected:
|
||||
QSharedPointer<RefactoringChangesData> m_data;
|
||||
|
||||
friend class RefactoringFile;
|
||||
@@ -152,12 +157,12 @@ public:
|
||||
virtual ~RefactoringChangesData();
|
||||
|
||||
virtual void indentSelection(const QTextCursor &selection,
|
||||
const QString &fileName,
|
||||
const Utils::FilePath &filePath,
|
||||
const TextDocument *textEditor) const;
|
||||
virtual void reindentSelection(const QTextCursor &selection,
|
||||
const QString &fileName,
|
||||
const Utils::FilePath &filePath,
|
||||
const TextDocument *textEditor) const;
|
||||
virtual void fileChanged(const QString &fileName);
|
||||
virtual void fileChanged(const Utils::FilePath &filePath);
|
||||
};
|
||||
|
||||
} // namespace TextEditor
|
||||
|
@@ -532,7 +532,7 @@ bool TextDocument::applyChangeSet(const ChangeSet &changeSet)
|
||||
if (changeSet.isEmpty())
|
||||
return true;
|
||||
RefactoringChanges changes;
|
||||
const RefactoringFilePtr file = changes.file(filePath().toString());
|
||||
const RefactoringFilePtr file = changes.file(filePath());
|
||||
file->setChangeSet(changeSet);
|
||||
return file->apply();
|
||||
}
|
||||
|
@@ -109,9 +109,10 @@ public:
|
||||
RefactoringChanges() {}
|
||||
virtual ~RefactoringChanges() {}
|
||||
|
||||
RefactoringFilePtr file(const QString &filePath) const
|
||||
RefactoringFilePtr file(const Utils::FilePath &filePath) const
|
||||
{
|
||||
return RefactoringFilePtr(new RefactoringFile(std::unique_ptr<QTextDocument>(new QTextDocument(readFile(filePath)))));
|
||||
return RefactoringFilePtr(new RefactoringFile(
|
||||
std::unique_ptr<QTextDocument>(new QTextDocument(readFile(filePath.toString())))));
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user