diff --git a/call-hierarchy-sample/README.md b/call-hierarchy-sample/README.md index 4b9d87ce..23c93cb8 100644 --- a/call-hierarchy-sample/README.md +++ b/call-hierarchy-sample/README.md @@ -1,6 +1,6 @@ # Call Hierarchy Provider Sample -This sample shows the **Call Hierarchy** in action based on a simple food pyramid model defined using simple subject~verb~object syntax. +This sample shows the **Call Hierarchy** in action based on a simple food pyramid model defined using simple subject ~ verb ~ object syntax. ![Sample](demo.gif) @@ -31,4 +31,4 @@ Right click on a noun or a verb and select _Peek Call Hierarchy_. ## Contributing to the Sample and Testing the Sample -Run the _Run Extension Tests_ configuration and verify in the Debug Console that all tests are passing. \ No newline at end of file +Run the _Run Extension Tests_ configuration and verify in the Debug Console that all tests are passing. diff --git a/call-hierarchy-sample/src/FoodPyramidHierarchyProvider.ts b/call-hierarchy-sample/src/FoodPyramidHierarchyProvider.ts index 0c2afeb0..5e87d6ba 100644 --- a/call-hierarchy-sample/src/FoodPyramidHierarchyProvider.ts +++ b/call-hierarchy-sample/src/FoodPyramidHierarchyProvider.ts @@ -88,33 +88,6 @@ export class FoodPyramidHierarchyProvider implements CallHierarchyProvider { return new CallHierarchyItem(SymbolKind.Object, word, `(${type})`, document.uri, range, range); } - deriveCalledItem(item: CallHierarchyItem, called: string, document: TextDocument): CallHierarchyOutgoingCall { - const range = this.rangeOf(called, document); - let calledItem = new CallHierarchyItem(item.kind, called, called, item.uri, range, range); - return new CallHierarchyOutgoingCall(calledItem, this.allRangesOf(called, document)); - } - - rangeOf(word: string, document: TextDocument): Range { - let match = new RegExp("\\b" + word + "\\b").exec(document.getText()); - let offset = match!.index; - return this.toRange(document, offset, word); - } - - allRangesOf(word: string, document: TextDocument): Range[] { - let pattern = new RegExp("\b" + word + "\b"); - let ranges: Range[] = []; - - var match: RegExpExecArray | null; - while (match = pattern.exec(document.getText())) { - ranges.push(this.toRange(document, match.index, word)); - } - return ranges; - } - - private toRange(document: TextDocument, offset: number, word: string) { - let position = document.positionAt(offset); - return new Range(position, position.translate({ characterDelta: word.length })); - } } /**