Skip to content

Commit 4aafa0e

Browse files
committed
Add comment documents
Split delim nodes
1 parent b911ba2 commit 4aafa0e

7 files changed

Lines changed: 535 additions & 477 deletions

File tree

src/complete.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
import { completeFromList, ifNotIn } from "@codemirror/autocomplete";
1+
import { completeFromList, ifNotIn, type CompletionSource } from "@codemirror/autocomplete";
22
import { atoms, keywords, types } from "./keywords";
33

44
type CompletionType = "class" | "constant" | "enum" |
55
"function" | "interface" | "keyword" | "method" | "namespace" |
66
"property" | "text" | "type" | "variable";
77

8+
/**
9+
* Gets C# keywords completion.
10+
* @returns A {@link CompletionSource} instance for C# keywords.
11+
*/
812
export function csharpCompletion() {
913
function map(type: CompletionType) {
1014
return (label: string) => { return { label, type }; }

src/csharp.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { parser } from "./syntax.grammar";
33
import {
44
LRLanguage,
55
LanguageSupport,
6+
LanguageDescription,
67
indentNodeProp,
78
foldNodeProp,
89
foldInside,
@@ -40,11 +41,15 @@ function docCommentXmlOverlay(from: number, content: string) {
4041
return ranges.length > 0 ? ranges : null;
4142
}
4243

44+
/** A language provider for C#. */
4345
export const csharpLanguage = LRLanguage.define({
4446
parser: parser.configure({
4547
props: [
4648
indentNodeProp.add({
47-
Delim: continuedIndent({ except: /^\s*[\)\]\}]/ }),
49+
BracesDelim: continuedIndent({ except: /^\s*[\}]/ }),
50+
BracketsDelim: continuedIndent({ except: /^\s*[\]]/ }),
51+
ParensDelim: continuedIndent({ except: /^\s*[\)]/ }),
52+
ChevronsDelim: continuedIndent({ except: /^\s*[\>]/ }),
4853
IfStmt: continuedIndent({ except: /^\s*({|else\b)/ }),
4954
TryStmt: continuedIndent({ except: /^\s*({|catch\b|finally\b)/ }),
5055
LabeledStmt: flatIndent,
@@ -116,6 +121,11 @@ export const csharpLanguage = LRLanguage.define({
116121
import { Prec } from "@codemirror/state";
117122
import { continueDocComment } from "./keymap";
118123
import { csharpCompletion } from "./complete";
124+
125+
/**
126+
* Gets C# support. Includes {@link continueDocComment}, {@link csharpCompletion} and {@link xml.support}.
127+
* @returns A {@link LanguageSupport} instance for C#.
128+
*/
119129
export function csharp() {
120130
return new LanguageSupport(csharpLanguage, [
121131
Prec.high(continueDocComment),
@@ -124,4 +134,17 @@ export function csharp() {
124134
}),
125135
xml.support
126136
]);
137+
}
138+
139+
/**
140+
* Gets C# language description.
141+
* @returns A {@link LanguageDescription} instance for C#.
142+
*/
143+
export function csharpData() {
144+
return LanguageDescription.of({
145+
name: "C#",
146+
alias: ["csharp", "cs"],
147+
extensions: ["cs", "csx"],
148+
support: csharp()
149+
});
127150
}

src/keymap.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { syntaxTree } from "@codemirror/language";
22
import { keymap } from "@codemirror/view";
33
import { EditorSelection } from "@codemirror/state";
44

5+
/** The {@link keymap} for continuing XML documentation comments. */
56
export const continueDocComment = keymap.of([{
67
key: "Enter",
78
run(view) {

0 commit comments

Comments
 (0)