vscode-typescript-languageservice
Advanced tools
Comparing version 0.26.6-alpha.0 to 0.26.6
@@ -10,3 +10,3 @@ import * as vscode from 'vscode-languageserver'; | ||
}; | ||
export declare function createLanguageService(ts: typeof import('typescript/lib/tsserverlibrary'), _host: LanguageServiceHost): { | ||
export declare function createLanguageService(ts: typeof import('typescript/lib/tsserverlibrary'), host: LanguageServiceHost, languageService: ts.LanguageService): { | ||
findDefinition: (uri: string, position: vscode.Position) => vscode.LocationLink[]; | ||
@@ -44,39 +44,4 @@ findTypeDefinition: (uri: string, position: vscode.Position) => vscode.LocationLink[]; | ||
__internal__: { | ||
raw: import("typescript/lib/tsserverlibrary").LanguageService; | ||
host: { | ||
getImportSuggestionsCache: () => any; | ||
getCompilationSettings(): ts.CompilerOptions; | ||
getNewLine?(): string; | ||
getProjectVersion?(): string; | ||
getScriptFileNames(): string[]; | ||
getScriptKind?(fileName: string): ts.ScriptKind; | ||
getScriptVersion(fileName: string): string; | ||
getScriptSnapshot(fileName: string): ts.IScriptSnapshot | undefined; | ||
getProjectReferences?(): readonly ts.ProjectReference[] | undefined; | ||
getLocalizedDiagnosticMessages?(): any; | ||
getCancellationToken?(): ts.HostCancellationToken; | ||
getCurrentDirectory(): string; | ||
getDefaultLibFileName(options: ts.CompilerOptions): string; | ||
log?(s: string): void; | ||
trace?(s: string): void; | ||
error?(s: string): void; | ||
useCaseSensitiveFileNames?(): boolean; | ||
readDirectory?(path: string, extensions?: readonly string[] | undefined, exclude?: readonly string[] | undefined, include?: readonly string[] | undefined, depth?: number | undefined): string[]; | ||
readFile?(path: string, encoding?: string | undefined): string | undefined; | ||
realpath?(path: string): string; | ||
fileExists?(path: string): boolean; | ||
getTypeRootsVersion?(): number; | ||
resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ts.ResolvedProjectReference | undefined, options: ts.CompilerOptions): (ts.ResolvedModule | undefined)[]; | ||
getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ts.ResolvedModuleWithFailedLookupLocations | undefined; | ||
resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference: ts.ResolvedProjectReference | undefined, options: ts.CompilerOptions): (ts.ResolvedTypeReferenceDirective | undefined)[]; | ||
getDirectories?(directoryName: string): string[]; | ||
getCustomTransformers?(): ts.CustomTransformers | undefined; | ||
isKnownTypesPackageName?(name: string): boolean; | ||
installPackage?(options: ts.InstallPackageOptions): Promise<ts.ApplyCodeActionCommandResult>; | ||
writeFile?(fileName: string, content: string): void; | ||
getParsedCommandLine?(fileName: string): ts.ParsedCommandLine | undefined; | ||
directoryExists?(directoryName: string): boolean; | ||
getFormatOptions?(document: TextDocument, options?: vscode.FormattingOptions | undefined): Promise<ts.FormatCodeSettings>; | ||
getPreferences?(document: TextDocument): Promise<ts.UserPreferences>; | ||
}; | ||
host: LanguageServiceHost; | ||
raw: ts.LanguageService; | ||
getTextDocument: (uri: string) => TextDocument | undefined; | ||
@@ -83,0 +48,0 @@ getValidTextDocument: (uri: string) => TextDocument | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createLanguageService = exports.getSemanticTokenLegend = void 0; | ||
const ShPlugin = require("typescript-vscode-sh-plugin"); | ||
const completions = require("./services/completion"); | ||
@@ -32,16 +31,4 @@ const completions2 = require("./services/completion2"); | ||
const path = require("path"); | ||
function createLanguageService(ts, _host) { | ||
var _a, _b; | ||
// @ts-ignore | ||
const importSuggestionsCache = (_b = (_a = ts.Completions) === null || _a === void 0 ? void 0 : _a.createImportSuggestionsForFileCache) === null || _b === void 0 ? void 0 : _b.call(_a); | ||
const host = { | ||
..._host, | ||
// @ts-ignore | ||
// TODO: crash on 'addListener' from 'node:process', reuse because TS has same problem | ||
getImportSuggestionsCache: () => importSuggestionsCache, | ||
}; | ||
function createLanguageService(ts, host, languageService) { | ||
const documents = new Map(); | ||
const shPlugin = ShPlugin({ typescript: ts }); | ||
let languageService = ts.createLanguageService(host); | ||
languageService = shPlugin.decorate(languageService); | ||
return { | ||
@@ -60,4 +47,4 @@ findDefinition: definitions.register(languageService, getValidTextDocument), | ||
doComplete: completions2.register(languageService, getValidTextDocument, host), | ||
doCompletionResolve: completionResolve.register(languageService, getValidTextDocument, host), | ||
doHover: hover.register(languageService, getValidTextDocument, ts), | ||
doCompletionResolve: completionResolve.register(languageService, getValidTextDocument, getTextDocument, host), | ||
doHover: hover.register(languageService, getValidTextDocument, getTextDocument, ts), | ||
doFormatting: formatting.register(languageService, getValidTextDocument, host), | ||
@@ -72,4 +59,4 @@ getSignatureHelp: signatureHelp.register(languageService, getValidTextDocument, ts), | ||
__internal__: { | ||
host, | ||
raw: languageService, | ||
host, | ||
getTextDocument, | ||
@@ -76,0 +63,0 @@ getValidTextDocument, |
@@ -5,2 +5,2 @@ import type * as ts from 'typescript'; | ||
import type { LanguageServiceHost } from '../'; | ||
export declare function register(languageService: ts.LanguageService, getTextDocument: (uri: string) => TextDocument | undefined, host: LanguageServiceHost): (item: vscode.CompletionItem, newOffset?: number | undefined) => Promise<vscode.CompletionItem>; | ||
export declare function register(languageService: ts.LanguageService, getTextDocument: (uri: string) => TextDocument | undefined, getTextDocument2: (uri: string) => TextDocument | undefined, host: LanguageServiceHost): (item: vscode.CompletionItem, newOffset?: number | undefined) => Promise<vscode.CompletionItem>; |
@@ -9,3 +9,3 @@ "use strict"; | ||
const shared = require("@volar/shared"); | ||
function register(languageService, getTextDocument, host) { | ||
function register(languageService, getTextDocument, getTextDocument2, host) { | ||
return async (item, newOffset) => { | ||
@@ -58,3 +58,3 @@ var _a, _b, _c, _d; | ||
kind: 'markdown', | ||
value: previewer.markdownDocumentation(details.documentation, details.tags, { toResource: shared.fsPathToUri }), | ||
value: previewer.markdownDocumentation(details.documentation, details.tags, { toResource: shared.fsPathToUri }, getTextDocument2), | ||
}; | ||
@@ -61,0 +61,0 @@ if (details) { |
import type * as ts from 'typescript'; | ||
import * as vscode from 'vscode-languageserver'; | ||
import type { TextDocument } from 'vscode-languageserver-textdocument'; | ||
export declare function register(languageService: ts.LanguageService, getTextDocument: (uri: string) => TextDocument | undefined, ts: typeof import('typescript/lib/tsserverlibrary')): (uri: string, position: vscode.Position, documentOnly?: boolean) => vscode.Hover | undefined; | ||
export declare function register(languageService: ts.LanguageService, getTextDocument: (uri: string) => TextDocument | undefined, getTextDocument2: (uri: string) => TextDocument | undefined, ts: typeof import('typescript/lib/tsserverlibrary')): (uri: string, position: vscode.Position, documentOnly?: boolean) => vscode.Hover | undefined; |
@@ -7,5 +7,5 @@ "use strict"; | ||
const shared = require("@volar/shared"); | ||
function register(languageService, getTextDocument, ts) { | ||
function register(languageService, getTextDocument, getTextDocument2, ts) { | ||
return (uri, position, documentOnly = false) => { | ||
var _a, _b, _c; | ||
var _a; | ||
const document = getTextDocument(uri); | ||
@@ -21,36 +21,3 @@ if (!document) | ||
const displayString = ts.displayPartsToString(info.displayParts); | ||
// fix https://github.com/johnsoncodehk/volar/issues/289 | ||
const mapedTags = (_b = (_a = info.tags) === null || _a === void 0 ? void 0 : _a.map(tag => { | ||
if (tag.text) { | ||
return { | ||
...tag, | ||
text: tag.text.map(part => { | ||
let target = part.target; | ||
if (target && 'fileName' in target) { | ||
const fileDoc = getTextDocument(shared.uriToFsPath(target.fileName)); | ||
const start = fileDoc.positionAt(target.textSpan.start); | ||
const end = fileDoc.positionAt(target.textSpan.start + target.textSpan.length); | ||
target = { | ||
file: target.fileName, | ||
start: { | ||
line: start.line + 1, | ||
offset: start.character + 1, | ||
}, | ||
end: { | ||
line: end.line + 1, | ||
offset: end.character + 1, | ||
}, | ||
}; | ||
return { | ||
...part, | ||
target, | ||
}; | ||
} | ||
return part; | ||
}), | ||
}; | ||
} | ||
return tag; | ||
})) !== null && _b !== void 0 ? _b : []; | ||
const documentation = previewer.markdownDocumentation((_c = info.documentation) !== null && _c !== void 0 ? _c : [], mapedTags, { toResource: shared.fsPathToUri }); | ||
const documentation = previewer.markdownDocumentation((_a = info.documentation) !== null && _a !== void 0 ? _a : [], info.tags, { toResource: shared.fsPathToUri }, getTextDocument2); | ||
if (displayString && !documentOnly) { | ||
@@ -57,0 +24,0 @@ parts.push(['```typescript', displayString, '```'].join('\n')); |
import type * as Proto from '../protocol'; | ||
import type { TextDocument } from 'vscode-languageserver-textdocument'; | ||
export interface IFilePathToResourceConverter { | ||
@@ -9,4 +10,4 @@ /** | ||
export declare function plainWithLinks(parts: readonly Proto.SymbolDisplayPart[] | string, filePathConverter: IFilePathToResourceConverter): string; | ||
export declare function tagsMarkdownPreview(tags: readonly Proto.JSDocTagInfo[], filePathConverter: IFilePathToResourceConverter): string; | ||
export declare function markdownDocumentation(documentation: Proto.SymbolDisplayPart[] | string | undefined, tags: Proto.JSDocTagInfo[] | undefined, filePathConverter: IFilePathToResourceConverter): string; | ||
export declare function addMarkdownDocumentation(out: string, documentation: Proto.SymbolDisplayPart[] | string | undefined, tags: Proto.JSDocTagInfo[] | undefined, converter: IFilePathToResourceConverter): string; | ||
export declare function tagsMarkdownPreview(tags: readonly ts.JSDocTagInfo[], filePathConverter: IFilePathToResourceConverter, getTextDocument: (uri: string) => TextDocument | undefined): string; | ||
export declare function markdownDocumentation(documentation: Proto.SymbolDisplayPart[] | string | undefined, tags: ts.JSDocTagInfo[] | undefined, filePathConverter: IFilePathToResourceConverter, getTextDocument: (uri: string) => TextDocument | undefined): string; | ||
export declare function addMarkdownDocumentation(out: string, documentation: Proto.SymbolDisplayPart[] | string | undefined, tags: ts.JSDocTagInfo[] | undefined, converter: IFilePathToResourceConverter, getTextDocument: (uri: string) => TextDocument | undefined): string; |
@@ -8,2 +8,3 @@ "use strict"; | ||
exports.addMarkdownDocumentation = exports.markdownDocumentation = exports.tagsMarkdownPreview = exports.plainWithLinks = void 0; | ||
const shared = require("@volar/shared"); | ||
function replaceLinks(text) { | ||
@@ -141,11 +142,50 @@ return text | ||
} | ||
function tagsMarkdownPreview(tags, filePathConverter) { | ||
function tagsMarkdownPreview(tags, filePathConverter, getTextDocument) { | ||
// fix https://github.com/johnsoncodehk/volar/issues/289 | ||
tags = tags.map(tag => { | ||
if (tag.text) { | ||
return { | ||
...tag, | ||
text: tag.text.map(part => { | ||
const target = part.target; | ||
if (target && 'fileName' in target) { | ||
const fileDoc = getTextDocument(shared.uriToFsPath(target.fileName)); | ||
if (fileDoc) { | ||
const start = fileDoc.positionAt(target.textSpan.start); | ||
const end = fileDoc.positionAt(target.textSpan.start + target.textSpan.length); | ||
const newTarget = { | ||
file: target.fileName, | ||
start: { | ||
line: start.line + 1, | ||
offset: start.character + 1, | ||
}, | ||
end: { | ||
line: end.line + 1, | ||
offset: end.character + 1, | ||
}, | ||
}; | ||
return { | ||
...part, | ||
target: newTarget, | ||
}; | ||
} | ||
return { | ||
...part, | ||
target: undefined, | ||
}; | ||
} | ||
return part; | ||
}), | ||
}; | ||
} | ||
return tag; | ||
}); | ||
return tags.map(tag => getTagDocumentation(tag, filePathConverter)).join(' \n\n'); | ||
} | ||
exports.tagsMarkdownPreview = tagsMarkdownPreview; | ||
function markdownDocumentation(documentation, tags, filePathConverter) { | ||
return addMarkdownDocumentation('', documentation, tags, filePathConverter); | ||
function markdownDocumentation(documentation, tags, filePathConverter, getTextDocument) { | ||
return addMarkdownDocumentation('', documentation, tags, filePathConverter, getTextDocument); | ||
} | ||
exports.markdownDocumentation = markdownDocumentation; | ||
function addMarkdownDocumentation(out, documentation, tags, converter) { | ||
function addMarkdownDocumentation(out, documentation, tags, converter, getTextDocument) { | ||
if (documentation) { | ||
@@ -155,3 +195,3 @@ out += plainWithLinks(documentation, converter); | ||
if (tags) { | ||
const tagsPreview = tagsMarkdownPreview(tags, converter); | ||
const tagsPreview = tagsMarkdownPreview(tags, converter, getTextDocument); | ||
if (tagsPreview) { | ||
@@ -158,0 +198,0 @@ out += '\n\n' + tagsPreview; |
{ | ||
"name": "vscode-typescript-languageservice", | ||
"version": "0.26.6-alpha.0", | ||
"version": "0.26.6", | ||
"main": "out/index.js", | ||
@@ -19,4 +19,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@volar/shared": "^0.26.6-alpha.0", | ||
"typescript-vscode-sh-plugin": "^0.6.14", | ||
"@volar/shared": "^0.26.6", | ||
"upath": "^2.0.1", | ||
@@ -26,3 +25,3 @@ "vscode-languageserver": "^8.0.0-next.1", | ||
}, | ||
"gitHead": "f81663048f69032b500543a55146020d85f5360f" | ||
"gitHead": "726c4c33f22daa70923ddd29715377304f3c6045" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4
112324
2212
1
- Removedtypescript-vscode-sh-plugin@^0.6.14
- Removedtypescript-vscode-sh-plugin@0.6.14(transitive)
Updated@volar/shared@^0.26.6