Skip to content

Commit e65edf8

Browse files
committed
chore: import Outline and OutlineTree from atom-ide-base
1 parent dcee038 commit e65edf8

File tree

3 files changed

+13
-31
lines changed

3 files changed

+13
-31
lines changed

lib/adapters/outline-view-adapter.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as atomIde from 'atom-ide';
2+
import type { OutlineTree, Outline } from 'atom-ide-base'
23
import Convert from '../convert';
34
import * as Utils from '../utils';
45
import { CancellationTokenSource } from 'vscode-jsonrpc';
@@ -43,7 +44,7 @@ export default class OutlineViewAdapter {
4344
* @param editor The Atom {TextEditor} containing the text the Outline should represent.
4445
* @returns A {Promise} containing the {Outline} of this document.
4546
*/
46-
public async getOutline(connection: LanguageClientConnection, editor: TextEditor): Promise<atomIde.Outline | null> {
47+
public async getOutline(connection: LanguageClientConnection, editor: TextEditor): Promise<Outline | null> {
4748
const results = await Utils.doWithCancellationToken(connection, this._cancellationTokens, (cancellationToken) =>
4849
connection.documentSymbol({ textDocument: Convert.editorToTextDocumentIdentifier(editor) }, cancellationToken),
4950
);
@@ -78,7 +79,7 @@ export default class OutlineViewAdapter {
7879
* should be converted to an {Array} of {OutlineTree}.
7980
* @returns An {Array} of {OutlineTree} containing the given symbols that the Outline View can display.
8081
*/
81-
public static createHierarchicalOutlineTrees(symbols: DocumentSymbol[]): atomIde.OutlineTree[] {
82+
public static createHierarchicalOutlineTrees(symbols: DocumentSymbol[]): OutlineTree[] {
8283
// Sort all the incoming symbols
8384
symbols.sort((a, b) => {
8485
if (a.range.start.line !== b.range.start.line) {
@@ -117,7 +118,7 @@ export default class OutlineViewAdapter {
117118
* should be converted to an {OutlineTree}.
118119
* @returns An {OutlineTree} containing the given symbols that the Outline View can display.
119120
*/
120-
public static createOutlineTrees(symbols: SymbolInformation[]): atomIde.OutlineTree[] {
121+
public static createOutlineTrees(symbols: SymbolInformation[]): OutlineTree[] {
121122
symbols.sort(
122123
(a, b) =>
123124
(a.location.range.start.line === b.location.range.start.line
@@ -146,7 +147,7 @@ export default class OutlineViewAdapter {
146147
return map;
147148
}, new Map());
148149

149-
const roots: atomIde.OutlineTree[] = [];
150+
const roots: OutlineTree[] = [];
150151

151152
// Put each item within its parent and extract out the roots
152153
for (const item of allItems) {
@@ -180,14 +181,14 @@ export default class OutlineViewAdapter {
180181
}
181182

182183
private static _getClosestParent(
183-
candidates: atomIde.OutlineTree[] | null,
184-
child: atomIde.OutlineTree,
185-
): atomIde.OutlineTree | null {
184+
candidates: OutlineTree[] | null,
185+
child: OutlineTree,
186+
): OutlineTree | null {
186187
if (candidates == null || candidates.length === 0) {
187188
return null;
188189
}
189190

190-
let parent: atomIde.OutlineTree | undefined;
191+
let parent: OutlineTree | undefined;
191192
for (const candidate of candidates) {
192193
if (
193194
candidate !== child &&
@@ -218,7 +219,7 @@ export default class OutlineViewAdapter {
218219
* @param symbol The {DocumentSymbol} to convert to an {OutlineTree}.
219220
* @returns The {OutlineTree} corresponding to the given {DocumentSymbol}.
220221
*/
221-
public static hierarchicalSymbolToOutline(symbol: DocumentSymbol): atomIde.OutlineTree {
222+
public static hierarchicalSymbolToOutline(symbol: DocumentSymbol): OutlineTree {
222223
const icon = OutlineViewAdapter.symbolKindToEntityKind(symbol.kind);
223224

224225
return {
@@ -243,7 +244,7 @@ export default class OutlineViewAdapter {
243244
* @param symbol The {SymbolInformation} to convert to an {OutlineTree}.
244245
* @returns The {OutlineTree} equivalent to the given {SymbolInformation}.
245246
*/
246-
public static symbolToOutline(symbol: SymbolInformation): atomIde.OutlineTree {
247+
public static symbolToOutline(symbol: SymbolInformation): OutlineTree {
247248
const icon = OutlineViewAdapter.symbolKindToEntityKind(symbol.kind);
248249
return {
249250
tokenizedText: [

lib/auto-languageclient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as ls from './languageclient';
33
import * as rpc from 'vscode-jsonrpc';
44
import * as path from 'path';
55
import * as atomIde from 'atom-ide';
6-
import type { OutlineProvider } from 'atom-ide-base'
6+
import type { OutlineProvider, Outline } from 'atom-ide-base'
77
import * as linter from 'atom/linter';
88
import Convert from './convert.js';
99
import ApplyEditAdapter from './adapters/apply-edit-adapter';
@@ -549,7 +549,7 @@ export default class AutoLanguageClient {
549549
};
550550
}
551551

552-
protected async getOutline(editor: TextEditor): Promise<atomIde.Outline | null> {
552+
protected async getOutline(editor: TextEditor): Promise<Outline | null> {
553553
const server = await this._serverManager.getServer(editor);
554554
if (server == null || !OutlineViewAdapter.canAdapt(server.capabilities)) {
555555
return null;

typings/atom-ide/index.d.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,6 @@ declare module 'atom-ide' {
22
import { Disposable, Grammar, Point, Range, TextEditor } from 'atom';
33
import * as ac from 'atom/autocomplete-plus';
44

5-
export interface OutlineTree {
6-
/** from atom$Octicon | atom$OcticonsPrivate (types not allowed over rpc so we use string) */
7-
icon?: string;
8-
9-
/** Must have `plainText` or the `tokenizedText` property. If both are present, `tokenizedText` is preferred. */
10-
plainText?: string;
11-
/** Must have `plainText` or the `tokenizedText` property. If both are present, `tokenizedText` is preferred. */
12-
tokenizedText?: TokenizedText;
13-
representativeName?: string;
14-
15-
startPosition: Point;
16-
endPosition?: Point;
17-
children: OutlineTree[];
18-
}
19-
20-
export interface Outline {
21-
outlineTrees: OutlineTree[];
22-
}
23-
245
export type TokenKind =
256
| 'keyword'
267
| 'class-name'

0 commit comments

Comments
 (0)