Skip to content

Commit 113b504

Browse files
Merge pull request intersystems-community#831 from a-boertien/colorize-output
Colorize VSCode ObjectScript Output
2 parents 962cc59 + e805ad7 commit 113b504

File tree

3 files changed

+98
-7
lines changed

3 files changed

+98
-7
lines changed

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
"enableProposedApi": true,
5353
"enabledApiProposals": [
5454
"fileSearchProvider",
55-
"textSearchProvider"
55+
"textSearchProvider",
56+
"outputChannelLanguage"
5657
],
5758
"activationEvents": [
5859
"onDebug",
@@ -449,10 +450,7 @@
449450
},
450451
{
451452
"id": "vscode-objectscript-output",
452-
"aliases": [],
453-
"mimetypes": [
454-
"text/x-code-output"
455-
]
453+
"aliases": []
456454
}
457455
],
458456
"grammars": [
@@ -490,6 +488,11 @@
490488
"language": "objectscript-csp",
491489
"scopeName": "source.objectscript_csp",
492490
"path": "syntaxes/objectscript-csp.tmLanguage.json"
491+
},
492+
{
493+
"language": "vscode-objectscript-output",
494+
"scopeName": "source.vscode_objectscript_output",
495+
"path": "syntaxes/vscode-objectscript-output.tmLanguage.json"
493496
}
494497
],
495498
"snippets": [

src/utils/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@ import { R_OK } from "constants";
44
import * as url from "url";
55
import { exec } from "child_process";
66
import * as vscode from "vscode";
7-
import { config, schemas, workspaceState, terminals } from "../extension";
7+
import { config, schemas, workspaceState, terminals, extensionId } from "../extension";
88
import { getCategory } from "../commands/export";
9+
const packageJson = vscode.extensions.getExtension(extensionId).packageJSON;
910

1011
let latestErrorMessage = "";
1112
export const outputChannel: {
1213
resetError?(): void;
1314
appendError?(value: string, show?: boolean): void;
14-
} & vscode.OutputChannel = vscode.window.createOutputChannel("ObjectScript");
15+
} & vscode.OutputChannel =
16+
typeof packageJson.enabledApiProposals === "object" &&
17+
packageJson.enabledApiProposals.includes("outputChannelLanguage")
18+
? vscode.window.createOutputChannel("ObjectScript", "vscode-objectscript-output")
19+
: vscode.window.createOutputChannel("ObjectScript");
1520

1621
/// Append Error if no duplicates previous one
1722
outputChannel.appendError = (value: string, show = true): void => {
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3+
"name": "vscode-objectscript-output",
4+
"scopeName": "source.vscode_objectscript_output",
5+
"patterns": [
6+
{
7+
"match": "^\\s*(?:\\> )?(?:ERROR).*\\#\\d+\\:",
8+
"name": "invalid"
9+
},
10+
{
11+
"match": "^\\s*(?:ERROR)\\s*\\:",
12+
"name": "invalid"
13+
},
14+
{
15+
"match": "^\\s*(?:Authorization error\\:)",
16+
"name": "invalid"
17+
},
18+
{
19+
"match": "^Detected \\d+ errors during compilation in \\S+",
20+
"name": "invalid"
21+
},
22+
{
23+
"match": "^Compilation finished successfully in \\S+",
24+
"name": "markup.bold"
25+
},
26+
{
27+
"match": "(?<=^Compiling (?:class|routine|file|table) \\:? ?)[^\\:\\s]+",
28+
"name": "entity.name.class"
29+
},
30+
{
31+
"match": "(?<=^Deleting (?:class|routine|file|table) )\\S+",
32+
"name": "entity.name.class"
33+
},
34+
{
35+
"match": "(?<=^Dropping orphaned procedure\\: )\\S+",
36+
"name": "entity.name.class"
37+
},
38+
{
39+
"match": "(?<=^(?:Class|Routine|File|Table) )\\S+(?= is up-to-date\\.)",
40+
"name": "entity.name.class"
41+
},
42+
{
43+
"match": "\\S+(?= is up to date\\. Compile of this item skipped\\.)",
44+
"name": "entity.name.class"
45+
},
46+
{
47+
"match": "(?<=^\\s*ERROR\\:\\s*)\\S+",
48+
"name": "entity.name.class"
49+
},
50+
{
51+
"match": "\"(.*?)\"",
52+
"name": "string.quoted"
53+
},
54+
{
55+
"match": "'(.*?)'",
56+
"name": "string.quoted"
57+
},
58+
{
59+
"match": "\\b(((0|1)?[0-9][1-2]?)|(Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(ust)?|Sept(ember)?|Oct(ober)?|Nov(ember)?|Dec(ember)?))[/|\\-|\\.| ]([0-2]?[0-9]|[3][0-1])[/|\\-|\\.| ]((19|20)?[0-9]{2})\\b",
60+
"name": "constant.numeric"
61+
},
62+
{
63+
"match": "\\b((19|20)?[0-9]{2}[/|\\-|\\.| ](((0|1)?[0-9][1-2]?)|(Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(ust)?|Sept(ember)?|Oct(ober)?|Nov(ember)?|Dec(ember)?))[/|\\-|\\.| ]([0-2]?[0-9]|[3][0-1]))\\b",
64+
"name": "constant.numeric"
65+
},
66+
{
67+
"match": "\\b([0-2]?[0-9]|[3][0-1])[/|\\-|\\.| ](((0|1)?[0-9][1-2]?)|(Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(ust)?|Sept(ember)?|Oct(ober)?|Nov(ember)?|Dec(ember)?))[/|\\-|\\.| ]((19|20)?[0-9]{2})\\b",
68+
"name": "constant.numeric"
69+
},
70+
{
71+
"match": "\\b([0|1]?[0-9]|2[0-3])\\:[0-5][0-9](\\:[0-5][0-9])?( ?(?i:(a|p)m?))?( ?[+-]?[0-9]*)?\\b",
72+
"name": "constant.numeric"
73+
},
74+
{
75+
"match": "\\b\\d+\\.?\\d*?\\b",
76+
"name": "constant.numeric"
77+
},
78+
{
79+
"match": "\\b(?i:(0?x)?[0-9a-f][0-9a-f]+)\\b",
80+
"name": "constant.numeric"
81+
}
82+
]
83+
}

0 commit comments

Comments
 (0)