diff --git a/ide/editor.lib/nbproject/project.properties b/ide/editor.lib/nbproject/project.properties index 9ced90b1758f..fb5e37b47275 100644 --- a/ide/editor.lib/nbproject/project.properties +++ b/ide/editor.lib/nbproject/project.properties @@ -16,7 +16,7 @@ # under the License. javac.compilerargs=-Xlint:unchecked -javac.source=1.8 +javac.release=17 spec.version.base=4.38.0 is.autoload=true diff --git a/ide/editor.lib/src/org/netbeans/editor/ext/ToolTipSupport.java b/ide/editor.lib/src/org/netbeans/editor/ext/ToolTipSupport.java index e062d975f543..f5d82b2c807a 100644 --- a/ide/editor.lib/src/org/netbeans/editor/ext/ToolTipSupport.java +++ b/ide/editor.lib/src/org/netbeans/editor/ext/ToolTipSupport.java @@ -19,7 +19,6 @@ package org.netbeans.editor.ext; -import org.netbeans.api.editor.StickyWindowSupport; import java.awt.Color; import java.awt.Container; import java.awt.Dimension; @@ -35,6 +34,7 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; +import java.awt.geom.Rectangle2D; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; @@ -156,7 +156,11 @@ public class ToolTipSupport { private static final String HTML_PREFIX_UPPERCASE = " JAVA_KEYWORDS = new HashSet(Arrays.asList(new String[] { + private static final Set JAVA_KEYWORDS = Set.of( "abstract", "continue", "for", "new", "switch", "assert", "default", "goto", "package", "synchronized", "boolean", "do", "if", "private", /*"this",*/ @@ -106,37 +90,10 @@ public class ToolTipAnnotation extends Annotation implements Runnable { "catch", "extends", "int", "short", "try", "char", "final", "interface", "static", "void", /*"class",*/ "finally", "long", "strictfp", "volatile", - "const", "float", "native", "super", "while", - })); - - private static final int MAX_STRING_LENGTH; + "const", "float", "native", "super", "while" + ); - static { - int maxStringLength = 100000; - String javaV = System.getProperty("java.version"); - if (javaV.startsWith("1.8.0")) { - String update = ""; - for (int i = "1.8.0_".length(); i < javaV.length(); i++) { - char c = javaV.charAt(i); - if (Character.isDigit(c)) { - update += c; - } else { - break; - } - } - int updateNo = 0; - if (!update.isEmpty()) { - try { - updateNo = Integer.parseInt(update); - } catch (NumberFormatException nfex) {} - } - if (updateNo < 60) { - // Memory problem on JDK 8, fixed in update 60 (https://bugs.openjdk.java.net/browse/JDK-8072775): - maxStringLength = 1000; - } - } - MAX_STRING_LENGTH = maxStringLength; - } + private static final int MAX_STRING_LENGTH = 100000; private Part lp; private EditorCookie ec; @@ -266,8 +223,8 @@ public void run () { return ; // Something went wrong... } String type = v.getType (); - if (v instanceof ObjectVariable) { - tooltipVariable = (ObjectVariable) v; + if (v instanceof ObjectVariable objectVariable) { + tooltipVariable = objectVariable; try { Object jdiValue = v.getClass().getMethod("getJDIValue").invoke(v); if (jdiValue == null) { @@ -275,27 +232,27 @@ public void run () { } } catch (Exception ex) {} if (tooltipVariable != null) { - v = getFormattedValue(d, (ObjectVariable) v); + v = getFormattedValue(d, objectVariable); } } - if (v instanceof ObjectVariable) { + if (v instanceof ObjectVariable objectVariable) { try { - String toString = ((ObjectVariable) v).getToStringValue(); + String toString = objectVariable.getToStringValue(); toolTipText = expression + " = " + - (type.length () == 0 ? + (type.isEmpty() ? "" : "(" + type + ") ") + toString; } catch (InvalidExpressionException ex) { toolTipText = expression + " = " + - (type.length () == 0 ? + (type.isEmpty() ? "" : "(" + type + ") ") + v.getValue (); } } else { toolTipText = expression + " = " + - (type.length () == 0 ? + (type.isEmpty() ? "" : "(" + type + ") ") + v.getValue (); @@ -462,7 +419,7 @@ private static boolean isValidTooltipLocation(JPDADebugger debugger, final String[] className = new String[]{""}; Future parsingTask; try { - parsingTask = ParserManager.parseWhenScanFinished(Collections.singleton(Source.create(doc)), new UserTask() { + parsingTask = ParserManager.parseWhenScanFinished(List.of(Source.create(doc)), new UserTask() { @Override public void run(ResultIterator resultIterator) throws Exception { Result res = resultIterator.getParserResult(offset); @@ -530,7 +487,7 @@ public void run(ResultIterator resultIterator) throws Exception { isValid[0] = false; return; } - if (TreeUtilities.CLASS_TREE_KINDS.contains(kind) && className[0].length() == 0) { + if (TreeUtilities.CLASS_TREE_KINDS.contains(kind) && className[0].isEmpty()) { TypeElement typeElement = (TypeElement)controller.getTrees().getElement(path); className[0] = ElementUtilities.getBinaryName(typeElement); } @@ -547,8 +504,8 @@ public void run(ResultIterator resultIterator) throws Exception { if (ElementKind.CLASS.equals(tk) || ElementKind.ENUM.equals(tk) || ElementKind.INTERFACE.equals(tk)) {*/ - if (typeElement instanceof TypeElement) { - String binaryClassName = ElementUtilities.getBinaryName((TypeElement) typeElement); + if (typeElement instanceof TypeElement typeElement1) { + String binaryClassName = ElementUtilities.getBinaryName(typeElement1); fieldOfPtr[0] = binaryClassName; /* String currentClassName = currentFrame.getClassName(); @@ -582,7 +539,7 @@ public void run(ResultIterator resultIterator) throws Exception { return false; } if (className[0].length() > 0) { - Set superTypeNames = new HashSet(); + Set superTypeNames = new HashSet<>(); This thisVar = currentFrame.getThisVariable(); if (thisVar != null) { String fqn = thisVar.getType(); @@ -676,7 +633,7 @@ private String resolveTypeName (final int offset, Source source) { final String[] result = new String[1]; result[0] = null; try { - ParserManager.parse(Collections.singleton(source), new UserTask() { + ParserManager.parse(List.of(source), new UserTask() { @Override public void run(ResultIterator resultIterator) throws Exception { Result res = resultIterator.getParserResult(offset);