< prev index next >

src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysis.java

Print this page

        

@@ -72,10 +72,28 @@
     /**
      * Internal only constructor
      */
     SourceCodeAnalysis() {}
 
+    /**Infer the type of the given expression. Returns null if the type of the expression cannot
+     * be inferred.
+     *
+     * @param code the expression for which the type should be inferred
+     * @param cursor current cursor position in the given code
+     * @return the inferred type, or null if it cannot be inferred
+     */
+    public abstract String analyzeType(String code, int cursor);
+
+    /**List the possible FQNs for an identifier in the given code immediately
+     * to the right of the given cursor position.
+     *
+     * @param code the expression for which the candidate FQNs should be computed
+     * @param cursor current cursor position in the given code
+     * @return the gathered FQNs
+     */
+    public abstract IndexResult getDeclaredSymbols(String code, int cursor);
+
     /**
      * The result of <code>analyzeCompletion(String input)</code>.
      * Describes the completeness and position of the first snippet in the given input.
      */
     public static class CompletionInfo {

@@ -196,6 +214,58 @@
          * likely to be the desired continuation. A smart continuation
          * is preferred.
          */
         public final boolean isSmart;
     }
+
+    /**List of possible qualified names.
+     */
+    public static final class IndexResult {
+
+        private final List<String> fqns;
+        private final int simpleNameLength;
+        private final boolean upToDate;
+        private final boolean resolvable;
+
+        public IndexResult(List<String> fqns, int simpleNameLength, boolean upToDate, boolean resolvable) {
+            this.fqns = fqns;
+            this.simpleNameLength = simpleNameLength;
+            this.upToDate = upToDate;
+            this.resolvable = resolvable;
+        }
+
+        /**Candidate fully qualified names (FQNs).
+         *
+         * @return possible fully qualified names
+         */
+        public List<String> getFqns() {
+            return fqns;
+        }
+
+        /**The length of the unresolvable simple name in the original code for which the
+         * FQNs where computed.
+         *
+         * @return the length of the simple name; -1 if there is no name right left to the cursor for
+         *         which the candidates could be computed
+         */
+        public int getSimpleNameLength() {
+            return simpleNameLength;
+        }
+
+        /**Whether the result is based on up to date data.
+         *
+         * @return true iff the results is based on up-to-date data
+         */
+        public boolean isUpToDate() {
+            return upToDate;
+        }
+
+        /**The given identifier refers to a resolvable element.
+         *
+         * @return true iff the given identifier refers to a resolvable element
+         */
+        public boolean isResolvable() {
+            return resolvable;
+        }
+
+    }
 }
< prev index next >