Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function adjustPosition(position: Position, delta: Position): Position {
let { line, character } = delta
return Position.create(position.line + line, line == 0 ? position.character + character : character)
}
function _selectorSymbol(node: StylusNode, text: string[]): SymbolInformation {
const firstSegment = node.segments[0];
const name = firstSegment.string
? node.segments.map(s => s.string).join('')
: firstSegment.nodes!.map(s => s.name).join('');
const lineno = Number(firstSegment.lineno) - 1;
const column = node.column - 1;
const posStart = Position.create(lineno, column);
const posEnd = Position.create(lineno, column + name.length);
const range = Range.create(posStart, posEnd);
return SymbolInformation.create(name, SymbolKind.Class, range);
}
function getReplaceRange(valueRange: Range, valueAfterLastSlash: string) {
const start = Position.create(valueRange.end.line, valueRange.end.character - valueAfterLastSlash.length);
const end = Position.create(valueRange.end.line, valueRange.end.character);
return Range.create(start, end);
}
function getRangeWithoutQuotes(range: Range) {
function getFullReplaceRange(valueRange: Range) {
const start = Position.create(valueRange.end.line, valueRange.start.character);
const end = Position.create(valueRange.end.line, valueRange.end.character);
return Range.create(start, end);
}
function getReplaceRange(valueRange: Range, valueAfterLastSlash: string) {
function _selectorCallSymbol(node: StylusNode, text: string[]): SymbolInformation {
const lineno = Number(node.lineno) - 1;
const name = prepareName(text[lineno]);
const column = Math.max(text[lineno].indexOf(name), 0);
const posStart = Position.create(lineno, column);
const posEnd = Position.create(lineno, column + name.length);
return SymbolInformation.create(name, SymbolKind.Class, Range.create(posStart, posEnd));
}
function getEOL(document: TextDocument): string {
let text = document.getText();
if (document.lineCount > 1) {
let to = document.offsetAt(Position.create(1, 0));
let from = to;
while (from > 0 && isEOL(text, from - 1)) {
from--;
}
return text.substr(from, to - from);
}
return '\n';
}
function _functionSymbol(node: StylusNode, text: string[]): SymbolInformation {
const name = node.name;
const lineno = Number(node.val!.lineno) - 1;
const column = Math.max(text[lineno].indexOf(name), 0);
const posStart = Position.create(lineno, column);
const posEnd = Position.create(lineno, column + name.length);
const range = Range.create(posStart, posEnd);
return SymbolInformation.create(name, SymbolKind.Function, range);
}
lgDiags.forEach(diag => {
let diagnostic: Diagnostic = {
severity: this.convertSeverity(diag.Severity),
range: {
start: Position.create(diag.Range.Start.Line, diag.Range.Start.Character),
end: Position.create(diag.Range.End.Line, diag.Range.End.Character),
},
message: diag.Message,
source: document.uri,
};
diagnostics.push(diagnostic);
});
function fromPositionToP(p: theia.Position): P {
return P.create(p.line, p.character);
}