Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/qute/commands/commandConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,6 @@ export namespace QuteJdtLsServerCommandConstants {
*/
export const JAVA_DEFINTION = 'qute/template/javaDefinition';

export const IS_IN_TEMPLATE_COMMAND_ID = 'qute/template/isInTemplate';

}
8 changes: 5 additions & 3 deletions src/qute/commands/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ async function updateQuteLanguageId(context: ExtensionContext, document: TextDoc
return;
}

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

}

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

interface TemplateValidationStatus {
Expand Down