Skip to content

Commit 89e9b8c

Browse files
committed
Formatting changes
1 parent ac59b7d commit 89e9b8c

File tree

3 files changed

+82
-80
lines changed

3 files changed

+82
-80
lines changed

server/.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Place your settings in this file to overwrite default and user settings.
22
{
3-
"typescript.tsdk": "./node_modules/typescript/lib"
3+
"typescript.tsdk": "./node_modules/typescript/lib",
4+
"editor.useTabStops": false,
5+
"editor.tabSize": 2
46
}

server/src/errors.ts

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,49 @@ import {DiagnosticSeverity, IConnection, Range, TextDocumentIdentifier} from 'vs
22
import {TextDocuments} from './documents';
33

44
export class ErrorCollector {
5-
private timer: NodeJS.Timer | undefined;
5+
private timer: NodeJS.Timer | undefined;
66

7-
constructor(
7+
constructor(
88
private documents: TextDocuments,
99
private connection: IConnection,
1010
private initialDelay: number = 1500,
1111
private nextDelay: number = 20) {}
1212

13-
public requestErrors(...documents: TextDocumentIdentifier[]) {
14-
if (this.timer) {
15-
clearTimeout(this.timer);
16-
this.timer = undefined;
17-
}
18-
let index = 0;
19-
let process: () => void;
13+
public requestErrors(...documents: TextDocumentIdentifier[]) {
14+
if (this.timer) {
15+
clearTimeout(this.timer);
16+
this.timer = undefined;
17+
}
18+
let index = 0;
19+
let process: () => void;
2020

21-
process = () => {
22-
this.timer = undefined;
23-
this.sendErrorsFor(documents[index++]);
24-
if (index < documents.length) this.timer = setTimeout(process, this.nextDelay);
25-
}
26-
this.timer = setTimeout(process, this.initialDelay);
27-
}
21+
process = () => {
22+
this.timer = undefined;
23+
this.sendErrorsFor(documents[index++]);
24+
if (index < documents.length) this.timer = setTimeout(process, this.nextDelay);
25+
}
26+
this.timer = setTimeout(process, this.initialDelay);
27+
}
2828

29-
private sendErrorsFor(document: TextDocumentIdentifier) {
30-
const {fileName, service} = this.documents.getServiceInfo(document);
31-
const diagnostics = service.getDiagnostics(fileName);
32-
if (diagnostics) {
33-
const offsets = ([] as number[]).concat(...diagnostics.map(d => [d.span.start, d.span.end]));
34-
const positions = this.documents.offsetsToPositions(document, offsets);
35-
const ranges: Range[] = [];
36-
for (let i = 0; i < positions.length; i += 2) {
37-
ranges.push(Range.create(positions[i], positions[i+1]));
38-
}
39-
this.connection.sendDiagnostics({
40-
uri: document.uri,
41-
diagnostics: diagnostics.map((diagnostic, i) => ({
42-
range: ranges[i],
43-
message: diagnostic.message,
44-
severity: DiagnosticSeverity.Error,
29+
private sendErrorsFor(document: TextDocumentIdentifier) {
30+
const {fileName, service} = this.documents.getServiceInfo(document);
31+
const diagnostics = service.getDiagnostics(fileName);
32+
if (diagnostics) {
33+
const offsets = ([] as number[]).concat(...diagnostics.map(d => [d.span.start, d.span.end]));
34+
const positions = this.documents.offsetsToPositions(document, offsets);
35+
const ranges: Range[] = [];
36+
for (let i = 0; i < positions.length; i += 2) {
37+
ranges.push(Range.create(positions[i], positions[i+1]));
38+
}
39+
this.connection.sendDiagnostics({
40+
uri: document.uri,
41+
diagnostics: diagnostics.map((diagnostic, i) => ({
42+
range: ranges[i],
43+
message: diagnostic.message,
44+
severity: DiagnosticSeverity.Error,
4545
source: 'Angular'
46-
}))
47-
});
48-
}
49-
}
46+
}))
47+
});
48+
}
49+
}
5050
}

server/src/server.ts

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
/// <reference path="../node_modules/@types/node/index.d.ts" />
99

1010
import {
11-
IPCMessageReader, IPCMessageWriter,
12-
createConnection, IConnection, TextDocumentSyncKind,
13-
TextDocument, Diagnostic, DiagnosticSeverity,
14-
InitializeParams, InitializeResult, TextDocumentPositionParams,
15-
CompletionItem, CompletionItemKind, TextDocumentIdentifier, Range
11+
IPCMessageReader, IPCMessageWriter,
12+
createConnection, IConnection, TextDocumentSyncKind,
13+
TextDocument, Diagnostic, DiagnosticSeverity,
14+
InitializeParams, InitializeResult, TextDocumentPositionParams,
15+
CompletionItem, CompletionItemKind, TextDocumentIdentifier, Range
1616
} from 'vscode-languageserver';
1717

1818
import {TextDocuments, TextDocumentEvent} from './documents';
@@ -31,12 +31,12 @@ let documents: TextDocuments = new TextDocuments(handleTextEvent);
3131
const errorCollector = new ErrorCollector(documents, connection);
3232

3333
function handleTextEvent(event: TextDocumentEvent) {
34-
switch (event.kind) {
35-
case 'context':
36-
case 'change':
37-
case 'opened':
38-
errorCollector.requestErrors(event.document);
39-
}
34+
switch (event.kind) {
35+
case 'context':
36+
case 'change':
37+
case 'opened':
38+
errorCollector.requestErrors(event.document);
39+
}
4040
}
4141

4242
// Make the text document manager listen on the connection
@@ -47,45 +47,45 @@ documents.listen(connection);
4747
// in the passed params the rootPath of the workspace plus the client capabilites.
4848
let workspaceRoot: string;
4949
connection.onInitialize((params): InitializeResult => {
50-
workspaceRoot = params.rootPath;
51-
return {
52-
capabilities: {
53-
// Tell the client that the server works in FULL text document sync mode
54-
textDocumentSync: documents.syncKind,
55-
// Tell the client that the server support code complete
56-
completionProvider: {
57-
resolveProvider: false,
58-
triggerCharacters: ['<', '.']
59-
}
60-
}
61-
}
50+
workspaceRoot = params.rootPath;
51+
return {
52+
capabilities: {
53+
// Tell the client that the server works in FULL text document sync mode
54+
textDocumentSync: documents.syncKind,
55+
// Tell the client that the server support code complete
56+
completionProvider: {
57+
resolveProvider: false,
58+
triggerCharacters: ['<', '.']
59+
}
60+
}
61+
}
6262
});
6363

6464
function compiletionKindToCompletionItemKind(kind: string): number {
65-
switch (kind) {
66-
case 'element': return CompletionItemKind.Class;
67-
case 'attribute': return CompletionItemKind.Field;
68-
case 'entity': return CompletionItemKind.Text;
69-
case 'member': return CompletionItemKind.Property;
70-
}
71-
return CompletionItemKind.Text;
65+
switch (kind) {
66+
case 'element': return CompletionItemKind.Class;
67+
case 'attribute': return CompletionItemKind.Field;
68+
case 'entity': return CompletionItemKind.Text;
69+
case 'member': return CompletionItemKind.Property;
70+
}
71+
return CompletionItemKind.Text;
7272
}
7373

7474
// This handler provides the initial list of the completion items.
7575
connection.onCompletion((textDocumentPosition: TextDocumentPositionParams): CompletionItem[] => {
76-
const {fileName, service, offset} = documents.getServiceInfo(textDocumentPosition.textDocument,
77-
textDocumentPosition.position)
78-
if (service) {
79-
const result = service.getCompletionsAt(fileName, offset);
80-
if (result) {
81-
return result.map(completion => ({
82-
label: completion.name,
83-
kind: compiletionKindToCompletionItemKind(completion.kind),
84-
detail: completion.kind,
85-
sortText: completion.sort
86-
}));
87-
}
88-
}
76+
const {fileName, service, offset} = documents.getServiceInfo(textDocumentPosition.textDocument,
77+
textDocumentPosition.position)
78+
if (service) {
79+
const result = service.getCompletionsAt(fileName, offset);
80+
if (result) {
81+
return result.map(completion => ({
82+
label: completion.name,
83+
kind: compiletionKindToCompletionItemKind(completion.kind),
84+
detail: completion.kind,
85+
sortText: completion.sort
86+
}));
87+
}
88+
}
8989
});
9090

9191

0 commit comments

Comments
 (0)