提交 ab5e98b2 编写于 作者: J Joao Moreno

💄 tslint

上级 5be404dd
......@@ -198,7 +198,7 @@ export function createScanner(text:string, ignoreTrivia:boolean = false):JSONSca
function scanNext():SyntaxKind {
value = '';
scanError = ScanError.None,
scanError = ScanError.None;
tokenOffset = pos;
......
......@@ -330,10 +330,9 @@ class Renderer extends treeDefaults.LegacyRenderer {
var fileReferences = <model.FileReferences> element,
fileReferencesContainer = builder.$('.reference-file');
new leftRightWidget.LeftRightWidget(fileReferencesContainer, (left: HTMLElement) => {
let lrwidget = new leftRightWidget.LeftRightWidget(fileReferencesContainer, (left: HTMLElement) => {
var resource = fileReferences.resource;
new fileLabel.FileLabel(left, resource, this._contextService);
let label = new fileLabel.FileLabel(left, resource, this._contextService);
return <lifecycle.IDisposable> null;
......
......@@ -277,6 +277,8 @@ export class Scanner {
}
}
let tokenType: TokenType = void 0;
// Comment - CSS
if (this._comment()) {
if (!this.ignoreComment) {
......@@ -302,7 +304,7 @@ export class Scanner {
}
// URL
var tokenType = this._url();
tokenType = this._url();
if (tokenType !== null) {
return this.finishToken(result, tokenType);
}
......@@ -349,8 +351,8 @@ export class Scanner {
// Percentage 43%
return this.finishToken(result, TokenType.Percentage);
} else if (this.ident(content)) {
var dim = this.stream.substring(pos).toLowerCase();
var tokenType = <TokenType>staticUnitTable[dim];
let dim = this.stream.substring(pos).toLowerCase();
tokenType = <TokenType>staticUnitTable[dim];
if (typeof tokenType !== 'undefined') {
// Known dimension 43px
return this.finishToken(result, tokenType, content.join(''));
......@@ -365,13 +367,13 @@ export class Scanner {
// String, BadString
content = [];
var tokenType = this._string(content);
tokenType = this._string(content);
if (tokenType !== null) {
return this.finishToken(result, tokenType, content.join(''));
}
// single character tokens
var tokenType = <TokenType>staticTokenTable[this.stream.peekChar()];
tokenType = <TokenType>staticTokenTable[this.stream.peekChar()];
if (typeof tokenType !== 'undefined') {
this.stream.advance(1);
return this.finishToken(result, tokenType);
......
......@@ -40,7 +40,7 @@ export class Scope {
return this.findInScope(offset, length);
}
return null;
}
}
private findInScope(offset: number, length: number = 0): Scope {
// find the first scope child that has an offset larger than offset + length
......@@ -67,7 +67,7 @@ export class Scope {
var symbol = this.symbols[index];
if (symbol.name === name && symbol.type === type) {
return symbol;
}
}
}
return null;
}
......@@ -141,33 +141,35 @@ export class ScopeBuilder implements nodes.IVisitor {
return true;
case nodes.NodeType.VariableDeclaration:
this.addSymbol(node, (<nodes.VariableDeclaration> node).getName(), nodes.ReferenceType.Variable);
return true;
return true;
case nodes.NodeType.Ruleset:
return this.visitRuleSet(<nodes.RuleSet> node);
case nodes.NodeType.MixinDeclaration:
this.addSymbol(node, (<nodes.MixinDeclaration> node).getName(), nodes.ReferenceType.Mixin);
return true;
return true;
case nodes.NodeType.FunctionDeclaration:
this.addSymbol(node, (<nodes.FunctionDeclaration> node).getName(), nodes.ReferenceType.Function);
return true;
case nodes.NodeType.FunctionParameter:
return true;
case nodes.NodeType.FunctionParameter: {
// parameters are part of the body scope
var scopeNode = (<nodes.BodyDeclaration> node.getParent()).getDeclarations();
let scopeNode = (<nodes.BodyDeclaration> node.getParent()).getDeclarations();
if (scopeNode) {
this.addSymbolToChildScope(scopeNode, node, (<nodes.FunctionParameter> node).getName(), nodes.ReferenceType.Variable);
}
return true;
return true;
}
case nodes.NodeType.Declarations:
this.addScope(node);
return true;
case nodes.NodeType.For:
case nodes.NodeType.Each:
case nodes.NodeType.Each: {
var forOrEachNode = <nodes.ForStatement | nodes.EachStatement> node;
var scopeNode = forOrEachNode.getDeclarations();
let scopeNode = forOrEachNode.getDeclarations();
if (scopeNode) {
this.addSymbolToChildScope(scopeNode, forOrEachNode.variable, forOrEachNode.variable.getName(), nodes.ReferenceType.Variable);
}
return true;
return true;
}
}
return true;
}
......@@ -245,7 +247,7 @@ export class Symbols {
return null;
}
private evaluateReferenceTypes(node: nodes.Node) : nodes.ReferenceType[] {
private evaluateReferenceTypes(node: nodes.Node) : nodes.ReferenceType[] {
if (node instanceof nodes.Identifier) {
var referenceTypes = (<nodes.Identifier> node).referenceTypes;
if (referenceTypes) {
......@@ -258,7 +260,7 @@ export class Symbols {
if ((propertyName === 'animation' || propertyName === 'animation-name')
&& decl.getValue() && decl.getValue().offset === node.offset) {
return [ nodes.ReferenceType.Keyframe ];
}
}
}
}
} else if (node instanceof nodes.Variable) {
......@@ -285,7 +287,7 @@ export class Symbols {
var referenceTypes = this.evaluateReferenceTypes(node);
if (referenceTypes) {
return this.internalFindSymbol(node, referenceTypes);
return this.internalFindSymbol(node, referenceTypes);
}
return null;
}
......@@ -299,7 +301,7 @@ export class Symbols {
}
if (symbol.name.length !== node.length || symbol.name !== node.getText()) {
return false;
}
}
var referenceTypes = this.evaluateReferenceTypes(node);
if (!referenceTypes || referenceTypes.indexOf(symbol.type) === -1) {
......@@ -320,6 +322,6 @@ export class Symbols {
}
scope = scope.parent;
}
return null;
return null;
}
}
......@@ -287,7 +287,7 @@ export class LintVisitor implements nodes.IVisitor {
/////////////////////////////////////////////////////////////
// With 'display: inline', the width, height, margin-top, margin-bottom, and float properties have no effect
var displayElems = this.fetchWithValue(propertyTable, 'display', 'inline');
let displayElems = this.fetchWithValue(propertyTable, 'display', 'inline');
if (displayElems.length > 0) {
[ 'width', 'height', 'margin-top', 'margin-bottom', 'float'].forEach(function(prop) {
var elem = self.fetch(propertyTable, prop);
......@@ -298,7 +298,7 @@ export class LintVisitor implements nodes.IVisitor {
}
// With 'display: inline-block', 'float' has no effect
var displayElems = this.fetchWithValue(propertyTable, 'display', 'inline-block');
displayElems = this.fetchWithValue(propertyTable, 'display', 'inline-block');
if (displayElems.length > 0) {
var elem = this.fetch(propertyTable, 'float');
for (var index = 0; index < elem.length; index++) {
......@@ -307,7 +307,7 @@ export class LintVisitor implements nodes.IVisitor {
}
// With 'display: block', 'vertical-align' has no effect
var displayElems = this.fetchWithValue(propertyTable, 'display', 'block');
displayElems = this.fetchWithValue(propertyTable, 'display', 'block');
if (displayElems.length > 0) {
var elem = this.fetch(propertyTable, 'vertical-align');
for (var index = 0; index < elem.length; index++) {
......
......@@ -157,7 +157,7 @@ function tokenize(mode:Modes.IMode, comments:boolean, line:string, state:JSONSta
lastWasColon = false;
break;
case json.SyntaxKind.StringLiteral:
type = lastWasColon ? jsonTokenTypes.TOKEN_VALUE_STRING : jsonTokenTypes.TOKEN_PROPERTY_NAME,
type = lastWasColon ? jsonTokenTypes.TOKEN_VALUE_STRING : jsonTokenTypes.TOKEN_PROPERTY_NAME;
lastWasColon = false;
break;
case json.SyntaxKind.NumericLiteral:
......
......@@ -535,8 +535,8 @@ class CSSimpleHTML extends CSState {
this.state = htmlMode.States.OpeningStartTag;
return { type: htmlTokenTypes.DELIM_START, bracket: Modes.Bracket.Open };
case htmlMode.States.OpeningEndTag:
var tagName = this.nextName(stream);
case htmlMode.States.OpeningEndTag: {
let tagName = this.nextName(stream);
if (tagName.length > 0) {
return {
type: htmlTokenTypes.getTag(tagName),
......@@ -549,9 +549,10 @@ class CSSimpleHTML extends CSState {
}
stream.advanceUntil('>', false);
return { type: '' };
}
case htmlMode.States.OpeningStartTag:
var tagName = this.nextName(stream);
case htmlMode.States.OpeningStartTag: {
let tagName = this.nextName(stream);
if (tagName.length > 0) {
this.state = htmlMode.States.WithinTag;
return {
......@@ -560,6 +561,7 @@ class CSSimpleHTML extends CSState {
};
}
break;
}
case htmlMode.States.WithinTag:
if (stream.skipWhitespace().length > 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册