Index: LocalCorrectionsSubProcessor.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java,v retrieving revision 1.12 diff -u -r1.12 LocalCorrectionsSubProcessor.java --- LocalCorrectionsSubProcessor.java 11 Jun 2002 10:58:34 -0000 1.12 +++ LocalCorrectionsSubProcessor.java 6 Aug 2002 16:34:49 -0000 @@ -1,6 +1,7 @@ package org.eclipse.jdt.internal.ui.text.correction; import java.util.ArrayList; +import java.util.List; import org.eclipse.core.runtime.CoreException; @@ -9,6 +10,9 @@ import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.Signature; +import org.eclipse.jdt.core.compiler.IScanner; +import org.eclipse.jdt.core.compiler.ITerminalSymbols; +import org.eclipse.jdt.core.compiler.InvalidInputException; import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.Assignment; @@ -148,13 +152,31 @@ MethodDeclaration methodDecl= (MethodDeclaration) decl; SimpleName name= methodDecl.getName(); + int pos= name.getStartPosition() + name.getLength(); + StringBuffer insertString= new StringBuffer(); if (methodDecl.thrownExceptions().isEmpty()) { insertString.append(" throws "); //$NON-NLS-1$ + try { + IScanner scanner= ASTResolving.createScanner(cu, name.getStartPosition()); + int nextNoken= scanner.getNextToken(); + while (nextNoken != ITerminalSymbols.TokenNameRPAREN) { + nextNoken= scanner.getNextToken(); + if (nextNoken == ITerminalSymbols.TokenNameEOF) { + return; + } + } + pos= scanner.getCurrentTokenEndPosition() + 1; + } catch (InvalidInputException e) { + return; + } } else { insertString.append(", "); //$NON-NLS-1$ - } + List thrownExceptions= methodDecl.thrownExceptions(); + ASTNode last= (ASTNode) thrownExceptions.get(thrownExceptions.size() - 1); + pos= last.getStartPosition() + last.getLength(); + } insertString.append(Signature.getSimpleName(uncaughtName)); String label= CorrectionMessages.getString("LocalCorrectionsSubProcessor.addthrows.description"); //$NON-NLS-1$