Skip to content

Commit

Permalink
Fix rule definitions in errors.tslint.json/warnings.tslint.json
Browse files Browse the repository at this point in the history
Opening error.tslint.json/warnings.tslint.json in Theia, I noticed it
complains about them not matching the expected schema.  It turns out
that the error ones should not have the "options" field.  For the
warnings one, we do not need to specify "true" if we provide options for
the rule (it's implied).

This patch fixes that, as well as some files that were infringing the
indent rule (treated as an error).  I verified that we get the same
warnings as before.

Change-Id: Iec23facc5ca4cca4e22cf964f873ef37d59ffe37
Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
  • Loading branch information
Simon Marchi authored and benoitf committed Dec 4, 2018
1 parent 8feee94 commit ad5ad5b
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 216 deletions.
62 changes: 26 additions & 36 deletions configs/errors.tslint.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
{
"defaultSeverity": "error",
"rules": {
"arrow-parens": {
"options": [
true,
"ban-single-arg-parens"
]
},
"arrow-return-shorthand": {
"options": [
true,
"multiline"
]
},
"arrow-parens": [
true,
"ban-single-arg-parens"
],
"arrow-return-shorthand": [
true,
"multiline"
],
"class-name": true,
"comment-format": [
true,
Expand All @@ -25,13 +21,11 @@
"SPDX-License-Identifier: EPL-2\\.0 OR GPL-2\\.0 WITH Classpath-exception-2\\.0"
],
"forin": true,
"indent": {
"options": [
true,
"spaces",
4
]
},
"indent": [
true,
"spaces",
4
],
"interface-over-type-literal": true,
"jsdoc-format": [
true,
Expand All @@ -58,23 +52,19 @@
"check-whitespace"
],
"one-variable-per-declaration": true,
"prefer-const": {
"options": [
true,
{
"destructuring": "all"
}
]
},
"quotemark": {
"options": [
true,
"single",
"jsx-single",
"avoid-escape",
"avoid-template"
]
},
"prefer-const": [
true,
{
"destructuring": "all"
}
],
"quotemark": [
true,
"single",
"jsx-single",
"avoid-escape",
"avoid-template"
],
"radix": false,
"semicolon": [
true,
Expand Down
7 changes: 2 additions & 5 deletions configs/warnings.tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
"await-promise": {
"severity": "warning",
"options": [
true,
"Thenable"
]
},
"no-any": {
"severity": "warning",
"options": true
"severity": "warning"
},
"no-implicit-dependencies": {
"severity": "warning",
Expand Down Expand Up @@ -45,8 +43,7 @@
]
},
"no-return-await": {
"severity": "warning",
"options": true
"severity": "warning"
},
"no-void-expression": {
"severity": "warning",
Expand Down
74 changes: 37 additions & 37 deletions packages/plugin-ext/src/api/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ export interface Completion {
export interface SingleEditOperation {
range: Range;
text: string;
/**
* This indicates that this operation has "insert" semantics.
* i.e. forceMoveMarkers = true => if `range` is collapsed, all markers at the position will be moved.
*/
/**
* This indicates that this operation has "insert" semantics.
* i.e. forceMoveMarkers = true => if `range` is collapsed, all markers at the position will be moved.
*/
forceMoveMarkers?: boolean;
}

Expand Down Expand Up @@ -344,42 +344,42 @@ export interface WorkspaceEdit {
}

export enum SymbolKind {
File = 0,
Module = 1,
Namespace = 2,
Package = 3,
Class = 4,
Method = 5,
Property = 6,
Field = 7,
Constructor = 8,
Enum = 9,
Interface = 10,
Function = 11,
Variable = 12,
Constant = 13,
String = 14,
Number = 15,
Boolean = 16,
Array = 17,
Object = 18,
Key = 19,
Null = 20,
EnumMember = 21,
Struct = 22,
Event = 23,
Operator = 24,
TypeParameter = 25
File = 0,
Module = 1,
Namespace = 2,
Package = 3,
Class = 4,
Method = 5,
Property = 6,
Field = 7,
Constructor = 8,
Enum = 9,
Interface = 10,
Function = 11,
Variable = 12,
Constant = 13,
String = 14,
Number = 15,
Boolean = 16,
Array = 17,
Object = 18,
Key = 19,
Null = 20,
EnumMember = 21,
Struct = 22,
Event = 23,
Operator = 24,
TypeParameter = 25
}

export interface DocumentSymbol {
name: string;
detail: string;
kind: SymbolKind;
containerName?: string;
range: Range;
selectionRange: Range;
children?: DocumentSymbol[];
name: string;
detail: string;
kind: SymbolKind;
containerName?: string;
range: Range;
selectionRange: Range;
children?: DocumentSymbol[];
}

export interface WorkspaceFoldersChangeEvent {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/main/browser/languages-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export class LanguagesMainImpl implements LanguagesMain {
}
}
this.disposables.set(handle, disposable);
}
}

protected createDocumentSymbolProvider(handle: number, selector: LanguageSelector | undefined): monaco.languages.DocumentSymbolProvider {
return {
Expand Down
92 changes: 46 additions & 46 deletions packages/plugin-ext/src/plugin/languages/lens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,58 +26,58 @@ import { CommandsConverter } from '../command-registry';
/** Adapts the calls from main to extension thread for providing/resolving the code lenses. */
export class CodeLensAdapter {

private static readonly BAD_CMD: theia.Command = { id: 'missing', label: '<<MISSING COMMAND>>' };
private static readonly BAD_CMD: theia.Command = { id: 'missing', label: '<<MISSING COMMAND>>' };

private cacheId = 0;
private cache = new Map<number, theia.CodeLens>();
private cacheId = 0;
private cache = new Map<number, theia.CodeLens>();

constructor(
private readonly provider: theia.CodeLensProvider,
private readonly documents: DocumentsExtImpl,
private readonly commands: CommandsConverter
) { }
constructor(
private readonly provider: theia.CodeLensProvider,
private readonly documents: DocumentsExtImpl,
private readonly commands: CommandsConverter
) { }

provideCodeLenses(resource: URI): Promise<CodeLensSymbol[] | undefined> {
const document = this.documents.getDocumentData(resource);
if (!document) {
return Promise.reject(new Error(`There is no document for ${resource}`));
}
provideCodeLenses(resource: URI): Promise<CodeLensSymbol[] | undefined> {
const document = this.documents.getDocumentData(resource);
if (!document) {
return Promise.reject(new Error(`There is no document for ${resource}`));
}

const doc = document.document;
const doc = document.document;

return Promise.resolve(this.provider.provideCodeLenses(doc, createToken())).then(lenses => {
if (Array.isArray(lenses)) {
return lenses.map(lens => {
const id = this.cacheId++;
const lensSymbol = ObjectIdentifier.mixin({
range: Converter.fromRange(lens.range)!,
command: this.commands.toInternal(lens.command)
}, id);
this.cache.set(id, lens);
return lensSymbol;
});
}
return undefined;
});
}
return Promise.resolve(this.provider.provideCodeLenses(doc, createToken())).then(lenses => {
if (Array.isArray(lenses)) {
return lenses.map(lens => {
const id = this.cacheId++;
const lensSymbol = ObjectIdentifier.mixin({
range: Converter.fromRange(lens.range)!,
command: this.commands.toInternal(lens.command)
}, id);
this.cache.set(id, lens);
return lensSymbol;
});
}
return undefined;
});
}

resolveCodeLens(resource: URI, symbol: CodeLensSymbol): Promise<CodeLensSymbol | undefined> {
const lens = this.cache.get(ObjectIdentifier.of(symbol));
if (!lens) {
return Promise.resolve(undefined);
}
resolveCodeLens(resource: URI, symbol: CodeLensSymbol): Promise<CodeLensSymbol | undefined> {
const lens = this.cache.get(ObjectIdentifier.of(symbol));
if (!lens) {
return Promise.resolve(undefined);
}

let resolve: Promise<theia.CodeLens | undefined>;
if (typeof this.provider.resolveCodeLens !== 'function' || lens.isResolved) {
resolve = Promise.resolve(lens);
} else {
resolve = Promise.resolve(this.provider.resolveCodeLens(lens, createToken()));
}
let resolve: Promise<theia.CodeLens | undefined>;
if (typeof this.provider.resolveCodeLens !== 'function' || lens.isResolved) {
resolve = Promise.resolve(lens);
} else {
resolve = Promise.resolve(this.provider.resolveCodeLens(lens, createToken()));
}

return resolve.then(newLens => {
newLens = newLens || lens;
symbol.command = this.commands.toInternal(newLens.command || CodeLensAdapter.BAD_CMD);
return symbol;
});
}
return resolve.then(newLens => {
newLens = newLens || lens;
symbol.command = this.commands.toInternal(newLens.command || CodeLensAdapter.BAD_CMD);
return symbol;
});
}
}
Loading

0 comments on commit ad5ad5b

Please sign in to comment.