Skip to content

Commit 1aeba0a

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

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@
117117
"qute.txt"
118118
],
119119
"configuration": "./language-support/qute/language-configuration.json"
120+
},
121+
{
122+
"id": "qute-md",
123+
"aliases": [
124+
"Qute MarkDown"
125+
],
126+
"extensions": [
127+
"qute.md"
128+
],
129+
"configuration": "./language-support/qute/language-configuration.json"
120130
}
121131
],
122132
"htmlLanguageParticipants": [

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: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ const LANGUAGE_MAP = new Map<string, string>([
211211
[".txt", "qute-txt"],
212212
[".yaml", "qute-yaml"],
213213
[".yml", "qute-yaml"],
214-
[".json", "qute-json"]
214+
[".json", "qute-json"],
215+
[".md", "qute-md"]
215216
]);
216217

217218
/**
@@ -244,7 +245,7 @@ async function updateQuteLanguageId(context: ExtensionContext, document: TextDoc
244245
return;
245246
}
246247

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

254255
}
255256

256-
function isInTemplates(document: TextDocument): boolean {
257+
async function isInTemplates(document: TextDocument): Promise<boolean> {
257258
if (document.fileName.includes(`resources${path.sep}templates${path.sep}`)) {
258259
// HTML, etc file is included in src/main/resources/templates
259260
return true;
@@ -262,7 +263,17 @@ function isInTemplates(document: TextDocument): boolean {
262263
// HTML, etc file is included in a JAR in templates JAR entry
263264
return true;
264265
}
265-
return false;
266+
return isInTemplates2(document.uri.toString());
267+
}
268+
269+
/**
270+
* Returns the label information for the given file URI.
271+
* @param uri the file URI
272+
* @return the label information for the given file URI.
273+
*/
274+
async function isInTemplates2(uri: string): Promise<boolean> {
275+
const params = { templateFileUri: uri };
276+
return await commands.executeCommand("java.execute.workspaceCommand", QuteJdtLsServerCommandConstants.IS_IN_TEMPLATE_COMMAND_ID, params);
266277
}
267278

268279
interface TemplateValidationStatus {

src/qute/languageServer/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export async function connectToQuteLS(context: ExtensionContext, api: JavaExtens
2121
{ scheme: 'file', language: 'qute-json' },
2222
{ scheme: 'file', language: 'qute-yaml' },
2323
{ scheme: 'file', language: 'qute-txt' },
24+
{ scheme: 'file', language: 'qute-md' },
2425
{ scheme: 'untitled', language: 'qute-html' },
2526
{ scheme: 'vscode-notebook-cell', language: 'qute-html' },
2627
{ scheme: 'file', language: 'java' }

0 commit comments

Comments
 (0)