Skip to content

Commit a055078

Browse files
committed
added syntax highlight on hover
1 parent 1836bec commit a055078

14 files changed

+980
-968
lines changed

Diff for: client/src/extension.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function activate(context: ExtensionContext) {
3838
// Options to control the language client
3939
const clientOptions: LanguageClientOptions = {
4040
// Register the server for plain text documents
41-
documentSelector: [{ scheme: 'file', language: 'sourcejs' }],
41+
documentSelector: [{ scheme: 'file', language: 'source' }],
4242
synchronize: {
4343
// Notify the server about file changes to '.clientrc files contained in the workspace
4444
fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
@@ -58,7 +58,7 @@ export function activate(context: ExtensionContext) {
5858
client.start();
5959

6060
context.subscriptions.push(
61-
commands.registerCommand("sourcejs.setLanguageVersion", async () => {
61+
commands.registerCommand("source.setLanguageVersion", async () => {
6262
const versions = [`Source ${SECTION}1`, `Source ${SECTION}2`, `Source ${SECTION}3`, `Source ${SECTION}4`]
6363
const selectedVersion = await window.showQuickPick(versions, {
6464
placeHolder: "Select the language version",

Diff for: package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@
1313
"contributes": {
1414
"languages": [
1515
{
16-
"id": "sourcejs",
16+
"id": "source",
1717
"aliases": [
1818
"Source",
19-
"sourcejs"
19+
"source"
2020
],
2121
"extensions": [
22-
".sourcejs"
22+
".source"
2323
],
2424
"configuration": "./language-configuration.json"
2525
}
2626
],
2727
"grammars": [
2828
{
29-
"language": "sourcejs",
30-
"scopeName": "source.sourcejs",
31-
"path": "./syntaxes/sourcejs.tmLanguage.json"
29+
"language": "source",
30+
"scopeName": "source.source",
31+
"path": "./syntaxes/source.tmLanguage.json"
3232
}
3333
],
3434
"configuration": {
@@ -50,8 +50,8 @@
5050
},
5151
"commands": [
5252
{
53-
"command": "sourcejs.setLanguageVersion",
54-
"title": "Sourcejs: Set Source Version Used"
53+
"command": "source.setLanguageVersion",
54+
"title": "Source: Set Source Version Used"
5555
}
5656
]
5757
},

Diff for: server/src/ast.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,8 @@ export class AST {
405405
}
406406
if (value === undefined)
407407
return null;
408-
else return {
408+
409+
return {
409410
contents: {
410411
kind: "markdown",
411412
value: value

Diff for: server/src/docs/build_docs.mjs

+16-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ function processConstant(names, element, document) {
5050
const descriptionDiv = document.createElement('div');
5151
descriptionDiv.appendChild(titleNode);
5252
descriptionDiv.appendChild(descriptionNode);
53-
const markdown = buildDescriptionMarkdown(descriptionDiv);
53+
54+
let markdown = buildDescriptionMarkdown(descriptionDiv);
55+
const lines = markdown.split("\n");
56+
lines.unshift("```source");
57+
lines[1] = lines[1].substring(5);
58+
lines.splice(2, 0, "```");
59+
markdown = lines.join("\n");
5460

5561
names.push({ label: name, title, description: markdown, meta: CONST_DECL });
5662
}
@@ -66,10 +72,16 @@ function processFunction(names, element, document) {
6672
const descriptionDiv = document.createElement('div');
6773
descriptionDiv.appendChild(titleNode);
6874
descriptionDiv.appendChild(descriptionNode);
69-
const html = buildDescriptionMarkdown(descriptionDiv);
75+
76+
let markdown = buildDescriptionMarkdown(descriptionDiv);
77+
const lines = markdown.split("\n");
78+
lines.unshift("```source");
79+
lines[1] = lines[1].substring(5);
80+
lines.splice(2, 0, "```");
81+
markdown = lines.join("\n");
7082

7183
const params = (Object.keys(patches["rename_params"])).includes(name) ? patches["rename_params"][name] : [...title.matchAll(/\w+\(([^)]*)\)/g)][0][1].split(",").map(s => s.trim());
72-
const autocomplete = { label: name, title, description: html, meta: FUNC_DECL, parameters: params[0] === '' ? [] : params };
84+
const autocomplete = { label: name, title, description: markdown, meta: FUNC_DECL, parameters: params[0] === '' ? [] : params };
7385

7486
if (Object.keys(patches["optional_params"]).includes(name))
7587
autocomplete["optional_params"] = patches["optional_params"][name];
@@ -148,7 +160,7 @@ async function buildDoc(name) {
148160
item["description"] = `#### ${key}:${doc[key]['type']}\n${turndownService.turndown(doc[key]["description"])}`;
149161
else if (doc[key]["kind"] === "function") {
150162
const params = doc[key]['params'].map(x => x[0]);
151-
item["description"] = `#### ${key}(${params.join(', ')}) → ${doc[key]['retType']}\n${turndownService.turndown(doc[key]["description"])}`;
163+
item["description"] = `\`\`\`source\n${key}(${params.join(', ')}) → ${doc[key]['retType']}\n\`\`\`\n${turndownService.turndown(doc[key]["description"])}`;
152164
item["parameters"] = params
153165
}
154166

Diff for: server/src/docs/modules.json

+580-580
Large diffs are not rendered by default.

Diff for: server/src/docs/source.json

+363-363
Large diffs are not rendered by default.

Diff for: server/src/utils.ts

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export const autocomplete_labels = source.map(version => version.map((doc, idx):
1313
return {
1414
label: doc.label,
1515
labelDetails: { detail: ` (${doc.meta})` },
16-
detail: doc.title,
1716
documentation: {
1817
kind: MarkupKind.Markdown,
1918
value: doc.description

Diff for: syntaxes/sourcejs.tmLanguage.json renamed to syntaxes/source.tmLanguage.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
"comments": {
1414
"patterns": [
1515
{
16-
"name": "comment.line.double-slash.sourcejs",
16+
"name": "comment.line.double-slash.source",
1717
"match": "//.*$"
1818
},
1919
{
20-
"name": "comment.block.sourcejs",
20+
"name": "comment.block.source",
2121
"begin": "/\\*",
2222
"end": "\\*/"
2323
}
@@ -26,23 +26,23 @@
2626
"strings": {
2727
"patterns": [
2828
{
29-
"name": "string.quoted.double.sourcejs",
29+
"name": "string.quoted.double.source",
3030
"begin": "\"",
3131
"end": "\"",
3232
"patterns": [
3333
{ "match": "\\\\.", "name": "constant.character.escape.sourcejs" }
3434
]
3535
},
3636
{
37-
"name": "string.quoted.single.sourcejs",
37+
"name": "string.quoted.single.source",
3838
"begin": "'",
3939
"end": "'",
4040
"patterns": [
4141
{ "match": "\\\\.", "name": "constant.character.escape.sourcejs" }
4242
]
4343
},
4444
{
45-
"name": "string.template.sourcejs",
45+
"name": "string.template.source",
4646
"begin": "`",
4747
"end": "`",
4848
"patterns": [
@@ -54,27 +54,27 @@
5454
"numbers": {
5555
"patterns": [
5656
{
57-
"name": "constant.numeric.sourcejs",
57+
"name": "constant.numeric.source",
5858
"match": "\\b(0[xX][0-9a-fA-F]+|0[bB][01]+|0[oO]?[0-7]+|\\d+(\\.\\d+)?([eE][+-]?\\d+)?|true|false)\\b"
5959
}
6060
]
6161
},
6262
"keywords": {
6363
"patterns": [
6464
{
65-
"name": "keyword.control.sourcejs",
65+
"name": "keyword.control.source",
6666
"match": "\\b(if|else|for|while|break|continue|return|function|in|let|const|import)\\b"
6767
}
6868
]
6969
},
7070
"operators": {
7171
"patterns": [
7272
{
73-
"name": "keyword.operator.sourcejs",
73+
"name": "keyword.operator.source",
7474
"match": "(\\+|\\-|\\*|\\/|%|===|!==|>|<|>=|<=|&&|\\|\\||!|=|=>)"
7575
}
7676
]
7777
}
7878
},
79-
"scopeName": "source.sourcejs"
79+
"scopeName": "source.source"
8080
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)