Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Remove unused folding ranges #162

Merged
merged 1 commit into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions src/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ import {
textDocument_implementation,
textDocument_typeDefinition,
TypeDefinitionResult,
FoldingRangeResult,
textDocument_foldingRange,
RangeBasedDocumentSymbol,
DefinitionTag,
DefinitionRange,
Expand Down Expand Up @@ -228,14 +226,6 @@ export class VertexBuilder {
}
}

public foldingRangeResult(values: lsp.FoldingRange[]): FoldingRangeResult {
return {
id: this.nextId(),
type: ElementTypes.vertex,
label: VertexLabels.foldingRangeResult,
result: values,
}
}

public hoverResult(value: lsp.Hover): HoverResult
public hoverResult(
Expand Down Expand Up @@ -403,18 +393,6 @@ export class EdgeBuilder {
}
}

public foldingRange(
from: Document,
to: FoldingRangeResult
): textDocument_foldingRange {
return {
id: this.nextId(),
type: ElementTypes.edge,
label: EdgeLabels.textDocument_foldingRange,
outV: from.id,
inV: to.id,
}
}

public diagnostic(
from: Project | Document,
Expand Down
55 changes: 0 additions & 55 deletions src/lsif.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,40 +126,6 @@ namespace Converter {
}
}

export function asFoldingRange(
this: void,
file: ts.SourceFile,
span: ts.OutliningSpan
): lsp.FoldingRange {
let kind = getFoldingRangeKind(span)
let start = file.getLineAndCharacterOfPosition(span.textSpan.start)
let end = file.getLineAndCharacterOfPosition(
span.textSpan.start + span.textSpan.length
)
return {
kind,
startLine: start.line,
startCharacter: start.character,
endLine: end.line,
endCharacter: end.character,
} as lsp.FoldingRange
}

function getFoldingRangeKind(
span: ts.OutliningSpan
): lsp.FoldingRangeKind | undefined {
switch (span.kind) {
case 'comment':
return lsp.FoldingRangeKind.Comment
case 'region':
return lsp.FoldingRangeKind.Region
case 'imports':
return lsp.FoldingRangeKind.Imports
case 'code':
default:
return undefined
}
}

const symbolKindMap: Map<number, lsp.SymbolKind> = new Map<
number,
Expand Down Expand Up @@ -302,7 +268,6 @@ class ProjectData extends LSIFData {
class DocumentData extends LSIFData {
private ranges: Range[]
private diagnostics: lsp.Diagnostic[] | undefined
private foldingRanges: lsp.FoldingRange[] | undefined
private documentSymbols: RangeBasedDocumentSymbol[] | undefined

public constructor(
Expand All @@ -329,9 +294,6 @@ class DocumentData extends LSIFData {
this.diagnostics = diagnostics
}

public addFoldingRanges(foldingRanges: lsp.FoldingRange[]): void {
this.foldingRanges = foldingRanges
}

public addDocumentSymbols(documentSymbols: RangeBasedDocumentSymbol[]): void {
this.documentSymbols = documentSymbols
Expand All @@ -346,11 +308,6 @@ class DocumentData extends LSIFData {
this.emit(dr)
this.emit(this.edge.diagnostic(this.document, dr))
}
if (this.foldingRanges !== undefined) {
const fr = this.vertex.foldingRangeResult(this.foldingRanges)
this.emit(fr)
this.emit(this.edge.foldingRange(this.document, fr))
}
if (this.documentSymbols !== undefined) {
const ds = this.vertex.documentSymbolResult(this.documentSymbols)
this.emit(ds)
Expand Down Expand Up @@ -2292,18 +2249,6 @@ class Visitor implements ResolverContext {
documentData.addDiagnostics(diagnostics)
}

// Folding ranges
let spans = this.languageService.getOutliningSpans(sourceFile as any)
if (ts.textSpanEnd.length > 0) {
let foldingRanges: lsp.FoldingRange[] = []
for (let span of spans) {
foldingRanges.push(Converter.asFoldingRange(sourceFile, span))
}
if (foldingRanges.length > 0) {
documentData.addFoldingRanges(foldingRanges)
}
}

// Document symbols.
let values = (this.symbolContainer.pop() as RangeBasedDocumentSymbol)
.children
Expand Down