当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript IConnection.onDocumentSymbol方法代码示例

本文整理汇总了TypeScript中vscode-languageserver.IConnection.onDocumentSymbol方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IConnection.onDocumentSymbol方法的具体用法?TypeScript IConnection.onDocumentSymbol怎么用?TypeScript IConnection.onDocumentSymbol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vscode-languageserver.IConnection的用法示例。


在下文中一共展示了IConnection.onDocumentSymbol方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: constructor

  constructor(
      protected connection: IConnection,
      private converter: AnalyzerLSPConverter,
      private featureFinder: FeatureFinder, private analyzer: LsAnalyzer,
      settings: Settings) {
    super();

    this.connection.onDefinition(async(textPosition) => {
      return this.handleErrors(
          this.getDefinition(textPosition), undefined) as Promise<Definition>;
    });

    this.connection.onReferences(async(params) => {
      return this.handleErrors(this.getReferences(params), []);
    });

    this.connection.onWorkspaceSymbol(async(params) => {
      const analysis =
          await this.analyzer.analyzePackage('get workspace symbols');
      const symbols = this.findSymbols(analysis);
      return fuzzaldrin.filter(symbols, params.query, {key: 'name'});
    });

    this.connection.onDocumentSymbol(async(params) => {
      const localPath = converter.getWorkspacePathToFile(params.textDocument);
      const analysis =
          await this.analyzer.analyze([localPath], 'get document symbols');
      const maybeDocument = analysis.getDocument(localPath);
      if (!(maybeDocument instanceof Document)) {
        return [];
      }
      return this.findSymbols(maybeDocument);
    });

    this.connection.onCodeLens(async(params) => {
      const lenses = [];
      if (settings.referencesCodeLens) {
        lenses.push(...await this.handleErrors(this.getCodeLenses(params), []));
      }
      return lenses;
    });
  }
开发者ID:asdfg9822,项目名称:polymer-editor-service,代码行数:42,代码来源:definition-finder.ts

示例2: constructor

  constructor(
      protected connection: IConnection,
      private converter: AnalyzerLSPConverter,
      private featureFinder: FeatureFinder, private analyzer: LsAnalyzer,
      settings: Settings) {
    super();
    this.connection.onDefinition(async(textPosition) => {
      return this.handleErrors(this.getDefinition(textPosition), null);
    });

    this.connection.onReferences(async(params) => {
      return this.handleErrors(this.getReferences(params), []);
    });

    this.connection.onWorkspaceSymbol(async(params) => {
      const analysis =
          await this.analyzer.analyzePackage({reason: 'get workspace symbols'});
      const symbols = this.findSymbols(analysis);
      return fuzzaldrin.filter(symbols, params.query, {key: 'name'});
    });

    this.connection.onDocumentSymbol(async(params) => {
      const url = params.textDocument.uri;
      const analysis =
          await this.analyzer.analyze([url], {reason: 'get document symbols'});
      const result = analysis.getDocument(url);
      if (!result.successful) {
        return [];
      }
      return this.findSymbols(result.value);
    });

    this.connection.onCodeLens(async(params) => {
      const lenses = [];
      if (settings.referencesCodeLens) {
        lenses.push(...await this.handleErrors(this.getCodeLenses(params), []));
      }
      return lenses;
    });
  }
开发者ID:MehdiRaash,项目名称:tools,代码行数:40,代码来源:definition-finder.ts

示例3: pushAll

	};
	let links: DocumentLink[] = [];
	languageModes.getAllModesInDocument(document).forEach(m => {
		if (m.findDocumentLinks) {
			pushAll(links, m.findDocumentLinks(document, documentContext));
		}
	});
	return links;
});

connection.onDocumentSymbol(documentSymbolParms => {
	let document = documents.get(documentSymbolParms.textDocument.uri);
	let symbols: SymbolInformation[] = [];
	languageModes.getAllModesInDocument(document).forEach(m => {
		if (m.findDocumentSymbols) {
			pushAll(symbols, m.findDocumentSymbols(document));
		}
	});
	return symbols;
});

connection.onRequest(DocumentColorRequest.type, params => {
	let infos: ColorInformation[] = [];
	let document = documents.get(params.textDocument.uri);
	if (document) {
		languageModes.getAllModesInDocument(document).forEach(m => {
			if (m.findDocumentColors) {
				pushAll(infos, m.findDocumentColors(document));
			}
		});
	}
开发者ID:armanio123,项目名称:vscode,代码行数:31,代码来源:htmlServerMain.ts

示例4: parse

connection.onDocumentSymbol((symbolParam) => {
  try {
    if (currentSettings.parser.exportSourcemap === false) {
      connection.window.showWarningMessage('\
        The current parser options have source maps disabled.\
        Without those, it\'s not possible to generate document symbol.\
        ', { title: 'More Info' }).then(() => {
          connection.sendNotification('openUrl', getHelpUrl('#no-sourcemaps-enabled'));
        });

      return Promise.resolve([]); // I cannot let you navigate if I have no source map.
    }

    const documentObject = documents.get(symbolParam.textDocument.uri);
    let textDocument = documentObject.getText();

    if (documentObject.languageId === 'apiblueprint') {
      textDocument = utf16to8(textDocument);

      /*
        The reason why this is happening just for API Blueprint is that drafter.js
        is coming from C++ code (using es). Swagger parser is pure javascript thuos
        sourcemaps are char based and not byte based.

        See https://github.com/apiaryio/fury.js/issues/63 for more details.
      */
    }

    const documentLines = textDocument.split(/\r?\n/g);
    const refractOutput = refractDocuments.get(symbolParam.textDocument.uri.toString());

    if (typeof (refractOutput) === 'undefined') {
      return parse(textDocument, currentSettings.parser)
        .then((output) => {
          refractDocuments.set(symbolParam.textDocument.uri.toString(), output);
          return refractUtils.extractSymbols(output, textDocument, documentLines, desideredSymbols);
        });
    }

    const symbolArray = refractUtils.extractSymbols(refractOutput, textDocument, documentLines, desideredSymbols);
    return Promise.resolve(symbolArray);
  } catch (err) {
    connection.window.showErrorMessage(err.message);
  }

});
开发者ID:XVincentX,项目名称:vscode-apielements,代码行数:46,代码来源:server.ts

示例5: catch

    connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
  }
}

connection.onDocumentSymbol((symbolParam) => {
  try {
    if (currentSettings.parser.exportSourcemap === false) {
      connection.window.showWarningMessage("\
        The current parser options have source maps disabled.\
        Without those, it's not possible to generate document symbol.\
        ");

      return Promise.resolve([]); // I cannot let you navigate if I have no source map.
    }

    const textDocument = utf16to8(documents.get(symbolParam.textDocument.uri).getText());
    const documentLines = textDocument.split(/\r?\n/g);
    const refractOutput = refractDocuments.get(symbolParam.textDocument.uri.toString());

    const symbolArray = refractUtils.extractSymbols(refractOutput, textDocument, documentLines);
    return Promise.resolve(symbolArray);
  } catch(err) {
    connection.window.showErrorMessage(err.message);
  }


});

connection.onRequest({method: "parserOutput"}, (code) => {
  try {
    return parser.parse(code);
开发者ID:smizell,项目名称:vscode-apielements,代码行数:31,代码来源:server.ts


注:本文中的vscode-languageserver.IConnection.onDocumentSymbol方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。