Skip to content

Commit 2a2a474

Browse files
Merge pull request #865 from gjsjohnmurray/fix-823
Add `objectscript-int` language id for .int files (#823)
2 parents 113b504 + 5af175b commit 2a2a474

File tree

4 files changed

+103
-9
lines changed

4 files changed

+103
-9
lines changed

package.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"onCommand:vscode-objectscript.hideExplorerForWorkspace",
7474
"onCommand:vscode-objectscript.showExplorerForWorkspace",
7575
"onLanguage:objectscript",
76+
"onLanguage:objectscript-int",
7677
"onLanguage:objectscript-class",
7778
"onLanguage:objectscript-macros",
7879
"onLanguage:xml",
@@ -416,7 +417,15 @@
416417
"ObjectScript"
417418
],
418419
"extensions": [
419-
".mac",
420+
".mac"
421+
]
422+
},
423+
{
424+
"id": "objectscript-int",
425+
"aliases": [
426+
"ObjectScript INT"
427+
],
428+
"extensions": [
420429
".int"
421430
]
422431
},
@@ -464,6 +473,11 @@
464473
"text.js": "js"
465474
}
466475
},
476+
{
477+
"language": "objectscript-int",
478+
"scopeName": "source.objectscript",
479+
"path": "syntaxes/objectscript.tmLanguage.json"
480+
},
467481
{
468482
"language": "objectscript-class",
469483
"scopeName": "source.objectscript_class",
@@ -503,6 +517,10 @@
503517
{
504518
"language": "objectscript",
505519
"path": "./snippets/objectscript.json"
520+
},
521+
{
522+
"language": "objectscript-int",
523+
"path": "./snippets/objectscript-int.json"
506524
}
507525
],
508526
"commands": [
@@ -1050,6 +1068,9 @@
10501068
{
10511069
"language": "objectscript"
10521070
},
1071+
{
1072+
"language": "objectscript-int"
1073+
},
10531074
{
10541075
"language": "objectscript-class"
10551076
}

snippets/objectscript-int.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"ForOrder": {
3+
"prefix": ["For"],
4+
"body": [
5+
"Set ${1:key} = \"\"",
6+
"For {",
7+
"\tSet $1 = \\$ORDER(${2:array}($1))",
8+
"\tQuit:$1=\"\"",
9+
"\t${3:// process $2($1)}",
10+
"}"
11+
],
12+
"description": "Iterate array with $Order"
13+
},
14+
"SQL Statement": {
15+
"prefix": ["sql"],
16+
"body": [
17+
"Set rs = ##class(%SQL.Statement).%ExecDirect(,\"SELECT ${1:*} FROM ${2:table}\")",
18+
"While rs.%Next() {",
19+
"\t${0:Write rs.ID, !}",
20+
"}"
21+
],
22+
"description": "Prepare and execute SQL Query, then iterate result set 'rs'"
23+
},
24+
"For": {
25+
"prefix": ["For"],
26+
"body": [
27+
"For ${1:i} = ${2:1}:${3:1}:${4:9} {",
28+
"\t${0:Write $1, !}",
29+
"}"
30+
],
31+
"description": "Typical For loop"
32+
},
33+
"For Each": {
34+
"prefix": ["For"],
35+
"body": [
36+
"For ${1:value} = \"${2:Red}\",\"${3:Green}\",\"${4:Blue}\" {",
37+
"\t${0:Write $1, !}",
38+
"}"
39+
],
40+
"description": "Loop through series of values"
41+
},
42+
"Do While": {
43+
"prefix": ["Do", "While"],
44+
"body": [
45+
"Do {",
46+
"\t$0",
47+
"} While (${1:1 /* condition */})"
48+
],
49+
"description": "Do While loop"
50+
},
51+
"While": {
52+
"prefix": ["While"],
53+
"body": [
54+
"While (${1:1 /* condition */}) {",
55+
"\t$0",
56+
"}"
57+
],
58+
"description": "While loop"
59+
},
60+
"Try Catch": {
61+
"prefix": ["Try"],
62+
"body": [
63+
"Try {",
64+
"\t$0",
65+
"}",
66+
"Catch ex {",
67+
"\tSet tSC=ex.AsStatus()",
68+
"}"
69+
],
70+
"description": "Try Catch"
71+
}
72+
}

src/extension.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
601601
vscode.window.onDidChangeTextEditorSelection((event: vscode.TextEditorSelectionChangeEvent) => {
602602
posPanel.text = "";
603603
const document = event.textEditor.document;
604-
if (document.languageId !== "objectscript") {
604+
if (!["objectscript", "objectscript-int"].includes(document.languageId)) {
605605
return;
606606
}
607607
if (event.selections.length > 1 || !event.selections[0].isEmpty) {
@@ -685,23 +685,23 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
685685
}
686686
}),
687687
vscode.languages.registerHoverProvider(
688-
documentSelector("objectscript-class", "objectscript", "objectscript-macros"),
688+
documentSelector("objectscript-class", "objectscript", "objectscript-int", "objectscript-macros"),
689689
new ObjectScriptHoverProvider()
690690
),
691691
vscode.languages.registerDocumentFormattingEditProvider(
692-
documentSelector("objectscript-class", "objectscript", "objectscript-macros"),
692+
documentSelector("objectscript-class", "objectscript", "objectscript-int", "objectscript-macros"),
693693
new DocumentFormattingEditProvider()
694694
),
695695
vscode.languages.registerDocumentRangeFormattingEditProvider(
696-
documentSelector("objectscript-class", "objectscript", "objectscript-macros"),
696+
documentSelector("objectscript-class", "objectscript", "objectscript-int", "objectscript-macros"),
697697
new DocumentRangeFormattingEditProvider()
698698
),
699699
vscode.languages.registerDefinitionProvider(
700-
documentSelector("objectscript-class", "objectscript", "objectscript-macros"),
700+
documentSelector("objectscript-class", "objectscript", "objectscript-int", "objectscript-macros"),
701701
new ObjectScriptDefinitionProvider()
702702
),
703703
vscode.languages.registerCompletionItemProvider(
704-
documentSelector("objectscript-class", "objectscript", "objectscript-macros"),
704+
documentSelector("objectscript-class", "objectscript", "objectscript-int", "objectscript-macros"),
705705
new ObjectScriptCompletionItemProvider(),
706706
"$",
707707
"^",
@@ -713,7 +713,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
713713
new ObjectScriptClassSymbolProvider()
714714
),
715715
vscode.languages.registerDocumentSymbolProvider(
716-
documentSelector("objectscript"),
716+
documentSelector("objectscript", "objectscript-int"),
717717
new ObjectScriptRoutineSymbolProvider()
718718
)
719719
);
@@ -728,7 +728,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
728728
new ObjectScriptClassFoldingRangeProvider()
729729
),
730730
vscode.languages.registerFoldingRangeProvider(
731-
documentSelector("objectscript"),
731+
documentSelector("objectscript", "objectscript-int"),
732732
new ObjectScriptFoldingRangeProvider()
733733
)
734734
);

src/web-extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
2525
),
2626
vscode.languages.setLanguageConfiguration("objectscript-class", getLanguageConfiguration("class")),
2727
vscode.languages.setLanguageConfiguration("objectscript", getLanguageConfiguration("routine")),
28+
vscode.languages.setLanguageConfiguration("objectscript-int", getLanguageConfiguration("routine")),
2829
vscode.languages.setLanguageConfiguration("objectscript-macros", getLanguageConfiguration("routine"))
2930
);
3031
}

0 commit comments

Comments
 (0)