How to use the vscode-languageserver-types.TextDocument.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 vuejs / vetur / server / src / services / typescriptService / preprocess.ts View on Github external
export function parseVueTemplate(text: string): string {
  const doc = TextDocument.create('test://test/test.vue', 'vue', 0, text);
  const regions = getVueDocumentRegions(doc);
  const template = regions.getSingleTypeDocument('template');

  if (template.languageId !== 'vue-html') {
    return '';
  }
  const rawText = template.getText();
  // skip checking on empty template
  if (rawText.replace(/\s/g, '') === '') {
    return '';
  }
  return rawText.replace(/ {10}/, '<template>') + '</template>';
}
github vuejs / vetur / server / src / modes / test-util / completion-test-util.ts View on Github external
return function test([value]: TemplateStringsArray) {
    const offset = value.indexOf('|');
    value = value.substr(0, offset) + value.substr(offset + 1);

    const document = TextDocument.create(setup.docUri, setup.langId, 0, value);
    const position = document.positionAt(offset);
    const items = setup.doComplete(document, position).items;
    return new CompletionAsserter(items, document);
  };
}
github vuejs / vetur / server / src / embeddedSupport / embeddedSupport.ts View on Github external
const oldContent = document.getText();
  let newContent = oldContent
    .split('\n')
    .map(line => ' '.repeat(line.length))
    .join('\n');

  let langId: string = defaultLanguageIdForBlockTypes[type];

  for (const r of regions) {
    if (r.type === type) {
      newContent = newContent.slice(0, r.start) + oldContent.slice(r.start, r.end) + newContent.slice(r.end);
      langId = r.languageId;
    }
  }

  return TextDocument.create(document.uri, langId, document.version, newContent);
}
github crapo / sadlos2 / sadl3 / com.ge.research.sadl.parent / io.typefox.lsp.monaco / src / main / ts / documentManager / documentManager.ts View on Github external
protected createDocument(uri: string, language: string, content: string): boolean {
        if (this.isOpened(uri)) {
            return false;
        }
        this._documents[uri] = TextDocument.create(uri, language, 1, content);
        return true;
    }
github OmarTawfik / github-actions-js / src / util / ranges.ts View on Github external
export function indexToPosition(text: string, index: number): Position {
  const document = TextDocument.create("", "", 1, text);
  return document.positionAt(index);
}
github vuejs / vetur / server / src / modes / script / javascript.ts View on Github external
function getSourceDoc(fileName: string, program: ts.Program): TextDocument {
  const sourceFile = program.getSourceFile(fileName)!;
  return TextDocument.create(fileName, 'vue', 0, sourceFile.getFullText());
}
github crapo / sadlos2 / sadl3 / com.ge.research.sadl.parent / io.typefox.lsp.monaco / src / main / ts / documentManager / documentManager.ts View on Github external
protected updateDocument(uri: string, content: string): boolean {
        const document = this._documents[uri];
        if (!document) {
            return false;
        }
        if (document.getText() === content) {
            return false;
        }
        const version = document.version + 1;
        this._documents[uri] = TextDocument.create(document.uri, document.languageId, version, content);
        return true;
    }
github vuejs / vetur / server / src / services / typescriptService / preprocess.ts View on Github external
export function parseVueScript(text: string): string {
  const doc = TextDocument.create('test://test/test.vue', 'vue', 0, text);
  const regions = getVueDocumentRegions(doc);
  const script = regions.getSingleTypeDocument('script');
  return script.getText() || 'export default {};';
}
github vuejs / vetur / server / src / modes / template / interpolationMode.ts View on Github external
function getSourceDoc(fileName: string, program: ts.Program): TextDocument {
  const sourceFile = program.getSourceFile(fileName)!;
  return TextDocument.create(fileName, 'vue', 0, sourceFile.getFullText());
}