mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-25055 - NPE: ExtractMethodProcessor.addToMethodCallLocation
This commit is contained in:
+5
-1
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user