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

To help you get started, we’ve selected a few vscode-languageserver-types 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 chemzqm / wxml-languageserver / src / services / wxmlComplete.ts View on Github external
function collectCharacterEntityProposals(): CompletionList {
    // character entities
    let k = offset - 1
    let characterStart = position.character
    while (k >= 0 && isLetterOrDigit(text, k)) {
      k--
      characterStart--
    }
    if (k >= 0 && text[k] === '&') {
      let range = Range.create(
        Position.create(position.line, characterStart - 1),
        position,
      )
      for (let entity in entities) {
        if (endsWith(entity, ';')) {
          const label = '&' + entity
          result.items.push({
            label,
            kind: CompletionItemKind.Keyword,
            documentation: `Character entity representing '${entities[entity]}'`,
            textEdit: TextEdit.replace(range, label),
            insertTextFormat: InsertTextFormat.PlainText,
          })
        }
      }
    }
github vuejs / vetur / server / src / modes / script / javascript.ts View on Github external
...change.textChanges.map(tc => {
          // currently, only import codeAction is available
          // change start of doc to start of script region
          if (tc.span.start === 0 && tc.span.length === 0) {
            const region = regionStart.get(doc);
            if (region) {
              const line = region.start.line;
              return {
                range: Range.create(line + 1, 0, line + 1, 0),
                newText: tc.newText
              };
            }
          }
          return {
            range: convertRange(doc, tc.span),
            newText: tc.newText
          };
        })
      );
github neoclide / coc-css / server / pathCompletion.ts View on Github external
function shiftRange(range: Range, startOffset: number, endOffset: number): Range {
	const start = shiftPosition(range.start, startOffset);
	const end = shiftPosition(range.end, endOffset);
	return Range.create(start, end);
}
github vuejs / vetur / server / src / modes / template / services / htmlLinks.ts View on Github external
): DocumentLink | null {
  const documentUri = Uri.parse(document.uri);
  const tokenContent = stripQuotes(attributeValue);
  if (tokenContent.length === 0) {
    return null;
  }
  if (tokenContent.length < attributeValue.length) {
    startOffset++;
    endOffset--;
  }
  const workspaceUrl = getWorkspaceUrl(documentUri, tokenContent, documentContext, base);
  if (!workspaceUrl || !isValidURI(workspaceUrl)) {
    return null;
  }
  return {
    range: Range.create(document.positionAt(startOffset), document.positionAt(endOffset)),
    target: workspaceUrl
  };
}
github neoclide / coc.nvim / src / list / source / location.ts View on Github external
locs.forEach(loc => {
      if (!loc.uri) {
        let fullpath = path.isAbsolute(loc.filename) ? loc.filename : path.join(context.cwd, loc.filename)
        loc.uri = URI.file(fullpath).toString()
      }
      if (!loc.bufnr && workspace.getDocument(loc.uri) != null) {
        loc.bufnr = workspace.getDocument(loc.uri).bufnr
      }
      if (!loc.range) {
        let { lnum, col } = loc
        loc.range = Range.create(lnum - 1, col - 1, lnum - 1, col - 1)
      } else {
        loc.lnum = loc.lnum || loc.range.start.line + 1
        loc.col = loc.col || loc.range.start.character + 1
      }
    })
    let bufnr = await this.nvim.call('bufnr', '%')
github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / lg / server / src / lg-server.ts View on Github external
end = idx;
          break;
        } else {
          lastIdx = idx;
        }
      }
      if (idx === lineText.length - 1) {
        start = lineText.lastIndexOf(' ') + 1;
        end = idx + 1;
      }
    }

    if (start < 0 || end < 0) {
      return;
    } else {
      range = Range.create(line, start, line, end);
    }

    return range;
  }
github eclipse-theia / theia / packages / languages / src / browser / workspace-symbols.ts View on Github external
this.openerService.getOpener(uri).then(opener => opener.open(uri, {
                selection: Range.create(sym.location.range.start, sym.location.range.start),
            }));
        });
github vuejs / vetur / server / src / modes / style / stylus / symbols-finder.ts View on Github external
function _variableSymbol(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 range = Range.create(lineno, column, lineno, column + name.length);

  return SymbolInformation.create(name, SymbolKind.Variable, range);
}
github neoclide / coc.nvim / src / handler / refactor.ts View on Github external
function adjustRange(range: Range, offset: number): Range {
  let { start, end } = range
  return Range.create(start.line - offset, start.character, end.line - offset, end.character)
}
github recca0120 / vscode-phpunit / server / src / phpunit / textline-range.ts View on Github external
private createRange(lines: string[], lineAt: number): Range {
        const line: string = lines[lineAt];
        const firstNonWhitespaceCharacterIndex: number = line.search(/\S|$/);

        return Range.create(
            {
                line: lineAt,
                character: firstNonWhitespaceCharacterIndex,
            },
            {
                line: lineAt,
                character: firstNonWhitespaceCharacterIndex + line.trim().length,
            }
        );
    }