Community
Participate
Working Groups
Build 3.0RC1 Using following code to generate source for a massive class, observe that generated code is invalid, but the first occurrences of syntax errors are not notified. public class X { public static void main(String[] args) { StringBuffer buffer = new StringBuffer(); buffer.append("public class Zork {\n"); for (int i = 0; i < 1000; i++) { buffer.append("\tint field_"+i+" = 0; \n"); } for (int i = 0; i < 1000; i++) { if (i == 0) buffer.append("\tvoid method_"+i+"() { /* default */ } \n"); else buffer.append("\tvoid method_"+i+"() { method_"+ (i-1)+"() \n"); } buffer.append("}\n"); System.out.println(buffer); } }
A problem is in CompletionResult#computePriority(IProblem problem). If the line number of problems is greater than 1000 then all priorities are the same. private int computePriority(IProblem problem){ final int P_STATIC = 1000; final int P_OUTSIDE_METHOD = 4000; final int P_FIRST_ERROR = 2000; final int P_ERROR = 10000; int priority = 1000 - problem.getSourceLineNumber(); // early problems first if (priority < 0) priority = 0; if (problem.isError()){ priority += P_ERROR; } ... } Another problem is that the referenceContext for method with error in signature is the CompilationUnit and not the method. That's because the diagnose of these methods occurs during diet parse and not method parse. private int computePriority(IProblem problem){ ... ReferenceContext context = problemsMap == null ? null : (ReferenceContext) problemsMap.get(problem); if (context != null){ if (context instanceof AbstractMethodDeclaration){ AbstractMethodDeclaration method = (AbstractMethodDeclaration) context; if (method.isStatic()) { priority += P_STATIC; } } else { priority += P_OUTSIDE_METHOD; } } else { priority += P_OUTSIDE_METHOD; } ... }
I created another bug report for the reference context problem (bug 65978)
Fixed and test added ParserTests#test021()
Verified in 200406110010