Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit c20c857

Browse files
committed
renames, also adopt for type and call hierarchy
1 parent 2ef177d commit c20c857

File tree

5 files changed

+35
-19
lines changed

5 files changed

+35
-19
lines changed

src/calls/model.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7-
import { SymbolItemEditorHighlights, SymbolItemNavigation, SymbolTreeInput } from '../references-view';
7+
import { SymbolItemDragAndDrop, SymbolItemEditorHighlights, SymbolItemNavigation, SymbolTreeInput } from '../references-view';
88
import { del, getThemeIcon, tail } from '../utils';
99

1010

@@ -37,6 +37,7 @@ export class CallsTreeInput implements SymbolTreeInput<CallItem> {
3737
get message() { return model.roots.length === 0 ? 'No results.' : undefined; },
3838
navigation: model,
3939
highlights: model,
40+
dnd: model,
4041
dispose() {
4142
provider.dispose();
4243
}
@@ -72,7 +73,7 @@ export class CallItem {
7273
}
7374
}
7475

75-
class CallsModel implements SymbolItemNavigation<CallItem>, SymbolItemEditorHighlights<CallItem> {
76+
class CallsModel implements SymbolItemNavigation<CallItem>, SymbolItemEditorHighlights<CallItem>, SymbolItemDragAndDrop<CallItem> {
7677

7778
readonly roots: CallItem[] = [];
7879

@@ -130,6 +131,12 @@ class CallsModel implements SymbolItemNavigation<CallItem>, SymbolItemEditorHigh
130131
}
131132
}
132133

134+
// --- dnd
135+
136+
getDragUri(item: CallItem): vscode.Uri | undefined {
137+
return item.item.uri.with({ fragment: `L${1 + item.item.range.start.line},${item.item.range.start.character}` });
138+
}
139+
133140
// --- highlights
134141

135142
getEditorHighlights(item: CallItem, uri: vscode.Uri): vscode.Range[] | undefined {

src/references-view.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export interface SymbolTreeModel<T> {
102102
/**
103103
* Optional support for drag and drop.
104104
*/
105-
uris?: SymbolItemUri<T>;
105+
dnd?: SymbolItemDragAndDrop<T>;
106106

107107
/**
108108
* Optional dispose function which is invoked when this model is
@@ -143,7 +143,7 @@ export interface SymbolItemEditorHighlights<T> {
143143
getEditorHighlights(item: T, uri: vscode.Uri): vscode.Range[] | undefined;
144144
}
145145

146-
export interface SymbolItemUri<T> {
146+
export interface SymbolItemDragAndDrop<T> {
147147

148-
getUri(item: T): vscode.Uri | undefined;
148+
getDragUri(item: T): vscode.Uri | undefined;
149149
}

src/references/model.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7-
import { SymbolItemEditorHighlights, SymbolItemNavigation, SymbolItemUri, SymbolTreeInput, SymbolTreeModel } from '../references-view';
7+
import { SymbolItemDragAndDrop, SymbolItemEditorHighlights, SymbolItemNavigation, SymbolTreeInput, SymbolTreeModel } from '../references-view';
88
import { del, getPreviewChunks, tail } from '../utils';
99

1010
export class ReferencesTreeInput implements SymbolTreeInput<FileItem | ReferenceItem> {
@@ -41,7 +41,7 @@ export class ReferencesTreeInput implements SymbolTreeInput<FileItem | Reference
4141
get message() { return model.message; },
4242
navigation: model,
4343
highlights: model,
44-
uris: model,
44+
dnd: model,
4545
dispose(): void {
4646
provider.dispose();
4747
}
@@ -53,7 +53,7 @@ export class ReferencesTreeInput implements SymbolTreeInput<FileItem | Reference
5353
}
5454
}
5555

56-
export class ReferencesModel implements SymbolItemNavigation<FileItem | ReferenceItem>, SymbolItemEditorHighlights<FileItem | ReferenceItem>, SymbolItemUri<FileItem | ReferenceItem> {
56+
export class ReferencesModel implements SymbolItemNavigation<FileItem | ReferenceItem>, SymbolItemEditorHighlights<FileItem | ReferenceItem>, SymbolItemDragAndDrop<FileItem | ReferenceItem> {
5757

5858
private _onDidChange = new vscode.EventEmitter<FileItem | ReferenceItem | undefined>();
5959
readonly onDidChangeTreeData = this._onDidChange.event;
@@ -246,11 +246,13 @@ export class ReferencesModel implements SymbolItemNavigation<FileItem | Referenc
246246
return result;
247247
}
248248

249-
getUri(item: FileItem | ReferenceItem): vscode.Uri | undefined {
249+
getDragUri(item: FileItem | ReferenceItem): vscode.Uri | undefined {
250250
if (item instanceof FileItem) {
251251
return item.uri;
252252
} else {
253-
return item.file.uri.with({ fragment: `L${item.location.range.start.line + 1},${item.location.range.start.character + 1}` });
253+
return item.file.uri.with({
254+
fragment: `L${item.location.range.start.line + 1},${item.location.range.start.character + 1}`
255+
});
254256
}
255257
}
256258
}

src/tree.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import * as vscode from 'vscode';
77
import { EditorHighlights } from './highlights';
88
import { Navigation } from './navigation';
9-
import { SymbolItemUri, SymbolTreeInput } from './references-view';
9+
import { SymbolItemDragAndDrop, SymbolTreeInput } from './references-view';
1010
import { ContextKey, isValidRequestPosition, WordAnchor } from './utils';
1111

1212
export class SymbolsTree {
@@ -68,7 +68,7 @@ export class SymbolsTree {
6868

6969
// set promise to tree data provider to trigger tree loading UI
7070
this._provider.update(modelPromise.then(model => model?.provider ?? this._history));
71-
this._dnd.update(modelPromise.then(model => model?.uris));
71+
this._dnd.update(modelPromise.then(model => model?.dnd));
7272

7373
const model = await modelPromise;
7474
if (this._input !== input) {
@@ -187,11 +187,11 @@ class TreeDataProviderDelegate implements vscode.TreeDataProvider<undefined> {
187187

188188
class TreeDndDelegate implements vscode.TreeDragAndDropController<undefined> {
189189

190-
private _delegate: SymbolItemUri<undefined> | undefined;
190+
private _delegate: SymbolItemDragAndDrop<undefined> | undefined;
191191

192192
readonly supportedMimeTypes: string[] = ['resourceurls'];
193193

194-
update(delegate: Promise<SymbolItemUri<unknown> | undefined>) {
194+
update(delegate: Promise<SymbolItemDragAndDrop<unknown> | undefined>) {
195195
this._delegate = undefined;
196196
delegate.then(value => this._delegate = value);
197197
}
@@ -200,7 +200,7 @@ class TreeDndDelegate implements vscode.TreeDragAndDropController<undefined> {
200200
if (this._delegate) {
201201
const urls: string[] = [];
202202
for (let item of source) {
203-
const uri = this._delegate.getUri(item);
203+
const uri = this._delegate.getDragUri(item);
204204
if (uri) {
205205
urls.push(uri.toString());
206206
}

src/types/model.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7-
import { SymbolItemEditorHighlights, SymbolItemNavigation, SymbolTreeInput } from '../references-view';
7+
import { SymbolItemDragAndDrop, SymbolItemEditorHighlights, SymbolItemNavigation, SymbolTreeInput } from '../references-view';
88
import { del, getThemeIcon, tail } from '../utils';
99

1010

@@ -37,6 +37,7 @@ export class TypesTreeInput implements SymbolTreeInput<TypeItem> {
3737
get message() { return model.roots.length === 0 ? 'No results.' : undefined; },
3838
navigation: model,
3939
highlights: model,
40+
dnd: model,
4041
dispose() {
4142
provider.dispose();
4243
}
@@ -70,7 +71,7 @@ export class TypeItem {
7071
}
7172
}
7273

73-
class TypesModel implements SymbolItemNavigation<TypeItem>, SymbolItemEditorHighlights<TypeItem> {
74+
class TypesModel implements SymbolItemNavigation<TypeItem>, SymbolItemEditorHighlights<TypeItem>, SymbolItemDragAndDrop<TypeItem> {
7475

7576
readonly roots: TypeItem[] = [];
7677

@@ -84,10 +85,10 @@ class TypesModel implements SymbolItemNavigation<TypeItem>, SymbolItemEditorHigh
8485
private async _resolveTypes(currentType: TypeItem): Promise<TypeItem[]> {
8586
if (this.direction === TypeHierarchyDirection.Supertypes) {
8687
const types = await vscode.commands.executeCommand<vscode.TypeHierarchyItem[]>('vscode.provideSupertypes', currentType.item);
87-
return types ? types.map(item => new TypeItem(this, item, currentType )) : [];
88+
return types ? types.map(item => new TypeItem(this, item, currentType)) : [];
8889
} else {
8990
const types = await vscode.commands.executeCommand<vscode.TypeHierarchyItem[]>('vscode.provideSubtypes', currentType.item);
90-
return types ? types.map(item => new TypeItem(this, item, currentType )) : [];
91+
return types ? types.map(item => new TypeItem(this, item, currentType)) : [];
9192
}
9293
}
9394

@@ -98,6 +99,12 @@ class TypesModel implements SymbolItemNavigation<TypeItem>, SymbolItemEditorHigh
9899
return item.children;
99100
}
100101

102+
// -- dnd
103+
104+
getDragUri(item: TypeItem): vscode.Uri | undefined {
105+
return item.item.uri.with({ fragment: `L${1 + item.item.range.start.line},${1 + item.item.range.start.character}` });
106+
}
107+
101108
// -- navigation
102109

103110
location(currentType: TypeItem) {

0 commit comments

Comments
 (0)