private String printDeclarationStack() { final StringBuilder out = new StringBuilder().append("\t\t\t"); for (ContextStackEntry jid : this.contextStack.all()) { out.append(((JavaId) jid.getConstructId()).getType().toString() + " "); } return out.toString(); }
@Deprecated public boolean headMatches(JavaId.Type[] pattern) { boolean result = true; int patternElementIndex = 0; ContextStackEntry construct = null; Iterator<ContextStackEntry> itr = this.iterator(); while (itr.hasNext() && patternElementIndex < pattern.length) { construct = itr.next(); if (!pattern[patternElementIndex].equals(((JavaId) construct.getConstructId()).type)) { result = false; break; } else { patternElementIndex++; } } return result; }
/** * Gets the top-most element <a>of a given types</a> (without removing it). * * @param _t * the type of context elements to consider * @return */ public ContextStackEntry peek(JavaId.Type[] _t) { final Iterator<ContextStackEntry> iterator = this.nestedDeclarationContexts.iterator(); ContextStackEntry entry = null, result = null; search: while (iterator.hasNext()) { entry = iterator.next(); for(int i=0; i<_t.length; i++ ){ if (((JavaId)entry.getConstructId()).getType().equals(_t[i])) { result = entry; break search; } } } return result; }
if (topmost_stack_entry!=null && ( (JavaId)topmost_stack_entry.getConstructId()).type.equals(JavaId.Type.METHOD)) { context = (JavaId)cse.getConstructId(); class_name.append(this.incrementNamedCounter(context, this.declaredName).toString() + this.declaredName); context = (JavaId)cse.getConstructId(); context = (JavaId)cse.getConstructId(); class_name.append(this.incrementAnonymousCounter(context).toString());
@Override public void exitMethodDeclaration(com.sap.psr.vulas.java.antlr.JavaParser.MethodDeclarationContext ctx) { final JavaId id = (JavaId) this.contextStack.pop().getConstructId(); }
@Override public void exitConstructorDeclaration(com.sap.psr.vulas.java.antlr.JavaParser.ConstructorDeclarationContext ctx) { final JavaId id = (JavaId)this.contextStack.pop().getConstructId(); }
@Override public void exitClassBody(@NotNull JavaParser.ClassBodyContext ctx) { final JavaId id = (JavaId) this.contextStack.pop().getConstructId(); this.isOfExpectedType(id, new JavaId.Type[] { JavaId.Type.CLASS }, true); this.constructIdBuilder.resetCurrentDeclarationContext(); }
@Override public void exitEnumDeclaration(@NotNull JavaParser.EnumDeclarationContext ctx) { final JavaId id = (JavaId)this.contextStack.pop().getConstructId(); this.isOfExpectedType(id, new JavaId.Type[] { JavaId.Type.ENUM }, true); }
/** * 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)); }
@Override public void enterConstructorDeclaration(@NotNull JavaParser.ConstructorDeclarationContext ctx) { // Peek JavaId and ensure it is a class or enum final JavaId class_ctx = (JavaId) this.contextStack.peek().getConstructId(); this.isOfExpectedType(class_ctx, new JavaId.Type[] { JavaId.Type.CLASS, JavaId.Type.ENUM }, true); // Build the identifier final JavaId id = new JavaConstructorId((JavaId)class_ctx, this.getParameters(ctx.formalParameters().formalParameterList())); this.contextStack.push(id); this.saveConstruct(id, this.getConstructContent(ctx)); }
@Override public void exitInterfaceDeclaration(@NotNull JavaParser.InterfaceDeclarationContext ctx) { final JavaId id = (JavaId)this.contextStack.pop().getConstructId(); this.isOfExpectedType(id, new JavaId.Type[] { JavaId.Type.INTERFACE }, true); }
/** * 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); }
@Override public void enterMethodDeclaration(@NotNull JavaParser.MethodDeclarationContext ctx) { // Peek JavaId and ensure it is a class or enum final JavaId class_ctx = (JavaId) this.contextStack.peek().getConstructId(); this.isOfExpectedType(class_ctx, new JavaId.Type[] { JavaId.Type.CLASS, JavaId.Type.ENUM }, true); // Build the identifier final JavaMethodId id = new JavaMethodId((JavaId) class_ctx, ctx.IDENTIFIER().getText(), this.getParameters(ctx.formalParameters().formalParameterList())); this.contextStack.push(id); this.saveConstruct(id, this.getConstructContent(ctx)); }