Set `printWidth` to 100

pull/2748/head
Alex Dima 4 years ago
parent 8cc4272694
commit 966506278e
No known key found for this signature in database
GPG Key ID: 6E58D7B045760DA0

@ -3,5 +3,6 @@
"singleQuote": true,
"trailingComma": "none",
"semi": true,
"useTabs": true
"useTabs": true,
"printWidth": 100
}

@ -40,26 +40,17 @@ function bundleOne(moduleId, exclude) {
packages: [
{
name: 'vscode-css-languageservice',
location: path.join(
REPO_ROOT,
'node_modules/vscode-css-languageservice/lib/umd'
),
location: path.join(REPO_ROOT, 'node_modules/vscode-css-languageservice/lib/umd'),
main: 'cssLanguageService'
},
{
name: 'vscode-languageserver-types',
location: path.join(
REPO_ROOT,
'node_modules/vscode-languageserver-types/lib/umd'
),
location: path.join(REPO_ROOT, 'node_modules/vscode-languageserver-types/lib/umd'),
main: 'main'
},
{
name: 'vscode-languageserver-textdocument',
location: path.join(
REPO_ROOT,
'node_modules/vscode-languageserver-textdocument/lib/umd'
),
location: path.join(REPO_ROOT, 'node_modules/vscode-languageserver-textdocument/lib/umd'),
main: 'main'
},
{
@ -75,14 +66,8 @@ function bundleOne(moduleId, exclude) {
]
},
async function (buildResponse) {
const devFilePath = path.join(
REPO_ROOT,
'release/dev/' + moduleId + '.js'
);
const minFilePath = path.join(
REPO_ROOT,
'release/min/' + moduleId + '.js'
);
const devFilePath = path.join(REPO_ROOT, 'release/dev/' + moduleId + '.js');
const minFilePath = path.join(REPO_ROOT, 'release/min/' + moduleId + '.js');
const fileContents = fs.readFileSync(devFilePath).toString();
console.log();
console.log(`Minifying ${devFilePath}...`);

@ -16,9 +16,7 @@ export function setupMode(defaults: LanguageServiceDefaults): IDisposable {
const client = new WorkerManager(defaults);
disposables.push(client);
const worker: languageFeatures.WorkerAccessor = (
...uris: Uri[]
): Promise<CSSWorker> => {
const worker: languageFeatures.WorkerAccessor = (...uris: Uri[]): Promise<CSSWorker> => {
return client.getLanguageServiceWorker(...uris);
};
@ -37,10 +35,7 @@ export function setupMode(defaults: LanguageServiceDefaults): IDisposable {
}
if (modeConfiguration.hovers) {
providers.push(
languages.registerHoverProvider(
languageId,
new languageFeatures.HoverAdapter(worker)
)
languages.registerHoverProvider(languageId, new languageFeatures.HoverAdapter(worker))
);
}
if (modeConfiguration.documentHighlights) {
@ -77,10 +72,7 @@ export function setupMode(defaults: LanguageServiceDefaults): IDisposable {
}
if (modeConfiguration.rename) {
providers.push(
languages.registerRenameProvider(
languageId,
new languageFeatures.RenameAdapter(worker)
)
languages.registerRenameProvider(languageId, new languageFeatures.RenameAdapter(worker))
);
}
if (modeConfiguration.colors) {
@ -100,9 +92,7 @@ export function setupMode(defaults: LanguageServiceDefaults): IDisposable {
);
}
if (modeConfiguration.diagnostics) {
providers.push(
new languageFeatures.DiagnosticsAdapter(languageId, worker, defaults)
);
providers.push(new languageFeatures.DiagnosticsAdapter(languageId, worker, defaults));
}
if (modeConfiguration.selectionRanges) {
providers.push(

@ -40,60 +40,33 @@ export class CSSWorker {
let document = this._getTextDocument(uri);
if (document) {
let stylesheet = this._languageService.parseStylesheet(document);
let diagnostics = this._languageService.doValidation(
document,
stylesheet
);
let diagnostics = this._languageService.doValidation(document, stylesheet);
return Promise.resolve(diagnostics);
}
return Promise.resolve([]);
}
async doComplete(
uri: string,
position: cssService.Position
): Promise<cssService.CompletionList> {
async doComplete(uri: string, position: cssService.Position): Promise<cssService.CompletionList> {
let document = this._getTextDocument(uri);
let stylesheet = this._languageService.parseStylesheet(document);
let completions = this._languageService.doComplete(
document,
position,
stylesheet
);
let completions = this._languageService.doComplete(document, position, stylesheet);
return Promise.resolve(completions);
}
async doHover(
uri: string,
position: cssService.Position
): Promise<cssService.Hover> {
async doHover(uri: string, position: cssService.Position): Promise<cssService.Hover> {
let document = this._getTextDocument(uri);
let stylesheet = this._languageService.parseStylesheet(document);
let hover = this._languageService.doHover(document, position, stylesheet);
return Promise.resolve(hover);
}
async findDefinition(
uri: string,
position: cssService.Position
): Promise<cssService.Location> {
async findDefinition(uri: string, position: cssService.Position): Promise<cssService.Location> {
let document = this._getTextDocument(uri);
let stylesheet = this._languageService.parseStylesheet(document);
let definition = this._languageService.findDefinition(
document,
position,
stylesheet
);
let definition = this._languageService.findDefinition(document, position, stylesheet);
return Promise.resolve(definition);
}
async findReferences(
uri: string,
position: cssService.Position
): Promise<cssService.Location[]> {
async findReferences(uri: string, position: cssService.Position): Promise<cssService.Location[]> {
let document = this._getTextDocument(uri);
let stylesheet = this._languageService.parseStylesheet(document);
let references = this._languageService.findReferences(
document,
position,
stylesheet
);
let references = this._languageService.findReferences(document, position, stylesheet);
return Promise.resolve(references);
}
async findDocumentHighlights(
@ -102,22 +75,13 @@ export class CSSWorker {
): Promise<cssService.DocumentHighlight[]> {
let document = this._getTextDocument(uri);
let stylesheet = this._languageService.parseStylesheet(document);
let highlights = this._languageService.findDocumentHighlights(
document,
position,
stylesheet
);
let highlights = this._languageService.findDocumentHighlights(document, position, stylesheet);
return Promise.resolve(highlights);
}
async findDocumentSymbols(
uri: string
): Promise<cssService.SymbolInformation[]> {
async findDocumentSymbols(uri: string): Promise<cssService.SymbolInformation[]> {
let document = this._getTextDocument(uri);
let stylesheet = this._languageService.parseStylesheet(document);
let symbols = this._languageService.findDocumentSymbols(
document,
stylesheet
);
let symbols = this._languageService.findDocumentSymbols(document, stylesheet);
return Promise.resolve(symbols);
}
async doCodeActions(
@ -127,23 +91,13 @@ export class CSSWorker {
): Promise<cssService.Command[]> {
let document = this._getTextDocument(uri);
let stylesheet = this._languageService.parseStylesheet(document);
let actions = this._languageService.doCodeActions(
document,
range,
context,
stylesheet
);
let actions = this._languageService.doCodeActions(document, range, context, stylesheet);
return Promise.resolve(actions);
}
async findDocumentColors(
uri: string
): Promise<cssService.ColorInformation[]> {
async findDocumentColors(uri: string): Promise<cssService.ColorInformation[]> {
let document = this._getTextDocument(uri);
let stylesheet = this._languageService.parseStylesheet(document);
let colorSymbols = this._languageService.findDocumentColors(
document,
stylesheet
);
let colorSymbols = this._languageService.findDocumentColors(document, stylesheet);
return Promise.resolve(colorSymbols);
}
async getColorPresentations(
@ -175,11 +129,7 @@ export class CSSWorker {
): Promise<cssService.SelectionRange[]> {
let document = this._getTextDocument(uri);
let stylesheet = this._languageService.parseStylesheet(document);
let ranges = this._languageService.getSelectionRanges(
document,
positions,
stylesheet
);
let ranges = this._languageService.getSelectionRanges(document, positions, stylesheet);
return Promise.resolve(ranges);
}
async doRename(
@ -189,12 +139,7 @@ export class CSSWorker {
): Promise<cssService.WorkspaceEdit> {
let document = this._getTextDocument(uri);
let stylesheet = this._languageService.parseStylesheet(document);
let renames = this._languageService.doRename(
document,
position,
newName,
stylesheet
);
let renames = this._languageService.doRename(document, position, newName, stylesheet);
return Promise.resolve(renames);
}
private _getTextDocument(uri: string): cssService.TextDocument {
@ -218,9 +163,6 @@ export interface ICreateData {
languageSettings: cssService.LanguageSettings;
}
export function create(
ctx: worker.IWorkerContext,
createData: ICreateData
): CSSWorker {
export function create(ctx: worker.IWorkerContext, createData: ICreateData): CSSWorker {
return new CSSWorker(ctx, createData);
}

@ -33,11 +33,7 @@ function format(message: string, args: any[]): string {
return result;
}
function localize(
key: string | LocalizeInfo,
message: string,
...args: any[]
): string {
function localize(key: string | LocalizeInfo, message: string, ...args: any[]): string {
return format(message, args);
}

@ -44,10 +44,7 @@ export class DiagnosticsAdapter {
let handle: number;
this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
window.clearTimeout(handle);
handle = window.setTimeout(
() => this._doValidate(model.uri, modeId),
500
);
handle = window.setTimeout(() => this._doValidate(model.uri, modeId), 500);
});
this._doValidate(model.uri, modeId);
@ -131,12 +128,8 @@ function toSeverity(lsSeverity: number): MarkerSeverity {
}
}
function toDiagnostics(
resource: Uri,
diag: cssService.Diagnostic
): editor.IMarkerData {
let code =
typeof diag.code === 'number' ? String(diag.code) : <string>diag.code;
function toDiagnostics(resource: Uri, diag: cssService.Diagnostic): editor.IMarkerData {
let code = typeof diag.code === 'number' ? String(diag.code) : <string>diag.code;
return {
severity: toSeverity(diag.severity),
@ -184,9 +177,7 @@ function toRange(range: cssService.Range): Range {
);
}
function isInsertReplaceEdit(
edit: TextEdit | InsertReplaceEdit
): edit is InsertReplaceEdit {
function isInsertReplaceEdit(edit: TextEdit | InsertReplaceEdit): edit is InsertReplaceEdit {
return (
typeof (<InsertReplaceEdit>edit).insert !== 'undefined' &&
typeof (<InsertReplaceEdit>edit).replace !== 'undefined'
@ -237,9 +228,7 @@ function toCompletionItemKind(kind: number): languages.CompletionItemKind {
return mItemKind.Property;
}
function toTextEdit(
textEdit: cssService.TextEdit
): editor.ISingleEditOperation {
function toTextEdit(textEdit: cssService.TextEdit): editor.ISingleEditOperation {
if (!textEdit) {
return void 0;
}
@ -303,13 +292,10 @@ export class CompletionAdapter implements languages.CompletionItemProvider {
item.insertText = entry.textEdit.newText;
}
if (entry.additionalTextEdits) {
item.additionalTextEdits = entry.additionalTextEdits.map(
toTextEdit
);
item.additionalTextEdits = entry.additionalTextEdits.map(toTextEdit);
}
if (entry.insertTextFormat === cssService.InsertTextFormat.Snippet) {
item.insertTextRules =
languages.CompletionItemInsertTextRule.InsertAsSnippet;
item.insertTextRules = languages.CompletionItemInsertTextRule.InsertAsSnippet;
}
return item;
});
@ -324,9 +310,7 @@ export class CompletionAdapter implements languages.CompletionItemProvider {
function isMarkupContent(thing: any): thing is cssService.MarkupContent {
return (
thing &&
typeof thing === 'object' &&
typeof (<cssService.MarkupContent>thing).kind === 'string'
thing && typeof thing === 'object' && typeof (<cssService.MarkupContent>thing).kind === 'string'
);
}
@ -353,10 +337,7 @@ function toMarkdownString(
}
function toMarkedStringArray(
contents:
| cssService.MarkupContent
| cssService.MarkedString
| cssService.MarkedString[]
contents: cssService.MarkupContent | cssService.MarkedString | cssService.MarkedString[]
): IMarkdownString[] {
if (!contents) {
return void 0;
@ -397,9 +378,7 @@ export class HoverAdapter implements languages.HoverProvider {
// --- document highlights ------
function toDocumentHighlightKind(
kind: number
): languages.DocumentHighlightKind {
function toDocumentHighlightKind(kind: number): languages.DocumentHighlightKind {
switch (kind) {
case cssService.DocumentHighlightKind.Read:
return languages.DocumentHighlightKind.Read;
@ -411,8 +390,7 @@ function toDocumentHighlightKind(
return languages.DocumentHighlightKind.Text;
}
export class DocumentHighlightAdapter
implements languages.DocumentHighlightProvider {
export class DocumentHighlightAdapter implements languages.DocumentHighlightProvider {
constructor(private _worker: WorkerAccessor) {}
public provideDocumentHighlights(
@ -424,10 +402,7 @@ export class DocumentHighlightAdapter
return this._worker(resource)
.then((worker) => {
return worker.findDocumentHighlights(
resource.toString(),
fromPosition(position)
);
return worker.findDocumentHighlights(resource.toString(), fromPosition(position));
})
.then((entries) => {
if (!entries) {
@ -464,10 +439,7 @@ export class DefinitionAdapter {
return this._worker(resource)
.then((worker) => {
return worker.findDefinition(
resource.toString(),
fromPosition(position)
);
return worker.findDefinition(resource.toString(), fromPosition(position));
})
.then((definition) => {
if (!definition) {
@ -493,10 +465,7 @@ export class ReferenceAdapter implements languages.ReferenceProvider {
return this._worker(resource)
.then((worker) => {
return worker.findReferences(
resource.toString(),
fromPosition(position)
);
return worker.findReferences(resource.toString(), fromPosition(position));
})
.then((entries) => {
if (!entries) {
@ -509,9 +478,7 @@ export class ReferenceAdapter implements languages.ReferenceProvider {
// --- rename ------
function toWorkspaceEdit(
edit: cssService.WorkspaceEdit
): languages.WorkspaceEdit {
function toWorkspaceEdit(edit: cssService.WorkspaceEdit): languages.WorkspaceEdit {
if (!edit || !edit.changes) {
return void 0;
}
@ -547,11 +514,7 @@ export class RenameAdapter implements languages.RenameProvider {
return this._worker(resource)
.then((worker) => {
return worker.doRename(
resource.toString(),
fromPosition(position),
newName
);
return worker.doRename(resource.toString(), fromPosition(position), newName);
})
.then((edit) => {
return toWorkspaceEdit(edit);
@ -664,11 +627,7 @@ export class DocumentColorAdapter implements languages.DocumentColorProvider {
return this._worker(resource)
.then((worker) =>
worker.getColorPresentations(
resource.toString(),
info.color,
fromRange(info.range)
)
worker.getColorPresentations(resource.toString(), info.color, fromRange(info.range))
)
.then((presentations) => {
if (!presentations) {
@ -682,9 +641,7 @@ export class DocumentColorAdapter implements languages.DocumentColorProvider {
item.textEdit = toTextEdit(presentation.textEdit);
}
if (presentation.additionalTextEdits) {
item.additionalTextEdits = presentation.additionalTextEdits.map(
toTextEdit
);
item.additionalTextEdits = presentation.additionalTextEdits.map(toTextEdit);
}
return item;
});
@ -714,9 +671,7 @@ export class FoldingRangeAdapter implements languages.FoldingRangeProvider {
end: range.endLine + 1
};
if (typeof range.kind !== 'undefined') {
result.kind = toFoldingRangeKind(
<cssService.FoldingRangeKind>range.kind
);
result.kind = toFoldingRangeKind(<cssService.FoldingRangeKind>range.kind);
}
return result;
});
@ -724,9 +679,7 @@ export class FoldingRangeAdapter implements languages.FoldingRangeProvider {
}
}
function toFoldingRangeKind(
kind: cssService.FoldingRangeKind
): languages.FoldingRangeKind {
function toFoldingRangeKind(kind: cssService.FoldingRangeKind): languages.FoldingRangeKind {
switch (kind) {
case cssService.FoldingRangeKind.Comment:
return languages.FoldingRangeKind.Comment;
@ -748,12 +701,7 @@ export class SelectionRangeAdapter implements languages.SelectionRangeProvider {
const resource = model.uri;
return this._worker(resource)
.then((worker) =>
worker.getSelectionRanges(
resource.toString(),
positions.map(fromPosition)
)
)
.then((worker) => worker.getSelectionRanges(resource.toString(), positions.map(fromPosition)))
.then((selectionRanges) => {
if (!selectionRanges) {
return;

@ -5,12 +5,6 @@
"outDir": "../out/esm",
"declaration": true,
"target": "es5",
"lib": [
"dom",
"es5",
"es2015.collection",
"es2015.promise",
"es2015.iterable"
]
"lib": ["dom", "es5", "es2015.collection", "es2015.promise", "es2015.iterable"]
}
}

@ -5,12 +5,6 @@
"outDir": "../out/amd",
"declaration": true,
"target": "es5",
"lib": [
"dom",
"es5",
"es2015.collection",
"es2015.promise",
"es2015.iterable"
]
"lib": ["dom", "es5", "es2015.collection", "es2015.promise", "es2015.iterable"]
}
}

@ -21,14 +21,9 @@ export class WorkerManager {
constructor(defaults: LanguageServiceDefaults) {
this._defaults = defaults;
this._worker = null;
this._idleCheckInterval = window.setInterval(
() => this._checkIfIdle(),
30 * 1000
);
this._idleCheckInterval = window.setInterval(() => this._checkIfIdle(), 30 * 1000);
this._lastUsedTime = 0;
this._configChangeListener = this._defaults.onDidChange(() =>
this._stopWorker()
);
this._configChangeListener = this._defaults.onDidChange(() => this._stopWorker());
}
private _stopWorker(): void {

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save