Signed-off-by: Yan Zhang <yanzh@microsoft.com>
This commit is contained in:
Yan Zhang 2023-03-13 12:48:24 +08:00 коммит произвёл GitHub
Родитель 5283a0a53f
Коммит 4a5f7f760f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 33 добавлений и 28 удалений

16
.vscode/launch.json поставляемый
Просмотреть файл

@ -16,6 +16,20 @@
], ],
"preLaunchTask": "npm: watch" "preLaunchTask": "npm: watch"
}, },
{
"name": "Extension<Multi-Module>",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"${workspaceFolder}/test/projects/multi-module",
"--extensionDevelopmentPath=${workspaceFolder}",
],
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "npm: watch"
},
{ {
"name": "Extension Tests - Maven Project", "name": "Extension Tests - Maven Project",
"type": "extensionHost", "type": "extensionHost",
@ -41,4 +55,4 @@
"port": 1044 "port": 1044
} }
] ]
} }

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

@ -25,8 +25,8 @@ class DefinitionProvider implements vscode.DefinitionProvider {
case XmlTagName.Version: { case XmlTagName.Version: {
const targetNode = tagNode.parent; const targetNode = tagNode.parent;
const selectionRange: vscode.Range = new vscode.Range( const selectionRange: vscode.Range = new vscode.Range(
targetNode && targetNode.startIndex !== null ?document.positionAt(targetNode?.startIndex) : position, targetNode && targetNode.startIndex !== null ? document.positionAt(targetNode?.startIndex) : position,
targetNode && targetNode.endIndex !== null ?document.positionAt(targetNode?.endIndex) : position, targetNode && targetNode.endIndex !== null ? document.positionAt(targetNode?.endIndex) : position,
); );
const siblingNodes: Node[] = tagNode.parent?.children ?? []; const siblingNodes: Node[] = tagNode.parent?.children ?? [];
@ -51,6 +51,20 @@ class DefinitionProvider implements vscode.DefinitionProvider {
} }
} }
} }
case XmlTagName.Module: {
const moduleName = getTextFromNode(tagNode.firstChild);
const targetUri = vscode.Uri.joinPath(document.uri, "..", moduleName, "pom.xml");
const selectionRange: vscode.Range = new vscode.Range(
tagNode && tagNode.startIndex !== null ? document.positionAt(tagNode.startIndex) : position,
tagNode && tagNode.endIndex !== null ? document.positionAt(tagNode.endIndex) : position,
);
const definitionLink: vscode.LocationLink = {
targetRange: new vscode.Range(0, 0, 0, 0),
targetUri,
originSelectionRange: selectionRange
};
return [definitionLink];
}
default: default:
return undefined; return undefined;
} }

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

@ -1,24 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import { MavenProjectManager } from "../../project/MavenProjectManager";
import { ITreeItem } from "./ITreeItem";
import { MavenProject } from "./MavenProject";
import { Menu } from "./Menu";
/**
* @deprecated
*/
export class ModulesMenu extends Menu implements ITreeItem {
constructor(projectNode: MavenProject) {
super(projectNode);
this.name = "Modules";
}
public getChildren() : MavenProject[] {
return this.project.modules.map(modulePomPath => {
const found: MavenProject | undefined = MavenProjectManager.get(modulePomPath);
return found ? found : new MavenProject(modulePomPath);
});
}
}

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

@ -14,7 +14,8 @@ export enum XmlTagName {
Plugins = "plugins", Plugins = "plugins",
Project = "project", Project = "project",
Dependency = "dependency", Dependency = "dependency",
Properties = "properties" Properties = "properties",
Module = "module"
} }
export function getNodesByTag(text: string, tag: string): Element[] { export function getNodesByTag(text: string, tag: string): Element[] {