Skip to content

Commit

Permalink
remove document symbols
Browse files Browse the repository at this point in the history
they were not in a usable state, and with next update [1], no symbols (outline) is better than broken outline, so sticky scroll still works fine

[1] microsoft/vscode#157165
  • Loading branch information
phil294 committed Sep 4, 2022
1 parent 40a7906 commit b170b9f
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 174 deletions.
2 changes: 0 additions & 2 deletions server/src/embeddedSupport/languageModes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
DocumentHighlight,
CompletionList,
Position,
SymbolInformation,
CodeActionContext,
CodeAction,
TextDocumentEdit
Expand Down Expand Up @@ -49,7 +48,6 @@ export interface LanguageMode {
doHover?(document: TextDocument, position: Position): Hover;
doSignatureHelp?(document: TextDocument, position: Position): SignatureHelp | null;
findDocumentHighlight?(document: TextDocument, position: Position): DocumentHighlight[];
findDocumentSymbols?(document: TextDocument): SymbolInformation[];
findDefinition?(document: TextDocument, position: Position): Definition;
findReferences?(document: TextDocument, position: Position): Location[];

Expand Down
51 changes: 2 additions & 49 deletions server/src/modes/script/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
CodeAction, CodeActionContext, CodeActionKind, CompletionItem, CompletionItemKind, CompletionItemTag, CompletionList, Definition, Diagnostic,
DiagnosticSeverity, DiagnosticTag, DocumentHighlight,
DocumentHighlightKind, Hover, Location, MarkedString, MarkupContent, ParameterInformation, Position, Range, SignatureHelp,
SignatureInformation, SymbolInformation, TextEdit
SignatureInformation, TextEdit
} from 'vscode-languageserver-types';
import { URI } from 'vscode-uri';
import { CoffeescriptDocumentRegions, LanguageId } from '../../embeddedSupport/embeddedSupport';
Expand All @@ -16,7 +16,7 @@ import { DocumentService } from '../../services/documentService';
import { EnvironmentService } from '../../services/EnvironmentService';
import transpile_service, { common_js_variable_name_character, get_line_at_line_no, get_word_around_position, pseudo_compile_coffee } from '../../services/transpileService';
import { IServiceHost } from '../../services/typescriptService/serviceHost';
import { toCompletionItemKind, toSymbolKind } from '../../services/typescriptService/util';
import { toCompletionItemKind } from '../../services/typescriptService/util';
import { CodeActionData, CodeActionDataKind, OrganizeImportsActionData } from '../../types';
import { isVCancellationRequested, VCancellationToken } from '../../utils/cancellationToken';
import { getFileFsPath, getFilePath } from '../../utils/paths';
Expand Down Expand Up @@ -721,53 +721,6 @@ export async function getJavascriptMode(
}
return [];
},
findDocumentSymbols(coffee_doc: TextDocument): SymbolInformation[] {
const { scriptDoc: js_doc, service } = updateCurrentCoffeescriptTextDocument(coffee_doc);
if (!languageServiceIncludesFile(service, coffee_doc.uri)) {
return [];
}
const fileFsPath = getFileFsPath(coffee_doc.uri);

const transpilation = transpile_service.result_by_uri.get(coffee_doc.uri)
if(!transpilation?.source_map)
return []

const items = service.getNavigationBarItems(fileFsPath);
if (!items) {
return [];
}
const result: SymbolInformation[] = [];
const existing: { [k: string]: boolean } = {};
const collectSymbols = (item: ts.NavigationBarItem, containerLabel?: string) => {
const sig = item.text + item.kind + item.spans[0]!.start;
if (item.kind !== 'script' && !existing[sig]) {
let range = convertRange(js_doc, item.spans[0]!)
if(transpilation?.source_map)
range = transpile_service.range_js_to_coffee(transpilation, range, coffee_doc) || range
const symbol: SymbolInformation = {
name: item.text,
kind: toSymbolKind(item.kind),
location: {
uri: coffee_doc.uri,
range
},
containerName: containerLabel
};
existing[sig] = true;
result.push(symbol);
containerLabel = item.text;
}

if (item.childItems && item.childItems.length > 0) {
for (const child of item.childItems) {
collectSymbols(child, containerLabel);
}
}
};

items.forEach(item => collectSymbols(item));
return result;
},
findDefinition(coffee_doc: TextDocument, coffee_position: Position): Definition {
const { scriptDoc: js_doc, service } = updateCurrentCoffeescriptTextDocument(coffee_doc);
if (!languageServiceIncludesFile(service, coffee_doc.uri)) {
Expand Down
10 changes: 0 additions & 10 deletions server/src/services/lsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
ServerCapabilities,
TextDocumentSyncKind,
Disposable,
DocumentSymbolParams,
CodeActionParams,
CompletionParams,
ExecuteCommandParams,
Expand All @@ -29,7 +28,6 @@ import {
Hover,
Location,
SignatureHelp,
SymbolInformation,
DocumentUri,
CodeAction,
CodeActionKind
Expand Down Expand Up @@ -358,7 +356,6 @@ export class LSP {

this.lspConnection.onDefinition(this.onDefinition.bind(this));
this.lspConnection.onDocumentHighlight(this.onDocumentHighlight.bind(this));
this.lspConnection.onDocumentSymbol(this.onDocumentSymbol.bind(this));
this.lspConnection.onHover(this.onHover.bind(this));
this.lspConnection.onReferences(this.onReferences.bind(this));
this.lspConnection.onSignatureHelp(this.onSignatureHelp.bind(this));
Expand Down Expand Up @@ -487,12 +484,6 @@ export class LSP {
return project?.onReferences(params) ?? [];
}

async onDocumentSymbol(params: DocumentSymbolParams): Promise<SymbolInformation[]> {
const project = await this.getProjectService(params.textDocument.uri);

return project?.onDocumentSymbol(params) ?? [];
}

async onSignatureHelp(params: TextDocumentPositionParams): Promise<SignatureHelp | null> {
const project = await this.getProjectService(params.textDocument.uri);

Expand Down Expand Up @@ -584,7 +575,6 @@ export class LSP {
documentFormattingProvider: false,
hoverProvider: true,
documentHighlightProvider: true,
documentSymbolProvider: true,
definitionProvider: true,
referencesProvider: true,
codeActionProvider: {
Expand Down
14 changes: 0 additions & 14 deletions server/src/services/projectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import {
Definition,
Diagnostic,
DocumentHighlight,
DocumentSymbolParams,
Hover,
Location,
SignatureHelp,
SymbolInformation,
TextDocumentEdit,
TextDocumentPositionParams
} from 'vscode-languageserver';
Expand All @@ -35,7 +33,6 @@ export interface ProjectService {
onDocumentHighlight(params: TextDocumentPositionParams): Promise<DocumentHighlight[]>;
onDefinition(params: TextDocumentPositionParams): Promise<Definition>;
onReferences(params: TextDocumentPositionParams): Promise<Location[]>;
onDocumentSymbol(params: DocumentSymbolParams): Promise<SymbolInformation[]>;
onSignatureHelp(params: TextDocumentPositionParams): Promise<SignatureHelp | null>;
onCodeAction(params: CodeActionParams): Promise<CodeAction[]>;
onCodeActionResolve(action: CodeAction): Promise<CodeAction>;
Expand Down Expand Up @@ -115,17 +112,6 @@ export async function createProjectService(
}
return [];
},
async onDocumentSymbol({ textDocument }) {
const doc = documentService.getDocument(textDocument.uri)!;
const symbols: SymbolInformation[] = [];

languageModes.getAllLanguageModeRangesInDocument(doc).forEach(m => {
if (m.mode.findDocumentSymbols) {
symbols.push.apply(symbols, m.mode.findDocumentSymbols(doc));
}
});
return symbols;
},
async onSignatureHelp({ textDocument, position }) {
const doc = documentService.getDocument(textDocument.uri)!;
const mode = languageModes.getModeAtPosition(doc, position);
Expand Down
29 changes: 1 addition & 28 deletions server/src/services/typescriptService/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type ts from 'typescript';
import { CompletionItemKind, SymbolKind } from 'vscode-languageserver';
import { CompletionItemKind } from 'vscode-languageserver';
import { EnvironmentService } from '../EnvironmentService';

export function isCoffeescriptFile(path: string, env: EnvironmentService) {
Expand Down Expand Up @@ -70,30 +70,3 @@ export function toCompletionItemKind(kind: ts.ScriptElementKind): CompletionItem

return CompletionItemKind.Property;
}

export function toSymbolKind(kind: ts.ScriptElementKind): SymbolKind {
switch (kind) {
case 'var':
case 'local var':
case 'const':
return SymbolKind.Variable;
case 'function':
case 'local function':
return SymbolKind.Function;
case 'enum':
return SymbolKind.Enum;
case 'module':
return SymbolKind.Module;
case 'class':
return SymbolKind.Class;
case 'interface':
return SymbolKind.Interface;
case 'method':
return SymbolKind.Method;
case 'property':
case 'getter':
case 'setter':
return SymbolKind.Property;
}
return SymbolKind.Variable;
}
71 changes: 0 additions & 71 deletions test/lsp/features/document-symbol/basic.test.ts

This file was deleted.

0 comments on commit b170b9f

Please sign in to comment.