Skip to content

Commit 97faac0

Browse files
committed
Support for multiple Qute template root
Signed-off-by: azerr <[email protected]>
1 parent cd2575f commit 97faac0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/qute/commands/commandConstants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,6 @@ export namespace QuteJdtLsServerCommandConstants {
9292
*/
9393
export const JAVA_DEFINTION = 'qute/template/javaDefinition';
9494

95+
export const IS_IN_TEMPLATE_COMMAND_ID = 'qute/template/isInTemplate';
96+
9597
}

src/qute/commands/registerCommands.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ async function updateQuteLanguageId(context: ExtensionContext, document: TextDoc
244244
return;
245245
}
246246

247-
if (isInTemplates(document)) {
247+
if (await isInTemplates(document)) {
248248
// The html, txt, yaml, json file is in src/main/resources/templates folder
249249
// The document must be forced with qute-* language id
250250
const fileName: string = path.basename(document.fileName);
@@ -253,7 +253,7 @@ async function updateQuteLanguageId(context: ExtensionContext, document: TextDoc
253253

254254
}
255255

256-
function isInTemplates(document: TextDocument): boolean {
256+
async function isInTemplates(document: TextDocument): Promise<boolean> {
257257
if (document.fileName.includes(`resources${path.sep}templates${path.sep}`)) {
258258
// HTML, etc file is included in src/main/resources/templates
259259
return true;
@@ -262,7 +262,9 @@ function isInTemplates(document: TextDocument): boolean {
262262
// HTML, etc file is included in a JAR in templates JAR entry
263263
return true;
264264
}
265-
return false;
265+
// consume JDT LS 'qute/template/isInTemplate' command
266+
const params = { templateFileUri: document.uri.toString() };
267+
return await commands.executeCommand("java.execute.workspaceCommand", QuteJdtLsServerCommandConstants.IS_IN_TEMPLATE_COMMAND_ID, params);
266268
}
267269

268270
interface TemplateValidationStatus {

0 commit comments

Comments
 (0)