create var from instanceOf check: do not insert before previous line end-line comment

This commit is contained in:
Anna Kozlova
2013-08-30 13:38:21 +04:00
parent 7d71ded718
commit 7c56a37bc4
3 changed files with 24 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -342,7 +342,11 @@ public class CreateLocalVarFromInstanceofAction extends BaseIntentionAction {
anchorAfter = newBranch.getCodeBlock().getLBrace();
}
else {
anchorAfter = ((PsiBlockStatement)thenBranch).getCodeBlock().getLBrace();
final PsiJavaToken lBrace = ((PsiBlockStatement)thenBranch).getCodeBlock().getLBrace();
if (lBrace != null) {
final PsiElement nextSibling = PsiTreeUtil.skipSiblingsForward(lBrace, PsiWhiteSpace.class);
anchorAfter = nextSibling instanceof PsiComment ? PsiTreeUtil.skipSiblingsForward(nextSibling, PsiComment.class) : lBrace;
}
}
}
}

View File

@@ -0,0 +1,10 @@
// "Insert '(String)o' declaration" "true"
class C {
void f(Object o, Object f) {
if (o instanceof String) {//todo comment
String s = (String) o;
}
}
}

View File

@@ -0,0 +1,8 @@
// "Insert '(String)o' declaration" "true"
class C {
void f(Object o, Object f) {
if (o instanceof String) {//todo comment
<caret>
}
}
}