/** * 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(); }
/** * Interfaces are not added to {@link #constructs}. */ @Override public void enterInterfaceDeclaration(@NotNull JavaParser.InterfaceDeclarationContext 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 JavaInterfaceId(decl_ctx, ctx.IDENTIFIER().getText()); this.contextStack.push(id); }
/** * 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.interfaceName; else return this.declarationContext.getName() + "$" + this.interfaceName; } else { return this.interfaceName; } }
/** * Returns the fully qualified interface name, i.e., including the name of the package in which it is defined. */ @Override public String getQualifiedName() { if(this.declarationContext!=null) { if(!this.isNested()) return this.declarationContext.getQualifiedName() + "." + this.interfaceName; else return this.declarationContext.getQualifiedName() + "$" + this.interfaceName; } else { return this.interfaceName; } }
/** * * @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()); } }