Add maven.warnConflictsInDiagnostics configuration setting (#715)

This commit is contained in:
Melody618 2021-08-23 10:25:41 +08:00 коммит произвёл GitHub
Родитель 012222f6d7
Коммит 16920bc6b3
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 19 добавлений и 2 удалений

Просмотреть файл

@ -667,6 +667,12 @@
"default": false,
"description": "%configuration.maven.pomfile.prefetchEffectivePom%",
"scope": "application"
},
"maven.dependency.enableConflictDiagnostics": {
"type": "boolean",
"default": "true",
"description": "%configuration.maven.dependency.enableConflictDiagnostics%",
"scope": "window"
}
}
}

Просмотреть файл

@ -37,5 +37,6 @@
"configuration.maven.terminal.favorites.alias": "A short name for the command.",
"configuration.maven.terminal.favorites.command": "Content of the favorite command.",
"configuration.maven.terminal.favorites.debug": "Whether to execute in debug mode.",
"configuration.maven.settingsFile": "Specifies the absolute path of your maven configuration file, the default value is ~/.m2/settings.xml"
"configuration.maven.settingsFile": "Specifies the absolute path of your maven configuration file, the default value is ~/.m2/settings.xml",
"configuration.maven.dependency.enableConflictDiagnostics": "Specify whether to show diagnostics for conflict dependencies."
}

Просмотреть файл

@ -35,5 +35,6 @@
"configuration.maven.terminal.favorites.alias": "命令的简称。",
"configuration.maven.terminal.favorites.command": "命令的内容。",
"configuration.maven.terminal.favorites.debug": "是否以调试模式运行。",
"configuration.maven.settingsFile": "指定 maven 配置文件的绝对路径, 默认是 ~/.m2/settings.xml"
"configuration.maven.settingsFile": "指定 maven 配置文件的绝对路径, 默认是 ~/.m2/settings.xml",
"configuration.maven.dependency.enableConflictDiagnostics": "指定是否在 POM 文件中显示依赖冲突。"
}

Просмотреть файл

@ -7,6 +7,7 @@ import { getRequestDelay, lruCache, MovingAverage } from "./debouncing";
import { mavenExplorerProvider } from "./explorer/mavenExplorerProvider";
import { Dependency } from "./explorer/model/Dependency";
import { MavenProject } from "./explorer/model/MavenProject";
import { Settings } from "./Settings";
import { UserError } from "./utils/errorUtils";
import { ElementNode, getNodesByTag, XmlTagName } from "./utils/lexerUtils";
@ -46,6 +47,10 @@ class DiagnosticProvider {
public async refreshDiagnostics(uri: vscode.Uri): Promise<void> {
const diagnostics: vscode.Diagnostic[] = [];
if (Settings.enableConflictDiagnostics() === false) {
this._collection.set(uri, diagnostics);
return;
}
const project: MavenProject | undefined = mavenExplorerProvider.getMavenProject(uri.fsPath);
if (project === undefined) {
throw new Error("Failed to get maven project.");

Просмотреть файл

@ -13,6 +13,10 @@ export namespace Settings {
return !!_getMavenSection<boolean>("maven.showInExplorerContextMenu");
}
export function enableConflictDiagnostics(): boolean {
return !!_getMavenSection<boolean>("dependency.enableConflictDiagnostics");
}
export function viewType(): string | undefined {
return _getMavenSection("view");
}