Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// ignore whitespace
continue;
case '\n':
// escape this newline
j = k;
continue nameLoop;
}
}
continue;
}
escapedName += char;
}
variables.push(new Variable(
escapedName,
Range.create(this.document.positionAt(offset + i + 1), this.document.positionAt(offset + arg.length)),
Range.create(this.document.positionAt(offset + i), this.document.positionAt(offset + arg.length))
));
}
break variableLoop;
}
}
return variables;
}
}
//遍历fields
for (let idx = 0, len = node['fields'].length; idx < len; idx++) {
let idxNode = node['fields'][idx];
if (type === travelMode.BUILD) {
if (idxNode['type'] === 'TableKeyString') {
//L
let retInfo = this.buildLvalueSymbals(idxNode['key'], type, deepLayer, prefix, baseInfo);
//R
this.buildRvalueSymbals(idxNode["value"], type, deepLayer, prefix, retInfo);
}
if (idxNode['type'] === 'TableKey') {
if(idxNode['key']['type'] === "StringLiteral"){
// L
let orgname = idxNode['key']['value'];
let displayName = baseInfo.name + '.' + orgname;
let rg = Location.create(this.docInfo["docUri"], Range.create(Position.create(idxNode['loc']["start"]["line"] - 1, idxNode['loc']["start"]["column"]), Position.create(idxNode['loc']["end"]["line"] - 1, idxNode['loc']["end"]["column"])));
let symb = this.createSymbolInfo( displayName, displayName, orgname, SymbolKind.Variable, rg, baseInfo.isLocal, prefix, deepLayer.concat());
this.pushToAutoList(symb);
let retInfo = {name: displayName, isLocal: baseInfo.isLocal};
// R
this.buildRvalueSymbals(idxNode["value"], type, deepLayer, prefix, retInfo);
}
if(idxNode['key']['type'] === "NumericLiteral"){
// L
let orgname = idxNode['key']['raw']; //TODO 【orgname】
let displayName = baseInfo.name + '[' + orgname + ']';
let rg = Location.create(this.docInfo["docUri"], Range.create(Position.create(idxNode['loc']["start"]["line"] - 1, idxNode['loc']["start"]["column"]), Position.create(idxNode['loc']["end"]["line"] - 1, idxNode['loc']["end"]["column"])));
let symb = this.createSymbolInfo( displayName, displayName, orgname, SymbolKind.Variable, rg, baseInfo.isLocal, prefix, deepLayer.concat());
this.pushToAutoList(symb);
let retInfo = {name: displayName, isLocal: baseInfo.isLocal};
// R
const resolved = this.resolverService.resolve(
node.toLocation(uri),
kosPath,
);
if (empty(resolved)) {
return undefined;
}
// resolve to the file system
const found = this.ioService.exists(resolved);
return (
found &&
Location.create(
found.toString(),
Range.create(Position.create(0, 0), Position.create(0, 0)),
)
);
}
return undefined;
}
const { declared } = token.tracker;
// exit if undefined
if (declared.uri === builtIn) {
return undefined;
}
return typeof declared.symbol.name !== 'string'
? declared.symbol.name
argStart = i;
}
// non-whitespace encountered, skip the escape and process the
// character normally
continue argumentLoop;
}
case '\'':
case '"':
if (argStart === -1) {
argStart = i;
}
for (let j = i + 1; j < content.length; j++) {
switch (content.charAt(j)) {
case char:
args.push(new Argument(content.substring(argStart, j + 1), content.substring(argStart, j + 1),
Range.create(this.document.positionAt(instructionNameEndOffset + start + argStart), this.document.positionAt(instructionNameEndOffset + start + j + 1))
));
i = j;
argStart = -1;
continue argumentLoop;
case this.escapeChar:
j++;
break;
}
}
break argumentLoop;
case ' ':
case '\t':
if (argStart !== -1) {
args.push(new Argument(content.substring(argStart, i), content.substring(argStart, i),
Range.create(this.document.positionAt(instructionNameEndOffset + start + argStart), this.document.positionAt(instructionNameEndOffset + start + i))
));
function convertRange(range: DiagnosticTextRange): Range {
return Range.create(convertPosition(range.start),
convertPosition(range.end));
}
constructor(symbol: T, public type: IType) {
this.declared = {
symbol,
type,
uri: builtIn,
range: Range.create(Position.create(0, 0), Position.create(0, 0)),
};
}
return results.map(r => Location.create(Uri.file(r.file).toString(),
Range.create(r.line, r.column, r.line, r.column + r.entity.length))
);
let XRegExp = require('xregexp');
let range: Range;
let match;
//start off generating a new suppression. If its going on the same line as the finding look for the
//newline (if it exists) and insert just before it
if(this.dsSettings.suppressionCommentPlacement == "same line as finding")
{
//check to see if this is the end of the document or not, as there is no newline at the end
match = XRegExp.exec(documentContents, DocumentUtilities.newlinePattern, startCharacter);
if (match)
{
let columnStart = (lineStart == 0)
? match.index
: match.index - documentContents.substr(0, match.index).lastIndexOf("\n") - 1;
range = Range.create(lineStart, columnStart, lineStart, columnStart + match[0].length);
documentContents = documentContents.substr(0, match.index);
}
else
{
//replace with end of file
let columnStart = (lineStart == 0)
? documentContents.length
: documentContents.length - documentContents.lastIndexOf("\n") - 1;
range = Range.create(lineStart, columnStart, lineStart, columnStart);
}
}
//if the suppression goes on the line above the logic is much simpler - we just insert at the front
//of the line and below we add a newline at the end of the suppression
else
{
range = Range.create(lineStart, 0, lineStart, 0);
function convertRange(document: TextDocument, span: ts.TextSpan): Range {
const startPosition = document.positionAt(span.start);
const endPosition = document.positionAt(span.start + span.length);
return Range.create(startPosition, endPosition);
}
private static elmMakeIssueToDiagnostic(issue: IElmIssue): Diagnostic {
const lineRange: Range = Range.create(
issue.region.start.line - 1,
issue.region.start.column - 1,
issue.region.end.line - 1,
issue.region.end.column - 1,
);
const messagePrefix = issue.overview ? `${issue.overview} - ` : "";
return Diagnostic.create(
lineRange,
`${messagePrefix}${issue.details.replace(/\[\d+m/g, "")}`,
this.severityStringToDiagnosticSeverity(issue.type),
undefined,
"Elm",
);
}