|
16 | 16 | */
|
17 | 17 | package spoon.support.visitor;
|
18 | 18 |
|
19 |
| -import java.awt.event.HierarchyListener; |
20 |
| -import java.util.ArrayList; |
21 |
| -import java.util.Collections; |
22 |
| -import java.util.HashMap; |
23 |
| -import java.util.HashSet; |
24 |
| -import java.util.List; |
25 |
| -import java.util.Map; |
26 |
| -import java.util.Set; |
27 |
| - |
28 | 19 | import spoon.SpoonException;
|
29 | 20 | import spoon.reflect.declaration.CtConstructor;
|
30 | 21 | import spoon.reflect.declaration.CtElement;
|
|
44 | 35 | import spoon.reflect.visitor.filter.SuperInheritanceHierarchyFunction;
|
45 | 36 | import spoon.support.SpoonClassNotFoundException;
|
46 | 37 |
|
| 38 | +import java.util.ArrayList; |
| 39 | +import java.util.Collections; |
| 40 | +import java.util.HashMap; |
| 41 | +import java.util.HashSet; |
| 42 | +import java.util.List; |
| 43 | +import java.util.Map; |
| 44 | +import java.util.Set; |
| 45 | + |
47 | 46 | /**
|
48 | 47 | * Helper class created from type X or reference to X.
|
49 | 48 | * It provides access to actual type arguments
|
@@ -366,16 +365,18 @@ private CtType<?> getEnclosingType(CtType<?> type) {
|
366 | 365 | */
|
367 | 366 | private CtTypeReference<?> getEnclosingType(CtTypeReference<?> typeRef) {
|
368 | 367 | CtType<?> type = typeRef.getTypeDeclaration();
|
369 |
| - if (type.hasModifier(ModifierKind.STATIC)) { |
370 |
| - return null; |
371 |
| - } |
372 |
| - CtType<?> declType = type.getDeclaringType(); |
373 |
| - if (declType == null) { |
374 |
| - return null; |
375 |
| - } |
376 |
| - if (declType.isInterface()) { |
377 |
| - //nested types of interfaces are static |
378 |
| - return null; |
| 368 | + if (type != null) { |
| 369 | + if (type.hasModifier(ModifierKind.STATIC)) { |
| 370 | + return null; |
| 371 | + } |
| 372 | + CtType<?> declType = type.getDeclaringType(); |
| 373 | + if (declType == null) { |
| 374 | + return null; |
| 375 | + } |
| 376 | + if (declType.isInterface()) { |
| 377 | + //nested types of interfaces are static |
| 378 | + return null; |
| 379 | + } |
379 | 380 | }
|
380 | 381 | return typeRef.getDeclaringType();
|
381 | 382 | }
|
|
0 commit comments