You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/03/09 21:03:03 UTC

[GitHub] [netbeans] sdedic commented on a change in pull request #3735: Support for Call Hierarchy for LSP

sdedic commented on a change in pull request #3735:
URL: https://github.com/apache/netbeans/pull/3735#discussion_r823086267



##########
File path: ide/api.lsp/src/org/netbeans/api/lsp/CallHierarchyEntry.java
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.api.lsp;
+
+import java.util.List;
+import org.netbeans.api.annotations.common.CheckForNull;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.spi.lsp.CallHierarchyProvider;
+
+/**
+ * Represents an entry in a call hierarchy chain. The entry identifies an element in a source which is the origin or target
+ * of an invocation/call. 
+ * 
+ * @since 1.69
+ * @author sdedic
+ */
+public final class CallHierarchyEntry {
+    /**
+     * The call origin or target element.
+     */
+    private StructureElement    element;
+    
+    /**
+     * Opaque implementation-specific data.
+     */
+    private String  customData;
+
+    /**
+     * Returns description of the call hierarchy element. See {@link StructureElemen} for structure details,
+     * @return description of the structural languagein call hierarchy
+     */
+    @NonNull
+    public StructureElement getElement() {
+        return element;
+    }
+    
+    /**
+     * Returns an opaque, mime type specific data which shall be interpreted by the {@link CallHierarchyProvider}
+     * in subsequent calls. For example, method signature can be put here.
+     * @return provider-specific data
+     */
+    @CheckForNull
+    public String getCustomData() {
+        return customData;
+    }
+
+    /**
+     * Constructs a new entry object.
+     * @param element represents call target or call origin, depending on usage
+     * @param customData implementation-specific data
+     */
+    public CallHierarchyEntry(StructureElement element, String customData) {
+        this.element = element;
+        this.customData = customData;
+    }
+    
+    
+    /**
+     * This structure is used for two purposes. For <b>outgoing calls</b> the {@link #getItem}
+     * returns the call target, and {@link #getRanges} returns locations in the origin
+     * {@link CallHierarchyElement} where the target is invoked from. For <b>incoming calls</b>
+     * the {@link #getItem} identifies the element that makes the call, while {@link #getRanges}
+     * locations where the call was made from from that element.
+     * 
+     */
+    public static final class Call {
+        private final CallHierarchyEntry item;
+        private final List<CallRange> ranges;
+
+        public Call(@NonNull CallHierarchyEntry item, List<CallRange> ranges) {
+            this.item = item;
+            this.ranges = ranges;
+        }
+        
+        /**
+         * @return Target or origin element of the call.
+         */
+        @NonNull
+        public CallHierarchyEntry getItem() {
+            return item;
+        }
+
+        /**
+         * @return text locations within the origin element where the target is invoked.
+         */
+        public List<CallRange> getRanges() {
+            return ranges;
+        }
+    }
+    
+    /**
+     * Represents a textual range. Range covers text from `startOffset' to `endOffset' (exclusive).
+     */
+    public static final class CallRange {
+        private final int startOffset;

Review comment:
       OK, will introduce a toplevel `Range` ... plus I guess I could add `getSelectionRange` and `getExtendedRange` to the `StructureElement` - right ?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists