Skip to content

Commit aa65dc6

Browse files
authored
Merge branch 'eclipse-jdt:master' into master
2 parents a8d2e31 + 260179e commit aa65dc6

3 files changed

Lines changed: 34 additions & 3 deletions

File tree

org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/hover/JavadocHoverTests.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,5 +430,36 @@ void foo(){}
430430
assertEquals("sequence doesn't match", expectedCodeSequence, actualSnippet);
431431
}
432432
}
433+
434+
@Test
435+
public void testCharConstant() throws Exception {
436+
String source=
437+
"""
438+
package p;
439+
public class Javadoc {
440+
static final char c = (char)0;
441+
}
442+
""";
443+
ICompilationUnit cu= getWorkingCopy("/TestSetupProject/src/p/Javadoc.java", source, null);
444+
assertNotNull("TestClass.java", cu);
445+
446+
IType type= cu.getType("Javadoc");
447+
// check javadoc on each member:
448+
for (IJavaElement member : type.getChildren()) {
449+
IJavaElement[] elements= { member };
450+
ISourceRange range= ((ISourceReference) member).getNameRange();
451+
JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(elements, cu, new Region(range.getOffset(), range.getLength()), null);
452+
String actualHtmlContent= hoverInfo.getHtml();
453+
System.out.println(actualHtmlContent);
454+
455+
String expectedCodeSequence = "char <a class='header' href='eclipse-javadoc:%E2%98%82=TestSetupProject/src%3Cp'>p</a>.<a class='header' href='eclipse-javadoc:%E2%98%82=TestSetupProject/src%3Cp%7BJavadoc.java%E2%98%83Javadoc'>Javadoc</a>.c</span> : <span style='white-space:pre'>'' [\\u0000]";
456+
457+
int index= actualHtmlContent.lastIndexOf("char");
458+
assertNotEquals(-1, index);
459+
String actualSnippet= actualHtmlContent.substring(index, index + expectedCodeSequence.length());
460+
assertEquals("sequence doesn't match", expectedCodeSequence, actualSnippet);
461+
}
462+
}
463+
433464
}
434465

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2145,8 +2145,8 @@ public static SemanticHighlighting[] getSemanticHighlightings() {
21452145
new MethodHighlighting(), // before types to get ctors
21462146
new TypeArgumentHighlighting(), // before other types
21472147
new AbstractClassHighlighting(), // before classes
2148-
new ClassHighlighting(),
21492148
new RecordHighlighting(),
2149+
new ClassHighlighting(),
21502150
new EnumHighlighting(),
21512151
new AnnotationHighlighting(), // before interfaces
21522152
new InterfaceHighlighting(),

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,9 +1362,9 @@ private static StringBuffer addLink(StringBuffer buf, String uri, String label)
13621362

13631363
public static String getHexConstantValue(Object constantValue) {
13641364
if (constantValue instanceof Character) {
1365-
String constantResult= '\'' + constantValue.toString() + '\'';
1366-
13671365
char charValue= ((Character) constantValue);
1366+
String constantResult= '\'' + (charValue == 0 ? "" : constantValue.toString()) + '\''; //$NON-NLS-1$
1367+
13681368
String hexString= Integer.toHexString(charValue);
13691369
StringBuilder hexResult= new StringBuilder("\\u"); //$NON-NLS-1$
13701370
for (int i= hexString.length(); i < 4; i++) {

0 commit comments

Comments
 (0)