How to use the vscode-languageserver.Range.create function in vscode-languageserver

To help you get started, we’ve selected a few vscode-languageserver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rcjsuen / dockerfile-language-server-nodejs / src / parser / instruction.ts View on Github external
// 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;
	}
}
github Tencent / LuaPanda / src / code / server / docSymbolProcesser.ts View on Github external
//遍历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
github jonnyboyC / kos-language-server / server / src / kls.ts View on Github external
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
github rcjsuen / dockerfile-language-server-nodejs / src / parser / instructions / propertyInstruction.ts View on Github external
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))
						));
github microsoft / pyright / server / src / languageService / documentSymbolProvider.ts View on Github external
function convertRange(range: DiagnosticTextRange): Range {
    return Range.create(convertPosition(range.start),
        convertPosition(range.end));
}
github jonnyboyC / kos-language-server / server / src / analysis / models / typeTracker.ts View on Github external
constructor(symbol: T, public type: IType) {
    this.declared = {
      symbol,
      type,
      uri: builtIn,
      range: Range.create(Position.create(0, 0), Position.create(0, 0)),
    };
  }
github area9innovation / flow9 / resources / vscode / flow / src / flow_language_server.ts View on Github external
return results.map(r => Location.create(Uri.file(r.file).toString(), 
			Range.create(r.line, r.column, r.line, r.column + r.entity.length))
		);
github microsoft / DevSkim-VSCode-Plugin / server / src / utility_classes / suppressions.ts View on Github external
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);
github marko-js / language-server / server / src / util-old / javascript.ts View on Github external
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);
}
github elm-tooling / elm-language-server / src / providers / diagnostics / elmDiagnosticsHelper.ts View on Github external
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",
    );
  }