/** * Returns the Java package in the context of which the construct is defined. * @return */ @Override public JavaPackageId getJavaPackageId() { if(this.isNested()) return this.declarationContext.getJavaPackageId(); else return (JavaPackageId)this.declarationContext; } }
/** * Returns the name of the Java package in which the class or nested class is defined. Returns null if a class is defined outside of a package. * @returns a Java package name */ @Override public ConstructId getDefinitionContext() { return this.getJavaPackageId(); }
if(j!=-1) { if(cid==null) cid = new JavaEnumId(pid, class_name.substring(k, j)); else cid = new JavaEnumId(cid, class_name.substring(k, j)); k = j+1; cid = new JavaEnumId(pid, class_name.substring(k)); else cid = new JavaEnumId(cid, class_name.substring(k)); k = j+1;
/** * Enums are added to {@link #constructs}. */ @Override public void enterEnumDeclaration(@NotNull JavaParser.EnumDeclarationContext ctx) { // Create JavaId and push to the stack final ContextStackEntry cse = this.contextStack.peek(); final JavaId decl_ctx = ( cse==null ? JavaPackageId.DEFAULT_PACKAGE : (JavaId)cse.getConstructId() ); final JavaId id = new JavaEnumId(decl_ctx, ctx.IDENTIFIER().getText()); this.contextStack.push(id); this.saveConstruct(id, this.getConstructContent(ctx)); }
/** * Returns a class name that is unique within the package in which the class is defined. * In case of nested classes, the names of parent classes will be included (e.g., OuterClass$InnerClass). * @returns the class name including the names of parent classes (if any) */ @Override public String getName() { if(this.declarationContext!=null) { if(!this.isNested()) return this.enumName; else return this.declarationContext.getName() + "$" + this.enumName; } else { return this.enumName; } }
/** * Returns the fully qualified class name, i.e., including the name of the package in which the class is defined. */ @Override public String getQualifiedName() { if(this.declarationContext!=null) { if(!this.isNested()) return this.declarationContext.getQualifiedName() + "." + this.enumName; else return this.declarationContext.getQualifiedName() + "$" + this.enumName; } else { return this.enumName; } }
/** * * @param _jid * @return */ private JavaId getCompilationUnit(JavaId _jid) { // Got it --> return provided object if( (_jid.getType().equals(JavaId.Type.CLASS) && !((JavaClassId)_jid).isNestedClass()) || (_jid.getType().equals(JavaId.Type.INTERFACE) && !((JavaInterfaceId)_jid).isNested()) || (_jid.getType().equals(JavaId.Type.ENUM) && !((JavaEnumId)_jid).isNested()) ) { return _jid; } else { return this.getCompilationUnit((JavaId)_jid.getDefinitionContext()); } }