From: axelcl Date: Tue, 19 Apr 2005 18:36:41 +0000 (+0000) Subject: Show line numbers (other than 1) in problems view for errors and warnings X-Git-Url: http://git.phpeclipse.com Show line numbers (other than 1) in problems view for errors and warnings --- diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/impl/ReferenceContext.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/impl/ReferenceContext.java index 54da4ed..7770bf7 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/impl/ReferenceContext.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/impl/ReferenceContext.java @@ -17,8 +17,6 @@ import net.sourceforge.phpdt.internal.compiler.CompilationResult; * escape in case of error: * For example: method, type or compilation unit. */ - - public interface ReferenceContext { void abort(int abortLevel); CompilationResult compilationResult(); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java index 01897dd..908fbf8 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java @@ -4343,8 +4343,8 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI } } if (scanner.recordLineSeparator) { - // compilationUnit.compilationResult.lineSeparatorPositions = - // scanner.getLineEnds(); + compilationUnit.compilationResult.lineSeparatorPositions = + scanner.getLineEnds(); } // check placement anomalies against other kinds of brackets for (int kind = 0; kind < BracketKinds; kind++) { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java index 1740a02..c5533b7 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java @@ -213,16 +213,15 @@ public class Scanner implements IScanner, ITerminalSymbols { public ICompilationUnit compilationUnit = null; /** - * Determines if the specified character is permissible as the first character in a PHP identifier or - * variable + * Determines if the specified character is permissible as the first character in a PHP identifier or variable * * The '$' character for PHP variables is regarded as a correct first character ! - * + * */ public static boolean isPHPIdentOrVarStart(char ch) { - return Character.isLetter(ch) || (ch == '$') ||(ch == '_') || (0x7F <= ch && ch <= 0xFF); + return Character.isLetter(ch) || (ch == '$') || (ch == '_') || (0x7F <= ch && ch <= 0xFF); } - + /** * Determines if the specified character is permissible as the first character in a PHP identifier. * @@ -333,13 +332,14 @@ public class Scanner implements IScanner, ITerminalSymbols { } return result; } - + public final char[] getRawTokenSourceEnd() { - int length = this.eofPosition - this.currentPosition - 1; - char[] sourceEnd = new char[length]; - System.arraycopy(this.source, this.currentPosition, sourceEnd, 0, length); - return sourceEnd; -} + int length = this.eofPosition - this.currentPosition - 1; + char[] sourceEnd = new char[length]; + System.arraycopy(this.source, this.currentPosition, sourceEnd, 0, length); + return sourceEnd; + } + public int getCurrentTokenStartPosition() { return this.startPosition; } @@ -1142,6 +1142,10 @@ public class Scanner implements IScanner, ITerminalSymbols { withoutUnicodePtr--; } } + } else if ((currentCharacter == '\r') || (currentCharacter == '\n')) { + if (recordLineSeparator) { + pushLineSeparator(); + } } // consume next character unicodeAsBackSlash = false; @@ -1240,6 +1244,12 @@ public class Scanner implements IScanner, ITerminalSymbols { } } break; + case '\r': + case '\n': + if (recordLineSeparator) { + pushLineSeparator(); + } + break; case '$': if (isPHPIdentifierStart(source[currentPosition]) || source[currentPosition] == '{') { currentPosition--; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/UnitParser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/UnitParser.java index 9785834..02cf244 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/UnitParser.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/UnitParser.java @@ -7,6 +7,7 @@ import net.sourceforge.phpdt.internal.compiler.CompilationResult; import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit; import net.sourceforge.phpdt.internal.compiler.problem.AbortCompilation; import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter; +import net.sourceforge.phpdt.internal.core.BasicCompilationUnit; import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode; import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration; import net.sourceforge.phpeclipse.internal.compiler.ast.ConstructorDeclaration; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/problem/ProblemReporter.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/problem/ProblemReporter.java index 3d5be38..8e8ed0a 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/problem/ProblemReporter.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/problem/ProblemReporter.java @@ -2529,10 +2529,10 @@ private String javadocVisibilityArgument(int visibility, int modifiers) { expectedTypeShortName }, expression.sourceStart, expression.sourceEnd); } - public void undefinedLabel(BranchStatement statement) { - String[] arguments = new String[] { new String(statement.label) }; - this.handle(IProblem.UndefinedLabel, arguments, arguments, statement.sourceStart, statement.sourceEnd); - } +// public void undefinedLabel(BranchStatement statement) { +// String[] arguments = new String[] { new String(statement.label) }; +// this.handle(IProblem.UndefinedLabel, arguments, arguments, statement.sourceStart, statement.sourceEnd); +// } public void unexpectedStaticModifierForField(SourceTypeBinding type, FieldDeclaration fieldDecl) { String[] arguments = new String[] { fieldDecl.name() }; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnitProblemFinder.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnitProblemFinder.java index 5ebd54c..145a0d1 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnitProblemFinder.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnitProblemFinder.java @@ -37,10 +37,10 @@ import net.sourceforge.phpdt.internal.compiler.parser.SourceTypeConverter; import net.sourceforge.phpdt.internal.compiler.parser.UnitParser; import net.sourceforge.phpdt.internal.compiler.problem.AbortCompilation; import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblemFactory; +import net.sourceforge.phpdt.internal.compiler.problem.ProblemHandler; import net.sourceforge.phpdt.internal.core.util.Util; import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration; -import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IProgressMonitor; /** @@ -316,6 +316,7 @@ public class CompilationUnitProblemFinder extends Compiler { System.out.println("PROBLEM FOUND while reconciling : "+problems[i].getMessage());//$NON-NLS-1$ } if (monitor != null && monitor.isCanceled()) break; + problemRequestor.acceptProblem(problems[i]); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/AbstractImageBuilder.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/AbstractImageBuilder.java index 32a8b41..d60ea71 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/AbstractImageBuilder.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/AbstractImageBuilder.java @@ -22,442 +22,447 @@ import net.sourceforge.phpdt.internal.compiler.Compiler; import net.sourceforge.phpdt.internal.compiler.DefaultErrorHandlingPolicies; import net.sourceforge.phpdt.internal.compiler.ICompilerRequestor; import net.sourceforge.phpdt.internal.compiler.problem.AbortCompilation; +import net.sourceforge.phpdt.internal.compiler.problem.ProblemHandler; import net.sourceforge.phpdt.internal.core.util.Util; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; /** - * The abstract superclass of Java builders. - * Provides the building and compilation mechanism - * in common with the batch and incremental builders. + * The abstract superclass of Java builders. Provides the building and compilation mechanism in common with the batch and + * incremental builders. */ public abstract class AbstractImageBuilder implements ICompilerRequestor { -protected PHPBuilder javaBuilder; -protected State newState; + protected PHPBuilder javaBuilder; -// local copies -protected NameEnvironment nameEnvironment; -protected ClasspathMultiDirectory[] sourceLocations; -protected BuildNotifier notifier; + protected State newState; -protected String encoding; -protected Compiler compiler; -protected WorkQueue workQueue; -protected ArrayList problemSourceFiles; -protected boolean compiledAllAtOnce; + // local copies + protected NameEnvironment nameEnvironment; -private boolean inCompiler; + protected ClasspathMultiDirectory[] sourceLocations; -public static int MAX_AT_ONCE = 1000; + protected BuildNotifier notifier; -protected AbstractImageBuilder(PHPBuilder javaBuilder) { - this.javaBuilder = javaBuilder; - this.newState = new State(javaBuilder); + protected String encoding; - // local copies - this.nameEnvironment = javaBuilder.nameEnvironment; - this.sourceLocations = this.nameEnvironment.sourceLocations; - this.notifier = javaBuilder.notifier; + protected Compiler compiler; - this.encoding = javaBuilder.javaProject.getOption(JavaCore.CORE_ENCODING, true); - this.compiler = newCompiler(); - this.workQueue = new WorkQueue(); - this.problemSourceFiles = new ArrayList(3); -} + protected WorkQueue workQueue; -public void acceptResult(CompilationResult result) { - // In Batch mode, we write out the class files, hold onto the dependency info - // & additional types and report problems. + protected ArrayList problemSourceFiles; - // In Incremental mode, when writing out a class file we need to compare it - // against the previous file, remembering if structural changes occured. - // Before reporting the new problems, we need to update the problem count & - // remove the old problems. Plus delete additional class files that no longer exist. + protected boolean compiledAllAtOnce; - SourceFile compilationUnit = (SourceFile) result.getCompilationUnit(); // go directly back to the sourceFile - if (!workQueue.isCompiled(compilationUnit)) { - try { - workQueue.finished(compilationUnit); + private boolean inCompiler; + + public static int MAX_AT_ONCE = 1000; + + protected AbstractImageBuilder(PHPBuilder javaBuilder) { + this.javaBuilder = javaBuilder; + this.newState = new State(javaBuilder); + + // local copies + this.nameEnvironment = javaBuilder.nameEnvironment; + this.sourceLocations = this.nameEnvironment.sourceLocations; + this.notifier = javaBuilder.notifier; + + this.encoding = javaBuilder.javaProject.getOption(JavaCore.CORE_ENCODING, true); + this.compiler = newCompiler(); + this.workQueue = new WorkQueue(); + this.problemSourceFiles = new ArrayList(3); + } + + public void acceptResult(CompilationResult result) { + // In Batch mode, we write out the class files, hold onto the dependency info + // & additional types and report problems. + + // In Incremental mode, when writing out a class file we need to compare it + // against the previous file, remembering if structural changes occured. + // Before reporting the new problems, we need to update the problem count & + // remove the old problems. Plus delete additional class files that no longer exist. + + SourceFile compilationUnit = (SourceFile) result.getCompilationUnit(); // go directly back to the sourceFile + if (!workQueue.isCompiled(compilationUnit)) { +// try { + workQueue.finished(compilationUnit); + try { updateProblemsFor(compilationUnit, result); // record compilation problems before potentially adding duplicate errors - updateTasksFor(compilationUnit, result); // record tasks - - String typeLocator = compilationUnit.typeLocator(); -// ClassFile[] classFiles = result.getClassFiles(); -// int length = classFiles.length; -// ArrayList duplicateTypeNames = null; -// ArrayList definedTypeNames = new ArrayList(length); -// for (int i = 0; i < length; i++) { -// ClassFile classFile = classFiles[i]; -// char[][] compoundName = classFile.getCompoundName(); -// char[] typeName = compoundName[compoundName.length - 1]; -// boolean isNestedType = CharOperation.contains('$', typeName); -// -// // Look for a possible collision, if one exists, report an error but do not write the class file -// if (isNestedType) { -// String qualifiedTypeName = new String(classFile.outerMostEnclosingClassFile().fileName()); -// if (newState.isDuplicateLocator(qualifiedTypeName, typeLocator)) -// continue; -// } else { -// String qualifiedTypeName = new String(classFile.fileName()); // the qualified type name "p1/p2/A" -// if (newState.isDuplicateLocator(qualifiedTypeName, typeLocator)) { -// if (duplicateTypeNames == null) -// duplicateTypeNames = new ArrayList(); -// duplicateTypeNames.add(compoundName); -// createErrorFor(compilationUnit.resource, ProjectPrefUtil.bind("build.duplicateClassFile", new String(typeName))); //$NON-NLS-1$ -// continue; -// } -// newState.recordLocatorForType(qualifiedTypeName, typeLocator); -// } -// definedTypeNames.add(writeClassFile(classFile, compilationUnit.sourceLocation.binaryFolder, !isNestedType)); -// } - -// finishedWith(typeLocator, result, compilationUnit.getMainTypeName(), definedTypeNames, duplicateTypeNames); - notifier.compiled(compilationUnit); + updateTasksFor(compilationUnit, result); // record tasks } catch (CoreException e) { - Util.log(e, "JavaBuilder handling CoreException"); //$NON-NLS-1$ - createErrorFor(compilationUnit.resource, Util.bind("build.inconsistentClassFile")); //$NON-NLS-1$ - } - } -} - -protected void cleanUp() { - this.nameEnvironment.cleanup(); - - this.javaBuilder = null; - this.nameEnvironment = null; - this.sourceLocations = null; - this.notifier = null; - this.compiler = null; - this.workQueue = null; - this.problemSourceFiles = null; -} - -/* Compile the given elements, adding more elements to the work queue -* if they are affected by the changes. -*/ -protected void compile(SourceFile[] units) { - int toDo = units.length; - if (this.compiledAllAtOnce = toDo <= MAX_AT_ONCE) { - // do them all now - if (PHPBuilder.DEBUG) - for (int i = 0; i < toDo; i++) - System.out.println("About to compile " + units[i].typeLocator()); //$NON-NLS-1$ - compile(units, null); - } else { - int i = 0; - boolean compilingFirstGroup = true; - while (i < toDo) { - int doNow = toDo < MAX_AT_ONCE ? toDo : MAX_AT_ONCE; - int index = 0; - SourceFile[] toCompile = new SourceFile[doNow]; - while (i < toDo && index < doNow) { - // Although it needed compiling when this method was called, it may have - // already been compiled when it was referenced by another unit. - SourceFile unit = units[i++]; - if (compilingFirstGroup || workQueue.isWaiting(unit)) { - if (PHPBuilder.DEBUG) - System.out.println("About to compile " + unit.typeLocator()); //$NON-NLS-1$ - toCompile[index++] = unit; - } - } - if (index < doNow) - System.arraycopy(toCompile, 0, toCompile = new SourceFile[index], 0, index); - SourceFile[] additionalUnits = new SourceFile[toDo - i]; - System.arraycopy(units, i, additionalUnits, 0, additionalUnits.length); - compilingFirstGroup = false; - compile(toCompile, additionalUnits); - } - } -} - -void compile(SourceFile[] units, SourceFile[] additionalUnits) { - if (units.length == 0) return; - notifier.aboutToCompile(units[0]); // just to change the message - - // extend additionalFilenames with all hierarchical problem types found during this entire build - if (!problemSourceFiles.isEmpty()) { - int toAdd = problemSourceFiles.size(); - int length = additionalUnits == null ? 0 : additionalUnits.length; - if (length == 0) - additionalUnits = new SourceFile[toAdd]; - else - System.arraycopy(additionalUnits, 0, additionalUnits = new SourceFile[length + toAdd], 0, length); - for (int i = 0; i < toAdd; i++) - additionalUnits[length + i] = (SourceFile) problemSourceFiles.get(i); - } - String[] initialTypeNames = new String[units.length]; - for (int i = 0, l = units.length; i < l; i++) - initialTypeNames[i] = units[i].initialTypeName; - nameEnvironment.setNames(initialTypeNames, additionalUnits); - notifier.checkCancel(); - try { - inCompiler = true; - compiler.compile(units); - } catch (AbortCompilation ignored) { - // ignore the AbortCompilcation coming from BuildNotifier.checkCancelWithinCompiler() - // the Compiler failed after the user has chose to cancel... likely due to an OutOfMemory error - } finally { - inCompiler = false; - } - // Check for cancel immediately after a compile, because the compiler may - // have been cancelled but without propagating the correct exception - notifier.checkCancel(); -} - -protected void createErrorFor(IResource resource, String message) { - try { - IMarker marker = resource.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); - int severity = IMarker.SEVERITY_ERROR; - if (message.equals(Util.bind("build.duplicateResource"))) //$NON-NLS-1$ - if (JavaCore.WARNING.equals(javaBuilder.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE, true))) - severity = IMarker.SEVERITY_WARNING; - marker.setAttributes( - new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IMarker.CHAR_START, IMarker.CHAR_END}, - new Object[] {message, new Integer(severity), new Integer(0), new Integer(1)}); - } catch (CoreException e) { - throw internalException(e); - } -} - -//protected void finishedWith(String sourceLocator, CompilationResult result, char[] mainTypeName) throws CoreException {//, ArrayList definedTypeNames, ArrayList duplicateTypeNames) throws CoreException { -// if (duplicateTypeNames == null) { -// newState.record(sourceLocator, result.qualifiedReferences, result.simpleNameReferences, mainTypeName, definedTypeNames); -// return; -// } -// -// char[][][] qualifiedRefs = result.qualifiedReferences; -// char[][] simpleRefs = result.simpleNameReferences; -// // for each duplicate type p1.p2.A, add the type name A (package was already added) -// next : for (int i = 0, l = duplicateTypeNames.size(); i < l; i++) { -// char[][] compoundName = (char[][]) duplicateTypeNames.get(i); -// char[] typeName = compoundName[compoundName.length - 1]; -// int sLength = simpleRefs.length; -// for (int j = 0; j < sLength; j++) -// if (CharOperation.equals(simpleRefs[j], typeName)) -// continue next; -// System.arraycopy(simpleRefs, 0, simpleRefs = new char[sLength + 1][], 0, sLength); -// simpleRefs[sLength] = typeName; -// } -// newState.record(sourceLocator, qualifiedRefs, simpleRefs, mainTypeName, definedTypeNames); -//} - -//protected IContainer createFolder(IPath packagePath, IContainer outputFolder) throws CoreException { -// if (packagePath.isEmpty()) return outputFolder; -// IFolder folder = outputFolder.getFolder(packagePath); -// if (!folder.exists()) { -// createFolder(packagePath.removeLastSegments(1), outputFolder); -// folder.create(true, true, null); -// folder.setDerived(true); -// } -// return folder; -//} - -protected RuntimeException internalException(CoreException t) { - ImageBuilderInternalException imageBuilderException = new ImageBuilderInternalException(t); - if (inCompiler) - return new AbortCompilation(true, imageBuilderException); - return imageBuilderException; -} - -protected Compiler newCompiler() { - // called once when the builder is initialized... can override if needed - return new Compiler( - nameEnvironment, - DefaultErrorHandlingPolicies.proceedWithAllProblems(), - javaBuilder.javaProject.getOptions(true), - this, - ProblemFactory.getProblemFactory(Locale.getDefault())); -} - -protected boolean isExcludedFromProject(IPath childPath) throws JavaModelException { - // answer whether the folder should be ignored when walking the project as a source folder - if (childPath.segmentCount() > 2) return false; // is a subfolder of a package - - for (int j = 0, k = sourceLocations.length; j < k; j++) { -// if (childPath.equals(sourceLocations[j].binaryFolder.getFullPath())) return true; - if (childPath.equals(sourceLocations[j].sourceFolder.getFullPath())) return true; - } - // skip default output folder which may not be used by any source folder - return false; //childPath.equals(javaBuilder.javaProject.getOutputLocation()); -} - -/** - * Creates a marker from each problem and adds it to the resource. - * The marker is as follows: - * - its type is T_PROBLEM - * - its plugin ID is the JavaBuilder's plugin ID - * - its message is the problem's message - * - its priority reflects the severity of the problem - * - its range is the problem's range - * - it has an extra attribute "ID" which holds the problem's id - */ -protected void storeProblemsFor(SourceFile sourceFile, IProblem[] problems) throws CoreException { - if (sourceFile == null || problems == null || problems.length == 0) return; - -// String missingClassFile = null; - IResource resource = sourceFile.resource; - for (int i = 0, l = problems.length; i < l; i++) { - IProblem problem = problems[i]; - int id = problem.getID(); - switch (id) { - case IProblem.IsClassPathCorrect : -// PHPBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject); // make this the only problem for this project -// String[] args = problem.getArguments(); -// missingClassFile = args[0]; - break; - case IProblem.SuperclassMustBeAClass : - case IProblem.SuperInterfaceMustBeAnInterface : - case IProblem.HierarchyCircularitySelfReference : - case IProblem.HierarchyCircularity : - case IProblem.HierarchyHasProblems : - case IProblem.SuperclassNotFound : - case IProblem.SuperclassNotVisible : - case IProblem.SuperclassAmbiguous : - case IProblem.SuperclassInternalNameProvided : - case IProblem.SuperclassInheritedNameHidesEnclosingName : - case IProblem.InterfaceNotFound : - case IProblem.InterfaceNotVisible : - case IProblem.InterfaceAmbiguous : - case IProblem.InterfaceInternalNameProvided : - case IProblem.InterfaceInheritedNameHidesEnclosingName : - // ensure that this file is always retrieved from source for the rest of the build - if (!problemSourceFiles.contains(sourceFile)) - problemSourceFiles.add(sourceFile); - break; - } - - if (id != IProblem.Task) { - IMarker marker = resource.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); - marker.setAttributes( - new String[] { - IMarker.MESSAGE, - IMarker.SEVERITY, - IJavaModelMarker.ID, - IMarker.CHAR_START, - IMarker.CHAR_END, - IMarker.LINE_NUMBER, - IJavaModelMarker.ARGUMENTS}, - new Object[] { - problem.getMessage(), - new Integer(problem.isError() ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING), - new Integer(id), - new Integer(problem.getSourceStart()), - new Integer(problem.getSourceEnd() + 1), - new Integer(problem.getSourceLineNumber()), - Util.getProblemArgumentsForMarker(problem.getArguments()) - }); - } - -/* Do NOT want to populate the Java Model just to find the matching Java element. - * Also cannot query compilation units located in folders with invalid package - * names such as 'a/b.c.d/e'. - - // compute a user-friendly location - IJavaElement element = JavaCore.create(resource); - if (element instanceof net.sourceforge.phpdt.core.ICompilationUnit) { // try to find a finer grain element - net.sourceforge.phpdt.core.ICompilationUnit unit = (net.sourceforge.phpdt.core.ICompilationUnit) element; - IJavaElement fragment = unit.getElementAt(problem.getSourceStart()); - if (fragment != null) element = fragment; - } - String location = null; - if (element instanceof JavaElement) - location = ((JavaElement) element).readableName(); - if (location != null) - marker.setAttribute(IMarker.LOCATION, location); -*/ - -// if (missingClassFile != null) -// throw new MissingClassFileException(missingClassFile); - } -} - -protected void storeTasksFor(SourceFile sourceFile, IProblem[] tasks) throws CoreException { - if (sourceFile == null || tasks == null || tasks.length == 0) return; - - IResource resource = sourceFile.resource; - for (int i = 0, l = tasks.length; i < l; i++) { - IProblem task = tasks[i]; - if (task.getID() == IProblem.Task) { - IMarker marker = resource.createMarker(IJavaModelMarker.TASK_MARKER); - int priority = IMarker.PRIORITY_NORMAL; - String compilerPriority = task.getArguments()[2]; - if (JavaCore.COMPILER_TASK_PRIORITY_HIGH.equals(compilerPriority)) - priority = IMarker.PRIORITY_HIGH; - else if (JavaCore.COMPILER_TASK_PRIORITY_LOW.equals(compilerPriority)) - priority = IMarker.PRIORITY_LOW; - marker.setAttributes( - new String[] { - IMarker.MESSAGE, - IMarker.PRIORITY, - IMarker.DONE, - IMarker.CHAR_START, - IMarker.CHAR_END, - IMarker.LINE_NUMBER, - IMarker.USER_EDITABLE, - }, - new Object[] { - task.getMessage(), - new Integer(priority), - new Boolean(false), - new Integer(task.getSourceStart()), - new Integer(task.getSourceEnd() + 1), - new Integer(task.getSourceLineNumber()), - new Boolean(false), - }); - } - } -} - -protected void updateProblemsFor(SourceFile sourceFile, CompilationResult result) throws CoreException { - IProblem[] problems = result.getProblems(); - if (problems == null || problems.length == 0) return; - - notifier.updateProblemCounts(problems); - storeProblemsFor(sourceFile, problems); -} - -protected void updateTasksFor(SourceFile sourceFile, CompilationResult result) throws CoreException { - IProblem[] tasks = result.getTasks(); - if (tasks == null || tasks.length == 0) return; - - storeTasksFor(sourceFile, tasks); -} - -//protected char[] writeClassFile(ClassFile classFile, IContainer outputFolder, boolean isSecondaryType) throws CoreException { -// String fileName = new String(classFile.fileName()); // the qualified type name "p1/p2/A" -// IPath filePath = new Path(fileName); -// IContainer container = outputFolder; -// if (filePath.segmentCount() > 1) { -// container = createFolder(filePath.removeLastSegments(1), outputFolder); -// filePath = new Path(filePath.lastSegment()); -// } -// -// IFile file = container.getFile(filePath.addFileExtension(JavaBuilder.CLASS_EXTENSION)); -// writeClassFileBytes(classFile.getBytes(), file, fileName, isSecondaryType); -// // answer the name of the class file as in Y or Y$M -// return filePath.lastSegment().toCharArray(); -//} -// -//protected void writeClassFileBytes(byte[] bytes, IFile file, String qualifiedFileName, boolean isSecondaryType) throws CoreException { -// if (file.exists()) { -// // Deal with shared output folders... last one wins... no collision cases detected -// if (JavaBuilder.DEBUG) -// System.out.println("Writing changed class file " + file.getName());//$NON-NLS-1$ -// file.setContents(new ByteArrayInputStream(bytes), true, false, null); -// if (!file.isDerived()) -// file.setDerived(true); -// } else { -// // Default implementation just writes out the bytes for the new class file... -// if (JavaBuilder.DEBUG) -// System.out.println("Writing new class file " + file.getName());//$NON-NLS-1$ -// file.create(new ByteArrayInputStream(bytes), IResource.FORCE, null); -// file.setDerived(true); -// } -//} -} + throw internalException(e); + } + + // String typeLocator = compilationUnit.typeLocator(); + // ClassFile[] classFiles = result.getClassFiles(); + // int length = classFiles.length; + // ArrayList duplicateTypeNames = null; + // ArrayList definedTypeNames = new ArrayList(length); + // for (int i = 0; i < length; i++) { + // ClassFile classFile = classFiles[i]; + // char[][] compoundName = classFile.getCompoundName(); + // char[] typeName = compoundName[compoundName.length - 1]; + // boolean isNestedType = CharOperation.contains('$', typeName); + // + // // Look for a possible collision, if one exists, report an error but do not write the class file + // if (isNestedType) { + // String qualifiedTypeName = new String(classFile.outerMostEnclosingClassFile().fileName()); + // if (newState.isDuplicateLocator(qualifiedTypeName, typeLocator)) + // continue; + // } else { + // String qualifiedTypeName = new String(classFile.fileName()); // the qualified type name "p1/p2/A" + // if (newState.isDuplicateLocator(qualifiedTypeName, typeLocator)) { + // if (duplicateTypeNames == null) + // duplicateTypeNames = new ArrayList(); + // duplicateTypeNames.add(compoundName); + // createErrorFor(compilationUnit.resource, ProjectPrefUtil.bind("build.duplicateClassFile", new String(typeName))); + // //$NON-NLS-1$ + // continue; + // } + // newState.recordLocatorForType(qualifiedTypeName, typeLocator); + // } + // definedTypeNames.add(writeClassFile(classFile, compilationUnit.sourceLocation.binaryFolder, !isNestedType)); + // } + + // finishedWith(typeLocator, result, compilationUnit.getMainTypeName(), definedTypeNames, duplicateTypeNames); + notifier.compiled(compilationUnit); +// } catch (CoreException e) { +// Util.log(e, "JavaBuilder handling CoreException"); //$NON-NLS-1$ +// createErrorFor(compilationUnit.resource, Util.bind("build.inconsistentClassFile")); //$NON-NLS-1$ +// } + } + } + + protected void cleanUp() { + this.nameEnvironment.cleanup(); + + this.javaBuilder = null; + this.nameEnvironment = null; + this.sourceLocations = null; + this.notifier = null; + this.compiler = null; + this.workQueue = null; + this.problemSourceFiles = null; + } + + /* + * Compile the given elements, adding more elements to the work queue if they are affected by the changes. + */ + protected void compile(SourceFile[] units) { + int toDo = units.length; + if (this.compiledAllAtOnce = toDo <= MAX_AT_ONCE) { + // do them all now + if (PHPBuilder.DEBUG) + for (int i = 0; i < toDo; i++) + System.out.println("About to compile " + units[i].typeLocator()); //$NON-NLS-1$ + compile(units, null); + } else { + int i = 0; + boolean compilingFirstGroup = true; + while (i < toDo) { + int doNow = toDo < MAX_AT_ONCE ? toDo : MAX_AT_ONCE; + int index = 0; + SourceFile[] toCompile = new SourceFile[doNow]; + while (i < toDo && index < doNow) { + // Although it needed compiling when this method was called, it may have + // already been compiled when it was referenced by another unit. + SourceFile unit = units[i++]; + if (compilingFirstGroup || workQueue.isWaiting(unit)) { + if (PHPBuilder.DEBUG) + System.out.println("About to compile " + unit.typeLocator()); //$NON-NLS-1$ + toCompile[index++] = unit; + } + } + if (index < doNow) + System.arraycopy(toCompile, 0, toCompile = new SourceFile[index], 0, index); + SourceFile[] additionalUnits = new SourceFile[toDo - i]; + System.arraycopy(units, i, additionalUnits, 0, additionalUnits.length); + compilingFirstGroup = false; + compile(toCompile, additionalUnits); + } + } + } + + void compile(SourceFile[] units, SourceFile[] additionalUnits) { + if (units.length == 0) + return; + notifier.aboutToCompile(units[0]); // just to change the message + + // extend additionalFilenames with all hierarchical problem types found during this entire build + if (!problemSourceFiles.isEmpty()) { + int toAdd = problemSourceFiles.size(); + int length = additionalUnits == null ? 0 : additionalUnits.length; + if (length == 0) + additionalUnits = new SourceFile[toAdd]; + else + System.arraycopy(additionalUnits, 0, additionalUnits = new SourceFile[length + toAdd], 0, length); + for (int i = 0; i < toAdd; i++) + additionalUnits[length + i] = (SourceFile) problemSourceFiles.get(i); + } + String[] initialTypeNames = new String[units.length]; + for (int i = 0, l = units.length; i < l; i++) + initialTypeNames[i] = units[i].initialTypeName; + nameEnvironment.setNames(initialTypeNames, additionalUnits); + notifier.checkCancel(); + try { + inCompiler = true; + compiler.compile(units); + } catch (AbortCompilation ignored) { + // ignore the AbortCompilcation coming from BuildNotifier.checkCancelWithinCompiler() + // the Compiler failed after the user has chose to cancel... likely due to an OutOfMemory error + } finally { + inCompiler = false; + } + // Check for cancel immediately after a compile, because the compiler may + // have been cancelled but without propagating the correct exception + notifier.checkCancel(); + } + + protected void createErrorFor(IResource resource, String message) { + try { + IMarker marker = resource.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); + int severity = IMarker.SEVERITY_ERROR; + if (message.equals(Util.bind("build.duplicateResource"))) //$NON-NLS-1$ + if (JavaCore.WARNING.equals(javaBuilder.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE, true))) + severity = IMarker.SEVERITY_WARNING; + marker.setAttributes(new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IMarker.CHAR_START, IMarker.CHAR_END }, new Object[] { + message, + new Integer(severity), + new Integer(0), + new Integer(1) }); + } catch (CoreException e) { + throw internalException(e); + } + } + + //protected void finishedWith(String sourceLocator, CompilationResult result, char[] mainTypeName) throws CoreException {//, + // ArrayList definedTypeNames, ArrayList duplicateTypeNames) throws CoreException { + // if (duplicateTypeNames == null) { + // newState.record(sourceLocator, result.qualifiedReferences, result.simpleNameReferences, mainTypeName, definedTypeNames); + // return; + // } + // + // char[][][] qualifiedRefs = result.qualifiedReferences; + // char[][] simpleRefs = result.simpleNameReferences; + // // for each duplicate type p1.p2.A, add the type name A (package was already added) + // next : for (int i = 0, l = duplicateTypeNames.size(); i < l; i++) { + // char[][] compoundName = (char[][]) duplicateTypeNames.get(i); + // char[] typeName = compoundName[compoundName.length - 1]; + // int sLength = simpleRefs.length; + // for (int j = 0; j < sLength; j++) + // if (CharOperation.equals(simpleRefs[j], typeName)) + // continue next; + // System.arraycopy(simpleRefs, 0, simpleRefs = new char[sLength + 1][], 0, sLength); + // simpleRefs[sLength] = typeName; + // } + // newState.record(sourceLocator, qualifiedRefs, simpleRefs, mainTypeName, definedTypeNames); + //} + + //protected IContainer createFolder(IPath packagePath, IContainer outputFolder) throws CoreException { + // if (packagePath.isEmpty()) return outputFolder; + // IFolder folder = outputFolder.getFolder(packagePath); + // if (!folder.exists()) { + // createFolder(packagePath.removeLastSegments(1), outputFolder); + // folder.create(true, true, null); + // folder.setDerived(true); + // } + // return folder; + //} + + protected RuntimeException internalException(CoreException t) { + ImageBuilderInternalException imageBuilderException = new ImageBuilderInternalException(t); + if (inCompiler) + return new AbortCompilation(true, imageBuilderException); + return imageBuilderException; + } + + protected Compiler newCompiler() { + // called once when the builder is initialized... can override if needed + return new Compiler(nameEnvironment, DefaultErrorHandlingPolicies.proceedWithAllProblems(), javaBuilder.javaProject + .getOptions(true), this, ProblemFactory.getProblemFactory(Locale.getDefault())); + } + + protected boolean isExcludedFromProject(IPath childPath) throws JavaModelException { + // answer whether the folder should be ignored when walking the project as a source folder + if (childPath.segmentCount() > 2) + return false; // is a subfolder of a package + + for (int j = 0, k = sourceLocations.length; j < k; j++) { + // if (childPath.equals(sourceLocations[j].binaryFolder.getFullPath())) return true; + if (childPath.equals(sourceLocations[j].sourceFolder.getFullPath())) + return true; + } + // skip default output folder which may not be used by any source folder + return false; //childPath.equals(javaBuilder.javaProject.getOutputLocation()); + } + + /** + * Creates a marker from each problem and adds it to the resource. The marker is as follows: - its type is T_PROBLEM - its plugin + * ID is the JavaBuilder's plugin ID - its message is the problem's message - its priority reflects the severity of the problem - + * its range is the problem's range - it has an extra attribute "ID" which holds the problem's id + */ + protected void storeProblemsFor(SourceFile sourceFile, IProblem[] problems) throws CoreException { + if (sourceFile == null || problems == null || problems.length == 0) + return; + + // String missingClassFile = null; + IResource resource = sourceFile.resource; + for (int i = 0, l = problems.length; i < l; i++) { + IProblem problem = problems[i]; + int id = problem.getID(); + switch (id) { + case IProblem.IsClassPathCorrect: + // PHPBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject); // make this the only problem for this project + // String[] args = problem.getArguments(); + // missingClassFile = args[0]; + break; + case IProblem.SuperclassMustBeAClass: + case IProblem.SuperInterfaceMustBeAnInterface: + case IProblem.HierarchyCircularitySelfReference: + case IProblem.HierarchyCircularity: + case IProblem.HierarchyHasProblems: + case IProblem.SuperclassNotFound: + case IProblem.SuperclassNotVisible: + case IProblem.SuperclassAmbiguous: + case IProblem.SuperclassInternalNameProvided: + case IProblem.SuperclassInheritedNameHidesEnclosingName: + case IProblem.InterfaceNotFound: + case IProblem.InterfaceNotVisible: + case IProblem.InterfaceAmbiguous: + case IProblem.InterfaceInternalNameProvided: + case IProblem.InterfaceInheritedNameHidesEnclosingName: + // ensure that this file is always retrieved from source for the rest of the build + if (!problemSourceFiles.contains(sourceFile)) + problemSourceFiles.add(sourceFile); + break; + } + + if (id != IProblem.Task) { + IMarker marker = resource.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); + marker.setAttributes(new String[] { + IMarker.MESSAGE, + IMarker.SEVERITY, + IJavaModelMarker.ID, + IMarker.CHAR_START, + IMarker.CHAR_END, + IMarker.LINE_NUMBER, + IJavaModelMarker.ARGUMENTS }, new Object[] { + problem.getMessage(), + new Integer(problem.isError() ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING), + new Integer(id), + new Integer(problem.getSourceStart()), + new Integer(problem.getSourceEnd() + 1), + new Integer(problem.getSourceLineNumber()), + Util.getProblemArgumentsForMarker(problem.getArguments()) }); + } + + /* + * Do NOT want to populate the Java Model just to find the matching Java element. Also cannot query compilation units located + * in folders with invalid package names such as 'a/b.c.d/e'. + * // compute a user-friendly location IJavaElement element = JavaCore.create(resource); if (element instanceof + * net.sourceforge.phpdt.core.ICompilationUnit) { // try to find a finer grain element + * net.sourceforge.phpdt.core.ICompilationUnit unit = (net.sourceforge.phpdt.core.ICompilationUnit) element; IJavaElement + * fragment = unit.getElementAt(problem.getSourceStart()); if (fragment != null) element = fragment; } String location = null; + * if (element instanceof JavaElement) location = ((JavaElement) element).readableName(); if (location != null) + * marker.setAttribute(IMarker.LOCATION, location); + */ + + // if (missingClassFile != null) + // throw new MissingClassFileException(missingClassFile); + } + } + + protected void storeTasksFor(SourceFile sourceFile, IProblem[] tasks) throws CoreException { + if (sourceFile == null || tasks == null || tasks.length == 0) + return; + + IResource resource = sourceFile.resource; + for (int i = 0, l = tasks.length; i < l; i++) { + IProblem task = tasks[i]; + if (task.getID() == IProblem.Task) { + IMarker marker = resource.createMarker(IJavaModelMarker.TASK_MARKER); + int priority = IMarker.PRIORITY_NORMAL; + String compilerPriority = task.getArguments()[2]; + if (JavaCore.COMPILER_TASK_PRIORITY_HIGH.equals(compilerPriority)) + priority = IMarker.PRIORITY_HIGH; + else if (JavaCore.COMPILER_TASK_PRIORITY_LOW.equals(compilerPriority)) + priority = IMarker.PRIORITY_LOW; + marker.setAttributes(new String[] { + IMarker.MESSAGE, + IMarker.PRIORITY, + IMarker.DONE, + IMarker.CHAR_START, + IMarker.CHAR_END, + IMarker.LINE_NUMBER, + IMarker.USER_EDITABLE, }, new Object[] { + task.getMessage(), + new Integer(priority), + new Boolean(false), + new Integer(task.getSourceStart()), + new Integer(task.getSourceEnd() + 1), + new Integer(task.getSourceLineNumber()), + new Boolean(false), }); + } + } + } + + protected void updateProblemsFor(SourceFile sourceFile, CompilationResult result) throws CoreException { + IProblem[] problems = result.getProblems(); + if (problems == null || problems.length == 0) + return; + //axelcl start insert - calculate line numbers + for (int i = 0; i < problems.length; i++) { + if (problems[i].getSourceLineNumber() == 1) { + problems[i].setSourceLineNumber(ProblemHandler + .searchLineNumber(result.lineSeparatorPositions, problems[i].getSourceStart())); + } + } + //axelcl end insert + notifier.updateProblemCounts(problems); + storeProblemsFor(sourceFile, problems); + } + + protected void updateTasksFor(SourceFile sourceFile, CompilationResult result) throws CoreException { + IProblem[] tasks = result.getTasks(); + if (tasks == null || tasks.length == 0) + return; + + storeTasksFor(sourceFile, tasks); + } + + //protected char[] writeClassFile(ClassFile classFile, IContainer outputFolder, boolean isSecondaryType) throws CoreException { + // String fileName = new String(classFile.fileName()); // the qualified type name "p1/p2/A" + // IPath filePath = new Path(fileName); + // IContainer container = outputFolder; + // if (filePath.segmentCount() > 1) { + // container = createFolder(filePath.removeLastSegments(1), outputFolder); + // filePath = new Path(filePath.lastSegment()); + // } + // + // IFile file = container.getFile(filePath.addFileExtension(JavaBuilder.CLASS_EXTENSION)); + // writeClassFileBytes(classFile.getBytes(), file, fileName, isSecondaryType); + // // answer the name of the class file as in Y or Y$M + // return filePath.lastSegment().toCharArray(); + //} + // + //protected void writeClassFileBytes(byte[] bytes, IFile file, String qualifiedFileName, boolean isSecondaryType) throws + // CoreException { + // if (file.exists()) { + // // Deal with shared output folders... last one wins... no collision cases detected + // if (JavaBuilder.DEBUG) + // System.out.println("Writing changed class file " + file.getName());//$NON-NLS-1$ + // file.setContents(new ByteArrayInputStream(bytes), true, false, null); + // if (!file.isDerived()) + // file.setDerived(true); + // } else { + // // Default implementation just writes out the bytes for the new class file... + // if (JavaBuilder.DEBUG) + // System.out.println("Writing new class file " + file.getName());//$NON-NLS-1$ + // file.create(new ByteArrayInputStream(bytes), IResource.FORCE, null); + // file.setDerived(true); + // } + //} +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/IncrementalImageBuilder.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/IncrementalImageBuilder.java index 5765f22..61db63d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/IncrementalImageBuilder.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/IncrementalImageBuilder.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import net.sourceforge.phpdt.core.compiler.IProblem; import net.sourceforge.phpdt.internal.compiler.CompilationResult; +import net.sourceforge.phpdt.internal.compiler.problem.ProblemHandler; import net.sourceforge.phpdt.internal.core.util.SimpleLookupTable; import net.sourceforge.phpdt.internal.core.util.Util; @@ -655,6 +656,16 @@ public class IncrementalImageBuilder extends AbstractImageBuilder { IProblem[] problems = result.getProblems(); if (problems == null && markers.length == 0) return; + +// axelcl start insert - calculate line numbers + for (int i = 0; i < problems.length; i++) { + if (problems[i].getSourceLineNumber() == 1) { + problems[i].setSourceLineNumber(ProblemHandler + .searchLineNumber(result.lineSeparatorPositions, problems[i].getSourceStart())); + } + } + //axelcl end insert + notifier.updateProblemCounts(markers, problems); PHPBuilder.removeProblemsFor(sourceFile.resource); storeProblemsFor(sourceFile, problems); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/BranchStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/BranchStatement.java index eb6b06f..df2725a 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/BranchStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/BranchStatement.java @@ -14,14 +14,14 @@ import net.sourceforge.phpdt.internal.compiler.codegen.Label; import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope; public abstract class BranchStatement extends Statement { - public char[] label; + public Expression expression; public Label targetLabel; public ASTNode[] subroutines; /** * BranchStatement constructor comment. */ -public BranchStatement(char[] l, int s,int e) { - label = l ; +public BranchStatement(Expression expr, int s,int e) { + expression = expr ; sourceStart = s; sourceEnd = e; } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/BreakStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/BreakStatement.java index 2c657e6..d56fc43 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/BreakStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/BreakStatement.java @@ -17,8 +17,8 @@ import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope; public class BreakStatement extends BranchStatement { - public BreakStatement(char[] label, int sourceStart, int e) { - super(label, sourceStart, e); + public BreakStatement(Expression expr, int sourceStart, int e) { + super(expr, sourceStart, e); } public FlowInfo analyseCode( @@ -30,52 +30,52 @@ public class BreakStatement extends BranchStatement { // to each of the traversed try statements, so that execution will terminate properly. // lookup the label, this should answer the returnContext - FlowContext targetContext = (label == null) - ? flowContext.getTargetContextForDefaultBreak() - : flowContext.getTargetContextForBreakLabel(label); - - if (targetContext == null) { - if (label == null) { - currentScope.problemReporter().invalidBreak(this); - } else { - currentScope.problemReporter().undefinedLabel(this); - } - return flowInfo; // pretend it did not break since no actual target - } - - targetLabel = targetContext.breakLabel(); - FlowContext traversedContext = flowContext; - int subIndex = 0, maxSub = 5; - subroutines = new ASTNode[maxSub]; - - do { - ASTNode sub; - if ((sub = traversedContext.subRoutine()) != null) { - if (subIndex == maxSub) { - System.arraycopy(subroutines, 0, (subroutines = new ASTNode[maxSub*=2]), 0, subIndex); // grow - } - subroutines[subIndex++] = sub; - if (sub.cannotReturn()) { - break; - } - } - traversedContext.recordReturnFrom(flowInfo.unconditionalInits()); - - ASTNode node; - if ((node = traversedContext.associatedNode) instanceof TryStatement) { - TryStatement tryStatement = (TryStatement) node; - flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits - } else if (traversedContext == targetContext) { - // only record break info once accumulated through subroutines, and only against target context - targetContext.recordBreakFrom(flowInfo); - break; - } - } while ((traversedContext = traversedContext.parent) != null); - - // resize subroutines - if (subIndex != maxSub) { - System.arraycopy(subroutines, 0, (subroutines = new ASTNode[subIndex]), 0, subIndex); - } +// FlowContext targetContext = (label == null) +// ? flowContext.getTargetContextForDefaultBreak() +// : flowContext.getTargetContextForBreakLabel(label); +// +// if (targetContext == null) { +// if (label == null) { +// currentScope.problemReporter().invalidBreak(this); +// } else { +// currentScope.problemReporter().undefinedLabel(this); +// } +// return flowInfo; // pretend it did not break since no actual target +// } +// +// targetLabel = targetContext.breakLabel(); +// FlowContext traversedContext = flowContext; +// int subIndex = 0, maxSub = 5; +// subroutines = new ASTNode[maxSub]; +// +// do { +// ASTNode sub; +// if ((sub = traversedContext.subRoutine()) != null) { +// if (subIndex == maxSub) { +// System.arraycopy(subroutines, 0, (subroutines = new ASTNode[maxSub*=2]), 0, subIndex); // grow +// } +// subroutines[subIndex++] = sub; +// if (sub.cannotReturn()) { +// break; +// } +// } +// traversedContext.recordReturnFrom(flowInfo.unconditionalInits()); +// +// ASTNode node; +// if ((node = traversedContext.associatedNode) instanceof TryStatement) { +// TryStatement tryStatement = (TryStatement) node; +// flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits +// } else if (traversedContext == targetContext) { +// // only record break info once accumulated through subroutines, and only against target context +// targetContext.recordBreakFrom(flowInfo); +// break; +// } +// } while ((traversedContext = traversedContext.parent) != null); +// +// // resize subroutines +// if (subIndex != maxSub) { +// System.arraycopy(subroutines, 0, (subroutines = new ASTNode[subIndex]), 0, subIndex); +// } return FlowInfo.DEAD_END; } @@ -83,14 +83,14 @@ public class BreakStatement extends BranchStatement { String s = tabString(tab); s += "break "; //$NON-NLS-1$ - if (label != null) - s += new String(label); + if (expression != null) + s += expression.toString(); return s; } public StringBuffer printStatement(int tab, StringBuffer output) { printIndent(tab, output).append("break "); //$NON-NLS-1$ - if (label != null) output.append(label); + if (expression != null) output.append(expression); return output.append(';'); } public void traverse( diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/ContinueStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/ContinueStatement.java index 96d2a1b..6f5479f 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/ContinueStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/ContinueStatement.java @@ -17,9 +17,9 @@ import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope; public class ContinueStatement extends BranchStatement { - public ContinueStatement(char[] l, int s, int e) { + public ContinueStatement(Expression expr, int s, int e) { - super(l, s, e); + super(expr, s, e); } public FlowInfo analyseCode( @@ -31,70 +31,70 @@ public class ContinueStatement extends BranchStatement { // to each of the traversed try statements, so that execution will terminate properly. // lookup the label, this should answer the returnContext - FlowContext targetContext = (label == null) - ? flowContext.getTargetContextForDefaultContinue() - : flowContext.getTargetContextForContinueLabel(label); +// FlowContext targetContext = (expression == null) +// ? flowContext.getTargetContextForDefaultContinue() +// : flowContext.getTargetContextForContinueLabel(label); - if (targetContext == null) { - if (label == null) { - currentScope.problemReporter().invalidContinue(this); - } else { - currentScope.problemReporter().undefinedLabel(this); - } - return flowInfo; // pretend it did not continue since no actual target - } +// if (targetContext == null) { +// if (expression == null) { +// currentScope.problemReporter().invalidContinue(this); +// } else { +// currentScope.problemReporter().undefinedLabel(this); +// } +// return flowInfo; // pretend it did not continue since no actual target +// } - if (targetContext == FlowContext.NotContinuableContext) { - currentScope.problemReporter().invalidContinue(this); - return flowInfo; // pretend it did not continue since no actual target - } - targetLabel = targetContext.continueLabel(); - FlowContext traversedContext = flowContext; - int subIndex = 0, maxSub = 5; - subroutines = new ASTNode[maxSub]; - - do { - ASTNode sub; - if ((sub = traversedContext.subRoutine()) != null) { - if (subIndex == maxSub) { - System.arraycopy(subroutines, 0, (subroutines = new ASTNode[maxSub*=2]), 0, subIndex); // grow - } - subroutines[subIndex++] = sub; - if (sub.cannotReturn()) { - break; - } - } - traversedContext.recordReturnFrom(flowInfo.unconditionalInits()); - - ASTNode node; - if ((node = traversedContext.associatedNode) instanceof TryStatement) { - TryStatement tryStatement = (TryStatement) node; - flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits - } else if (traversedContext == targetContext) { - // only record continue info once accumulated through subroutines, and only against target context - targetContext.recordContinueFrom(flowInfo); - break; - } - } while ((traversedContext = traversedContext.parent) != null); - - // resize subroutines - if (subIndex != maxSub) { - System.arraycopy(subroutines, 0, (subroutines = new ASTNode[subIndex]), 0, subIndex); - } +// if (targetContext == FlowContext.NotContinuableContext) { +// currentScope.problemReporter().invalidContinue(this); +// return flowInfo; // pretend it did not continue since no actual target +// } +// targetLabel = targetContext.continueLabel(); +// FlowContext traversedContext = flowContext; +// int subIndex = 0, maxSub = 5; +// subroutines = new ASTNode[maxSub]; +// +// do { +// ASTNode sub; +// if ((sub = traversedContext.subRoutine()) != null) { +// if (subIndex == maxSub) { +// System.arraycopy(subroutines, 0, (subroutines = new ASTNode[maxSub*=2]), 0, subIndex); // grow +// } +// subroutines[subIndex++] = sub; +// if (sub.cannotReturn()) { +// break; +// } +// } +// traversedContext.recordReturnFrom(flowInfo.unconditionalInits()); +// +// ASTNode node; +// if ((node = traversedContext.associatedNode) instanceof TryStatement) { +// TryStatement tryStatement = (TryStatement) node; +// flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits +// } else if (traversedContext == targetContext) { +// // only record continue info once accumulated through subroutines, and only against target context +// targetContext.recordContinueFrom(flowInfo); +// break; +// } +// } while ((traversedContext = traversedContext.parent) != null); +// +// // resize subroutines +// if (subIndex != maxSub) { +// System.arraycopy(subroutines, 0, (subroutines = new ASTNode[subIndex]), 0, subIndex); +// } return FlowInfo.DEAD_END; } public StringBuffer printStatement(int tab, StringBuffer output) { printIndent(tab, output).append("continue "); //$NON-NLS-1$ - if (label != null) output.append(label); + if (expression != null) output.append(expression); return output.append(';'); } public String toString(int tab) { String s = tabString(tab); s += "continue "; //$NON-NLS-1$ - if (label != null) - s += new String(label); + if (expression != null) + s += expression.toString(); return s; } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaOutlinePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaOutlinePage.java index 68e3777..42cc560 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaOutlinePage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaOutlinePage.java @@ -35,8 +35,6 @@ import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds; import net.sourceforge.phpdt.internal.ui.PHPUiImages; import net.sourceforge.phpdt.internal.ui.actions.AbstractToggleLinkingAction; import net.sourceforge.phpdt.internal.ui.actions.CompositeActionGroup; -import net.sourceforge.phpdt.internal.ui.dnd.JdtViewerDragAdapter; -import net.sourceforge.phpdt.internal.ui.dnd.TransferDragSourceListener; import net.sourceforge.phpdt.internal.ui.preferences.MembersOrderPreferenceCache; import net.sourceforge.phpdt.internal.ui.viewsupport.AppearanceAwareLabelProvider; import net.sourceforge.phpdt.internal.ui.viewsupport.DecoratingJavaLabelProvider; @@ -110,7 +108,6 @@ import org.eclipse.ui.texteditor.TextEditorAction; import org.eclipse.ui.texteditor.TextOperationAction; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; import org.eclipse.ui.views.navigator.LocalSelectionTransfer; -import org.eclipse.ui.views.navigator.RefactorActionGroup; /**