File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/core/compiler
org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/core/search/matching Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -1671,9 +1671,9 @@ public interface IProblem {
16711671 int NullExpressionReference = Internal + 672 ;
16721672 /** @since 3.9 */
16731673 int PotentialNullExpressionReference = Internal + 673 ;
1674- /** @since 3.42 */
1674+ /** @since 3.43 */
16751675 int LocalMustBeEffectivelyFinal = Internal + 674 ;
1676- /** @since 3.42 */
1676+ /** @since 3.43 */
16771677 int ResourceLocalMustBeEffectivelyFinal = Internal + 675 ;
16781678
16791679 /**
@@ -2615,7 +2615,7 @@ public interface IProblem {
26152615 int RecordErasureIncompatibilityInCanonicalConstructor = TypeRelated + 1768 ;
26162616 /** @since 3.41 */
26172617 int CompactConstructorOnlyInRecords = TypeRelated + 1769 ;
2618- /** @since 3.42 */
2618+ /** @since 3.43 */
26192619 int RecordAccessorMissingOverrideAnnotation = TypeRelated + 1770 ;
26202620 /* records - end */
26212621
Original file line number Diff line number Diff line change @@ -784,6 +784,29 @@ public String findImportForString(String s) {
784784 if ( simpleNameMatch != -1 ) {
785785 return simpleNameMatch ;
786786 }
787+ if ( node instanceof Type t ) {
788+ String qualifiedNameFromNode = getQualifiedNameFromType (t );
789+ char [] qualifiedPattern = getQualifiedPattern (trp .simpleName ,trp .qualification );
790+ if ( qualifiedNameFromNode != null && qualNameFromBinding .endsWith (qualifiedNameFromNode )) {
791+ // Might be a rare situation where two top-level classes defined in same file?
792+ int level3 = resolveLevelForTypeSourceName (qualifiedPattern , qualifiedNameFromNode .toCharArray (), typeBinding );
793+ if ( level3 != IMPOSSIBLE_MATCH ) {
794+ return level3 ;
795+ }
796+ } else {
797+ org .eclipse .jdt .core .dom .CompilationUnit cu = findCompilationUnitAncestor (node );
798+ String pkg = cu .getPackage () == null ? null : cu .getPackage ().getName ().toString ();
799+ if ( pkg != null ) {
800+ if ( qualNameFromBinding .startsWith (pkg + "." )) {
801+ String suffix = qualNameFromBinding .substring (pkg .length () + 1 );
802+ int level3 = resolveLevelForTypeSourceName (qualifiedPattern , suffix .toCharArray (), typeBinding );
803+ if ( level3 != IMPOSSIBLE_MATCH ) {
804+ return level3 ;
805+ }
806+ }
807+ }
808+ }
809+ }
787810 }
788811 if ( newLevel == ACCURATE_MATCH ) {
789812 if ( trp .hasTypeArguments () ) {
You can’t perform that action at this time.
0 commit comments