mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
@Override added
This commit is contained in:
+1
@@ -372,6 +372,7 @@ public class AnnotationsHighlightUtil {
|
||||
|
||||
public static class AnnotationReturnTypeVisitor extends PsiTypeVisitor<Boolean> {
|
||||
public static final AnnotationReturnTypeVisitor INSTANCE = new AnnotationReturnTypeVisitor();
|
||||
@Override
|
||||
public Boolean visitType(PsiType type) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
+5
@@ -38,6 +38,7 @@ public class CreateAnnotationMethodFromUsageFix extends CreateFromUsageBaseFix {
|
||||
myNameValuePair = SmartPointerManager.getInstance(valuePair.getProject()).createSmartPsiElementPointer(valuePair);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAvailableImpl(int offset) {
|
||||
final PsiNameValuePair call = getNameValuePair();
|
||||
if (call == null || !call.isValid()) return false;
|
||||
@@ -49,12 +50,14 @@ public class CreateAnnotationMethodFromUsageFix extends CreateFromUsageBaseFix {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PsiElement getElement() {
|
||||
final PsiNameValuePair call = getNameValuePair();
|
||||
if (call == null || !call.getManager().isInProject(call)) return null;
|
||||
return call;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void invokeImpl(final PsiClass targetClass) {
|
||||
if (targetClass == null) return;
|
||||
|
||||
@@ -121,11 +124,13 @@ public class CreateAnnotationMethodFromUsageFix extends CreateFromUsageBaseFix {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean isValidElement(PsiElement element) {
|
||||
final PsiReference reference = element.getReference();
|
||||
return reference != null && reference.resolve() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return QuickFixBundle.message("create.method.from.usage.family");
|
||||
|
||||
+1
@@ -107,6 +107,7 @@ public class CreateClassFromNewFix extends CreateFromUsageBaseFix {
|
||||
final Editor editor = positionCursor(project, aClass.getContainingFile(), aClass);
|
||||
final TextRange textRange = aClass.getTextRange();
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new WriteCommandAction(project, getText(), getText()) {
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
public class BlockJoinLinesHandler implements JoinLinesHandlerDelegate {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.editorActions.BlockJoinLinesHandler");
|
||||
|
||||
@Override
|
||||
public int tryJoinLines(final Document document, final PsiFile psiFile, final int start, final int end) {
|
||||
PsiElement elementAtStartLineEnd = psiFile.findElementAt(start);
|
||||
PsiElement elementAtNextLineStart = psiFile.findElementAt(end);
|
||||
|
||||
+5
@@ -42,6 +42,7 @@ import java.util.Comparator;
|
||||
public abstract class CopyPasteReferenceProcessor<TRef extends PsiElement> implements CopyPastePostProcessor<ReferenceTransferableData> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor");
|
||||
|
||||
@Override
|
||||
public ReferenceTransferableData collectTransferableData(PsiFile file, final Editor editor, final int[] startOffsets, final int[] endOffsets) {
|
||||
if (file instanceof PsiCompiledFile) {
|
||||
file = ((PsiCompiledFile) file).getDecompiledPsiFile();
|
||||
@@ -67,6 +68,7 @@ public abstract class CopyPasteReferenceProcessor<TRef extends PsiElement> imple
|
||||
|
||||
protected abstract void addReferenceData(PsiFile file, int startOffset, PsiElement element, ArrayList<ReferenceTransferableData.ReferenceData> to);
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ReferenceTransferableData extractTransferableData(final Transferable content) {
|
||||
ReferenceTransferableData referenceData = null;
|
||||
@@ -90,6 +92,7 @@ public abstract class CopyPasteReferenceProcessor<TRef extends PsiElement> imple
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processTransferableData(final Project project,
|
||||
final Editor editor,
|
||||
final RangeMarker bounds,
|
||||
@@ -113,6 +116,7 @@ public abstract class CopyPasteReferenceProcessor<TRef extends PsiElement> imple
|
||||
}
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
restoreReferences(referenceData, refs);
|
||||
}
|
||||
@@ -170,6 +174,7 @@ public abstract class CopyPasteReferenceProcessor<TRef extends PsiElement> imple
|
||||
Arrays.sort(
|
||||
selectedObjects,
|
||||
new Comparator<Object>() {
|
||||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
String fqName1 = getFQName(o1);
|
||||
String fqName2 = getFQName(o2);
|
||||
|
||||
+1
@@ -28,6 +28,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
public class DeclarationJoinLinesHandler implements JoinLinesHandlerDelegate {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.editorActions.DeclarationJoinLinesHandler");
|
||||
|
||||
@Override
|
||||
public int tryJoinLines(final Document document, final PsiFile file, final int start, final int end) {
|
||||
PsiElement elementAtStartLineEnd = file.findElementAt(start);
|
||||
PsiElement elementAtNextLineStart = file.findElementAt(end);
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.psi.util.PsiUtil;
|
||||
public class JavaBackspaceHandler extends BackspaceHandlerDelegate {
|
||||
private boolean myToDeleteGt;
|
||||
|
||||
@Override
|
||||
public void beforeCharDeleted(char c, PsiFile file, Editor editor) {
|
||||
int offset = editor.getCaretModel().getOffset() - 1;
|
||||
myToDeleteGt = c =='<' &&
|
||||
@@ -36,6 +37,7 @@ public class JavaBackspaceHandler extends BackspaceHandlerDelegate {
|
||||
&& JavaTypedHandler.isAfterClassLikeIdentifierOrDot(offset, editor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charDeleted(final char c, final PsiFile file, final Editor editor) {
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
final CharSequence chars = editor.getDocument().getCharsSequence();
|
||||
|
||||
+3
@@ -29,6 +29,7 @@ import java.util.ArrayList;
|
||||
public class JavaCopyPasteReferenceProcessor extends CopyPasteReferenceProcessor<PsiJavaCodeReferenceElement> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.editorActions.JavaCopyPasteReferenceProcessor");
|
||||
|
||||
@Override
|
||||
protected void addReferenceData(PsiFile file, int startOffset, PsiElement element, ArrayList<ReferenceTransferableData.ReferenceData> to) {
|
||||
if (element instanceof PsiJavaCodeReferenceElement) {
|
||||
if (!((PsiJavaCodeReferenceElement)element).isQualified()) {
|
||||
@@ -57,6 +58,7 @@ public class JavaCopyPasteReferenceProcessor extends CopyPasteReferenceProcessor
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected PsiJavaCodeReferenceElement[] findReferencesToRestore(PsiFile file,
|
||||
RangeMarker bounds,
|
||||
ReferenceTransferableData.ReferenceData[] referenceData) {
|
||||
@@ -102,6 +104,7 @@ public class JavaCopyPasteReferenceProcessor extends CopyPasteReferenceProcessor
|
||||
return refs;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void restoreReferences(ReferenceTransferableData.ReferenceData[] referenceData,
|
||||
PsiJavaCodeReferenceElement[] refs) {
|
||||
for (int i = 0; i < refs.length; i++) {
|
||||
|
||||
@@ -33,6 +33,7 @@ public class JavaQuoteHandler extends SimpleTokenSetQuoteHandler implements Java
|
||||
concatenatableStrings = TokenSet.create(JavaTokenType.STRING_LITERAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpeningQuote(HighlighterIterator iterator, int offset) {
|
||||
boolean openingQuote = super.isOpeningQuote(iterator, offset);
|
||||
|
||||
@@ -50,6 +51,7 @@ public class JavaQuoteHandler extends SimpleTokenSetQuoteHandler implements Java
|
||||
return openingQuote;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosingQuote(HighlighterIterator iterator, int offset) {
|
||||
boolean closingQuote = super.isClosingQuote(iterator, offset);
|
||||
|
||||
@@ -67,22 +69,27 @@ public class JavaQuoteHandler extends SimpleTokenSetQuoteHandler implements Java
|
||||
return closingQuote;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TokenSet getConcatenatableStringTokenTypes() {
|
||||
return concatenatableStrings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStringConcatenationOperatorRepresentation() {
|
||||
return "+";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TokenSet getStringTokenTypes() {
|
||||
return myLiteralTokenSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAppropriateElementTypeForLiteral(final @NotNull IElementType tokenType) {
|
||||
return isAppropriateElementTypeForLiteralStatic(tokenType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needParenthesesAroundConcatenation(final PsiElement element) {
|
||||
// example code: "some string".length() must become ("some" + " string").length()
|
||||
return element.getParent() instanceof PsiLiteralExpression && element.getParent().getParent() instanceof PsiReferenceExpression;
|
||||
|
||||
@@ -51,6 +51,7 @@ public class JavaTypedHandler extends TypedHandlerDelegate {
|
||||
|
||||
private static void autoPopupMemberLookup(Project project, final Editor editor) {
|
||||
AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, new Condition<PsiFile>() {
|
||||
@Override
|
||||
public boolean value(final PsiFile file) {
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
|
||||
@@ -81,6 +82,7 @@ public class JavaTypedHandler extends TypedHandlerDelegate {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result beforeCharTyped(final char c, final Project project, final Editor editor, final PsiFile file, final FileType fileType) {
|
||||
if (c == '@' && file instanceof PsiJavaFile) {
|
||||
autoPopupJavadocLookup(project, editor);
|
||||
@@ -141,6 +143,7 @@ public class JavaTypedHandler extends TypedHandlerDelegate {
|
||||
return Result.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result charTyped(final char c, final Project project, final Editor editor, @NotNull final PsiFile file) {
|
||||
if (myJavaLTTyped) {
|
||||
myJavaLTTyped = false;
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiJavaToken;
|
||||
|
||||
public class LiteralJoinLinesHandler implements JoinLinesHandlerDelegate {
|
||||
@Override
|
||||
public int tryJoinLines(final Document doc, final PsiFile psiFile, final int offsetNear, final int end) {
|
||||
CharSequence text = doc.getCharsSequence();
|
||||
|
||||
|
||||
+6
@@ -30,14 +30,17 @@ public class ReferenceTransferableData implements TextBlockTransferableData, Clo
|
||||
myReferenceDatas = referenceDatas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataFlavor getFlavor() {
|
||||
return ReferenceData.getDataFlavor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOffsetCount() {
|
||||
return myReferenceDatas.length * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOffsets(final int[] offsets, int index) {
|
||||
for (ReferenceData data : myReferenceDatas) {
|
||||
offsets[index++] = data.startOffset;
|
||||
@@ -46,6 +49,7 @@ public class ReferenceTransferableData implements TextBlockTransferableData, Clo
|
||||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setOffsets(final int[] offsets, int index) {
|
||||
for (ReferenceData data : myReferenceDatas) {
|
||||
data.startOffset = offsets[index++];
|
||||
@@ -54,6 +58,7 @@ public class ReferenceTransferableData implements TextBlockTransferableData, Clo
|
||||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReferenceTransferableData clone() {
|
||||
ReferenceData[] newReferenceData = new ReferenceData[myReferenceDatas.length];
|
||||
for (int i = 0; i < myReferenceDatas.length; i++) {
|
||||
@@ -81,6 +86,7 @@ public class ReferenceTransferableData implements TextBlockTransferableData, Clo
|
||||
this.staticMemberName = staticMemberDescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
try{
|
||||
return super.clone();
|
||||
|
||||
@@ -54,6 +54,7 @@ class RestoreReferencesDialog extends DialogWrapper {
|
||||
myList.setSelectionInterval(0, myNamedElements.length - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doOKAction() {
|
||||
Object[] values = myList.getSelectedValues();
|
||||
mySelectedElements = new Object[values.length];
|
||||
@@ -61,6 +62,7 @@ class RestoreReferencesDialog extends DialogWrapper {
|
||||
super.doOKAction();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
myList = new JBList(myNamedElements);
|
||||
@@ -89,6 +91,7 @@ class RestoreReferencesDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getDimensionServiceKey(){
|
||||
return "#com.intellij.codeInsight.editorActions.RestoreReferencesDialog";
|
||||
}
|
||||
|
||||
+1
@@ -118,6 +118,7 @@ public class StringLiteralCopyPasteProcessor implements CopyPastePreProcessor {
|
||||
return unescapeStringCharacters(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String preprocessOnPaste(final Project project, final PsiFile file, final Editor editor, String text, final RawText rawText) {
|
||||
final Document document = editor.getDocument();
|
||||
PsiDocumentManager.getInstance(project).commitDocument(document);
|
||||
|
||||
+1
@@ -27,6 +27,7 @@ import com.intellij.util.text.CharArrayUtil;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class AfterSemicolonEnterProcessor implements EnterProcessor {
|
||||
@Override
|
||||
public boolean doEnter(Editor editor, PsiElement psiElement, boolean isModified) {
|
||||
if (psiElement instanceof PsiExpressionStatement ||
|
||||
psiElement instanceof PsiDeclarationStatement ||
|
||||
|
||||
+1
@@ -31,6 +31,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class BlockBraceFixer implements Fixer{
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (psiElement instanceof PsiCodeBlock && afterUnmatchedBrace(editor,psiElement.getContainingFile().getFileType())) {
|
||||
PsiCodeBlock block = (PsiCodeBlock) psiElement;
|
||||
|
||||
+1
@@ -29,6 +29,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
*/
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class CatchDeclarationFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (psiElement instanceof PsiCatchSection) {
|
||||
final Document doc = editor.getDocument();
|
||||
|
||||
+1
@@ -34,6 +34,7 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class CommentBreakerEnterProcessor implements EnterProcessor {
|
||||
@Override
|
||||
public boolean doEnter(Editor editor, PsiElement psiElement, boolean isModified) {
|
||||
if (isModified) return false;
|
||||
final PsiElement atCaret = psiElement.getContainingFile().findElementAt(editor.getCaretModel().getOffset());
|
||||
|
||||
+1
@@ -32,6 +32,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
*/
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class DoWhileConditionFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (psiElement instanceof PsiDoWhileStatement) {
|
||||
final Document doc = editor.getDocument();
|
||||
|
||||
+1
@@ -30,6 +30,7 @@ import com.intellij.util.text.CharArrayUtil;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class EnumFieldFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (psiElement instanceof PsiEnumConstant) {
|
||||
int insertionOffset = psiElement.getTextRange().getEndOffset();
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
*/
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class IfConditionFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (psiElement instanceof PsiIfStatement) {
|
||||
final Document doc = editor.getDocument();
|
||||
|
||||
+2
@@ -94,6 +94,7 @@ public class JavaSmartEnterProcessor extends SmartEnterProcessor {
|
||||
|
||||
private final JavadocFixer myJavadocFixer = new JavadocFixer();
|
||||
|
||||
@Override
|
||||
public boolean process(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile psiFile) {
|
||||
final Document document = editor.getDocument();
|
||||
final String textForRollback = document.getText();
|
||||
@@ -236,6 +237,7 @@ public class JavaSmartEnterProcessor extends SmartEnterProcessor {
|
||||
return element instanceof PsiClass || element instanceof PsiCodeBlock || element instanceof PsiStatement || element instanceof PsiMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected PsiElement getStatementAtCaret(Editor editor, PsiFile psiFile) {
|
||||
final PsiElement atCaret = super.getStatementAtCaret(editor, psiFile);
|
||||
|
||||
+1
@@ -46,6 +46,7 @@ public class LeaveCodeBlockEnterProcessor implements EnterProcessor {
|
||||
JavaElementType.FOREACH_STATEMENT
|
||||
);
|
||||
|
||||
@Override
|
||||
public boolean doEnter(Editor editor, PsiElement psiElement, boolean isModified) {
|
||||
PsiElement parent = psiElement.getParent();
|
||||
if (!(parent instanceof PsiCodeBlock)) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class LiteralFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement)
|
||||
throws IncorrectOperationException {
|
||||
if (psiElement instanceof PsiJavaToken) {
|
||||
|
||||
+1
@@ -29,6 +29,7 @@ import com.intellij.util.text.CharArrayUtil;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class MethodCallFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
PsiExpressionList args = null;
|
||||
if (psiElement instanceof PsiMethodCallExpression && !(psiElement instanceof JspMethodCall)) {
|
||||
|
||||
+1
@@ -30,6 +30,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class MissingArrayInitializerBraceFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (!(psiElement instanceof PsiArrayInitializerExpression)) return;
|
||||
PsiArrayInitializerExpression expr = (PsiArrayInitializerExpression)psiElement;
|
||||
|
||||
+1
@@ -28,6 +28,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class MissingCatchBodyFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (!(psiElement instanceof PsiCatchSection)) return;
|
||||
PsiCatchSection catchSection = (PsiCatchSection) psiElement;
|
||||
|
||||
+1
@@ -30,6 +30,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class MissingForBodyFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
PsiForStatement forStatement = getForStatementParent(psiElement);
|
||||
if (forStatement == null) return;
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
* @author Maxim.Mossienko
|
||||
*/
|
||||
public class MissingForeachBodyFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
PsiForeachStatement forStatement = getForeachStatementParent(psiElement);
|
||||
if (forStatement == null) return;
|
||||
|
||||
+1
@@ -24,6 +24,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
* @author max
|
||||
*/
|
||||
public class MissingIfBranchesFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (!(psiElement instanceof PsiIfStatement)) return;
|
||||
|
||||
|
||||
+1
@@ -30,6 +30,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class MissingMethodBodyFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (!(psiElement instanceof PsiMethod)) return;
|
||||
PsiMethod method = (PsiMethod) psiElement;
|
||||
|
||||
+1
@@ -31,6 +31,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class MissingReturnExpressionFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (!(psiElement instanceof PsiReturnStatement)) {
|
||||
return;
|
||||
|
||||
+1
@@ -38,6 +38,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class MissingSwitchBodyFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (!(psiElement instanceof PsiSwitchStatement)) return;
|
||||
PsiSwitchStatement switchStatement = (PsiSwitchStatement) psiElement;
|
||||
|
||||
+1
@@ -29,6 +29,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class MissingSynchronizedBodyFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (!(psiElement instanceof PsiSynchronizedStatement)) return;
|
||||
PsiSynchronizedStatement syncStatement = (PsiSynchronizedStatement) psiElement;
|
||||
|
||||
+1
@@ -29,6 +29,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
*/
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class MissingThrowExpressionFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement)
|
||||
throws IncorrectOperationException {
|
||||
if (psiElement instanceof PsiThrowStatement) {
|
||||
|
||||
+1
@@ -31,6 +31,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class MissingWhileBodyFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (!(psiElement instanceof PsiWhileStatement)) return;
|
||||
PsiWhileStatement whileStatement = (PsiWhileStatement) psiElement;
|
||||
|
||||
+1
@@ -30,6 +30,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class ParameterListFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (psiElement instanceof PsiParameterList) {
|
||||
if (!StringUtil.endsWithChar(psiElement.getText(), ')')) {
|
||||
|
||||
+1
@@ -21,6 +21,7 @@ import com.intellij.psi.PsiParenthesizedExpression;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
|
||||
public class ParenthesizedFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (psiElement instanceof PsiParenthesizedExpression) {
|
||||
final PsiElement lastChild = psiElement.getLastChild();
|
||||
|
||||
+1
@@ -40,6 +40,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class PlainEnterProcessor implements EnterProcessor {
|
||||
@Override
|
||||
public boolean doEnter(Editor editor, PsiElement psiElement, boolean isModified) {
|
||||
PsiCodeBlock block = getControlStatementBlock(editor.getCaretModel().getOffset(), psiElement);
|
||||
if (processExistingBlankLine(editor, block, psiElement)) {
|
||||
|
||||
+1
@@ -39,6 +39,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class SemicolonFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
boolean fixed = fixReturn(editor, psiElement) || fixForUpdate(editor, psiElement, processor)
|
||||
|| fixAfterLastValidElement(editor, psiElement);
|
||||
|
||||
+1
@@ -36,6 +36,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
*/
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class SwitchExpressionFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (psiElement instanceof PsiSwitchStatement) {
|
||||
final Document doc = editor.getDocument();
|
||||
|
||||
+1
@@ -29,6 +29,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
*/
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class WhileConditionFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (psiElement instanceof PsiWhileStatement) {
|
||||
final Document doc = editor.getDocument();
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.lang.ASTNode;
|
||||
* @author maxim
|
||||
*/
|
||||
public class XmlTagFixer implements Fixer {
|
||||
@Override
|
||||
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (psiElement instanceof XmlTag) {
|
||||
final ASTNode emptyTagEnd = XmlChildRole.EMPTY_TAG_END_FINDER.findChild(psiElement.getNode());
|
||||
|
||||
+2
@@ -29,6 +29,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class AntLikePropertySelectionHandler implements ExtendWordSelectionHandler {
|
||||
@Override
|
||||
public boolean canSelect(PsiElement e) {
|
||||
Language l = e.getLanguage();
|
||||
if (!(l.equals(StdLanguages.JAVA)
|
||||
@@ -40,6 +41,7 @@ public class AntLikePropertySelectionHandler implements ExtendWordSelectionHandl
|
||||
return PsiTreeUtil.getParentOfType(e, PsiComment.class) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||
TextRange range = e.getTextRange();
|
||||
char prevLeftChar = ' ';
|
||||
|
||||
+1
@@ -23,6 +23,7 @@ import com.intellij.codeInsight.editorActions.ExtendWordSelectionHandlerBase;
|
||||
|
||||
public class BasicSelectioner extends ExtendWordSelectionHandlerBase {
|
||||
|
||||
@Override
|
||||
public boolean canSelect(PsiElement e) {
|
||||
return canSelectBasic(e);
|
||||
}
|
||||
|
||||
+2
@@ -24,11 +24,13 @@ import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CaseStatementsSelectioner extends BasicSelectioner {
|
||||
@Override
|
||||
public boolean canSelect(PsiElement e) {
|
||||
return e.getParent() instanceof PsiCodeBlock &&
|
||||
e.getParent().getParent() instanceof PsiSwitchStatement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TextRange> select(PsiElement statement, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||
List<TextRange> result = new ArrayList<TextRange>();
|
||||
PsiElement caseStart = statement;
|
||||
|
||||
+2
@@ -23,10 +23,12 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CodeBlockOrInitializerSelectioner extends BasicSelectioner {
|
||||
@Override
|
||||
public boolean canSelect(PsiElement e) {
|
||||
return e instanceof PsiCodeBlock || e instanceof PsiArrayInitializerExpression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||
List<TextRange> result = new ArrayList<TextRange>();
|
||||
|
||||
|
||||
+2
@@ -26,10 +26,12 @@ import com.intellij.util.text.CharArrayUtil;
|
||||
import java.util.List;
|
||||
|
||||
public class DocCommentSelectioner extends LineCommentSelectioner {
|
||||
@Override
|
||||
public boolean canSelect(PsiElement e) {
|
||||
return e instanceof PsiDocComment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||
List<TextRange> result = super.select(e, editorText, cursorOffset, editor);
|
||||
|
||||
|
||||
+2
@@ -28,10 +28,12 @@ import com.intellij.util.text.CharArrayUtil;
|
||||
import java.util.List;
|
||||
|
||||
public class DocTagSelectioner extends WordSelectioner {
|
||||
@Override
|
||||
public boolean canSelect(PsiElement e) {
|
||||
return e instanceof PsiDocTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||
List<TextRange> result = super.select(e, editorText, cursorOffset, editor);
|
||||
|
||||
|
||||
+2
@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor;
|
||||
import java.util.List;
|
||||
|
||||
public class FieldSelectioner extends WordSelectioner {
|
||||
@Override
|
||||
public boolean canSelect(PsiElement e) {
|
||||
return e instanceof PsiField;
|
||||
}
|
||||
@@ -38,6 +39,7 @@ public class FieldSelectioner extends WordSelectioner {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||
List<TextRange> result = super.select(e, editorText, cursorOffset, editor);
|
||||
final PsiField field = (PsiField)e;
|
||||
|
||||
+2
@@ -26,11 +26,13 @@ import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class FinallyBlockSelectioner extends BasicSelectioner {
|
||||
@Override
|
||||
public boolean canSelect(PsiElement e) {
|
||||
return e instanceof PsiKeyword && PsiKeyword.FINALLY.equals(e.getText());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||
List<TextRange> result = new ArrayList<TextRange>();
|
||||
|
||||
|
||||
+2
@@ -26,10 +26,12 @@ import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class IfStatementSelectioner extends BasicSelectioner {
|
||||
@Override
|
||||
public boolean canSelect(PsiElement e) {
|
||||
return e instanceof PsiIfStatement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||
List<TextRange> result = new ArrayList<TextRange>();
|
||||
result.addAll(expandToWholeLine(editorText, e.getTextRange(), false));
|
||||
|
||||
+1
@@ -23,6 +23,7 @@ import com.intellij.psi.javadoc.PsiDocTag;
|
||||
* @author yole
|
||||
*/
|
||||
public class JavaBasicWordSelectionFilter implements Condition<PsiElement> {
|
||||
@Override
|
||||
public boolean value(final PsiElement e) {
|
||||
return !(e instanceof PsiCodeBlock) &&
|
||||
!(e instanceof PsiArrayInitializerExpression) &&
|
||||
|
||||
+2
@@ -22,10 +22,12 @@ import com.intellij.openapi.editor.Editor;
|
||||
import java.util.List;
|
||||
|
||||
public class JavaTokenSelectioner extends BasicSelectioner {
|
||||
@Override
|
||||
public boolean canSelect(PsiElement e) {
|
||||
return e instanceof PsiJavaToken && !(e instanceof PsiKeyword) && !(e.getParent()instanceof PsiCodeBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||
PsiJavaToken token = (PsiJavaToken)e;
|
||||
|
||||
|
||||
+2
@@ -23,10 +23,12 @@ import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ListSelectioner extends BasicSelectioner {
|
||||
@Override
|
||||
public boolean canSelect(PsiElement e) {
|
||||
return e instanceof PsiParameterList || e instanceof PsiExpressionList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||
|
||||
PsiElement[] children = e.getChildren();
|
||||
|
||||
+2
@@ -27,6 +27,7 @@ import com.intellij.psi.StringEscapesTokenTypes;
|
||||
import java.util.List;
|
||||
|
||||
public class LiteralSelectioner extends BasicSelectioner {
|
||||
@Override
|
||||
public boolean canSelect(PsiElement e) {
|
||||
PsiElement parent = e.getParent();
|
||||
return
|
||||
@@ -38,6 +39,7 @@ public class LiteralSelectioner extends BasicSelectioner {
|
||||
((PsiLiteralExpression)element).getType().equalsToText("java.lang.String") && element.getText().startsWith("\"") && element.getText().endsWith("\"");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||
List<TextRange> result = super.select(e, editorText, cursorOffset, editor);
|
||||
|
||||
|
||||
+2
@@ -27,10 +27,12 @@ import java.util.List;
|
||||
*/
|
||||
|
||||
public class MethodOrClassSelectioner extends BasicSelectioner {
|
||||
@Override
|
||||
public boolean canSelect(PsiElement e) {
|
||||
return e instanceof PsiClass && !(e instanceof PsiTypeParameter) || e instanceof PsiMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||
List<TextRange> result = super.select(e, editorText, cursorOffset, editor);
|
||||
|
||||
|
||||
+2
@@ -23,10 +23,12 @@ import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ReferenceSelectioner extends BasicSelectioner {
|
||||
@Override
|
||||
public boolean canSelect(PsiElement e) {
|
||||
return e instanceof PsiJavaCodeReferenceElement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||
|
||||
PsiElement endElement = e;
|
||||
|
||||
+2
@@ -26,10 +26,12 @@ import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class StatementGroupSelectioner extends BasicSelectioner {
|
||||
@Override
|
||||
public boolean canSelect(PsiElement e) {
|
||||
return e instanceof PsiStatement || e instanceof PsiComment && !(e instanceof PsiDocComment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||
List<TextRange> result = new ArrayList<TextRange>();
|
||||
|
||||
|
||||
+2
@@ -26,10 +26,12 @@ import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TypeCastSelectioner extends BasicSelectioner {
|
||||
@Override
|
||||
public boolean canSelect(PsiElement e) {
|
||||
return e instanceof PsiTypeCastExpression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||
List<TextRange> result = new ArrayList<TextRange>();
|
||||
result.addAll(expandToWholeLine(editorText, e.getTextRange(), false));
|
||||
|
||||
@@ -32,8 +32,10 @@ public class CollapseBlockHandler implements CodeInsightActionHandler {
|
||||
public static final String ourPlaceHolderText = "{...}";
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.folding.impl.CollapseBlockHandler");
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
|
||||
editor.getFoldingModel().runBatchFoldingOperation(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final EditorFoldingInfo info = EditorFoldingInfo.get(editor);
|
||||
FoldingModelEx model = (FoldingModelEx) editor.getFoldingModel();
|
||||
@@ -81,6 +83,7 @@ public class CollapseBlockHandler implements CodeInsightActionHandler {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
+3
@@ -33,6 +33,7 @@ public class CollapseExpandJavadocsHandler implements CodeInsightActionHandler {
|
||||
myExpand = isExpand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, @NotNull final Editor editor, @NotNull PsiFile file){
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
|
||||
@@ -40,6 +41,7 @@ public class CollapseExpandJavadocsHandler implements CodeInsightActionHandler {
|
||||
foldingManager.updateFoldRegions(editor);
|
||||
final FoldRegion[] allFoldRegions = editor.getFoldingModel().getAllFoldRegions();
|
||||
Runnable processor = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (FoldRegion region : allFoldRegions) {
|
||||
PsiElement element = EditorFoldingInfo.get(editor).getPsiElement(region);
|
||||
@@ -52,6 +54,7 @@ public class CollapseExpandJavadocsHandler implements CodeInsightActionHandler {
|
||||
editor.getFoldingModel().runBatchFoldingOperation(processor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
+25
@@ -37,10 +37,12 @@ import java.io.File;
|
||||
)
|
||||
public class JavaCodeFoldingSettingsImpl extends JavaCodeFoldingSettings implements PersistentStateComponent<JavaCodeFoldingSettingsImpl>,
|
||||
ExportableComponent {
|
||||
@Override
|
||||
public boolean isCollapseImports() {
|
||||
return CodeFoldingSettings.getInstance().COLLAPSE_IMPORTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseImports(boolean value) {
|
||||
CodeFoldingSettings.getInstance().COLLAPSE_IMPORTS = value;
|
||||
}
|
||||
@@ -50,79 +52,98 @@ public class JavaCodeFoldingSettingsImpl extends JavaCodeFoldingSettings impleme
|
||||
return COLLAPSE_CLOSURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseLambdas(boolean value) {
|
||||
COLLAPSE_CLOSURES = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseConstructorGenericParameters() {
|
||||
return COLLAPSE_CONSTRUCTOR_GENERIC_PARAMETERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseConstructorGenericParameters(boolean value) {
|
||||
COLLAPSE_CONSTRUCTOR_GENERIC_PARAMETERS = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseMethods() {
|
||||
return CodeFoldingSettings.getInstance().COLLAPSE_METHODS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseMethods(boolean value) {
|
||||
CodeFoldingSettings.getInstance().COLLAPSE_METHODS = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseAccessors() {
|
||||
return COLLAPSE_ACCESSORS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseAccessors(boolean value) {
|
||||
COLLAPSE_ACCESSORS = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseInnerClasses() {
|
||||
return COLLAPSE_INNER_CLASSES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseInnerClasses(boolean value) {
|
||||
COLLAPSE_INNER_CLASSES = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseJavadocs() {
|
||||
return CodeFoldingSettings.getInstance().COLLAPSE_DOC_COMMENTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseJavadocs(boolean value) {
|
||||
CodeFoldingSettings.getInstance().COLLAPSE_DOC_COMMENTS = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseFileHeader() {
|
||||
return CodeFoldingSettings.getInstance().COLLAPSE_FILE_HEADER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseFileHeader(boolean value) {
|
||||
CodeFoldingSettings.getInstance().COLLAPSE_FILE_HEADER = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseAnonymousClasses() {
|
||||
return COLLAPSE_ANONYMOUS_CLASSES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseAnonymousClasses(boolean value) {
|
||||
COLLAPSE_ANONYMOUS_CLASSES = value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isCollapseAnnotations() {
|
||||
return COLLAPSE_ANNOTATIONS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseAnnotations(boolean value) {
|
||||
COLLAPSE_ANNOTATIONS = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseI18nMessages() {
|
||||
return COLLAPSE_I18N_MESSAGES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseI18nMessages(boolean value) {
|
||||
COLLAPSE_I18N_MESSAGES = value;
|
||||
}
|
||||
@@ -157,20 +178,24 @@ public class JavaCodeFoldingSettingsImpl extends JavaCodeFoldingSettings impleme
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean COLLAPSE_SUPPRESS_WARNINGS = true;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean COLLAPSE_END_OF_LINE_COMMENTS = false;
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public File[] getExportFiles() {
|
||||
return new File[]{PathManager.getOptionsFile("editor.codeinsight")};
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getPresentableName() {
|
||||
return IdeBundle.message("code.folding.settings");
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaCodeFoldingSettingsImpl getState() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(final JavaCodeFoldingSettingsImpl state) {
|
||||
XmlSerializerUtil.copyBean(state, this);
|
||||
}
|
||||
|
||||
+2
@@ -29,6 +29,7 @@ import java.util.StringTokenizer;
|
||||
public class JavaElementSignatureProvider extends AbstractElementSignatureProvider {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.folding.impl.JavaElementSignatureProvider");
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getSignature(@NotNull final PsiElement element) {
|
||||
if (element instanceof PsiImportList) {
|
||||
@@ -152,6 +153,7 @@ public class JavaElementSignatureProvider extends AbstractElementSignatureProvid
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PsiElement restoreBySignatureTokens(@NotNull PsiFile file,
|
||||
@NotNull PsiElement parent,
|
||||
@NotNull String type,
|
||||
|
||||
@@ -635,6 +635,7 @@ public class JavaFoldingBuilder extends CustomFoldingBuilder implements DumbAwar
|
||||
}
|
||||
|
||||
final String params = StringUtil.join(method.getParameterList().getParameters(), new Function<PsiParameter, String>() {
|
||||
@Override
|
||||
public String fun(final PsiParameter psiParameter) {
|
||||
String typeName;
|
||||
if (quick) {
|
||||
|
||||
+1
@@ -23,6 +23,7 @@ import com.intellij.codeInsight.folding.impl.CollapseBlockHandler;
|
||||
* @author ven
|
||||
*/
|
||||
public class CollapseBlockAction extends BaseCodeInsightAction {
|
||||
@Override
|
||||
protected CodeInsightActionHandler getHandler() {
|
||||
return new CollapseBlockHandler ();
|
||||
}
|
||||
|
||||
+1
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.actions.BaseCodeInsightAction;
|
||||
import com.intellij.codeInsight.folding.impl.CollapseExpandJavadocsHandler;
|
||||
|
||||
public class CollapseJavadocsAction extends BaseCodeInsightAction{
|
||||
@Override
|
||||
protected CodeInsightActionHandler getHandler(){
|
||||
return new CollapseExpandJavadocsHandler(false);
|
||||
}
|
||||
|
||||
+1
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.actions.BaseCodeInsightAction;
|
||||
import com.intellij.codeInsight.folding.impl.CollapseExpandJavadocsHandler;
|
||||
|
||||
public class ExpandJavadocsAction extends BaseCodeInsightAction{
|
||||
@Override
|
||||
protected CodeInsightActionHandler getHandler(){
|
||||
return new CollapseExpandJavadocsHandler(true);
|
||||
}
|
||||
|
||||
+4
@@ -42,18 +42,22 @@ public class HighlightExceptionsHandler extends HighlightUsagesHandlerBase<PsiCl
|
||||
myTypeFilter = typeFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PsiClass> getTargets() {
|
||||
return ChooseClassAndDoHighlightRunnable.resolveClasses(myClassTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void selectTargets(final List<PsiClass> targets, final Consumer<List<PsiClass>> selectionConsumer) {
|
||||
new ChooseClassAndDoHighlightRunnable(myClassTypes, myEditor, CodeInsightBundle.message("highlight.exceptions.thrown.chooser.title")) {
|
||||
@Override
|
||||
protected void selected(PsiClass... classes) {
|
||||
selectionConsumer.consume(Arrays.asList(classes));
|
||||
}
|
||||
}.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void computeUsages(final List<PsiClass> targets) {
|
||||
final Project project = myEditor.getProject();
|
||||
final PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
|
||||
|
||||
+2
@@ -30,6 +30,7 @@ import java.util.Collection;
|
||||
* @author yole
|
||||
*/
|
||||
public class HighlightExceptionsHandlerFactory implements HighlightUsagesHandlerFactory {
|
||||
@Override
|
||||
public HighlightUsagesHandlerBase createHighlightUsagesHandler(final Editor editor, final PsiFile file) {
|
||||
int offset = TargetElementUtilBase.adjustOffset(editor.getDocument(), editor.getCaretModel().getOffset());
|
||||
PsiElement target = file.findElementAt(offset);
|
||||
@@ -79,6 +80,7 @@ public class HighlightExceptionsHandlerFactory implements HighlightUsagesHandler
|
||||
final Collection<PsiClassType> allThrownExceptions = ExceptionUtil.collectUnhandledExceptions(tryStatement.getTryBlock(),
|
||||
tryStatement.getTryBlock());
|
||||
Condition<PsiType> filter = new Condition<PsiType>() {
|
||||
@Override
|
||||
public boolean value(PsiType type) {
|
||||
for (PsiParameter parameter : catchBlockParameters) {
|
||||
boolean isAssignable = parameter.getType().isAssignableFrom(type);
|
||||
|
||||
+3
@@ -40,14 +40,17 @@ public class HighlightExitPointsHandler extends HighlightUsagesHandlerBase<PsiEl
|
||||
myTarget = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PsiElement> getTargets() {
|
||||
return Collections.singletonList(myTarget);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void selectTargets(final List<PsiElement> targets, final Consumer<List<PsiElement>> selectionConsumer) {
|
||||
selectionConsumer.consume(targets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void computeUsages(final List<PsiElement> targets) {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed(ProductivityFeatureNames.CODEASSISTS_HIGHLIGHT_RETURN);
|
||||
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ import com.intellij.codeInsight.TargetElementUtilBase;
|
||||
* @author yole
|
||||
*/
|
||||
public class HighlightExitPointsHandlerFactory implements HighlightUsagesHandlerFactory {
|
||||
@Override
|
||||
public HighlightUsagesHandlerBase createHighlightUsagesHandler(final Editor editor, final PsiFile file) {
|
||||
int offset = TargetElementUtilBase.adjustOffset(editor.getDocument(), editor.getCaretModel().getOffset());
|
||||
PsiElement target = file.findElementAt(offset);
|
||||
|
||||
+4
@@ -38,6 +38,7 @@ public class HighlightOverridingMethodsHandler extends HighlightUsagesHandlerBas
|
||||
myClass = psiClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PsiClass> getTargets() {
|
||||
PsiReferenceList list = PsiKeyword.EXTENDS.equals(myTarget.getText()) ? myClass.getExtendsList() : myClass.getImplementsList();
|
||||
if (list == null) return Collections.emptyList();
|
||||
@@ -45,14 +46,17 @@ public class HighlightOverridingMethodsHandler extends HighlightUsagesHandlerBas
|
||||
return ChooseClassAndDoHighlightRunnable.resolveClasses(classTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void selectTargets(final List<PsiClass> targets, final Consumer<List<PsiClass>> selectionConsumer) {
|
||||
new ChooseClassAndDoHighlightRunnable(targets, myEditor, CodeInsightBundle.message("highlight.overridden.classes.chooser.title")) {
|
||||
@Override
|
||||
protected void selected(PsiClass... classes) {
|
||||
selectionConsumer.consume(Arrays.asList(classes));
|
||||
}
|
||||
}.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void computeUsages(final List<PsiClass> classes) {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed("codeassists.highlight.implements");
|
||||
for (PsiMethod method : myClass.getMethods()) {
|
||||
|
||||
+1
@@ -23,6 +23,7 @@ import com.intellij.codeInsight.TargetElementUtilBase;
|
||||
* @author yole
|
||||
*/
|
||||
public class HighlightOverridingMethodsHandlerFactory implements HighlightUsagesHandlerFactory {
|
||||
@Override
|
||||
public HighlightUsagesHandlerBase createHighlightUsagesHandler(final Editor editor, final PsiFile file) {
|
||||
int offset = TargetElementUtilBase.adjustOffset(editor.getDocument(), editor.getCaretModel().getOffset());
|
||||
final PsiElement target = file.findElementAt(offset);
|
||||
|
||||
+1
@@ -29,6 +29,7 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
* @author yole
|
||||
*/
|
||||
public class HighlightSuppressedWarningsFactory implements HighlightUsagesHandlerFactory {
|
||||
@Override
|
||||
public HighlightUsagesHandlerBase createHighlightUsagesHandler(final Editor editor, final PsiFile file) {
|
||||
int offset = TargetElementUtilBase.adjustOffset(editor.getDocument(), editor.getCaretModel().getOffset());
|
||||
final PsiElement target = file.findElementAt(offset);
|
||||
|
||||
+4
@@ -62,6 +62,7 @@ public class HighlightSuppressedWarningsHandler extends HighlightUsagesHandlerBa
|
||||
mySuppressedExpression = suppressedExpression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PsiLiteralExpression> getTargets() {
|
||||
final List<PsiLiteralExpression> result = new ArrayList<PsiLiteralExpression>();
|
||||
if (mySuppressedExpression != null) {
|
||||
@@ -84,6 +85,7 @@ public class HighlightSuppressedWarningsHandler extends HighlightUsagesHandlerBa
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void selectTargets(List<PsiLiteralExpression> targets, final Consumer<List<PsiLiteralExpression>> selectionConsumer) {
|
||||
if (targets.size() == 1) {
|
||||
selectionConsumer.consume(targets);
|
||||
@@ -106,6 +108,7 @@ public class HighlightSuppressedWarningsHandler extends HighlightUsagesHandlerBa
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void computeUsages(List<PsiLiteralExpression> targets) {
|
||||
final Project project = myTarget.getProject();
|
||||
final PsiElement parent = myTarget.getParent().getParent();
|
||||
@@ -130,6 +133,7 @@ public class HighlightSuppressedWarningsHandler extends HighlightUsagesHandlerBa
|
||||
((RefManagerImpl)context.getRefManager()).inspectionReadActionStarted();
|
||||
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
|
||||
Runnable inspect = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pass.doInspectInBatch(managerEx, Collections.<InspectionProfileEntry>singletonList(tool));
|
||||
}
|
||||
|
||||
@@ -34,10 +34,12 @@ public class JavaBraceMatcher implements PairedBraceMatcher {
|
||||
new BracePair(JavaDocTokenType.DOC_INLINE_TAG_START, JavaDocTokenType.DOC_INLINE_TAG_END, false),
|
||||
};
|
||||
|
||||
@Override
|
||||
public BracePair[] getPairs() {
|
||||
return pairs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPairedBracesAllowedBeforeType(@NotNull final IElementType lbraceType, @Nullable final IElementType contextType) {
|
||||
if (contextType instanceof IJavaElementType) return isPairedBracesAllowedBeforeTypeInJava(contextType);
|
||||
return true;
|
||||
@@ -53,6 +55,7 @@ public class JavaBraceMatcher implements PairedBraceMatcher {
|
||||
|| tokenType == JavaTokenType.LBRACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCodeConstructStart(final PsiFile file, int openingBraceOffset) {
|
||||
PsiElement element = file.findElementAt(openingBraceOffset);
|
||||
if (element == null || element instanceof PsiFile) return openingBraceOffset;
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author yole
|
||||
*/
|
||||
public class JavaHighlightUsagesDescriptionProvider implements ElementDescriptionProvider {
|
||||
@Override
|
||||
public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) {
|
||||
if (!(location instanceof HighlightUsagesDescriptionLocation)) return null;
|
||||
|
||||
|
||||
+4
@@ -23,10 +23,12 @@ import com.intellij.psi.util.PsiUtil;
|
||||
* @author yole
|
||||
*/
|
||||
public class JavaReadWriteAccessDetector extends ReadWriteAccessDetector {
|
||||
@Override
|
||||
public boolean isReadWriteAccessible(final PsiElement element) {
|
||||
return element instanceof PsiVariable && !(element instanceof ImplicitVariable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeclarationWriteAccess(final PsiElement element) {
|
||||
if (element instanceof PsiVariable && ((PsiVariable)element).getInitializer() != null) {
|
||||
return true;
|
||||
@@ -37,10 +39,12 @@ public class JavaReadWriteAccessDetector extends ReadWriteAccessDetector {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Access getReferenceAccess(final PsiElement referencedElement, final PsiReference reference) {
|
||||
return getExpressionAccess(reference.getElement());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Access getExpressionAccess(final PsiElement expression) {
|
||||
if (!(expression instanceof PsiExpression)) return Access.Read;
|
||||
PsiExpression expr = (PsiExpression) expression;
|
||||
|
||||
@@ -70,11 +70,13 @@ public class AddAnnotationFix extends LocalQuickFixAndIntentionActionOnPsiElemen
|
||||
return CodeInsightBundle.message("inspection.i18n.quickfix.annotate.as", shortName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getText() {
|
||||
return myText;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return CodeInsightBundle.message("intention.add.annotation.family");
|
||||
|
||||
@@ -46,6 +46,7 @@ public abstract class AddAnnotationIntention extends BaseIntentionAction {
|
||||
public abstract Pair<String, String[]> getAnnotations(@NotNull Project project);
|
||||
|
||||
// include not in project files
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
CaretModel caretModel = editor.getCaretModel();
|
||||
int position = caretModel.getOffset();
|
||||
|
||||
+4
@@ -42,6 +42,7 @@ import java.util.List;
|
||||
public class AddOnDemandStaticImportAction extends PsiElementBaseIntentionAction {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.intention.impl.AddOnDemandStaticImportAction");
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return CodeInsightBundle.message("intention.add.on.demand.static.import.family");
|
||||
@@ -81,6 +82,7 @@ public class AddOnDemandStaticImportAction extends PsiElementBaseIntentionAction
|
||||
return psiClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
|
||||
PsiClass classToImport = getClassToPerformStaticImport(element);
|
||||
if (classToImport != null) {
|
||||
@@ -138,6 +140,7 @@ public class AddOnDemandStaticImportAction extends PsiElementBaseIntentionAction
|
||||
});
|
||||
|
||||
expressionToDequalifyOffsets.forEachDescending(new TIntProcedure() {
|
||||
@Override
|
||||
public boolean execute(int offset) {
|
||||
PsiJavaCodeReferenceElement expression = PsiTreeUtil.findElementOfClassAtOffset(root, offset, PsiJavaCodeReferenceElement.class, false);
|
||||
if (expression == null) {
|
||||
@@ -158,6 +161,7 @@ public class AddOnDemandStaticImportAction extends PsiElementBaseIntentionAction
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull final Project project, final Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
|
||||
invoke(project, file, editor, element);
|
||||
|
||||
+5
@@ -33,16 +33,19 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class AddOverrideAnnotationAction implements IntentionAction {
|
||||
private static final String JAVA_LANG_OVERRIDE = "java.lang.Override";
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getText() {
|
||||
return CodeInsightBundle.message("intention.add.override.annotation");
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return CodeInsightBundle.message("intention.add.override.annotation.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(file)) return false;
|
||||
PsiMethod method = findMethod(file, editor.getCaretModel().getOffset());
|
||||
@@ -59,6 +62,7 @@ public class AddOverrideAnnotationAction implements IntentionAction {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
PsiMethod method = findMethod(file, editor.getCaretModel().getOffset());
|
||||
if (method != null) {
|
||||
@@ -80,6 +84,7 @@ public class AddOverrideAnnotationAction implements IntentionAction {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
+3
@@ -40,6 +40,7 @@ public class AddSingleMemberStaticImportAction extends PsiElementBaseIntentionAc
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.intention.impl.AddSingleMemberStaticImportAction");
|
||||
private static final Key<PsiElement> TEMP_REFERENT_USER_DATA = new Key<PsiElement>("TEMP_REFERENT_USER_DATA");
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return CodeInsightBundle.message("intention.add.single.member.static.import.family");
|
||||
@@ -105,6 +106,7 @@ public class AddSingleMemberStaticImportAction extends PsiElementBaseIntentionAc
|
||||
return aClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
|
||||
String classQName = getStaticImportClass(element);
|
||||
if (classQName != null) {
|
||||
@@ -198,6 +200,7 @@ public class AddSingleMemberStaticImportAction extends PsiElementBaseIntentionAc
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull final Project project, final Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
|
||||
invoke(file, element);
|
||||
|
||||
+3
@@ -46,6 +46,7 @@ public class AssignFieldFromParameterAction extends BaseIntentionAction {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
PsiParameter myParameter = CreateFieldFromParameterAction.findParameterAtCursor(file, editor);
|
||||
final PsiType type = getType(myParameter);
|
||||
@@ -70,11 +71,13 @@ public class AssignFieldFromParameterAction extends BaseIntentionAction {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return CodeInsightBundle.message("intention.assign.field.from.parameter.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
PsiParameter myParameter = CreateFieldFromParameterAction.findParameterAtCursor(file, editor);
|
||||
if (!CodeInsightUtilBase.prepareFileForWrite(myParameter.getContainingFile())) return;
|
||||
|
||||
+3
@@ -62,6 +62,7 @@ public class ColorChooserIntentionAction extends PsiElementBaseIntentionAction {
|
||||
setText(CodeInsightBundle.message("intention.color.chooser.dialog"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) {
|
||||
// new Color(...)
|
||||
if (psiElement().inside(psiElement(PsiNewExpression.class)).accepts(element)) {
|
||||
@@ -102,11 +103,13 @@ public class ColorChooserIntentionAction extends PsiElementBaseIntentionAction {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException {
|
||||
if (!CodeInsightUtilBase.prepareFileForWrite(file)) return;
|
||||
PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
|
||||
|
||||
+5
@@ -39,16 +39,19 @@ import java.util.List;
|
||||
* @author ven
|
||||
*/
|
||||
public class ConcatenationToMessageFormatAction implements IntentionAction {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return CodeInsightBundle.message("intention.replace.concatenation.with.formatted.output.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getText() {
|
||||
return CodeInsightBundle.message("intention.replace.concatenation.with.formatted.output.text");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
if (!CodeInsightUtilBase.prepareFileForWrite(file)) return;
|
||||
final PsiElement element = findElementAtCaret(editor, file);
|
||||
@@ -124,6 +127,7 @@ public class ConcatenationToMessageFormatAction implements IntentionAction {
|
||||
return newExpr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
if (PsiUtil.getLanguageLevel(file).compareTo(LanguageLevel.JDK_1_4) < 0) return false;
|
||||
final PsiElement element = findElementAtCaret(editor, file);
|
||||
@@ -155,6 +159,7 @@ public class ConcatenationToMessageFormatAction implements IntentionAction {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
+2
@@ -77,11 +77,13 @@ public class ConvertAbsolutePathToRelativeIntentionAction extends PsiElementBase
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return "Convert " + (isConvertToRelative() ? "absolute" : "relative") + " path to " + (isConvertToRelative() ? "relative" : "absolute");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
final PsiReference reference = file.findReferenceAt(editor.getCaretModel().getOffset());
|
||||
final FileReference fileReference = reference == null ? null : findFileReference(reference);
|
||||
|
||||
+9
@@ -131,6 +131,7 @@ public class ConvertToBasicLatinAction extends PsiElementBaseIntentionAction {
|
||||
private static class MyLiteralHandler extends Handler {
|
||||
private static final TokenSet LITERALS = TokenSet.create(JavaTokenType.CHARACTER_LITERAL, JavaTokenType.STRING_LITERAL);
|
||||
|
||||
@Override
|
||||
public PsiElement findApplicable(final PsiElement element) {
|
||||
final PsiElement parent = element.getParent();
|
||||
return element instanceof PsiJavaToken &&
|
||||
@@ -139,10 +140,12 @@ public class ConvertToBasicLatinAction extends PsiElementBaseIntentionAction {
|
||||
? parent : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement createReplacement(final PsiElement element, final String newText) {
|
||||
return JavaPsiFacade.getElementFactory(element.getProject()).createExpressionFromText(newText, element.getParent());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(final StringBuilder sb, final char ch) {
|
||||
sb.append(String.format("\\u%04x", (int)ch));
|
||||
}
|
||||
@@ -151,6 +154,7 @@ public class ConvertToBasicLatinAction extends PsiElementBaseIntentionAction {
|
||||
private static class MyDocCommentHandler extends Handler {
|
||||
private static Map<Character, String> ourEntities = null;
|
||||
|
||||
@Override
|
||||
public PsiElement findApplicable(final PsiElement element) {
|
||||
if (element instanceof PsiDocComment) return element;
|
||||
if (element instanceof PsiDocToken) return element.getParent();
|
||||
@@ -167,6 +171,7 @@ public class ConvertToBasicLatinAction extends PsiElementBaseIntentionAction {
|
||||
return super.processText(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(final StringBuilder sb, final char ch) {
|
||||
assert ourEntities != null;
|
||||
final String entity = ourEntities.get(ch);
|
||||
@@ -178,6 +183,7 @@ public class ConvertToBasicLatinAction extends PsiElementBaseIntentionAction {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement createReplacement(final PsiElement element, final String newText) {
|
||||
return JavaPsiFacade.getElementFactory(element.getProject()).createDocCommentFromText(newText);
|
||||
}
|
||||
@@ -202,6 +208,7 @@ public class ConvertToBasicLatinAction extends PsiElementBaseIntentionAction {
|
||||
ourEntities = new HashMap<Character, String>();
|
||||
final Pattern pattern = Pattern.compile("&#(\\d+);");
|
||||
XmlUtil.processXmlElements(file, new PsiElementProcessor() {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element) {
|
||||
if (element instanceof XmlEntityDecl) {
|
||||
final XmlEntityDecl entity = (XmlEntityDecl)element;
|
||||
@@ -220,10 +227,12 @@ public class ConvertToBasicLatinAction extends PsiElementBaseIntentionAction {
|
||||
}
|
||||
|
||||
private static class MyCommentHandler extends MyDocCommentHandler {
|
||||
@Override
|
||||
public PsiElement findApplicable(final PsiElement element) {
|
||||
return element instanceof PsiComment ? element : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement createReplacement(final PsiElement element, final String newText) {
|
||||
return JavaPsiFacade.getElementFactory(element.getProject()).createCommentFromText(newText, element.getParent());
|
||||
}
|
||||
|
||||
+4
@@ -25,19 +25,23 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author yole
|
||||
*/
|
||||
public class CopyAbstractMethodImplementationAction extends ImplementAbstractMethodAction {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return "Copy Abstract Method Implementation";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getIntentionName(final PsiMethod method) {
|
||||
return CodeInsightBundle.message("copy.abstract.method.intention.name", method.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAvailable(final MyElementProcessor processor) {
|
||||
return processor.hasMissingImplementations() && processor.hasExistingImplementations();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void invokeHandler(final Project project, final Editor editor, final PsiMethod method) {
|
||||
new CopyAbstractMethodImplementationHandler(project, editor, method).invoke();
|
||||
}
|
||||
|
||||
+4
@@ -64,6 +64,7 @@ public class CopyAbstractMethodImplementationHandler {
|
||||
|
||||
public void invoke() {
|
||||
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
searchExistingImplementations();
|
||||
}
|
||||
@@ -78,6 +79,7 @@ public class CopyAbstractMethodImplementationHandler {
|
||||
}
|
||||
else {
|
||||
Collections.sort(mySourceMethods, new Comparator<PsiMethod>() {
|
||||
@Override
|
||||
public int compare(final PsiMethod o1, final PsiMethod o2) {
|
||||
PsiClass c1 = o1.getContainingClass();
|
||||
PsiClass c2 = o2.getContainingClass();
|
||||
@@ -88,6 +90,7 @@ public class CopyAbstractMethodImplementationHandler {
|
||||
final JList list = new JBList(methodArray);
|
||||
list.setCellRenderer(new MethodCellRenderer(true));
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int index = list.getSelectedIndex();
|
||||
if (index < 0) return;
|
||||
@@ -148,6 +151,7 @@ public class CopyAbstractMethodImplementationHandler {
|
||||
private void copyImplementation(final PsiMethod sourceMethod) {
|
||||
final List<PsiMethod> generatedMethods = new ArrayList<PsiMethod>();
|
||||
new WriteCommandAction(myProject, getTargetFiles()) {
|
||||
@Override
|
||||
protected void run(final Result result) throws Throwable {
|
||||
for (PsiEnumConstant enumConstant : myTargetEnumConstants) {
|
||||
PsiClass initializingClass = enumConstant.getOrCreateInitializingClass();
|
||||
|
||||
@@ -127,18 +127,22 @@ public class CreateClassDialog extends DialogWrapper {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Action[] createActions() {
|
||||
return new Action[]{getOKAction(), getCancelAction()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return myClassNameEditable ? myTfClassName : myPackageComponent.getChildComponent();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
return new JPanel(new BorderLayout());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createNorthPanel() {
|
||||
JPanel panel = new JPanel(new GridBagLayout());
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
@@ -160,6 +164,7 @@ public class CreateClassDialog extends DialogWrapper {
|
||||
panel.add(myTfClassName, gbConstraints);
|
||||
|
||||
myTfClassName.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
protected void textChanged(DocumentEvent e) {
|
||||
getOKAction().setEnabled(JavaPsiFacade.getInstance(myProject).getNameHelper().isIdentifier(myTfClassName.getText()));
|
||||
}
|
||||
@@ -177,6 +182,7 @@ public class CreateClassDialog extends DialogWrapper {
|
||||
gbConstraints.weightx = 1;
|
||||
|
||||
new AnAction() {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
myPackageComponent.getButton().doClick();
|
||||
}
|
||||
@@ -217,6 +223,7 @@ public class CreateClassDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
private static class MyTextField extends JTextField {
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
Dimension size = super.getPreferredSize();
|
||||
FontMetrics fontMetrics = getFontMetrics(getFont());
|
||||
@@ -225,12 +232,14 @@ public class CreateClassDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doOKAction() {
|
||||
RecentsManager.getInstance(myProject).registerRecentEntry(RECENTS_KEY, myPackageComponent.getText());
|
||||
final String packageName = getPackageName();
|
||||
|
||||
final String[] errorString = new String[1];
|
||||
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
final PackageWrapper targetPackage = new PackageWrapper(PsiManager.getInstance(myProject), packageName);
|
||||
|
||||
+6
@@ -96,12 +96,14 @@ public class CreateFieldFromParameterAction implements IntentionAction {
|
||||
return new PsiType[]{psiClass instanceof PsiTypeParameter ? subst.substitute((PsiTypeParameter)psiClass) : elementFactory.createType(psiClass, substitutor)};
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getText() {
|
||||
if (myName == null) return CodeInsightBundle.message("intention.create.fields.from.parameters.text");
|
||||
return CodeInsightBundle.message("intention.create.field.from.parameter.text", myName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
PsiParameter psiParameter = findParameterAtCursor(file, editor);
|
||||
PsiMethod method = null;
|
||||
@@ -212,11 +214,13 @@ public class CreateFieldFromParameterAction implements IntentionAction {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return CodeInsightBundle.message("intention.create.field.from.parameter.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
invoke(project, editor, file, !ApplicationManager.getApplication().isUnitTestMode());
|
||||
}
|
||||
@@ -340,6 +344,7 @@ public class CreateFieldFromParameterAction implements IntentionAction {
|
||||
final String fieldName = fieldNameToCalc;
|
||||
final PsiType fieldType = type;
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
PsiManager psiManager = PsiManager.getInstance(project);
|
||||
@@ -476,6 +481,7 @@ public class CreateFieldFromParameterAction implements IntentionAction {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
+13
@@ -63,6 +63,7 @@ class CreateFieldFromParameterDialog extends DialogWrapper {
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doOKAction() {
|
||||
if (myCbFinal.isEnabled()) {
|
||||
PropertiesComponent.getInstance().setValue(PROPERTY_NAME, ""+myCbFinal.isSelected());
|
||||
@@ -88,6 +89,7 @@ class CreateFieldFromParameterDialog extends DialogWrapper {
|
||||
close(OK_EXIT_CODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
updateOkStatus();
|
||||
@@ -111,6 +113,7 @@ class CreateFieldFromParameterDialog extends DialogWrapper {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createNorthPanel() {
|
||||
if (myNames.length > 1) {
|
||||
final ComboBox combobox = new ComboBox(myNames, 200);
|
||||
@@ -121,6 +124,7 @@ class CreateFieldFromParameterDialog extends DialogWrapper {
|
||||
|
||||
combobox.registerKeyboardAction(
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (combobox.isPopupVisible()) {
|
||||
combobox.setPopupVisible(false);
|
||||
@@ -136,6 +140,7 @@ class CreateFieldFromParameterDialog extends DialogWrapper {
|
||||
|
||||
combobox.addItemListener(
|
||||
new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
updateOkStatus();
|
||||
}
|
||||
@@ -143,14 +148,17 @@ class CreateFieldFromParameterDialog extends DialogWrapper {
|
||||
);
|
||||
combobox.getEditor().getEditorComponent().addKeyListener(
|
||||
new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
updateOkStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
updateOkStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
updateOkStatus();
|
||||
}
|
||||
@@ -159,6 +167,7 @@ class CreateFieldFromParameterDialog extends DialogWrapper {
|
||||
}
|
||||
else {
|
||||
JTextField field = new JTextField() {
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
Dimension size = super.getPreferredSize();
|
||||
return new Dimension(200, size.height);
|
||||
@@ -168,6 +177,7 @@ class CreateFieldFromParameterDialog extends DialogWrapper {
|
||||
field.setText(myNames[0]);
|
||||
|
||||
field.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
protected void textChanged(DocumentEvent e) {
|
||||
updateOkStatus();
|
||||
}
|
||||
@@ -215,6 +225,7 @@ class CreateFieldFromParameterDialog extends DialogWrapper {
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
JPanel panel = new JPanel(new GridBagLayout());
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
@@ -237,6 +248,7 @@ class CreateFieldFromParameterDialog extends DialogWrapper {
|
||||
gbConstraints.gridy++;
|
||||
panel.add(myCbFinal, gbConstraints);
|
||||
myCbFinal.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
requestFocusInNameWindow();
|
||||
if (myCbFinal.isEnabled()) {
|
||||
@@ -261,6 +273,7 @@ class CreateFieldFromParameterDialog extends DialogWrapper {
|
||||
setOKActionEnabled(JavaPsiFacade.getInstance(myProject).getNameHelper().isIdentifier(text));
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return myNameField;
|
||||
}
|
||||
|
||||
@@ -64,11 +64,13 @@ public class CreateSubclassAction extends BaseIntentionAction {
|
||||
private String myText = CodeInsightBundle.message("intention.implement.abstract.class.default.text");
|
||||
@NonNls private static final String IMPL_SUFFIX = "Impl";
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getText() {
|
||||
return myText;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return CodeInsightBundle.message("intention.implement.abstract.class.family");
|
||||
@@ -120,6 +122,7 @@ public class CreateSubclassAction extends BaseIntentionAction {
|
||||
: CodeInsightBundle.message("intention.implement.abstract.class.subclass.text");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull final Project project, Editor editor, final PsiFile file) throws IncorrectOperationException {
|
||||
PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
|
||||
final PsiClass psiClass = PsiTreeUtil.getParentOfType(element, PsiClass.class);
|
||||
@@ -196,6 +199,7 @@ public class CreateSubclassAction extends BaseIntentionAction {
|
||||
}
|
||||
catch (final IncorrectOperationException e) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Messages.showErrorDialog(project, CodeInsightBundle.message("intention.error.cannot.create.class.message", className) +
|
||||
"\n"+e.getLocalizedMessage(),
|
||||
@@ -308,6 +312,7 @@ public class CreateSubclassAction extends BaseIntentionAction {
|
||||
OverrideImplementUtil.chooseAndImplementMethods(project, editor, targetClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
+8
@@ -43,16 +43,19 @@ public class DeannotateIntentionAction implements IntentionAction {
|
||||
private static final Logger LOG = Logger.getInstance("#" + DeannotateIntentionAction.class.getName());
|
||||
private String myAnnotationName = null;
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getText() {
|
||||
return CodeInsightBundle.message("deannotate.intention.action.text") + (myAnnotationName != null ? " " + myAnnotationName : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return CodeInsightBundle.message("deannotate.intention.action.text");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
PsiModifierListOwner listOwner = getContainer(editor, file);
|
||||
if (listOwner != null) {
|
||||
@@ -119,13 +122,16 @@ public class DeannotateIntentionAction implements IntentionAction {
|
||||
return listOwner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull final Project project, Editor editor, final PsiFile file) throws IncorrectOperationException {
|
||||
final PsiModifierListOwner listOwner = getContainer(editor, file);
|
||||
final ExternalAnnotationsManager annotationsManager = ExternalAnnotationsManager.getInstance(project);
|
||||
final PsiAnnotation[] externalAnnotations = annotationsManager.findExternalAnnotations(listOwner);
|
||||
JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<PsiAnnotation>(CodeInsightBundle.message("deannotate.intention.chooser.title"), externalAnnotations) {
|
||||
@Override
|
||||
public PopupStep onChosen(final PsiAnnotation selectedValue, final boolean finalChoice) {
|
||||
new WriteCommandAction(project){
|
||||
@Override
|
||||
protected void run(final Result result) throws Throwable {
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (annotationsManager.deannotate(listOwner, selectedValue.getQualifiedName()) && virtualFile != null && virtualFile.isInLocalFileSystem()) {
|
||||
@@ -136,6 +142,7 @@ public class DeannotateIntentionAction implements IntentionAction {
|
||||
return PopupStep.FINAL_CHOICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getTextFor(final PsiAnnotation value) {
|
||||
final String qualifiedName = value.getQualifiedName();
|
||||
@@ -145,6 +152,7 @@ public class DeannotateIntentionAction implements IntentionAction {
|
||||
}).showInBestPositionFor(editor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
@@ -40,11 +40,13 @@ public class ExpandStaticImportAction extends PsiElementBaseIntentionAction {
|
||||
private static final String REPLACE_THIS_OCCURRENCE = "Replace this occurrence and keep the method";
|
||||
private static final String REPLACE_ALL_AND_DELETE_IMPORT = "Replace all and delete the import";
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return "Expand Static Import";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(element)) return false;
|
||||
final PsiElement parent = element.getParent();
|
||||
@@ -106,6 +108,7 @@ public class ExpandStaticImportAction extends PsiElementBaseIntentionAction {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull final Project project, final Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
|
||||
invoke(project, file, editor, element);
|
||||
|
||||
+5
@@ -38,11 +38,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ImplementAbstractMethodAction extends BaseIntentionAction {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return CodeInsightBundle.message("intention.implement.abstract.method.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
final PsiMethod method = findMethod(file, offset);
|
||||
@@ -114,6 +116,7 @@ public class ImplementAbstractMethodAction extends BaseIntentionAction {
|
||||
return myHasExistingImplementations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element) {
|
||||
if (element instanceof PsiClass) {
|
||||
PsiClass aClass = (PsiClass) element;
|
||||
@@ -160,6 +163,7 @@ public class ImplementAbstractMethodAction extends BaseIntentionAction {
|
||||
return PsiTreeUtil.getParentOfType(file.findElementAt(offset), PsiMethod.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
PsiMethod method = findMethod(file, editor.getCaretModel().getOffset());
|
||||
if (method == null) return;
|
||||
@@ -171,6 +175,7 @@ public class ImplementAbstractMethodAction extends BaseIntentionAction {
|
||||
new ImplementAbstractMethodHandler(project, editor, method).invoke();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
+4
@@ -44,6 +44,7 @@ import java.util.List;
|
||||
public class InvertIfConditionAction extends PsiElementBaseIntentionAction {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.intention.impl.InvertIfConditionAction");
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
|
||||
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
@@ -66,16 +67,19 @@ public class InvertIfConditionAction extends PsiElementBaseIntentionAction {
|
||||
return block != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getText() {
|
||||
return getFamilyName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return CodeInsightBundle.message("intention.invert.if.condition");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
if (!CodeInsightUtilBase.prepareFileForWrite(file)) return;
|
||||
|
||||
|
||||
+4
@@ -39,16 +39,19 @@ import java.util.List;
|
||||
* @author cdr
|
||||
*/
|
||||
public class MoveFieldAssignmentToInitializerAction extends BaseIntentionAction {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getText() {
|
||||
return CodeInsightBundle.message("intention.move.field.assignment.to.declaration");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
final PsiAssignmentExpression assignment = getAssignmentUnderCaret(editor, file);
|
||||
if (assignment == null) return false;
|
||||
@@ -155,6 +158,7 @@ public class MoveFieldAssignmentToInitializerAction extends BaseIntentionAction
|
||||
return PsiTreeUtil.getParentOfType(element, PsiAssignmentExpression.class, false, PsiMember.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
final PsiAssignmentExpression assignment = getAssignmentUnderCaret(editor, file);
|
||||
if (assignment == null) return;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user