Lines 1-6
Link Here
|
1 |
package org.eclipse.jdt.internal.ui.text.correction; |
1 |
package org.eclipse.jdt.internal.ui.text.correction; |
2 |
|
2 |
|
3 |
import java.util.ArrayList; |
3 |
import java.util.ArrayList; |
|
|
4 |
import java.util.List; |
4 |
|
5 |
|
5 |
import org.eclipse.core.runtime.CoreException; |
6 |
import org.eclipse.core.runtime.CoreException; |
6 |
|
7 |
|
Lines 9-14
Link Here
|
9 |
import org.eclipse.jdt.core.ICompilationUnit; |
10 |
import org.eclipse.jdt.core.ICompilationUnit; |
10 |
import org.eclipse.jdt.core.JavaModelException; |
11 |
import org.eclipse.jdt.core.JavaModelException; |
11 |
import org.eclipse.jdt.core.Signature; |
12 |
import org.eclipse.jdt.core.Signature; |
|
|
13 |
import org.eclipse.jdt.core.compiler.IScanner; |
14 |
import org.eclipse.jdt.core.compiler.ITerminalSymbols; |
15 |
import org.eclipse.jdt.core.compiler.InvalidInputException; |
12 |
import org.eclipse.jdt.core.dom.AST; |
16 |
import org.eclipse.jdt.core.dom.AST; |
13 |
import org.eclipse.jdt.core.dom.ASTNode; |
17 |
import org.eclipse.jdt.core.dom.ASTNode; |
14 |
import org.eclipse.jdt.core.dom.Assignment; |
18 |
import org.eclipse.jdt.core.dom.Assignment; |
Lines 148-160
Link Here
|
148 |
|
152 |
|
149 |
MethodDeclaration methodDecl= (MethodDeclaration) decl; |
153 |
MethodDeclaration methodDecl= (MethodDeclaration) decl; |
150 |
SimpleName name= methodDecl.getName(); |
154 |
SimpleName name= methodDecl.getName(); |
|
|
155 |
|
151 |
int pos= name.getStartPosition() + name.getLength(); |
156 |
int pos= name.getStartPosition() + name.getLength(); |
|
|
157 |
|
152 |
StringBuffer insertString= new StringBuffer(); |
158 |
StringBuffer insertString= new StringBuffer(); |
153 |
if (methodDecl.thrownExceptions().isEmpty()) { |
159 |
if (methodDecl.thrownExceptions().isEmpty()) { |
154 |
insertString.append(" throws "); //$NON-NLS-1$ |
160 |
insertString.append(" throws "); //$NON-NLS-1$ |
|
|
161 |
try { |
162 |
IScanner scanner= ASTResolving.createScanner(cu, name.getStartPosition()); |
163 |
int nextNoken= scanner.getNextToken(); |
164 |
while (nextNoken != ITerminalSymbols.TokenNameRPAREN) { |
165 |
nextNoken= scanner.getNextToken(); |
166 |
if (nextNoken == ITerminalSymbols.TokenNameEOF) { |
167 |
return; |
168 |
} |
169 |
} |
170 |
pos= scanner.getCurrentTokenEndPosition() + 1; |
171 |
} catch (InvalidInputException e) { |
172 |
return; |
173 |
} |
155 |
} else { |
174 |
} else { |
156 |
insertString.append(", "); //$NON-NLS-1$ |
175 |
insertString.append(", "); //$NON-NLS-1$ |
157 |
} |
176 |
List thrownExceptions= methodDecl.thrownExceptions(); |
|
|
177 |
ASTNode last= (ASTNode) thrownExceptions.get(thrownExceptions.size() - 1); |
178 |
pos= last.getStartPosition() + last.getLength(); |
179 |
} |
158 |
insertString.append(Signature.getSimpleName(uncaughtName)); |
180 |
insertString.append(Signature.getSimpleName(uncaughtName)); |
159 |
|
181 |
|
160 |
String label= CorrectionMessages.getString("LocalCorrectionsSubProcessor.addthrows.description"); //$NON-NLS-1$ |
182 |
String label= CorrectionMessages.getString("LocalCorrectionsSubProcessor.addthrows.description"); //$NON-NLS-1$ |