Skip to content

Commit

Permalink
Add new contribution point that allows other extension to register th…
Browse files Browse the repository at this point in the history
…e build file pattern.

Close redhat-developer#1825
Signed-off-by: Siarhei Leanavets siarhei_leanavets1@epam.com
  • Loading branch information
LeonovecSergey committed Mar 24, 2021
1 parent 2c97a64 commit 2ed6f16
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
8 changes: 8 additions & 0 deletions schemas/package.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
"type": "string",
"description": "Relative path to a Java language server extension JAR file"
}
},
"javaBuildFilePatterns": {
"type": "array",
"markdownDescription": "Java build file patterns",
"items": {
"type": "string",
"description": "Specific build file patterns"
}
}
}
}
Expand Down
15 changes: 14 additions & 1 deletion src/standardLanguageClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { markdownPreviewProvider } from "./markdownPreviewProvider";
import { RefactorDocumentProvider, javaRefactorKinds } from "./codeActionProvider";
import { typeHierarchyTree } from "./typeHierarchy/typeHierarchyTree";
import { TypeHierarchyDirection, TypeHierarchyItem } from "./typeHierarchy/protocol";
import * as vscode from "vscode";

const extensionName = 'Language Support for Java';
const GRADLE_CHECKSUM = "gradle/checksum/prompt";
Expand Down Expand Up @@ -465,7 +466,19 @@ function projectConfigurationUpdate(languageClient: LanguageClient, uri?: Uri) {
}

function isJavaConfigFile(path: String) {
return path.endsWith('pom.xml') || path.endsWith('.gradle');
return path.endsWith('pom.xml') || path.endsWith('.gradle')
|| isBuildFilePattern(path);
}

function isBuildFilePattern(fileName: String): boolean {
return vscode
.extensions
.all
.filter(extension => extension.packageJSON['contributes'] && Array.isArray(extension.packageJSON['contributes']['javaBuildFilePatterns']))
.map(extension => extension.packageJSON['contributes']['javaBuildFilePatterns'])
.reduce((acc, val) => acc.concat(val), [])
.filter((pattern: String) => fileName.toLowerCase().endsWith(pattern.toLowerCase()))
.length > 0;
}

function setProjectConfigurationUpdate(languageClient: LanguageClient, uri: Uri, status: FeatureStatus) {
Expand Down

0 comments on commit 2ed6f16

Please sign in to comment.