Commit 8b67458a authored by Jaroslaw Kobus's avatar Jaroslaw Kobus
Browse files

Prefix editor's uniqueId with plugin name



In this way we minimize the chance of
generating non-unique id.

Change-Id: Idd177c5a4b44b17a58c2a944ec77b9517e91964e
Reviewed-by: Eike Ziller's avatarEike Ziller <eike.ziller@qt.io>
parent acb07875
......@@ -30,6 +30,8 @@
namespace DiffEditor {
namespace Constants {
const char DIFF_EDITOR_PLUGIN[] = "DiffEditorPlugin";
const char DIFF_EDITOR_ID[] = "Diff Editor";
const char DIFF_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("DiffEditor", "Diff Editor");
const char DIFF_EDITOR_MIMETYPE[] = "text/x-patch";
......
......@@ -55,7 +55,8 @@ public:
QString makePatch(bool revert, bool addPrefix = false) const;
static Core::IDocument *findOrCreateDocument(const QString &vcsId, const QString &displayName);
static Core::IDocument *findOrCreateDocument(const QString &vcsId,
const QString &displayName);
static DiffEditorController *controller(Core::IDocument *document);
public slots:
......
......@@ -428,7 +428,8 @@ DiffEditorServiceImpl::DiffEditorServiceImpl(QObject *parent) :
void DiffEditorServiceImpl::diffModifiedFiles(const QStringList &fileNames)
{
const QString documentId = QLatin1String("Diff Modified Files");
const QString documentId = Constants::DIFF_EDITOR_PLUGIN
+ QLatin1String(".DiffModifiedFiles");
const QString title = tr("Diff Modified Files");
auto const document = qobject_cast<DiffEditorDocument *>(
DiffEditorController::findOrCreateDocument(documentId, title));
......@@ -520,7 +521,8 @@ void DiffEditorPlugin::diffCurrentFile()
if (fileName.isEmpty())
return;
const QString documentId = QLatin1String("Diff ") + fileName;
const QString documentId = Constants::DIFF_EDITOR_PLUGIN
+ QLatin1String(".Diff.") + fileName;
const QString title = tr("Diff \"%1\"").arg(fileName);
auto const document = qobject_cast<DiffEditorDocument *>(
DiffEditorController::findOrCreateDocument(documentId, title));
......@@ -535,7 +537,8 @@ void DiffEditorPlugin::diffCurrentFile()
void DiffEditorPlugin::diffOpenFiles()
{
const QString documentId = QLatin1String("Diff Open Files");
const QString documentId = Constants::DIFF_EDITOR_PLUGIN
+ QLatin1String(".DiffOpenFiles");
const QString title = tr("Diff Open Files");
auto const document = qobject_cast<DiffEditorDocument *>(
DiffEditorController::findOrCreateDocument(documentId, title));
......@@ -566,7 +569,8 @@ void DiffEditorPlugin::diffExternalFiles()
if (EditorManager::skipOpeningBigTextFile(fileName2))
return;
const QString documentId = QLatin1String("Diff ") + fileName1 + QLatin1String(", ") + fileName2;
const QString documentId = Constants::DIFF_EDITOR_PLUGIN
+ QLatin1String(".DiffExternalFiles.") + fileName1 + QLatin1Char('.') + fileName2;
const QString title = tr("Diff \"%1\", \"%2\"").arg(fileName1, fileName2);
auto const document = qobject_cast<DiffEditorDocument *>(
DiffEditorController::findOrCreateDocument(documentId, title));
......
......@@ -747,7 +747,9 @@ void GitClient::diffFiles(const QString &workingDirectory,
const QStringList &unstagedFileNames,
const QStringList &stagedFileNames) const
{
requestReload("Files:" + workingDirectory,
const QString documentId = QLatin1String(Constants::GIT_PLUGIN)
+ QLatin1String(".DiffFiles.") + workingDirectory;
requestReload(documentId,
workingDirectory, tr("Git Diff Files"),
[this, workingDirectory, stagedFileNames, unstagedFileNames]
(IDocument *doc) -> DiffEditorController* {
......@@ -758,7 +760,9 @@ void GitClient::diffFiles(const QString &workingDirectory,
void GitClient::diffProject(const QString &workingDirectory, const QString &projectDirectory) const
{
requestReload("Project:" + workingDirectory,
const QString documentId = QLatin1String(Constants::GIT_PLUGIN)
+ QLatin1String(".DiffProject.") + workingDirectory;
requestReload(documentId,
workingDirectory, tr("Git Diff Project"),
[this, workingDirectory, projectDirectory]
(IDocument *doc) -> DiffEditorController* {
......@@ -768,7 +772,9 @@ void GitClient::diffProject(const QString &workingDirectory, const QString &proj
void GitClient::diffRepository(const QString &workingDirectory)
{
requestReload("Repository:" + workingDirectory,
const QString documentId = QLatin1String(Constants::GIT_PLUGIN)
+ QLatin1String(".DiffRepository.") + workingDirectory;
requestReload(documentId,
workingDirectory, tr("Git Diff Repository"),
[this, workingDirectory](IDocument *doc) -> DiffEditorController* {
return new RepositoryDiffController(doc, workingDirectory);
......@@ -779,7 +785,8 @@ void GitClient::diffFile(const QString &workingDirectory, const QString &fileNam
{
const QString title = tr("Git Diff \"%1\"").arg(fileName);
const QString sourceFile = VcsBaseEditor::getSource(workingDirectory, fileName);
const QString documentId = "File:" + sourceFile;
const QString documentId = QLatin1String(Constants::GIT_PLUGIN)
+ QLatin1String(".DifFile.") + sourceFile;
requestReload(documentId, sourceFile, title,
[this, workingDirectory, fileName]
(IDocument *doc) -> DiffEditorController* {
......@@ -791,7 +798,8 @@ void GitClient::diffBranch(const QString &workingDirectory,
const QString &branchName) const
{
const QString title = tr("Git Diff Branch \"%1\"").arg(branchName);
const QString documentId = "Branch:" + branchName;
const QString documentId = QLatin1String(Constants::GIT_PLUGIN)
+ QLatin1String(".DiffBranch.") + branchName;
requestReload(documentId, workingDirectory, title,
[this, workingDirectory, branchName]
(IDocument *doc) -> DiffEditorController* {
......@@ -898,7 +906,8 @@ void GitClient::show(const QString &source, const QString &id, const QString &na
const QString repoDirectory = VcsManager::findTopLevelForDirectory(workingDirectory);
if (!repoDirectory.isEmpty())
workingDirectory = repoDirectory;
const QString documentId = "Show:" + id;
const QString documentId = QLatin1String(Constants::GIT_PLUGIN)
+ QLatin1String(".Show.") + id;
requestReload(documentId, source, title,
[this, workingDirectory, id]
(IDocument *doc) -> DiffEditorController* {
......
......@@ -30,6 +30,8 @@
namespace Git {
namespace Constants {
const char GIT_PLUGIN[] = "GitPlugin";
const char GIT_COMMAND_LOG_EDITOR_ID[] = "Git Command Log Editor";
const char GIT_COMMAND_LOG_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Git Command Log Editor");
const char GIT_LOG_EDITOR_ID[] = "Git File Log Editor";
......
......@@ -25,6 +25,7 @@
#include "gitgrep.h"
#include "gitclient.h"
#include "gitconstants.h"
#include "gitplugin.h"
#include <coreplugin/editormanager/editormanager.h>
......@@ -294,8 +295,12 @@ IEditor *GitGrep::openEditor(const SearchResultItem &item,
if (fileContent == content)
return nullptr; // open the file for read/write
}
const QString documentId = QLatin1String(Git::Constants::GIT_PLUGIN)
+ QLatin1String(".GitShow.") + params.ref
+ QLatin1String(".") + relativePath;
QString title = tr("Git Show %1:%2").arg(params.ref).arg(relativePath);
IEditor *editor = EditorManager::openEditorWithContents(Id(), &title, content, title,
IEditor *editor = EditorManager::openEditorWithContents(Id(), &title, content, documentId,
EditorManager::DoNotSwitchToDesignMode);
editor->gotoLine(item.mainRange.begin.line, item.mainRange.begin.column);
editor->document()->setTemporary(true);
......
......@@ -688,17 +688,19 @@ void QmlJSEditorWidget::inspectElementUnderCursor() const
const CppComponentValue *cppValue = findCppComponentToInspect(semanticInfo, cursorPosition);
if (!cppValue) {
QString title = tr("Code Model Not Available");
const QString nothingToShow = QStringLiteral("nothingToShow");
const QString documentId = Constants::QML_JS_EDITOR_PLUGIN + QStringLiteral(".NothingToShow");
EditorManager::openEditorWithContents(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, &title,
tr("Code model not available.").toUtf8(), nothingToShow,
tr("Code model not available.").toUtf8(), documentId,
EditorManager::IgnoreNavigationHistory);
return;
}
QString title = tr("Code Model of %1").arg(cppValue->metaObject()->className());
const QString documentId = Constants::QML_JS_EDITOR_PLUGIN + QStringLiteral(".Class.")
+ cppValue->metaObject()->className();
IEditor *outputEditor = EditorManager::openEditorWithContents(
Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, &title, QByteArray(),
cppValue->metaObject()->className(), EditorManager::IgnoreNavigationHistory);
documentId, EditorManager::IgnoreNavigationHistory);
if (!outputEditor)
return;
......
......@@ -30,6 +30,8 @@
namespace QmlJSEditor {
namespace Constants {
const char QML_JS_EDITOR_PLUGIN[] = "QmlJSEditorPlugin";
const char M_CONTEXT[] = "QML JS Editor.ContextMenu";
const char M_REFACTORING_MENU_INSERTION_POINT[] = "QmlJSEditor.RefactorGroup";
......
......@@ -300,7 +300,8 @@ void SubversionClient::diff(const QString &workingDirectory, const QStringList &
Q_UNUSED(extraOptions);
const QString vcsCmdString = vcsCommandString(DiffCommand);
const QString documentId = VcsBaseEditor::getTitleId(workingDirectory, files);
const QString documentId = QLatin1String(Constants::SUBVERSION_PLUGIN)
+ QLatin1String(".Diff.") + VcsBaseEditor::getTitleId(workingDirectory, files);
const QString title = vcsEditorTitle(vcsCmdString, documentId);
DiffController *controller = findOrCreateDiffEditor(documentId, workingDirectory, title,
......@@ -328,7 +329,8 @@ void SubversionClient::log(const QString &workingDir,
void SubversionClient::describe(const QString &workingDirectory, int changeNumber, const QString &title)
{
const QString documentId = VcsBaseEditor::editorTag(DiffOutput,
const QString documentId = QLatin1String(Constants::SUBVERSION_PLUGIN)
+ QLatin1String(".Describe.") + VcsBaseEditor::editorTag(DiffOutput,
workingDirectory,
QStringList(),
QString::number(changeNumber));
......
......@@ -30,6 +30,8 @@
namespace Subversion {
namespace Constants {
const char SUBVERSION_PLUGIN[] = "SubversionPlugin";
const char NON_INTERACTIVE_OPTION[] = "--non-interactive";
enum { debug = 0 };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment