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


TypeScript IConnection.onReferences方法代码示例

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

在下文中一共展示了IConnection.onReferences方法的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:

	return [];
});

connection.onDefinition(definitionParams => {
	let document = documents.get(definitionParams.textDocument.uri);
	let mode = languageModes.getModeAtPosition(document, definitionParams.position);
	if (mode && mode.findDefinition) {
		return mode.findDefinition(document, definitionParams.position);
	}
	return [];
});

connection.onReferences(referenceParams => {
	let document = documents.get(referenceParams.textDocument.uri);
	let mode = languageModes.getModeAtPosition(document, referenceParams.position);
	if (mode && mode.findReferences) {
		return mode.findReferences(document, referenceParams.position);
	}
	return [];
});

connection.onSignatureHelp(signatureHelpParms => {
	let document = documents.get(signatureHelpParms.textDocument.uri);
	let mode = languageModes.getModeAtPosition(document, signatureHelpParms.position);
	if (mode && mode.doSignatureHelp) {
		return mode.doSignatureHelp(document, signatureHelpParms.position);
	}
	return null;
});

connection.onDocumentRangeFormatting(async formatParams => {
	let document = documents.get(formatParams.textDocument.uri);
开发者ID:armanio123,项目名称:vscode,代码行数:32,代码来源:htmlServerMain.ts


示例4: initStylableLanguageService


//.........这里部分代码省略.........
                            .concat(newCssService.getDiagnostics(doc));
                    }
                    connection.sendDiagnostics({ uri: doc.uri, diagnostics });
                }
            }
        });
    }

    // docsDispatcher.onDidOpen(diagnose);
    docsDispatcher.onDidChangeContent(diagnose);

    connection.onDidChangeConfiguration(diagnose);

    connection.onDefinition(
        async (params): Promise<Definition> => {
            const doc = fs.loadTextFileSync(params.textDocument.uri);
            const pos = params.position;

            const res = await provider
                .getDefinitionLocation(doc, {
                    line: pos.line,
                    character: pos.character
                }, fromVscodePath(params.textDocument.uri), fs);
            return res.map(loc => Location.create(toVscodePath(loc.uri), loc.range));
        }
    );

    connection.onHover(
        (params: TextDocumentPositionParams): Hover | null => {
            return newCssService.doHover(fs.get(params.textDocument.uri), params.position);
        }
    );

    connection.onReferences(
        (params: ReferenceParams): Location[] => {
            const refs = getRefs(params, fs, services.styl);
            if (refs.length) {
                return dedupeRefs(refs);
            } else {
                return dedupeRefs(newCssService.findReferences(fs.get(params.textDocument.uri), params.position));
            }
        }
    );

    connection.onDocumentFormatting(() => {
        return null;
    });

    connection.onDocumentColor((params: DocumentColorParams) => {
        const document = fs.get(params.textDocument.uri);
        return resolveDocumentColors(services.styl, newCssService, document);
    });

    connection.onColorPresentation((params: ColorPresentationParams) => {
        const document = fs.get(params.textDocument.uri);

        return getColorPresentation(newCssService, document, params);
    });

    connection.onRenameRequest(
        (params): WorkspaceEdit => {
            const edit: WorkspaceEdit = { changes: {} };
            getRenameRefs(
                {
                    context: { includeDeclaration: true },
                    position: params.position,
开发者ID:wix,项目名称:stylable-intelligence,代码行数:67,代码来源:service.ts


示例5: constructor


//.........这里部分代码省略.........
                    } catch (e) {
                        console.error(params, e);
                        return resolve([]);
                    }
                }, function () {
                    return reject()
                });
            });
        });

        this.connection.onHover((params: TextDocumentPositionParams): Promise<Hover> => {
            const enter = new Date().getTime();
            return new Promise<Hover>(function (resolve, reject) {
                initialized.then(function () {
                    const init = new Date().getTime();
                    try {
                        let reluri = util.uri2reluri(params.textDocument.uri, workspaceRoot);
                        const quickInfo: ts.QuickInfo = service.getHover(reluri, params.position.line, params.position.character);
                        let contents = [];
                        if (quickInfo) {
                            contents.push({
                                language: 'javascript',
                                value: ts.displayPartsToString(quickInfo.displayParts)
                            });
                            let documentation = ts.displayPartsToString(quickInfo.documentation);
                            if (documentation) {
                                contents.push({ language: 'text/html', value: documentation });
                            }
                        }
                        const exit = new Date().getTime();
                        console.error('hover', params.textDocument.uri, params.position.line, params.position.character, 'total', (exit - enter) / 1000.0, 'busy', (exit - init) / 1000.0, 'wait', (init - enter) / 1000.0);
                        resolve({ contents: contents });
                    } catch (e) {
                        console.error(params, e);
                        resolve({ contents: [] });
                    }
                }, function () {
                    return reject()
                })
            });
        });

        this.connection.onReferences((params: ReferenceParams): Promise<Location[]> => {
            return new Promise<Location[]>(function (resolve, reject) {
                const enter = new Date().getTime();
                initialized.then(function () {
                    const init = new Date().getTime();
                    try {
                        // const refs: ts.ReferenceEntry[] = service.getReferences('file:///' + req.body.File, req.body.Line + 1, req.body.Character + 1);
                        let reluri = util.uri2reluri(params.textDocument.uri, workspaceRoot);
                        const refEntries: ts.ReferenceEntry[] = service.getReferences(reluri, params.position.line, params.position.character);
                        const result: Location[] = [];
                        if (refEntries) {
                            for (let ref of refEntries) {
                                let start = ts.getLineAndCharacterOfPosition(service.services.getProgram().getSourceFile(ref.fileName), ref.textSpan.start);
                                let end = ts.getLineAndCharacterOfPosition(service.services.getProgram().getSourceFile(ref.fileName), ref.textSpan.start + ref.textSpan.length);
                                result.push(Location.create(util.path2uri(workspaceRoot, ref.fileName), {
                                    start: start,
                                    end: end
                                }));

                            }
                        }
                        const exit = new Date().getTime();
                        console.error('references', params.textDocument.uri, params.position.line, params.position.character, 'total', (exit - enter) / 1000.0, 'busy', (exit - init) / 1000.0, 'wait', (init - enter) / 1000.0);
                        return resolve(result);
                    } catch (e) {
                        console.error(params, e);
                        return resolve([]);
                    }
                }, function () {
                    return reject()
                })
            });
        });

        this.connection.onRequest(GlobalRefsRequest.type, (params: WorkspaceSymbolParams): Promise<SymbolInformation[]> => {
            return new Promise<SymbolInformation[]>(function (resolve, reject) {
                initialized.then(function () {

                    try {
                        console.error('global-refs', params.query);
                        const externals = service.getExternalRefs();
                        if (externals) {
                            let res = externals.map(external => {
                                return SymbolInformation.create(external.name, util.formEmptyKind(), util.formEmptyRange(), util.formExternalUri(external));
                            });
                            return resolve(res);
                        }
                        return resolve([]);
                    } catch (e) {
                        console.error(params, e);
                        return resolve([]);
                    }
                }, function () {
                    return reject()
                })
            });
        });
    }
开发者ID:antonina-cherednichenko,项目名称:poc-jslang-server,代码行数:101,代码来源:connection.ts



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