Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cf253ec

Browse files
authored
bundle v12 service and add snippet for v12 service (#51)
* Revert "feat(rename): Support renaming from TypeScript files" This reverts commit 9ae1511. * fix(service): bundle v12 service * feat(snippet): add snippet for v12 service * chore(test): delete test data
1 parent 518d11c commit cf253ec

File tree

191 files changed

+118129
-92
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+118129
-92
lines changed

‎override_rename_ts_plugin/README.md‎

Lines changed: 0 additions & 6 deletions
This file was deleted.

‎override_rename_ts_plugin/index.js‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎override_rename_ts_plugin/package.json‎

Lines changed: 0 additions & 6 deletions
This file was deleted.

‎package.json‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "coc-angular",
33
"description": "Editor services for Angular templates",
4-
"version": "13.2.4",
4+
"version": "13.2.6",
55
"keywords": [
66
"coc.nvim",
77
"angular",
@@ -102,13 +102,7 @@
102102
"description": "Enable/disable snippet completions from Angular language server. Requires using TypeScript 4.3+ in the workspace and the `legacy View Engine` option to be disabled."
103103
}
104104
}
105-
},
106-
"typescriptServerPlugins": [
107-
{
108-
"name": "@angular/override-rename-ts-plugin",
109-
"enableForWorkspaceTypeScriptVersions": true
110-
}
111-
]
105+
}
112106
},
113107
"scripts": {
114108
"build": "rm -rf ./out/ && webpack",
@@ -124,9 +118,7 @@
124118
},
125119
"dependencies": {
126120
"v12_language_service": "file:v12_language_service",
127-
"@angular/override-rename-ts-plugin": "file:override_rename_ts_plugin",
128121
"@angular/language-server": "13.2.3",
129-
"@angular/language-service": "13.2.2",
130122
"typescript": "~4.4.3"
131123
}
132124
}

‎src/client.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,16 @@ export class AngularLanguageClient implements vscode.Disposable {
7070
prepareRename: async (
7171
document: vscode.TextDocument, position: vscode.Position,
7272
token: vscode.CancellationToken, next: vscode.PrepareRenameSignature) => {
73-
if (await this.isInAngularProject(document)) {
73+
// We are able to provide renames for many types of string literals: template strings,
74+
// pipe names, and hopefully in the future selectors and input/output aliases. Because
75+
// TypeScript isn't able to provide renames for these, we can more or less
76+
// guarantee that the Angular Language service will be called for the rename as the
77+
// fallback. We specifically do not provide renames outside of string literals
78+
// because we cannot ensure our extension is prioritized for renames in TS files (see
79+
// https://github.com/microsoft/vscode/issues/115354) we disable renaming completely so we
80+
// can provide consistent expectations.
81+
if (await this.isInAngularProject(document) &&
82+
isInsideStringLiteral(document, position)) {
7483
return next(document, position, token);
7584
}
7685
},
@@ -160,7 +169,7 @@ export class AngularLanguageClient implements vscode.Disposable {
160169
return [...(angularCompletions ?? []), ...(htmlProviderCompletions?.items ?? [])];
161170
}
162171

163-
return angularCompletionsPromise;
172+
return angularCompletionsPromise.then(items=>provideCompletionItem(document,position,items));
164173
}
165174
}
166175
};

‎src/middleware/provideCompletionItem.ts‎

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,10 @@
1-
import { ProvideCompletionItemsSignature,CompletionContext,TextDocument, Position, CancellationToken,CompletionItem, CompletionItemKind, CompletionList,InsertTextFormat, Range,workspace,window } from 'coc.nvim';
1+
import { TextDocument, Position, CompletionItem, CompletionItemKind, InsertTextFormat, Range } from 'coc.nvim';
22

33
export const provideCompletionItem = async (
44
document: TextDocument,
55
position: Position,
6-
context: CompletionContext,
7-
token: CancellationToken,
8-
next: ProvideCompletionItemsSignature
6+
items: CompletionItem[]
97
) => {
10-
const res = await next(document, position, context, token)
11-
if (!res) {
12-
return res
13-
}
14-
let items: CompletionItem[] = []
15-
let isIncomplete: boolean
16-
17-
if ((res as CompletionList).isIncomplete !== undefined) {
18-
isIncomplete = (res as CompletionList).isIncomplete
19-
items = (res as CompletionList).items
20-
} else {
21-
items = res as CompletionItem[]
22-
}
23-
248
const { line: lineNum, character: colNr } = position
259
const line = document.getText(Range.create(
2610
Position.create(lineNum, 0),
@@ -30,13 +14,19 @@ export const provideCompletionItem = async (
3014
const nextCharCol = colNr
3115

3216
items = items.map(item => {
33-
if (item.kind === CompletionItemKind.Method && item.detail === 'method') {
17+
if (item.insertTextFormat === InsertTextFormat.Snippet) {
18+
return item
19+
} else if (item.kind === CompletionItemKind.Method &&
20+
item.detail &&
21+
(item.detail === 'method' || item.detail.startsWith('(method)'))
22+
) {
3423
/**
3524
* methodName()| => methodName(|)
3625
*/
37-
if (item.textEdit&&/\(\)$/.test(item.textEdit.newText)) {
26+
if (item.textEdit) {
3827
item.insertTextFormat = InsertTextFormat.Snippet
39-
item.textEdit.newText = `${item.textEdit.newText.slice(0, -2)}(\${1})\${0}`
28+
const textEdit = item.textEdit
29+
item.textEdit.newText = `${/\(\)$/.test(textEdit.newText) ? textEdit.newText.slice(0, -2) : textEdit.newText}(\${1})\${0}`
4030
}
4131
} else if (item.kind === CompletionItemKind.Property && item.detail === 'attribute') {
4232
const c = item.textEdit && line[item.textEdit.range.start.character - 1] || line[charCol]
@@ -109,12 +99,5 @@ export const provideCompletionItem = async (
10999
return item
110100
})
111101

112-
if (isIncomplete !== undefined) {
113-
return {
114-
isIncomplete,
115-
items
116-
}
117-
}
118-
119102
return items
120103
};
8 KB
Binary file not shown.

‎v12_language_service/node_modules/.bin/installServerIntoExtension‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎v12_language_service/node_modules/.bin/ngserver‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎v12_language_service/node_modules/.yarn-integrity‎

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /