Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call hierarchy api #80112

Closed
wants to merge 12 commits into from
Closed

call hierarchy api #80112

wants to merge 12 commits into from

Conversation

jrieken
Copy link
Member

@jrieken jrieken commented Aug 30, 2019

This PR refines the call hierarchy API proposal and adopts the UX for it. The new proposal is

	export enum CallHierarchyDirection {
		CallsFrom = 1,
		CallsTo = 2,
	}

	export class CallHierarchySymbol {
		kind: SymbolKind;
		tags?: ReadonlyArray<SymbolTag>;
		name: string;
		detail?: string;
		uri: Uri;
		range: Range;
		selectionRange: Range;

		constructor(kind: SymbolKind, name: string, detail: string, uri: Uri, range: Range, selectionRange: Range);
	}

	export class CallHierarchyItem {
		source: CallHierarchySymbol;
		targets: ReadonlyArray<CallHierarchySymbol>;
	}

	export interface CallHierarchyItemProvider {
		provideCallHierarchyItems(document: TextDocument, position: Position, direction: CallHierarchyDirection, token: CancellationToken): ProviderResult<CallHierarchyItem[]>;
	}

	export namespace languages {
		export function registerCallHierarchyProvider(selector: DocumentSelector, provider: CallHierarchyItemProvider): Disposable;
	}

@weinand weinand assigned mjbvz and jrieken and unassigned mjbvz Aug 30, 2019
@mjbvz
Copy link
Collaborator

mjbvz commented Aug 30, 2019

/cc @rbuckton Since I know you were were looking into microsoft/TypeScript#31863

@jrieken jrieken added this to the September 2019 milestone Sep 2, 2019
@jrieken
Copy link
Member Author

jrieken commented Sep 2, 2019

Another round of API ideas (closer to the original)

		class CallHierarchyItem {
			kind: SymbolKind;
			name: string;
			detail?: string;
			uri: Uri;
			range: Range;
			selectionRange: Range;
		}

		interface CallsTo {
			source: CallHierarchyItem,
			sourceRanges: Range[]
		}

		interface CallsFrom {
			sourceRanges: Range[],
			target: CallHierarchyItem
		}

		interface CallHierarchyItemProvider {

			resolveCallHierarchyItem(document: TextDocument, postion: Position, token: CancellationToken): ProviderResult<CallHierarchyItem>;

			provideCallsTo(target: CallHierarchyItem, token: CancellationToken): ProviderResult<CallsTo[]>;

			provideCallsFrom(source: CallHierarchyItem, token: CancellationToken): ProviderResult<CallsFrom[]>;
		}

@rbuckton
Copy link
Member

rbuckton commented Sep 10, 2019

Will call hierarchy only be limited to calls to/from, or is it possible it will evolve to support other concepts?

For example:

  • constructs/constructed by (i.e. via new)
  • read by/written by (i.e. fields or accessors)

@jrieken
Copy link
Member Author

jrieken commented Sep 11, 2019

Will call hierarchy only be limited to calls to/from, or is it possible it will evolve to support other concepts?

Anything callable and anything that makes calls. The obvious are functions/methods but constructors and getters/setters are also valid. Generally, VS Code doesn't care/know about what's valid and it will simply ask the language brains for incoming/outgoing calls for a document position.

@jrieken
Copy link
Member Author

jrieken commented Sep 11, 2019

fyi - closing this in favour of #70231 (comment). That explains the latest proposal which we are very likely to settle on. Let's continue the discussions there.

@jrieken jrieken closed this Sep 11, 2019
@jrieken jrieken deleted the joh/api/callHierarchy branch September 11, 2019 13:47
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants