EA-25055 - NPE: ExtractMethodProcessor.addToMethodCallLocation

This commit is contained in:
anna
2011-02-10 15:36:15 +01:00
parent c63939a9b9
commit e68e835f94
4 changed files with 49 additions and 1 deletions
@@ -884,7 +884,11 @@ public class ExtractMethodProcessor implements MatchProvider {
protected PsiElement addToMethodCallLocation(PsiStatement statement) throws IncorrectOperationException {
if (myEnclosingBlockStatement == null) {
PsiStatement containingStatement = PsiTreeUtil.getParentOfType(myExpression != null ? myExpression : myElements[0], PsiStatement.class, false);
PsiElement containingStatement = PsiTreeUtil.getParentOfType(myExpression != null ? myExpression : myElements[0], PsiStatement.class, false);
if (containingStatement == null) {
containingStatement = PsiTreeUtil.getParentOfType(myExpression != null ? myExpression : myElements[0], PsiComment.class, false);
}
return containingStatement.getParent().addBefore(statement, containingStatement);
}
else {
@@ -0,0 +1,18 @@
public class ExtractMethods {
public void processLine(String line) {
<selection>
//final Charset charset = myProcessHandler.getCharset();
final OutputStream outputStream = null;//myProcessHandler.getProcessInput();
try {
//byte[] bytes = (line + "\n").getBytes(charset.name());
byte[] bytes = (line + "\n").getBytes();
outputStream.write(bytes);
outputStream.flush();
}
catch (IOException e) {
// ignore
}
</selection>
}
}
@@ -0,0 +1,22 @@
public class ExtractMethods {
public void processLine(String line) {
newMethod(line);
}
private void newMethod(String line) {
//final Charset charset = myProcessHandler.getCharset();
final OutputStream outputStream = null;//myProcessHandler.getProcessInput();
try {
//byte[] bytes = (line + "\n").getBytes(charset.name());
byte[] bytes = (line + "\n").getBytes();
outputStream.write(bytes);
outputStream.flush();
}
catch (IOException e) {
// ignore
}
}
}
@@ -475,6 +475,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
doTest();
}
public void testNearComment() throws Exception {
doTest();
}
private void doPrepareErrorTest(final String expectedMessage) throws Exception {
String expectedError = null;
try {