'Suppress warnings' as quick fix options

If no quick fix is available a special intention is shown
This commit is contained in:
Andrey Breslav
2013-09-22 19:24:46 +04:00
parent b379ab3ebd
commit a13b66c58e
79 changed files with 879 additions and 9 deletions
@@ -22,13 +22,10 @@ import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.JetNodeTypes;
import org.jetbrains.jet.lexer.JetTokens;
import java.util.List;
import static org.jetbrains.jet.lexer.JetTokens.EQ;
import static org.jetbrains.jet.lexer.JetTokens.VAL_KEYWORD;
import static org.jetbrains.jet.lexer.JetTokens.VAR_KEYWORD;
import static org.jetbrains.jet.lexer.JetTokens.*;
public class JetMultiDeclaration extends JetDeclarationImpl {
public JetMultiDeclaration(@NotNull ASTNode node) {
@@ -58,4 +55,9 @@ public class JetMultiDeclaration extends JetDeclarationImpl {
}
return PsiTreeUtil.getNextSiblingOfType(eqNode.getPsi(), JetExpression.class);
}
@Nullable
public ASTNode getValOrVarNode() {
return getNode().findChildByType(TokenSet.create(VAL_KEYWORD, VAR_KEYWORD));
}
}
@@ -197,11 +197,22 @@ public class JetPsiFactory {
}
public static JetModifierList createModifierList(Project project, JetKeywordToken modifier) {
String text = modifier.getValue() + " val x";
JetProperty property = createProperty(project, text);
return createModifierList(project, modifier.getValue());
}
public static JetModifierList createModifierList(Project project, String text) {
JetProperty property = createProperty(project, text + " val x");
return property.getModifierList();
}
@NotNull
public static JetAnnotation createAnnotation(Project project, String text) {
JetProperty property = createProperty(project, text + " val x");
JetModifierList modifierList = property.getModifierList();
assert modifierList != null;
return modifierList.getAnnotations().get(0);
}
public static JetModifierList createConstructorModifierList(Project project, JetKeywordToken modifier) {
JetClass aClass = createClass(project, "class C " + modifier.getValue() + " (){}");
return aClass.getPrimaryConstructorModifierList();
@@ -1003,4 +1003,22 @@ public class JetPsiUtil {
return new StringBuilder(inFileParent.getText()).insert(inFileParentOffset, "<caret>").toString();
}
@Nullable
public static JetModifierList replaceModifierList(@NotNull JetModifierListOwner owner, @Nullable JetModifierList modifierList) {
JetModifierList oldModifierList = owner.getModifierList();
if (modifierList == null) {
if (oldModifierList != null) oldModifierList.delete();
return null;
}
else {
if (oldModifierList == null) {
PsiElement firstChild = owner.getFirstChild();
return (JetModifierList) owner.addBefore(modifierList, firstChild);
}
else {
return (JetModifierList) oldModifierList.replace(modifierList);
}
}
}
}