Java Code Examples for org.codehaus.groovy.ast.ClassNode#isPrimaryClassNode()
The following examples show how to use
org.codehaus.groovy.ast.ClassNode#isPrimaryClassNode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroovyVirtualSourceProvider.java From netbeans with Apache License 2.0 | 6 votes |
private Parameter[] selectAccessibleConstructorFromSuper(ConstructorNode node) { ClassNode type = node.getDeclaringClass(); ClassNode superType = type.getSuperClass(); boolean hadPrivateConstructor = false; for (ConstructorNode c : superType.getDeclaredConstructors()) { // Only look at things we can actually call if (c.isPublic() || c.isProtected()) { return c.getParameters(); } } // fall back for parameterless constructor if (superType.isPrimaryClassNode()) { return Parameter.EMPTY_ARRAY; } return null; }
Example 2
Source File: StaticImportVisitor.java From groovy with Apache License 2.0 | 5 votes |
private static Expression findStaticField(ClassNode staticImportType, String fieldName) { if (staticImportType.isPrimaryClassNode() || staticImportType.isResolved()) { FieldNode field = getField(staticImportType, fieldName); if (field != null && field.isStatic()) return newStaticPropertyX(staticImportType, fieldName); } return null; }
Example 3
Source File: StaticImportVisitor.java From groovy with Apache License 2.0 | 5 votes |
private static Expression findStaticMethod(ClassNode staticImportType, String methodName, Expression args) { if (staticImportType.isPrimaryClassNode() || staticImportType.isResolved()) { if (staticImportType.hasPossibleStaticMethod(methodName, args)) { return newStaticMethodCallX(staticImportType, methodName, args); } } return null; }
Example 4
Source File: ResolveVisitor.java From groovy with Apache License 2.0 | 5 votes |
protected boolean resolve(final ClassNode type, final boolean testModuleImports, final boolean testDefaultImports, final boolean testStaticInnerClasses) { resolveGenericsTypes(type.getGenericsTypes()); if (type.isResolved() || type.isPrimaryClassNode()) return true; if (type.isArray()) { ClassNode element = type.getComponentType(); boolean resolved = resolve(element, testModuleImports, testDefaultImports, testStaticInnerClasses); if (resolved) { ClassNode cn = element.makeArray(); type.setRedirect(cn); } return resolved; } // test if vanilla name is current class name if (currentClass == type) return true; String typeName = type.getName(); GenericsType genericsType = genericParameterNames.get(new GenericsTypeName(typeName)); if (genericsType != null) { type.setRedirect(genericsType.getType()); type.setGenericsTypes(new GenericsType[]{genericsType}); type.setGenericsPlaceHolder(true); return true; } if (currentClass.getNameWithoutPackage().equals(typeName)) { type.setRedirect(currentClass); return true; } return (!type.hasPackageName() && resolveNestedClass(type)) || resolveFromModule(type, testModuleImports) || resolveFromCompileUnit(type) || (testDefaultImports && !type.hasPackageName() && resolveFromDefaultImports(type)) || resolveToOuter(type) || (testStaticInnerClasses && type.hasPackageName() && resolveFromStaticInnerClasses(type)); }
Example 5
Source File: AnnotationCollectorTransform.java From groovy with Apache License 2.0 | 5 votes |
private static List<AnnotationNode> getMeta(ClassNode cn) { List<AnnotationNode> meta = cn.getNodeMetaData(AnnotationCollector.class); if (meta == null) { if (cn.isPrimaryClassNode()) { meta = getTargetListFromAnnotations(cn); } else { meta = getTargetListFromClass(cn); } cn.setNodeMetaData(AnnotationCollector.class, meta); } return meta; }
Example 6
Source File: DependencyTracker.java From groovy with Apache License 2.0 | 5 votes |
private void addToCache(ClassNode node){ if (node == null) return; String name = node.getName(); if (!precompiledDependencies.containsKey(name) && !node.isPrimaryClassNode()) { return; } current.add(node.getName()); addToCache(node.getSuperClass()); addToCache(node.getInterfaces()); }
Example 7
Source File: JavaStubGenerator.java From groovy with Apache License 2.0 | 5 votes |
private static Parameter[] selectAccessibleConstructorFromSuper(ConstructorNode node) { ClassNode type = node.getDeclaringClass(); ClassNode superType = type.getUnresolvedSuperClass(); Parameter[] bestMatch = null; for (ConstructorNode c : superType.getDeclaredConstructors()) { // Only look at things we can actually call if (!c.isPublic() && !c.isProtected()) continue; Parameter[] parameters = c.getParameters(); // workaround for GROOVY-5859: remove generic type info Parameter[] copy = new Parameter[parameters.length]; for (int i = 0; i < copy.length; i++) { Parameter orig = parameters[i]; copy[i] = new Parameter(orig.getOriginType().getPlainNodeReference(), orig.getName()); } if (noExceptionToAvoid(node,c)) return copy; if (bestMatch==null) bestMatch = copy; } if (bestMatch!=null) return bestMatch; // fall back for parameterless constructor if (superType.isPrimaryClassNode()) { return Parameter.EMPTY_ARRAY; } return null; }