forked from qt-creator/qt-creator
qmljs: (QString -> Utils::FilePath)++
convert more QString containing paths to Utils::FilePath Change-Id: I1219d7d147993e48cfa641dc9bea72ab38c90f51 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
committed by
Tim Jenssen
parent
0bb272d411
commit
fd89043de2
@@ -126,8 +126,8 @@ ExpressionNode *QmlExpressionUnderCursor::operator()(const QTextCursor &cursor)
|
||||
ExpressionUnderCursor expressionUnderCursor;
|
||||
_text = expressionUnderCursor(cursor);
|
||||
|
||||
Document::MutablePtr newDoc = Document::create(
|
||||
QLatin1String("<expression>"), Dialect::JavaScript);
|
||||
Document::MutablePtr newDoc = Document::create(Utils::FilePath::fromString("<expression>"),
|
||||
Dialect::JavaScript);
|
||||
newDoc->setSource(_text);
|
||||
newDoc->parseExpression();
|
||||
exprDoc = newDoc;
|
||||
|
||||
@@ -648,7 +648,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
|
||||
if (contextFinder.isInImport()) {
|
||||
QStringList patterns;
|
||||
patterns << QLatin1String("*.qml") << QLatin1String("*.js");
|
||||
if (completeFileName(document->path(), literalText, patterns))
|
||||
if (completeFileName(document->path().toString(), literalText, patterns))
|
||||
return createContentProposal();
|
||||
return nullptr;
|
||||
}
|
||||
@@ -658,7 +658,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
|
||||
if (!value) {
|
||||
// do nothing
|
||||
} else if (value->asUrlValue()) {
|
||||
if (completeUrl(document->path(), literalText))
|
||||
if (completeUrl(document->path().toString(), literalText))
|
||||
return createContentProposal();
|
||||
}
|
||||
|
||||
|
||||
@@ -107,8 +107,9 @@ public:
|
||||
{
|
||||
QString componentName = m_componentName;
|
||||
|
||||
const QString currentFileName = currentFile->qmljsDocument()->fileName();
|
||||
QString path = QFileInfo(currentFileName).path();
|
||||
const Utils::FilePath currentFileName = currentFile->qmljsDocument()->fileName();
|
||||
Utils::FilePath path = currentFileName.parentDir();
|
||||
QString pathStr = path.toUserOutput();
|
||||
|
||||
QmlJS::PropertyReader propertyReader(currentFile->qmljsDocument(), m_initializer);
|
||||
QStringList result;
|
||||
@@ -133,20 +134,23 @@ public:
|
||||
for (const QString &property : qAsConst(sortedPropertiesWithoutId))
|
||||
sourcePreview.append(QLatin1String(" ") + property + QLatin1String(": ") + propertyReader.readAstValue(property));
|
||||
|
||||
const bool confirm = ComponentNameDialog::go(&componentName, &path, &suffix,
|
||||
sortedPropertiesWithoutId,
|
||||
sourcePreview,
|
||||
QFileInfo(currentFileName).fileName(),
|
||||
&result,
|
||||
Core::ICore::dialogParent());
|
||||
const bool confirm = ComponentNameDialog::go(&componentName,
|
||||
&pathStr,
|
||||
&suffix,
|
||||
sortedPropertiesWithoutId,
|
||||
sourcePreview,
|
||||
currentFileName.fileName(),
|
||||
&result,
|
||||
Core::ICore::dialogParent());
|
||||
if (!confirm)
|
||||
return;
|
||||
|
||||
path = Utils::FilePath::fromUserInput(pathStr);
|
||||
if (componentName.isEmpty() || path.isEmpty())
|
||||
return;
|
||||
|
||||
const QString newFileName = path + QLatin1Char('/') + componentName
|
||||
+ QLatin1String(".") + suffix;
|
||||
const Utils::FilePath newFileName = path.pathAppended(componentName + QLatin1String(".")
|
||||
+ suffix);
|
||||
|
||||
QString imports;
|
||||
UiProgram *prog = currentFile->qmljsDocument()->qmlProgram();
|
||||
@@ -190,18 +194,18 @@ public:
|
||||
// stop if we can't create the new file
|
||||
const bool reindent = true;
|
||||
const bool openEditor = false;
|
||||
const Utils::FilePath newFilePath = Utils::FilePath::fromString(newFileName);
|
||||
if (!refactoring.createFile(newFilePath, newComponentSource, reindent, openEditor))
|
||||
const Utils::FilePath newFilePath = newFileName;
|
||||
if (!refactoring.createFile(newFileName, newComponentSource, reindent, openEditor))
|
||||
return;
|
||||
|
||||
if (path == QFileInfo(currentFileName).path()) {
|
||||
if (path.toString() == currentFileName.toFileInfo().path()) {
|
||||
// hack for the common case, next version should use the wizard
|
||||
ProjectExplorer::Node * oldFileNode =
|
||||
ProjectExplorer::ProjectTree::nodeForFile(Utils::FilePath::fromString(currentFileName));
|
||||
ProjectExplorer::Node *oldFileNode = ProjectExplorer::ProjectTree::nodeForFile(
|
||||
currentFileName);
|
||||
if (oldFileNode) {
|
||||
ProjectExplorer::FolderNode *containingFolder = oldFileNode->parentFolderNode();
|
||||
if (containingFolder)
|
||||
containingFolder->addFiles({FilePath::fromString(newFileName)});
|
||||
containingFolder->addFiles({newFileName});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,20 +222,21 @@ public:
|
||||
currentFile->appendIndentRange(Range(start, end + 1));
|
||||
currentFile->apply();
|
||||
|
||||
Core::IVersionControl *versionControl =
|
||||
Core::VcsManager::findVersionControlForDirectory(FilePath::fromString(path));
|
||||
Core::IVersionControl *versionControl = Core::VcsManager::findVersionControlForDirectory(
|
||||
path);
|
||||
if (versionControl
|
||||
&& versionControl->supportsOperation(Core::IVersionControl::AddOperation)) {
|
||||
const QMessageBox::StandardButton button = QMessageBox::question(
|
||||
Core::ICore::dialogParent(),
|
||||
Core::VcsManager::msgAddToVcsTitle(),
|
||||
Core::VcsManager::msgPromptToAddToVcs(QStringList(newFileName), versionControl),
|
||||
Core::VcsManager::msgPromptToAddToVcs(QStringList(newFileName.toString()),
|
||||
versionControl),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
if (button == QMessageBox::Yes && !versionControl->vcsAdd(FilePath::fromString(newFileName))) {
|
||||
if (button == QMessageBox::Yes && !versionControl->vcsAdd(newFileName)) {
|
||||
QMessageBox::warning(Core::ICore::dialogParent(),
|
||||
Core::VcsManager::msgAddToVcsFailedTitle(),
|
||||
Core::VcsManager::msgToAddToVcsFailed(QStringList(newFileName),
|
||||
versionControl));
|
||||
Core::VcsManager::msgToAddToVcsFailed(
|
||||
QStringList(newFileName.toString()), versionControl));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ void QmlJSEditorWidget::foldAuxiliaryData()
|
||||
void QmlJSEditorWidget::updateModificationChange(bool changed)
|
||||
{
|
||||
if (!changed && m_modelManager)
|
||||
m_modelManager->fileChangedOnDisk(textDocument()->filePath().toString());
|
||||
m_modelManager->fileChangedOnDisk(textDocument()->filePath());
|
||||
}
|
||||
|
||||
bool QmlJSEditorWidget::isOutlineCursorChangesBlocked()
|
||||
@@ -789,12 +789,13 @@ void QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor,
|
||||
Utils::Link link;
|
||||
link.linkTextStart = literal->literalToken.begin();
|
||||
link.linkTextEnd = literal->literalToken.end();
|
||||
if (semanticInfo.snapshot.document(text)) {
|
||||
link.targetFilePath = Utils::FilePath::fromString(text);
|
||||
Utils::FilePath targetFilePath = Utils::FilePath::fromUserInput(text);
|
||||
if (semanticInfo.snapshot.document(targetFilePath)) {
|
||||
link.targetFilePath = targetFilePath;
|
||||
processLinkCallback(link);
|
||||
return;
|
||||
}
|
||||
const Utils::FilePath relative = Utils::FilePath::fromString(semanticInfo.document->path()).pathAppended(text);
|
||||
const Utils::FilePath relative = semanticInfo.document->path().pathAppended(text);
|
||||
if (relative.exists()) {
|
||||
link.targetFilePath = m_modelManager->fileToSource(relative);
|
||||
processLinkCallback(link);
|
||||
@@ -806,14 +807,14 @@ void QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor,
|
||||
Evaluate evaluator(&scopeChain);
|
||||
const Value *value = evaluator.reference(node);
|
||||
|
||||
QString fileName;
|
||||
Utils::FilePath fileName;
|
||||
int line = 0, column = 0;
|
||||
|
||||
if (! (value && value->getSourceLocation(&fileName, &line, &column)))
|
||||
return processLinkCallback(Utils::Link());
|
||||
|
||||
Utils::Link link;
|
||||
link.targetFilePath = m_modelManager->fileToSource(FilePath::fromString(fileName));
|
||||
link.targetFilePath = m_modelManager->fileToSource(fileName);
|
||||
link.targetLine = line;
|
||||
link.targetColumn = column - 1; // adjust the column
|
||||
|
||||
@@ -845,12 +846,12 @@ void QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor,
|
||||
|
||||
void QmlJSEditorWidget::findUsages()
|
||||
{
|
||||
m_findReferences->findUsages(textDocument()->filePath().toString(), textCursor().position());
|
||||
m_findReferences->findUsages(textDocument()->filePath(), textCursor().position());
|
||||
}
|
||||
|
||||
void QmlJSEditorWidget::renameSymbolUnderCursor()
|
||||
{
|
||||
m_findReferences->renameUsages(textDocument()->filePath().toString(), textCursor().position());
|
||||
m_findReferences->renameUsages(textDocument()->filePath(), textCursor().position());
|
||||
}
|
||||
|
||||
void QmlJSEditorWidget::showContextPane()
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <qmljstools/qmljsmodelmanager.h>
|
||||
#include <qmljstools/qmljsqtstylecodeformatter.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/infobar.h>
|
||||
|
||||
#include <QDebug>
|
||||
@@ -512,7 +513,7 @@ QmlJSEditorDocumentPrivate::QmlJSEditorDocumentPrivate(QmlJSEditorDocument *pare
|
||||
connect(&m_updateOutlineModelTimer, &QTimer::timeout,
|
||||
this, &QmlJSEditorDocumentPrivate::updateOutlineModel);
|
||||
|
||||
modelManager->updateSourceFiles(QStringList(parent->filePath().toString()), false);
|
||||
modelManager->updateSourceFiles(Utils::FilePaths({parent->filePath()}), false);
|
||||
}
|
||||
|
||||
QmlJSEditorDocumentPrivate::~QmlJSEditorDocumentPrivate()
|
||||
@@ -533,13 +534,12 @@ void QmlJSEditorDocumentPrivate::invalidateFormatterCache()
|
||||
|
||||
void QmlJSEditorDocumentPrivate::reparseDocument()
|
||||
{
|
||||
ModelManagerInterface::instance()->updateSourceFiles(QStringList(q->filePath().toString()),
|
||||
false);
|
||||
ModelManagerInterface::instance()->updateSourceFiles(Utils::FilePaths({q->filePath()}), false);
|
||||
}
|
||||
|
||||
void QmlJSEditorDocumentPrivate::onDocumentUpdated(Document::Ptr doc)
|
||||
{
|
||||
if (q->filePath().toString() != doc->fileName())
|
||||
if (q->filePath() != doc->fileName())
|
||||
return;
|
||||
|
||||
// text document has changed, simply wait for the next onDocumentUpdated
|
||||
|
||||
@@ -261,7 +261,7 @@ void QmlJSEditorPluginPrivate::reformatFile()
|
||||
if (m_currentDocument->isSemanticInfoOutdated()) {
|
||||
QmlJS::Document::MutablePtr latestDocument;
|
||||
|
||||
const QString fileName = m_currentDocument->filePath().toString();
|
||||
const Utils::FilePath fileName = m_currentDocument->filePath();
|
||||
latestDocument = snapshot.documentFromSource(QString::fromUtf8(m_currentDocument->contents()),
|
||||
fileName,
|
||||
QmlJS::ModelManagerInterface::guessLanguageOfFile(fileName));
|
||||
|
||||
@@ -739,7 +739,7 @@ public:
|
||||
: context(context), name(name), scope(scope), future(future)
|
||||
{ }
|
||||
|
||||
QList<Usage> operator()(const QString &fileName)
|
||||
QList<Usage> operator()(const Utils::FilePath &fileName)
|
||||
{
|
||||
QList<Usage> usages;
|
||||
if (future->isPaused())
|
||||
@@ -755,7 +755,11 @@ public:
|
||||
FindUsages findUsages(doc, context);
|
||||
const FindUsages::Result results = findUsages(name, scope);
|
||||
for (const SourceLocation &loc : results)
|
||||
usages.append(Usage(modelManager->fileToSource(Utils::FilePath::fromString(fileName)).toString(), matchingLine(loc.offset, doc->source()), loc.startLine, loc.startColumn - 1, loc.length));
|
||||
usages.append(Usage(modelManager->fileToSource(fileName),
|
||||
matchingLine(loc.offset, doc->source()),
|
||||
loc.startLine,
|
||||
loc.startColumn - 1,
|
||||
loc.length));
|
||||
if (future->isPaused())
|
||||
future->waitForResume();
|
||||
return usages;
|
||||
@@ -782,7 +786,7 @@ public:
|
||||
: context(context), name(name), scope(scope), future(future)
|
||||
{ }
|
||||
|
||||
QList<Usage> operator()(const QString &fileName)
|
||||
QList<Usage> operator()(const Utils::FilePath &fileName)
|
||||
{
|
||||
QList<Usage> usages;
|
||||
if (future->isPaused())
|
||||
@@ -842,7 +846,7 @@ FindReferences::~FindReferences() = default;
|
||||
static void find_helper(QFutureInterface<FindReferences::Usage> &future,
|
||||
const ModelManagerInterface::WorkingCopy &workingCopy,
|
||||
Snapshot snapshot,
|
||||
const QString &fileName,
|
||||
const Utils::FilePath &fileName,
|
||||
quint32 offset,
|
||||
QString replacement)
|
||||
{
|
||||
@@ -851,7 +855,7 @@ static void find_helper(QFutureInterface<FindReferences::Usage> &future,
|
||||
// ### this is a great candidate for map-reduce
|
||||
const ModelManagerInterface::WorkingCopy::Table &all = workingCopy.all();
|
||||
for (auto it = all.cbegin(), end = all.cend(); it != end; ++it) {
|
||||
const QString fileName = it.key();
|
||||
const Utils::FilePath fileName = it.key();
|
||||
Document::Ptr oldDoc = snapshot.document(fileName);
|
||||
if (oldDoc && oldDoc->editorRevision() == it.value().second)
|
||||
continue;
|
||||
@@ -895,17 +899,17 @@ static void find_helper(QFutureInterface<FindReferences::Usage> &future,
|
||||
if (!replacement.isNull() && replacement.isEmpty())
|
||||
replacement = name;
|
||||
|
||||
QStringList files;
|
||||
Utils::FilePaths files;
|
||||
for (const Document::Ptr &doc : qAsConst(snapshot)) {
|
||||
// ### skip files that don't contain the name token
|
||||
files.append(modelManager->fileToSource(Utils::FilePath::fromString(doc->fileName())).toString());
|
||||
files.append(modelManager->fileToSource(doc->fileName()));
|
||||
}
|
||||
files = Utils::filteredUnique(files);
|
||||
|
||||
future.setProgressRange(0, files.size());
|
||||
|
||||
// report a dummy usage to indicate the search is starting
|
||||
FindReferences::Usage searchStarting(replacement, name, 0, 0, 0);
|
||||
FindReferences::Usage searchStarting(Utils::FilePath::fromString(replacement), name, 0, 0, 0);
|
||||
|
||||
if (findTarget.typeKind() == findTarget.TypeKind){
|
||||
const ObjectValue *typeValue = value_cast<ObjectValue>(findTarget.targetValue());
|
||||
@@ -936,7 +940,7 @@ static void find_helper(QFutureInterface<FindReferences::Usage> &future,
|
||||
future.setProgressValue(files.size());
|
||||
}
|
||||
|
||||
void FindReferences::findUsages(const QString &fileName, quint32 offset)
|
||||
void FindReferences::findUsages(const Utils::FilePath &fileName, quint32 offset)
|
||||
{
|
||||
ModelManagerInterface *modelManager = ModelManagerInterface::instance();
|
||||
|
||||
@@ -946,7 +950,8 @@ void FindReferences::findUsages(const QString &fileName, quint32 offset)
|
||||
m_synchronizer.addFuture(result);
|
||||
}
|
||||
|
||||
void FindReferences::renameUsages(const QString &fileName, quint32 offset,
|
||||
void FindReferences::renameUsages(const Utils::FilePath &fileName,
|
||||
quint32 offset,
|
||||
const QString &replacement)
|
||||
{
|
||||
ModelManagerInterface *modelManager = ModelManagerInterface::instance();
|
||||
@@ -962,7 +967,8 @@ void FindReferences::renameUsages(const QString &fileName, quint32 offset,
|
||||
m_synchronizer.addFuture(result);
|
||||
}
|
||||
|
||||
QList<FindReferences::Usage> FindReferences::findUsageOfType(const QString &fileName, const QString &typeName)
|
||||
QList<FindReferences::Usage> FindReferences::findUsageOfType(const Utils::FilePath &fileName,
|
||||
const QString &typeName)
|
||||
{
|
||||
QList<Usage> usages;
|
||||
ModelManagerInterface *modelManager = ModelManagerInterface::instance();
|
||||
@@ -979,9 +985,9 @@ QList<FindReferences::Usage> FindReferences::findUsageOfType(const QString &file
|
||||
|
||||
QmlJS::Snapshot snapshot = modelManager->snapshot();
|
||||
|
||||
QSet<QString> docDone;
|
||||
QSet<Utils::FilePath> docDone;
|
||||
for (const QmlJS::Document::Ptr &doc : qAsConst(snapshot)) {
|
||||
QString sourceFile = modelManager->fileToSource(Utils::FilePath::fromString(doc->fileName())).toString();
|
||||
Utils::FilePath sourceFile = modelManager->fileToSource(doc->fileName());
|
||||
if (docDone.contains(sourceFile))
|
||||
continue;
|
||||
docDone.insert(sourceFile);
|
||||
@@ -1006,7 +1012,7 @@ void FindReferences::displayResults(int first, int last)
|
||||
// the first usage is always a dummy to indicate we now start searching
|
||||
if (first == 0) {
|
||||
Usage dummy = m_watcher.future().resultAt(0);
|
||||
const QString replacement = dummy.path;
|
||||
const QString replacement = dummy.path.toString();
|
||||
const QString symbolName = dummy.lineText;
|
||||
const QString label = tr("QML/JS Usages:");
|
||||
|
||||
@@ -1044,7 +1050,7 @@ void FindReferences::displayResults(int first, int last)
|
||||
for (int index = first; index != last; ++index) {
|
||||
Usage result = m_watcher.future().resultAt(index);
|
||||
SearchResultItem item;
|
||||
item.setFilePath(Utils::FilePath::fromString(result.path));
|
||||
item.setFilePath(result.path);
|
||||
item.setLineText(result.lineText);
|
||||
item.setMainRange(result.line, result.col, result.len);
|
||||
item.setUseTextEditorFont(true);
|
||||
@@ -1078,13 +1084,13 @@ void FindReferences::onReplaceButtonClicked(const QString &text, const QList<Sea
|
||||
preserveCase);
|
||||
|
||||
// files that are opened in an editor are changed, but not saved
|
||||
QStringList changedOnDisk;
|
||||
QStringList changedUnsavedEditors;
|
||||
Utils::FilePaths changedOnDisk;
|
||||
Utils::FilePaths changedUnsavedEditors;
|
||||
for (const Utils::FilePath &filePath : filePaths) {
|
||||
if (DocumentModel::documentForFilePath(filePath))
|
||||
changedOnDisk += filePath.toString();
|
||||
changedOnDisk += filePath;
|
||||
else
|
||||
changedUnsavedEditors += filePath.toString();
|
||||
changedUnsavedEditors += filePath;
|
||||
}
|
||||
|
||||
if (!changedOnDisk.isEmpty())
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "qmljseditor_global.h"
|
||||
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/futuresynchronizer.h>
|
||||
|
||||
#include <QObject>
|
||||
@@ -49,11 +50,16 @@ public:
|
||||
class Usage
|
||||
{
|
||||
public:
|
||||
Usage(const QString &path, const QString &lineText, int line, int col, int len)
|
||||
: path(path), lineText(lineText), line(line), col(col), len(len) {}
|
||||
Usage(const Utils::FilePath &path, const QString &lineText, int line, int col, int len)
|
||||
: path(path)
|
||||
, lineText(lineText)
|
||||
, line(line)
|
||||
, col(col)
|
||||
, len(len)
|
||||
{}
|
||||
|
||||
public:
|
||||
QString path;
|
||||
Utils::FilePath path;
|
||||
QString lineText;
|
||||
int line = 0;
|
||||
int col = 0;
|
||||
@@ -68,11 +74,12 @@ signals:
|
||||
void changed();
|
||||
|
||||
public:
|
||||
void findUsages(const QString &fileName, quint32 offset);
|
||||
void renameUsages(const QString &fileName, quint32 offset,
|
||||
void findUsages(const Utils::FilePath &fileName, quint32 offset);
|
||||
void renameUsages(const Utils::FilePath &fileName,
|
||||
quint32 offset,
|
||||
const QString &replacement = QString());
|
||||
|
||||
static QList<Usage> findUsageOfType(const QString &fileName, const QString &typeName);
|
||||
static QList<Usage> findUsageOfType(const Utils::FilePath &fileName, const QString &typeName);
|
||||
|
||||
private:
|
||||
void displayResults(int first, int last);
|
||||
|
||||
@@ -125,7 +125,7 @@ static inline QString getModuleName(const ScopeChain &scopeChain, const Document
|
||||
+ QString::number(minorVersion) ;
|
||||
} else if (importInfo.isValid() && importInfo.type() == ImportType::Directory) {
|
||||
const QString path = importInfo.path();
|
||||
const QDir dir(qmlDocument->path());
|
||||
const QDir dir = qmlDocument->path().toDir();
|
||||
// should probably try to make it relatve to some import path, not to the document path
|
||||
QString relativeDir = dir.relativeFilePath(path);
|
||||
const QString name = relativeDir.replace(QLatin1Char('/'), QLatin1Char('.'));
|
||||
@@ -364,7 +364,7 @@ void QmlJSHoverHandler::handleImport(const ScopeChain &scopeChain, AST::UiImport
|
||||
if (import.info.ast() == node) {
|
||||
if (import.info.type() == ImportType::Library
|
||||
&& !import.libraryPath.isEmpty()) {
|
||||
QString msg = tr("Library at %1").arg(import.libraryPath);
|
||||
QString msg = tr("Library at %1").arg(import.libraryPath.toString());
|
||||
const LibraryInfo &libraryInfo = scopeChain.context()->snapshot().libraryInfo(import.libraryPath);
|
||||
if (libraryInfo.pluginTypeInfoStatus() == LibraryInfo::DumpDone) {
|
||||
msg += QLatin1Char('\n');
|
||||
|
||||
@@ -56,7 +56,7 @@ void QmlJSQuickFixOperation::perform()
|
||||
{
|
||||
QmlJSRefactoringChanges refactoring(ModelManagerInterface::instance(),
|
||||
m_interface->semanticInfo().snapshot);
|
||||
QmlJSRefactoringFilePtr current = refactoring.file(Utils::FilePath::fromString(fileName()));
|
||||
QmlJSRefactoringFilePtr current = refactoring.file(fileName());
|
||||
|
||||
performChanges(current, refactoring);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ const QmlJSQuickFixAssistInterface *QmlJSQuickFixOperation::assistInterface() co
|
||||
return m_interface.data();
|
||||
}
|
||||
|
||||
QString QmlJSQuickFixOperation::fileName() const
|
||||
Utils::FilePath QmlJSQuickFixOperation::fileName() const
|
||||
{
|
||||
return m_interface->semanticInfo().document->fileName();
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ protected:
|
||||
const Internal::QmlJSQuickFixAssistInterface *assistInterface() const;
|
||||
|
||||
/// \returns The name of the file for for which this operation is invoked.
|
||||
QString fileName() const;
|
||||
Utils::FilePath fileName() const;
|
||||
|
||||
private:
|
||||
QmlJSQuickFixInterface m_interface;
|
||||
|
||||
@@ -123,7 +123,8 @@ QmlJSTools::SemanticInfo SemanticInfoUpdater::makeNewSemanticInfo(const QmlJS::D
|
||||
semanticInfo.setRootScopeChain(QSharedPointer<const ScopeChain>(scopeChain));
|
||||
|
||||
if (doc->language() == Dialect::Json) {
|
||||
Utils::JsonSchema *schema = QmlJSEditorPlugin::jsonManager()->schemaForFile(doc->fileName());
|
||||
Utils::JsonSchema *schema = QmlJSEditorPlugin::jsonManager()->schemaForFile(
|
||||
doc->fileName().toString());
|
||||
if (schema) {
|
||||
JsonCheck jsonChecker(doc);
|
||||
semanticInfo.staticAnalysisMessages = jsonChecker(schema);
|
||||
|
||||
@@ -880,8 +880,7 @@ void QmlOutlineModel::reparentNodes(QmlOutlineItem *targetItem, int row, QList<Q
|
||||
}
|
||||
|
||||
QmlJSRefactoringChanges refactoring(ModelManagerInterface::instance(), m_semanticInfo.snapshot);
|
||||
TextEditor::RefactoringFilePtr file = refactoring.file(
|
||||
Utils::FilePath::fromString(m_semanticInfo.document->fileName()));
|
||||
TextEditor::RefactoringFilePtr file = refactoring.file(m_semanticInfo.document->fileName());
|
||||
file->setChangeSet(changeSet);
|
||||
for (const Utils::ChangeSet::Range &range : qAsConst(changedRanges)) {
|
||||
file->appendIndentRange(range);
|
||||
|
||||
@@ -86,14 +86,14 @@ void QmlTaskManager::collectMessages(QFutureInterface<FileErrorMessages> &future
|
||||
bool updateSemantic)
|
||||
{
|
||||
for (const ModelManagerInterface::ProjectInfo &info : projectInfos) {
|
||||
QHash<QString, QList<DiagnosticMessage> > linkMessages;
|
||||
QHash<Utils::FilePath, QList<DiagnosticMessage>> linkMessages;
|
||||
ContextPtr context;
|
||||
if (updateSemantic) {
|
||||
QmlJS::Link link(snapshot, vContext, QmlJS::LibraryInfo());
|
||||
context = link(&linkMessages);
|
||||
}
|
||||
|
||||
for (const QString &fileName : qAsConst(info.sourceFiles)) {
|
||||
for (const Utils::FilePath &fileName : qAsConst(info.sourceFiles)) {
|
||||
Document::Ptr document = snapshot.document(fileName);
|
||||
if (!document)
|
||||
continue;
|
||||
@@ -102,17 +102,17 @@ void QmlTaskManager::collectMessages(QFutureInterface<FileErrorMessages> &future
|
||||
result.fileName = fileName;
|
||||
if (document->language().isFullySupportedLanguage()) {
|
||||
result.tasks = convertToTasks(document->diagnosticMessages(),
|
||||
FilePath::fromString(fileName),
|
||||
fileName,
|
||||
Constants::TASK_CATEGORY_QML);
|
||||
|
||||
if (updateSemantic) {
|
||||
result.tasks += convertToTasks(linkMessages.value(fileName),
|
||||
FilePath::fromString(fileName),
|
||||
fileName,
|
||||
Constants::TASK_CATEGORY_QML_ANALYSIS);
|
||||
|
||||
Check checker(document, context);
|
||||
result.tasks += convertToTasks(checker(),
|
||||
FilePath::fromString(fileName),
|
||||
fileName,
|
||||
Constants::TASK_CATEGORY_QML_ANALYSIS);
|
||||
}
|
||||
}
|
||||
@@ -156,9 +156,9 @@ void QmlTaskManager::updateMessagesNow(bool updateSemantic)
|
||||
m_messageCollector.setFuture(future);
|
||||
}
|
||||
|
||||
void QmlTaskManager::documentsRemoved(const QStringList &path)
|
||||
void QmlTaskManager::documentsRemoved(const Utils::FilePaths &path)
|
||||
{
|
||||
for (const QString &item : path)
|
||||
for (const Utils::FilePath &item : path)
|
||||
removeTasksForFile(item);
|
||||
}
|
||||
|
||||
@@ -180,13 +180,13 @@ void QmlTaskManager::displayAllResults()
|
||||
|
||||
void QmlTaskManager::insertTask(const Task &task)
|
||||
{
|
||||
Tasks tasks = m_docsWithTasks.value(task.file.toString());
|
||||
Tasks tasks = m_docsWithTasks.value(task.file);
|
||||
tasks.append(task);
|
||||
m_docsWithTasks.insert(task.file.toString(), tasks);
|
||||
m_docsWithTasks.insert(task.file, tasks);
|
||||
TaskHub::addTask(task);
|
||||
}
|
||||
|
||||
void QmlTaskManager::removeTasksForFile(const QString &fileName)
|
||||
void QmlTaskManager::removeTasksForFile(const Utils::FilePath &fileName)
|
||||
{
|
||||
if (m_docsWithTasks.contains(fileName)) {
|
||||
const Tasks tasks = m_docsWithTasks.value(fileName);
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
|
||||
void updateMessages();
|
||||
void updateSemanticMessagesNow();
|
||||
void documentsRemoved(const QStringList &path);
|
||||
void documentsRemoved(const Utils::FilePaths &path);
|
||||
|
||||
private:
|
||||
void displayResults(int begin, int end);
|
||||
@@ -57,14 +57,14 @@ private:
|
||||
void updateMessagesNow(bool updateSemantic = false);
|
||||
|
||||
void insertTask(const ProjectExplorer::Task &task);
|
||||
void removeTasksForFile(const QString &fileName);
|
||||
void removeTasksForFile(const Utils::FilePath &fileName);
|
||||
void removeAllTasks(bool clearSemantic);
|
||||
|
||||
private:
|
||||
class FileErrorMessages
|
||||
{
|
||||
public:
|
||||
QString fileName;
|
||||
Utils::FilePath fileName;
|
||||
ProjectExplorer::Tasks tasks;
|
||||
};
|
||||
static void collectMessages(QFutureInterface<FileErrorMessages> &future,
|
||||
@@ -74,7 +74,7 @@ private:
|
||||
bool updateSemantic);
|
||||
|
||||
private:
|
||||
QHash<QString, ProjectExplorer::Tasks > m_docsWithTasks;
|
||||
QHash<Utils::FilePath, ProjectExplorer::Tasks> m_docsWithTasks;
|
||||
QFutureWatcher<FileErrorMessages> m_messageCollector;
|
||||
QTimer m_updateDelay;
|
||||
bool m_updatingSemantic = false;
|
||||
|
||||
@@ -219,7 +219,7 @@ void QuickToolBar::apply(TextEditor::TextEditorWidget *editorWidget, Document::P
|
||||
else
|
||||
contextWidget()->rePosition(p3 , p1, p2, QmlJsEditingSettings::get().pinContextPane());
|
||||
contextWidget()->setOptions(QmlJsEditingSettings::get().enableContextPane(), QmlJsEditingSettings::get().pinContextPane());
|
||||
contextWidget()->setPath(document->path());
|
||||
contextWidget()->setPath(document->path().toString());
|
||||
contextWidget()->setProperties(&propertyReader);
|
||||
m_doc = document;
|
||||
m_node = node;
|
||||
|
||||
Reference in New Issue
Block a user