本文整理汇总了TypeScript中vscode-languageserver.IConnection.onHover方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IConnection.onHover方法的具体用法?TypeScript IConnection.onHover怎么用?TypeScript IConnection.onHover使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode-languageserver.IConnection
的用法示例。
在下文中一共展示了IConnection.onHover方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(
protected connection: IConnection,
private converter: AnalyzerLSPConverter,
private featureFinder: FeatureFinder, private readonly logger: Logger) {
super();
this.connection.onHover(async(textPosition) => {
logger.log(`Hover request: ${textPosition.position.line}:${textPosition
.position.character} in ${textPosition.textDocument}`);
return await this.handleErrors(
this.getDocsForHover(textPosition), undefined);
});
}
示例2: constructor
constructor(
protected connection: IConnection,
private converter: AnalyzerLSPConverter,
private featureFinder: FeatureFinder, private readonly logger: Logger) {
super();
this.connection.onHover(async(textPosition) => {
logger.log(`Hover request: ${textPosition.position.line}:${textPosition
.position.character} in ${textPosition.textDocument}`);
const hoverOrUndefined = await this.handleErrors(
this.getDocsForHover(textPosition), undefined);
// it is actually ok to return undefined here, but the type system
// disagrees.
return hoverOrUndefined as Hover;
});
}
示例3:
connection.onCompletionResolve(item => {
let data = item.data;
if (data && data.languageId && data.uri) {
let mode = languageModes.getMode(data.languageId);
let document = documents.get(data.uri);
if (mode && mode.doResolve && document) {
return mode.doResolve(document, item);
}
}
return item;
});
connection.onHover(textDocumentPosition => {
let document = documents.get(textDocumentPosition.textDocument.uri);
let mode = languageModes.getModeAtPosition(document, textDocumentPosition.position);
if (mode && mode.doHover) {
return mode.doHover(document, textDocumentPosition.position);
}
return null;
});
connection.onDocumentHighlight(documentHighlightParams => {
let document = documents.get(documentHighlightParams.textDocument.uri);
let mode = languageModes.getModeAtPosition(document, documentHighlightParams.position);
if (mode && mode.findDocumentHighlight) {
return mode.findDocumentHighlight(document, documentHighlightParams.position);
}
return [];
});
connection.onDefinition(definitionParams => {
let document = documents.get(definitionParams.textDocument.uri);
示例4: createConnection
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {createConnection, Hover, IConnection, InitializeResult, IPCMessageReader, IPCMessageWriter} from 'vscode-languageserver';
const connection: IConnection = createConnection(
new IPCMessageReader(process), new IPCMessageWriter(process));
connection.onInitialize((params): InitializeResult => {
return {
capabilities: {hoverProvider: true}
}
});
connection.onHover(async(params): Promise<Hover> => {
return {
contents: {language: 'javascript', value: 'Hello World'}
}
});
console.log('Starting Server...');
connection.listen();
示例5: initStylableLanguageService
//.........这里部分代码省略.........
} else {
diagnostics = createDiagnosis(doc, processor, services.requireModule)
.map(diag => {
diag.source = 'stylable';
return diag;
})
.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(
示例6: constructor
//.........这里部分代码省略.........
let start = ts.getLineAndCharacterOfPosition(service.services.getProgram().getSourceFile(def.fileName), def.textSpan.start);
let end = ts.getLineAndCharacterOfPosition(service.services.getProgram().getSourceFile(def.fileName), def.textSpan.start + def.textSpan.length);
result.push(Location.create(util.path2uri(workspaceRoot, def.fileName), {
start: start,
end: end
}));
// }
}
} else {
//check whether definition is external, if uri string returned, add this location
// TODO
/*
let externalDef = connection.service.getExternalDefinition(params.textDocument.uri, params.position.line, params.position.character);
if (externalDef) {
let fileName = externalDef.file;
let res = Location.create(util.formExternalUri(externalDef), util.formEmptyRange());
result.push(res);
}
*/
}
const exit = new Date().getTime();
console.error('definition', 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.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[]> => {