mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -16,9 +16,9 @@
|
||||
package org.intellij.images.completion;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.file.FileLookupInfoProvider;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import org.intellij.images.fileTypes.ImageFileTypeManager;
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class ImageLookupInfoProvider extends FileLookupInfoProvider {
|
||||
|
||||
public Pair<String, String> getLookupInfo(@NotNull VirtualFile file, Project project) {
|
||||
public Couple<String> getLookupInfo(@NotNull VirtualFile file, Project project) {
|
||||
final String[] s = new String[] {null};
|
||||
ImageInfoIndex.processValues(file, new FileBasedIndex.ValueProcessor<ImageInfoIndex.ImageInfo>() {
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
@@ -40,7 +40,7 @@ public class ImageLookupInfoProvider extends FileLookupInfoProvider {
|
||||
}
|
||||
}, project);
|
||||
|
||||
return s[0] == null ? null : new Pair<String, String>(file.getName(), s[0]);
|
||||
return s[0] == null ? null : Couple.newOne(file.getName(), s[0]);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -77,7 +77,11 @@ public class JavaSuppressionUtil {
|
||||
if (modifierList == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final PsiModifierListOwner owner = (PsiModifierListOwner)modifierList.getParent();
|
||||
final PsiElement parent = modifierList.getParent();
|
||||
if (!(parent instanceof PsiModifierListOwner)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final PsiModifierListOwner owner = (PsiModifierListOwner)parent;
|
||||
PsiAnnotation annotation = AnnotationUtil.findAnnotation(owner, SUPPRESS_INSPECTIONS_ANNOTATION_NAME);
|
||||
if (annotation == null) {
|
||||
return Collections.emptyList();
|
||||
|
||||
+1
@@ -245,6 +245,7 @@ public class LocalCanBeFinal extends BaseJavaBatchLocalInspectionTool {
|
||||
final PsiVariable variable = iterator.next();
|
||||
if (shouldBeIgnored(variable)) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
final PsiElement parent = variable.getParent();
|
||||
if (!(parent instanceof PsiDeclarationStatement)) {
|
||||
|
||||
@@ -1135,7 +1135,7 @@ public class ExpectedTypesProvider {
|
||||
LOG.error("Vararg parameter with non-array type. Class=" + parameter.getClass() + "; type=" + parameter.getType());
|
||||
}
|
||||
}
|
||||
PsiType parameterType = GenericsUtil.getVariableTypeByExpressionType(substitutor.substitute(type));
|
||||
PsiType parameterType = substitutor.substitute(type);
|
||||
if (parameterType instanceof PsiCapturedWildcardType) {
|
||||
parameterType = ((PsiCapturedWildcardType)parameterType).getWildcard();
|
||||
}
|
||||
|
||||
+3
-1
@@ -120,7 +120,9 @@ public class BringVariableIntoScopeFix implements IntentionAction {
|
||||
}
|
||||
LOG.assertTrue(commonParent != null);
|
||||
PsiDeclarationStatement added = (PsiDeclarationStatement)commonParent.addBefore(newDeclaration, child);
|
||||
PsiLocalVariable addedVar = (PsiLocalVariable)added.getDeclaredElements()[0];
|
||||
final PsiElement[] declaredElements = added.getDeclaredElements();
|
||||
LOG.assertTrue(declaredElements.length > 0, added.getText());
|
||||
PsiLocalVariable addedVar = (PsiLocalVariable)declaredElements[0];
|
||||
CodeStyleManager.getInstance(manager.getProject()).reformat(commonParent);
|
||||
|
||||
//Leave initializer assignment
|
||||
|
||||
+60
-37
@@ -17,15 +17,14 @@ package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionInitializationContext;
|
||||
import com.intellij.codeInsight.completion.JavaCompletionContributor;
|
||||
import com.intellij.codeInsight.template.CustomTemplateCallback;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.openapi.editor.EditorModificationUtil;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -33,6 +32,7 @@ import java.util.Set;
|
||||
|
||||
|
||||
public class JavaPostfixTemplateProvider implements PostfixTemplateProvider {
|
||||
public static final Key<SmartPsiElementPointer<PsiElement>> ADDED_SEMICOLON = Key.create("postfix_added_semicolon");
|
||||
private final Set<PostfixTemplate> templates;
|
||||
|
||||
|
||||
@@ -76,54 +76,77 @@ public class JavaPostfixTemplateProvider implements PostfixTemplateProvider {
|
||||
return currentChar == '.' || currentChar == '!';
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElement preExpand(@NotNull Editor editor, @NotNull PsiElement context, int offset, @NotNull final String key) {
|
||||
|
||||
return addSemicolonIfNeeded(editor, editor.getDocument(), context, offset - key.length());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiFile preCheck(@NotNull Editor editor, @NotNull PsiFile copyFile, int currentOffset) {
|
||||
Document document = copyFile.getViewProvider().getDocument();
|
||||
assert document != null;
|
||||
CharSequence sequence = document.getCharsSequence();
|
||||
StringBuilder fileContentWithoutKey = new StringBuilder(sequence);
|
||||
if (isSemicolonNeeded(copyFile, editor)) {
|
||||
fileContentWithoutKey.insert(currentOffset, ';');
|
||||
copyFile = PostfixLiveTemplate.copyFile(copyFile, fileContentWithoutKey);
|
||||
}
|
||||
|
||||
return copyFile;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static PsiElement addSemicolonIfNeeded(@NotNull final Editor editor,
|
||||
@NotNull final Document document,
|
||||
@NotNull final PsiElement context,
|
||||
final int offset) {
|
||||
public void preExpand(@NotNull final PsiFile file, @NotNull final Editor editor) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
|
||||
final Ref<PsiElement> newContext = Ref.create(context);
|
||||
final PsiFile file = context.getContainingFile();
|
||||
file.putUserData(ADDED_SEMICOLON, null);
|
||||
if (isSemicolonNeeded(file, editor)) {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
|
||||
public void run() {
|
||||
document.insertString(offset, ";");
|
||||
PsiDocumentManager.getInstance(context.getProject()).commitDocument(document);
|
||||
newContext.set(CustomTemplateCallback.getContext(file, offset - 1));
|
||||
Document document = file.getViewProvider().getDocument();
|
||||
assert document != null;
|
||||
EditorModificationUtil.insertStringAtCaret(editor, ";", false, false);
|
||||
PsiDocumentManager.getInstance(file.getProject()).commitDocument(document);
|
||||
PsiElement at = file.findElementAt(editor.getCaretModel().getOffset());
|
||||
if (at != null && at.getNode().getElementType() == JavaTokenType.SEMICOLON) {
|
||||
file.putUserData(ADDED_SEMICOLON, SmartPointerManager.getInstance(file.getProject()).createSmartPsiElementPointer(at));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return newContext.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterExpand(@NotNull final PsiFile file, @NotNull final Editor editor) {
|
||||
final SmartPsiElementPointer<PsiElement> pointer = file.getUserData(ADDED_SEMICOLON);
|
||||
if (pointer != null) {
|
||||
final PsiElement addedSemicolon = pointer.getElement();
|
||||
file.putUserData(ADDED_SEMICOLON, null);
|
||||
if (addedSemicolon != null && addedSemicolon.isValid()) {
|
||||
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
addedSemicolon.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiFile preCheck(final @NotNull PsiFile copyFile, final @NotNull Editor realEditor, final int currentOffset) {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() {
|
||||
@Override
|
||||
public PsiFile compute() {
|
||||
Document document = copyFile.getViewProvider().getDocument();
|
||||
assert document != null;
|
||||
CharSequence sequence = document.getCharsSequence();
|
||||
StringBuilder fileContentWithSemicolon = new StringBuilder(sequence);
|
||||
if (isSemicolonNeeded(copyFile, realEditor)) {
|
||||
fileContentWithSemicolon.insert(currentOffset, ';');
|
||||
return PostfixLiveTemplate.copyFile(copyFile, fileContentWithSemicolon);
|
||||
}
|
||||
|
||||
return copyFile;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void doNotDeleteSemicolon(@NotNull PsiFile file) {
|
||||
file.putUserData(ADDED_SEMICOLON, null);
|
||||
}
|
||||
|
||||
private static boolean isSemicolonNeeded(@NotNull PsiFile file, @NotNull Editor editor) {
|
||||
return JavaCompletionContributor.semicolonNeeded(editor, file, CompletionInitializationContext.calcStartOffset(editor));
|
||||
}
|
||||
|
||||
+2
-7
@@ -17,7 +17,7 @@ package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ReturnStatementPostfixTemplate extends NonVoidPostfixTemplate {
|
||||
@@ -27,11 +27,6 @@ public class ReturnStatementPostfixTemplate extends NonVoidPostfixTemplate {
|
||||
|
||||
@Override
|
||||
public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
|
||||
PsiExpression expr = PostfixTemplatesUtils.getTopmostExpression(context);
|
||||
PsiElement parent = expr != null ? expr.getParent() : null;
|
||||
if (!(parent instanceof PsiExpressionStatement)) return;
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(expr.getProject()).getElementFactory();
|
||||
PsiReturnStatement returnStatement = (PsiReturnStatement)factory.createStatementFromText("return " + expr.getText() + ";", parent);
|
||||
parent.replace(returnStatement);
|
||||
PostfixTemplatesUtils.createSimpleStatement(context, editor, "return");
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -17,6 +17,7 @@ package com.intellij.codeInsight.template.postfix.util;
|
||||
|
||||
import com.intellij.codeInsight.generation.surroundWith.JavaExpressionSurrounder;
|
||||
import com.intellij.codeInsight.generation.surroundWith.JavaWithIfExpressionSurrounder;
|
||||
import com.intellij.codeInsight.template.postfix.templates.JavaPostfixTemplateProvider;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -52,6 +53,7 @@ public abstract class PostfixTemplatesUtils {
|
||||
PsiStatement statement = factory.createStatementFromText(prefix + expr.getText() + suffix + ";", parent);
|
||||
PsiElement replace = parent.replace(statement);
|
||||
editor.getCaretModel().moveToOffset(replace.getTextRange().getEndOffset() + offset);
|
||||
JavaPostfixTemplateProvider.doNotDeleteSemicolon(replace.getContainingFile());
|
||||
}
|
||||
|
||||
@Contract("null -> false")
|
||||
|
||||
+2
-1
@@ -85,7 +85,8 @@ public class UnusedParametersInspection extends GlobalJavaBatchInspectionTool {
|
||||
|
||||
final List<ProblemDescriptor> result = new ArrayList<ProblemDescriptor>();
|
||||
for (RefParameter refParameter : unusedParameters) {
|
||||
final PsiIdentifier psiIdentifier = refParameter.getElement().getNameIdentifier();
|
||||
final PsiParameter parameter = refParameter.getElement();
|
||||
final PsiIdentifier psiIdentifier = parameter != null ? parameter.getNameIdentifier() : null;
|
||||
if (psiIdentifier != null) {
|
||||
result.add(manager.createProblemDescriptor(psiIdentifier,
|
||||
refMethod.isAbstract()
|
||||
|
||||
@@ -130,6 +130,9 @@ public class SpecialAnnotationsUtil {
|
||||
InspectionsBundle.message("special.annotations.list.annotation.pattern"), "Remove");
|
||||
}
|
||||
|
||||
if (borderTitle == null) {
|
||||
return toolbarDecorator.createPanel();
|
||||
}
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(SeparatorFactory.createSeparator(borderTitle, null), BorderLayout.NORTH);
|
||||
panel.add(toolbarDecorator.createPanel(), BorderLayout.CENTER);
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -21,8 +21,8 @@ import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.util.EmptyQuery;
|
||||
import com.intellij.util.Query;
|
||||
import com.intellij.util.QueryExecutor;
|
||||
|
||||
@@ -112,4 +112,9 @@ public interface PsiSubstitutor {
|
||||
* @see PsiType#isValid()
|
||||
*/
|
||||
boolean isValid();
|
||||
|
||||
/**
|
||||
* If this substitutor is not valid, throws an exception with some diagnostics
|
||||
*/
|
||||
void ensureValid();
|
||||
}
|
||||
|
||||
@@ -164,6 +164,11 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
|
||||
final PsiJavaCodeReferenceElement classOrAnonymousClassReference = newExpression.getClassOrAnonymousClassReference();
|
||||
LOG.assertTrue(classOrAnonymousClassReference != null);
|
||||
final DiamondInferenceResult result = new DiamondInferenceResult(classOrAnonymousClassReference.getReferenceName() + "<>");
|
||||
|
||||
if (PsiUtil.isRawSubstitutor(staticFactory, inferredSubstitutor)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
for (PsiTypeParameter parameter : parameters) {
|
||||
for (PsiTypeParameter classParameter : classParameters) {
|
||||
if (Comparing.strEqual(classParameter.getName(), parameter.getName())) {
|
||||
|
||||
@@ -75,4 +75,6 @@ public final class EmptySubstitutorImpl extends EmptySubstitutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ensureValid() { }
|
||||
}
|
||||
|
||||
@@ -481,8 +481,8 @@ public class PsiImplUtil {
|
||||
}
|
||||
|
||||
public static PsiType normalizeWildcardTypeByPosition(@NotNull PsiType type, @NotNull PsiExpression expression) {
|
||||
LOG.assertTrue(expression.isValid());
|
||||
LOG.assertTrue(type.isValid());
|
||||
PsiUtilCore.ensureValid(expression);
|
||||
PsiUtil.ensureValidType(type);
|
||||
|
||||
PsiExpression toplevel = expression;
|
||||
while (toplevel.getParent() instanceof PsiArrayAccessExpression &&
|
||||
|
||||
@@ -533,13 +533,21 @@ public class PsiSubstitutorImpl implements PsiSubstitutor {
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
Collection<PsiType> substitutorValues = mySubstitutionMap.values();
|
||||
for (PsiType type : substitutorValues) {
|
||||
for (PsiType type : mySubstitutionMap.values()) {
|
||||
if (type != null && !type.isValid()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ensureValid() {
|
||||
for (PsiType type : mySubstitutionMap.values()) {
|
||||
if (type != null) {
|
||||
PsiUtil.ensureValidType(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Map<PsiTypeParameter, PsiType> getSubstitutionMap() {
|
||||
|
||||
@@ -169,7 +169,7 @@ public class PsiImmediateClassType extends PsiClassType.Stub {
|
||||
private enum TextType { PRESENTABLE, CANONICAL, INT_CANONICAL }
|
||||
|
||||
private String getText(@NotNull TextType textType, boolean annotated) {
|
||||
assert mySubstitutor.isValid();
|
||||
mySubstitutor.ensureValid();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buildText(myClass, mySubstitutor, buffer, textType, annotated);
|
||||
return buffer.toString();
|
||||
|
||||
+2
-1
@@ -376,10 +376,11 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
|
||||
PsiFile containingFile = SharedImplUtil.getContainingFile(fileElement);
|
||||
boolean valid = containingFile != null && containingFile.isValid();
|
||||
if (!valid) {
|
||||
PsiUtilCore.ensureValid(this);
|
||||
LOG.error("invalid!");
|
||||
return JavaResolveResult.EMPTY_ARRAY;
|
||||
}
|
||||
Project project = manager.getProject();
|
||||
Project project = getProject();
|
||||
|
||||
return multiResolve(incompleteCode, containingFile, project);
|
||||
}
|
||||
|
||||
+8
-10
@@ -192,21 +192,19 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
|
||||
List<ConstraintFormula> constraints,
|
||||
PsiSubstitutor substitutor,
|
||||
PsiParameter[] targetParameters) {
|
||||
final PsiTypeElement qualifierTypeElement = myExpression.getQualifierType();
|
||||
final PsiExpression qualifierExpression = myExpression.getQualifierExpression();
|
||||
PsiType qualifierType;
|
||||
if (qualifierTypeElement != null) {
|
||||
qualifierType = qualifierTypeElement.getType();
|
||||
final PsiElement qualifier = myExpression.getQualifier();
|
||||
PsiType qualifierType = null;
|
||||
if (qualifier instanceof PsiTypeElement) {
|
||||
qualifierType = ((PsiTypeElement)qualifier).getType();
|
||||
final PsiClass qualifierClass = PsiUtil.resolveClassInType(qualifierType);
|
||||
if (qualifierClass != null) {
|
||||
qualifierType = JavaPsiFacade.getElementFactory(myExpression.getProject()).createType(qualifierClass, PsiSubstitutor.EMPTY);
|
||||
}
|
||||
}
|
||||
else {
|
||||
LOG.assertTrue(qualifierExpression != null);
|
||||
qualifierType = qualifierExpression.getType();
|
||||
if (qualifierType == null && qualifierExpression instanceof PsiReferenceExpression) {
|
||||
final JavaResolveResult resolveResult = ((PsiReferenceExpression)qualifierExpression).advancedResolve(false);
|
||||
else if (qualifier instanceof PsiExpression) {
|
||||
qualifierType = ((PsiExpression)qualifier).getType();
|
||||
if (qualifierType == null && qualifier instanceof PsiReferenceExpression) {
|
||||
final JavaResolveResult resolveResult = ((PsiReferenceExpression)qualifier).advancedResolve(false);
|
||||
final PsiElement res = resolveResult.getElement();
|
||||
if (res instanceof PsiClass) {
|
||||
PsiClass containingClass = (PsiClass)res;
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import java.util.*;
|
||||
|
||||
class Sample {
|
||||
public static List getList() {return null;}
|
||||
List<Integer> list = new ArrayList<>(getList());
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Test {
|
||||
|
||||
interface I<T> { void m(T arg); }
|
||||
|
||||
<T1> void foo(T1 arg, java.io.Serializable x) {}
|
||||
<T2> void foo(I<T2> arg, Cloneable x) {}
|
||||
|
||||
void test(int[] array) {
|
||||
this.<String>foo<error descr="Cannot resolve method 'foo(<lambda expression>, int[])'">(p -> {}, array)</error>;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
public class Foo {
|
||||
void m(Object o) {
|
||||
"test".cast<caret>.length()
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
public class Foo {
|
||||
void m(Object o) {
|
||||
(() "test")<caret>.length()
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
public class Foo {
|
||||
void m() {
|
||||
int[] xs = {1, 2, 3};
|
||||
xs.for<caret>
|
||||
xs = new int[0];
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class Foo {
|
||||
void m() {
|
||||
int[] xs = {1, 2, 3};
|
||||
for (int x : xs) {
|
||||
<caret>
|
||||
}
|
||||
xs = new int[0];
|
||||
}
|
||||
}
|
||||
+1
@@ -101,6 +101,7 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testMultipleConstructors() { doTest(false, false); }
|
||||
public void testHighlightInaccessibleFromClassModifierList() { doTest(false, false); }
|
||||
public void testInnerInTypeArguments() { doTest(false, false); }
|
||||
public void testRawSubstitutor() { doTest(false, false); }
|
||||
|
||||
public void testIncompleteDiamonds() throws Exception {
|
||||
doTest(false, false);
|
||||
|
||||
+4
@@ -103,6 +103,10 @@ public class MostSpecificResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
public void testJDK8042508() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
+2
-2
@@ -178,7 +178,7 @@ public class TemplatesCompletionTest extends CompletionAutoPopupTestCase {
|
||||
type("r");
|
||||
myFixture.assertPreferredCompletionItems(selectedIndex, ".par", "parents");
|
||||
}
|
||||
|
||||
|
||||
public void testTabCompletionWithTemplatesInAutopopup() {
|
||||
LiveTemplateCompletionContributor.ourShowTemplatesInTests = true;
|
||||
|
||||
@@ -196,7 +196,7 @@ public class TemplatesCompletionTest extends CompletionAutoPopupTestCase {
|
||||
type(".if\t");
|
||||
checkResultByFile();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/template/postfix/completion";
|
||||
|
||||
+57
-11
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -5,17 +20,48 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class AssertStatementPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "assert"; }
|
||||
protected String getSuffix() {
|
||||
return "assert";
|
||||
}
|
||||
|
||||
public void testBooleanVariableBeforeAssignment() { doTest(); }
|
||||
public void testBoxedBooleanVariable() { doTest(); }
|
||||
public void testNotBooleanExpression() { doTest(); }
|
||||
public void testUnresolvedVariable() { doTest(); }
|
||||
public void testSeveralConditions() { doTest(); }
|
||||
public void testIntegerComparison() { doTest(); }
|
||||
public void testMethodInvocation() { doTest(); }
|
||||
public void testInstanceof() { doTest(); }
|
||||
public void testInstanceofBeforeReturnStatement() { doTest(); }
|
||||
public void testNotNull() { doTest(); }
|
||||
public void testBooleanVariableBeforeAssignment() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBoxedBooleanVariable() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNotBooleanExpression() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testUnresolvedVariable() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSeveralConditions() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIntegerComparison() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testMethodInvocation() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInstanceof() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInstanceofBeforeReturnStatement() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNotNull() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+22
-5
@@ -20,10 +20,27 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class CastPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "cast"; }
|
||||
protected String getSuffix() {
|
||||
return "cast";
|
||||
}
|
||||
|
||||
public void testSingleExpression() { doTest(); } // jdk mock needed
|
||||
public void testVoidExpression() { doTest(); }
|
||||
public void testSingleArgument() { doTest(); }
|
||||
public void testInsideString() { doTest(); }
|
||||
public void testSingleExpression() {
|
||||
doTest();
|
||||
} // jdk mock needed
|
||||
|
||||
public void testVoidExpression() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSingleArgument() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInsideString() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testChainCall() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
+52
-10
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -5,16 +20,43 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class ElseStatementPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "else"; }
|
||||
protected String getSuffix() {
|
||||
return "else";
|
||||
}
|
||||
|
||||
public void testBooleanVariable() { doTest(); }
|
||||
public void testBoxedBooleanVariable() { doTest(); }
|
||||
public void testBitOperations() { doTest(); }
|
||||
public void testBitOperationsWithMethod() { doTest(); }
|
||||
public void testUnresolvedVariable() { doTest(); }
|
||||
public void testInstanceof() { doTest(); }
|
||||
public void testIntegerComparison() { doTest(); }
|
||||
public void testLogicalOperations() { doTest(); }
|
||||
public void testBooleanVariable() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNotNull() { doTest(); }
|
||||
public void testBoxedBooleanVariable() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBitOperations() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBitOperationsWithMethod() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testUnresolvedVariable() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInstanceof() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIntegerComparison() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testLogicalOperations() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNotNull() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
+25
-3
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -6,10 +21,17 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author ignatov
|
||||
*/
|
||||
public class FieldPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
public void testSimple() { doTest(); }
|
||||
public void testFoo() { doTest(); }
|
||||
public void testSimple() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testFoo() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "field"; }
|
||||
protected String getSuffix() {
|
||||
return "field";
|
||||
}
|
||||
}
|
||||
|
||||
+45
-8
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -5,13 +20,35 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class ForAscendingPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "fori"; }
|
||||
protected String getSuffix() {
|
||||
return "fori";
|
||||
}
|
||||
|
||||
public void testIntArray() { doTest(); }
|
||||
public void testIntNumber() { doTest(); }
|
||||
public void testByteNumber() { doTest(); }
|
||||
public void testBoxedByteNumber() { doTest(); }
|
||||
public void testCollection() { doTest(); }
|
||||
public void testBoxedIntegerArray() { doTest(); }
|
||||
public void testBoxedLongArray() { doTest(); }
|
||||
public void testIntArray() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIntNumber() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testByteNumber() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBoxedByteNumber() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testCollection() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBoxedIntegerArray() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBoxedLongArray() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
+33
-5
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -5,10 +20,23 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class ForDescendingPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "forr"; }
|
||||
protected String getSuffix() {
|
||||
return "forr";
|
||||
}
|
||||
|
||||
public void testIntArray() { doTest(); }
|
||||
public void testByteNumber() { doTest(); }
|
||||
public void testBoxedIntegerArray() { doTest(); }
|
||||
public void testBoxedLongArray() { doTest(); }
|
||||
public void testIntArray() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testByteNumber() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBoxedIntegerArray() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBoxedLongArray() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
+25
-2
@@ -1,11 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ForeachTemplateTest extends PostfixTemplateTestCase {
|
||||
public void testInts() { doTest(); }
|
||||
public void testInts() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBeforeAssignment() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "for"; }
|
||||
protected String getSuffix() {
|
||||
return "for";
|
||||
}
|
||||
}
|
||||
|
||||
+10
-3
@@ -20,8 +20,15 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class FormatPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "format"; }
|
||||
protected String getSuffix() {
|
||||
return "format";
|
||||
}
|
||||
|
||||
public void testString() { doTest(); }
|
||||
public void testNotString() { doTest(); }
|
||||
public void testString() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNotString() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
+38
-10
@@ -18,17 +18,45 @@ package com.intellij.codeInsight.template.postfix.templates;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IfStatementPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
public void testBooleanVariableBeforeAssignment() { doTest(); }
|
||||
public void testBoxedBooleanVariable() { doTest(); }
|
||||
public void testNotBooleanExpression() { doTest(); }
|
||||
public void testUnresolvedVariable() { doTest(); }
|
||||
public void testSeveralConditions() { doTest(); }
|
||||
public void testIntegerComparison() { doTest(); }
|
||||
public void testMethodInvocation() { doTest(); }
|
||||
public void testInstanceof() { doTest(); }
|
||||
public void testInstanceofBeforeReturnStatement() { doTest(); }
|
||||
public void testBooleanVariableBeforeAssignment() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBoxedBooleanVariable() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNotBooleanExpression() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testUnresolvedVariable() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSeveralConditions() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIntegerComparison() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testMethodInvocation() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInstanceof() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInstanceofBeforeReturnStatement() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "if"; }
|
||||
protected String getSuffix() {
|
||||
return "if";
|
||||
}
|
||||
}
|
||||
|
||||
+15
-5
@@ -20,13 +20,21 @@ import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class InstanceofPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
public void testSingleExpression() { doTest(); }
|
||||
public void testAlias() { doTest(); }
|
||||
public void testPrimitive() { doTest(); }
|
||||
public void testSingleExpression() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAlias() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPrimitive() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSingleExpressionTemplate() {
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
|
||||
|
||||
|
||||
myFixture.configureByFile(getTestName(true) + ".java");
|
||||
myFixture.type('\t');
|
||||
|
||||
@@ -43,5 +51,7 @@ public class InstanceofPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "instanceof"; }
|
||||
protected String getSuffix() {
|
||||
return "instanceof";
|
||||
}
|
||||
}
|
||||
|
||||
+34
-6
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -8,11 +23,24 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class NotExpressionPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "not"; }
|
||||
protected String getSuffix() {
|
||||
return "not";
|
||||
}
|
||||
|
||||
public void testSimple() { doTest(); }
|
||||
public void testComplexCondition() { doTest(); }
|
||||
public void testBoxedBoolean() { doTest(); }
|
||||
public void testExclamation() { doTest(); }
|
||||
// public void testNegation() { doTest(); } // todo: test for chooser
|
||||
public void testSimple() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testComplexCondition() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBoxedBoolean() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testExclamation() {
|
||||
doTest();
|
||||
}
|
||||
// public void testNegation() { doTest(); } // todo: test for chooser
|
||||
}
|
||||
+22
-6
@@ -20,11 +20,27 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class NotNullPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "notnull"; }
|
||||
protected String getSuffix() {
|
||||
return "notnull";
|
||||
}
|
||||
|
||||
public void testSimple() { doTest(); }
|
||||
public void testPrimitive() { doTest(); }
|
||||
public void testNn() { doTest(); }
|
||||
public void testSecondStatement() { doTest(); }
|
||||
public void testElseStatement() { doTest(); }
|
||||
public void testSimple() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPrimitive() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNn() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSecondStatement() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testElseStatement() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
+14
-4
@@ -23,9 +23,19 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class NullPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "null"; }
|
||||
protected String getSuffix() {
|
||||
return "null";
|
||||
}
|
||||
|
||||
public void testSimple() { doTest(); }
|
||||
public void testPrimitive() { doTest(); }
|
||||
public void testSecondStatement() { doTest(); }
|
||||
public void testSimple() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPrimitive() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSecondStatement() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
+25
-3
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -8,8 +23,15 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class ParPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "par"; }
|
||||
protected String getSuffix() {
|
||||
return "par";
|
||||
}
|
||||
|
||||
public void testSimple() { doTest(); }
|
||||
public void testExtra() { doTest(); }
|
||||
public void testSimple() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testExtra() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
+29
-4
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -8,9 +23,19 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class ReturnPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "return"; }
|
||||
protected String getSuffix() {
|
||||
return "return";
|
||||
}
|
||||
|
||||
public void testSimple() { doTest(); }
|
||||
public void testComposite() { doTest(); }
|
||||
public void testComposite2() { doTest(); }
|
||||
public void testSimple() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testComposite() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testComposite2() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
+10
-3
@@ -20,8 +20,15 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class SoutPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "sout"; }
|
||||
protected String getSuffix() {
|
||||
return "sout";
|
||||
}
|
||||
|
||||
public void testSimple() { doTest(); }
|
||||
public void testVoid() { doTest(); }
|
||||
public void testSimple() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testVoid() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
+45
-8
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -8,13 +23,35 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class SwitchPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "switch"; }
|
||||
protected String getSuffix() {
|
||||
return "switch";
|
||||
}
|
||||
|
||||
public void testInt() { doTest(); }
|
||||
public void testByte() { doTest(); }
|
||||
public void testChar() { doTest(); }
|
||||
public void testShort() { doTest(); }
|
||||
public void testEnum() { doTest(); }
|
||||
public void testString() { doTest(); }
|
||||
public void testComposite() { doTest(); }
|
||||
public void testInt() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testByte() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testChar() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testShort() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testEnum() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testString() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testComposite() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
+21
-2
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -8,7 +23,11 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class SynchronizedPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "synchronized"; }
|
||||
protected String getSuffix() {
|
||||
return "synchronized";
|
||||
}
|
||||
|
||||
public void testObject() { doTest(); }
|
||||
public void testObject() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
+21
-2
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -5,7 +20,11 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class ThrowStatementPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "throw"; }
|
||||
protected String getSuffix() {
|
||||
return "throw";
|
||||
}
|
||||
|
||||
public void testSimple() { doTest(); }
|
||||
public void testSimple() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
+15
-4
@@ -24,8 +24,19 @@ public class TryPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
return "try";
|
||||
}
|
||||
|
||||
public void testSimple() { doTest(); }
|
||||
public void testStatement() { doTest(); }
|
||||
public void testMultiStatement() { doTest(); }
|
||||
public void testNotStatement() { doTest(); }
|
||||
public void testSimple() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testStatement() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testMultiStatement() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNotStatement() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
+15
-4
@@ -32,8 +32,19 @@ public class TryWithResourcesPostfixTemplateTest extends PostfixTemplateTestCase
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
|
||||
}
|
||||
|
||||
public void testSimple() { doTest(); }
|
||||
public void testSimpleWithMyException() { doTest(); }
|
||||
public void testSimpleWithConflict() { doTest(); }
|
||||
public void testSimpleNotAutoCloseable() { doTest(); }
|
||||
public void testSimple() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSimpleWithMyException() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSimpleWithConflict() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSimpleNotAutoCloseable() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
+25
-3
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -8,8 +23,15 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class VarPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "var"; }
|
||||
protected String getSuffix() {
|
||||
return "var";
|
||||
}
|
||||
|
||||
public void testSimple() { doTest(); }
|
||||
public void testAdd() { doTest(); }
|
||||
public void testSimple() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAdd() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
+33
-5
@@ -1,14 +1,42 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class WhileStatementPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
public void testBooleanVariable() { doTest(); }
|
||||
public void testBoxedBooleanVariable() { doTest(); }
|
||||
public void testStringVariable() { doTest(); }
|
||||
public void testUnresolvedVariable() { doTest(); }
|
||||
public void testBooleanVariable() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBoxedBooleanVariable() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testStringVariable() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testUnresolvedVariable() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() { return "while"; }
|
||||
protected String getSuffix() {
|
||||
return "while";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2079,18 +2079,23 @@ public class Mappings {
|
||||
final TIntHashSet old = myClassToSubclasses.get(superClass);
|
||||
|
||||
if (old == null) {
|
||||
myClassToSubclasses.replace(superClass, added);
|
||||
if (added != null && !added.isEmpty()) {
|
||||
myClassToSubclasses.replace(superClass, added);
|
||||
}
|
||||
}
|
||||
else {
|
||||
boolean changed = false;
|
||||
if (removed != null) {
|
||||
old.removeAll(removed.toArray());
|
||||
changed |= old.removeAll(removed.toArray());
|
||||
}
|
||||
|
||||
if (added != null) {
|
||||
old.addAll(added.toArray());
|
||||
changed |= old.addAll(added.toArray());
|
||||
}
|
||||
|
||||
myClassToSubclasses.replace(superClass, old);
|
||||
if (changed) {
|
||||
myClassToSubclasses.replace(superClass, old);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -20,7 +20,7 @@ import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.editor.colors.CodeInsightColors;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -40,7 +40,7 @@ public class ProblemDescriptorUtil {
|
||||
@interface FlagConstant {
|
||||
}
|
||||
|
||||
public static Pair<String, String> XML_CODE_MARKER = Pair.create("<xml-code>", "</xml-code>");
|
||||
public static Couple<String> XML_CODE_MARKER = Couple.newOne("<xml-code>", "</xml-code>");
|
||||
|
||||
public static String extractHighlightedText(@NotNull CommonProblemDescriptor descriptor, PsiElement psiElement) {
|
||||
if (psiElement == null || !psiElement.isValid()) return "";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -23,8 +23,8 @@ import com.intellij.lang.LanguageCommenters;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.NullableComputable;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiComment;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -116,13 +116,13 @@ public class SuppressionUtil extends SuppressionUtilCore {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Pair<String, String> getBlockPrefixSuffixPair(PsiElement comment) {
|
||||
public static Couple<String> getBlockPrefixSuffixPair(PsiElement comment) {
|
||||
final Commenter commenter = LanguageCommenters.INSTANCE.forLanguage(comment.getLanguage());
|
||||
if (commenter != null) {
|
||||
final String prefix = commenter.getBlockCommentPrefix();
|
||||
final String suffix = commenter.getBlockCommentSuffix();
|
||||
if (prefix != null || suffix != null) {
|
||||
return Pair.create(StringUtil.notNullize(prefix), StringUtil.notNullize(suffix));
|
||||
return Couple.newOne(StringUtil.notNullize(prefix), StringUtil.notNullize(suffix));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -140,7 +140,7 @@ public class SuppressionUtil extends SuppressionUtilCore {
|
||||
if (prefix != null) {
|
||||
return commentText.startsWith(prefix + SUPPRESS_INSPECTIONS_TAG_NAME);
|
||||
}
|
||||
final Pair<String, String> prefixSuffixPair = getBlockPrefixSuffixPair(comment);
|
||||
final Couple<String> prefixSuffixPair = getBlockPrefixSuffixPair(comment);
|
||||
return prefixSuffixPair != null
|
||||
&& commentText.startsWith(prefixSuffixPair.first + SUPPRESS_INSPECTIONS_TAG_NAME)
|
||||
&& commentText.endsWith(prefixSuffixPair.second);
|
||||
@@ -150,7 +150,7 @@ public class SuppressionUtil extends SuppressionUtilCore {
|
||||
boolean replaceOtherSuppressionIds, @NotNull Language commentLanguage) {
|
||||
final String oldSuppressionCommentText = comment.getText();
|
||||
final String lineCommentPrefix = getLineCommentPrefix(comment);
|
||||
Pair<String, String> blockPrefixSuffix = null;
|
||||
Couple<String> blockPrefixSuffix = null;
|
||||
if (lineCommentPrefix == null) {
|
||||
blockPrefixSuffix = getBlockPrefixSuffixPair(comment);
|
||||
}
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.FileASTNode;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.UserDataHolder;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
@@ -60,13 +62,21 @@ public class PsiInvalidElementAccessException extends RuntimeException {
|
||||
(message == null ? "" : "; " + message);
|
||||
}
|
||||
|
||||
public static Object findInvalidationTrace(ASTNode element) {
|
||||
public static Object findInvalidationTrace(@Nullable ASTNode element) {
|
||||
while (element != null) {
|
||||
Object trace = element.getUserData(INVALIDATION_TRACE);
|
||||
if (trace != null) {
|
||||
return trace;
|
||||
}
|
||||
element = element.getTreeParent();
|
||||
ASTNode parent = element.getTreeParent();
|
||||
if (parent == null && element instanceof FileASTNode) {
|
||||
PsiElement psi = element.getPsi();
|
||||
trace = psi == null ? null : psi.getUserData(INVALIDATION_TRACE);
|
||||
if (trace != null) {
|
||||
return trace;
|
||||
}
|
||||
}
|
||||
element = parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -112,7 +122,7 @@ public class PsiInvalidElementAccessException extends RuntimeException {
|
||||
return "psi is outdated";
|
||||
}
|
||||
|
||||
public static void setInvalidationTrace(ASTNode element, Object trace) {
|
||||
public static void setInvalidationTrace(UserDataHolder element, Object trace) {
|
||||
element.putUserData(INVALIDATION_TRACE, trace);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
|
||||
private boolean myComponentsCreated = false;
|
||||
|
||||
private MutablePicoContainer myPicoContainer;
|
||||
private volatile MutablePicoContainer myPicoContainer;
|
||||
private volatile boolean myDisposed = false;
|
||||
private volatile boolean myDisposeCompleted = false;
|
||||
|
||||
|
||||
@@ -25,10 +25,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiInvalidElementAccessException;
|
||||
import com.intellij.psi.PsiWhiteSpace;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.tree.CompositeElement;
|
||||
import com.intellij.psi.impl.source.tree.SharedImplUtil;
|
||||
@@ -559,11 +556,26 @@ public class DebugUtil {
|
||||
}
|
||||
|
||||
public static void onInvalidated(@NotNull ASTNode treeElement) {
|
||||
Object trace = calcInvalidationTrace(treeElement);
|
||||
if (trace != null) {
|
||||
PsiInvalidElementAccessException.setInvalidationTrace(treeElement, trace);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onInvalidated(@NotNull FileViewProvider provider) {
|
||||
Object trace = calcInvalidationTrace(null);
|
||||
if (trace != null) {
|
||||
PsiInvalidElementAccessException.setInvalidationTrace(provider, trace);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Object calcInvalidationTrace(@Nullable ASTNode treeElement) {
|
||||
if (!PsiInvalidElementAccessException.isTrackingInvalidation()) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
if (PsiInvalidElementAccessException.findInvalidationTrace(treeElement) != null) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
Object trace = ourPsiModificationTrace.get();
|
||||
@@ -571,7 +583,7 @@ public class DebugUtil {
|
||||
trace = new Throwable();
|
||||
LOG.info("PSI invalidated outside transaction", (Throwable)trace);
|
||||
}
|
||||
PsiInvalidElementAccessException.setInvalidationTrace(treeElement, trace);
|
||||
return trace;
|
||||
}
|
||||
|
||||
public static void revalidateNode(@NotNull ASTNode element) {
|
||||
|
||||
@@ -44,7 +44,7 @@ public interface FileManager extends Disposable {
|
||||
|
||||
FileViewProvider findViewProvider(@NotNull VirtualFile file);
|
||||
FileViewProvider findCachedViewProvider(@NotNull VirtualFile file);
|
||||
void setViewProvider(@NotNull VirtualFile virtualFile, FileViewProvider fileViewProvider);
|
||||
void setViewProvider(@NotNull VirtualFile virtualFile, @Nullable FileViewProvider fileViewProvider);
|
||||
|
||||
@NotNull
|
||||
List<PsiFile> getAllCachedFiles();
|
||||
|
||||
@@ -36,10 +36,7 @@ import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileVisitor;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiDocumentManagerBase;
|
||||
import com.intellij.psi.impl.PsiFileEx;
|
||||
import com.intellij.psi.impl.PsiManagerImpl;
|
||||
import com.intellij.psi.impl.PsiTreeChangeEventImpl;
|
||||
import com.intellij.psi.impl.*;
|
||||
import com.intellij.psi.impl.file.PsiDirectoryFactory;
|
||||
import com.intellij.psi.impl.source.PsiFileImpl;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
@@ -197,7 +194,18 @@ public class FileManagerImpl implements FileManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViewProvider(@NotNull final VirtualFile virtualFile, final FileViewProvider fileViewProvider) {
|
||||
public void setViewProvider(@NotNull final VirtualFile virtualFile, @Nullable final FileViewProvider fileViewProvider) {
|
||||
FileViewProvider prev = findCachedViewProvider(virtualFile);
|
||||
if (prev != null) {
|
||||
DebugUtil.startPsiModification(null);
|
||||
try {
|
||||
DebugUtil.onInvalidated(prev);
|
||||
}
|
||||
finally {
|
||||
DebugUtil.finishPsiModification();
|
||||
}
|
||||
}
|
||||
|
||||
if (!(virtualFile instanceof VirtualFileWindow)) {
|
||||
if (fileViewProvider == null) {
|
||||
myVFileToViewProviderMap.remove(virtualFile);
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -59,7 +60,7 @@ public abstract class ReferenceProvidersRegistry {
|
||||
|
||||
public static PsiReference[] getReferencesFromProviders(PsiElement context, @NotNull PsiReferenceService.Hints hints) {
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
assert context.isValid() : "Invalid context: " + context;
|
||||
PsiUtilCore.ensureValid(context);
|
||||
|
||||
ReferenceProvidersRegistry registry = getInstance();
|
||||
return registry.doGetReferencesFromProviders(context, hints);
|
||||
|
||||
@@ -2,7 +2,6 @@ com.intellij.properties
|
||||
com.intellij.javaee
|
||||
GenerateToString
|
||||
StrutsAssistant
|
||||
com.intellij.testAssistant
|
||||
WebServicesPlugin
|
||||
Geronimo
|
||||
Coverage
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -31,8 +31,8 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileTypes.ContentBasedFileSubstitutor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
@@ -52,7 +52,7 @@ import java.util.*;
|
||||
public class FoldingUpdate {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.folding.impl.FoldingUpdate");
|
||||
|
||||
private static final Key<ParameterizedCachedValue<Runnable, Pair<Boolean,Boolean>>> CODE_FOLDING_KEY = Key.create("code folding");
|
||||
private static final Key<ParameterizedCachedValue<Runnable, Couple<Boolean>>> CODE_FOLDING_KEY = Key.create("code folding");
|
||||
private static final Key<String> CODE_FOLDING_FILE_EXTENSION_KEY = Key.create("code folding file extension");
|
||||
|
||||
private static final Comparator<PsiElement> COMPARE_BY_OFFSET = new Comparator<PsiElement>() {
|
||||
@@ -80,7 +80,7 @@ public class FoldingUpdate {
|
||||
currentFileExtension = virtualFile.getExtension();
|
||||
}
|
||||
|
||||
ParameterizedCachedValue<Runnable, Pair<Boolean,Boolean>> value = editor.getUserData(CODE_FOLDING_KEY);
|
||||
ParameterizedCachedValue<Runnable, Couple<Boolean>> value = editor.getUserData(CODE_FOLDING_KEY);
|
||||
if (value != null) {
|
||||
// There was a problem that old fold regions have been cached on file extension change (e.g. *.java -> *.groovy).
|
||||
// We want to drop them in such circumstances.
|
||||
@@ -96,14 +96,14 @@ public class FoldingUpdate {
|
||||
if (quick) return getUpdateResult(file, document, quick, project, editor, applyDefaultState).getValue();
|
||||
|
||||
return CachedValuesManager.getManager(project).getParameterizedCachedValue(
|
||||
editor, CODE_FOLDING_KEY, new ParameterizedCachedValueProvider<Runnable, Pair<Boolean, Boolean>>() {
|
||||
@Override
|
||||
public CachedValueProvider.Result<Runnable> compute(Pair<Boolean,Boolean> param) {
|
||||
Document document = editor.getDocument();
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
|
||||
return getUpdateResult(file, document, param.first, project, editor, param.second);
|
||||
}
|
||||
}, false, Pair.create(quick, applyDefaultState));
|
||||
editor, CODE_FOLDING_KEY, new ParameterizedCachedValueProvider<Runnable, Couple<Boolean>>() {
|
||||
@Override
|
||||
public CachedValueProvider.Result<Runnable> compute(Couple<Boolean> param) {
|
||||
Document document = editor.getDocument();
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
|
||||
return getUpdateResult(file, document, param.first, project, editor, param.second);
|
||||
}
|
||||
}, false, Couple.newOne(quick, applyDefaultState));
|
||||
}
|
||||
|
||||
private static CachedValueProvider.Result<Runnable> getUpdateResult(PsiFile file,
|
||||
|
||||
+6
-6
@@ -32,7 +32,7 @@ import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.impl.AbstractFileType;
|
||||
import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
@@ -625,7 +625,7 @@ public class CommentByBlockCommentHandler implements CodeInsightActionHandler {
|
||||
return new TextRange(delOffset1, delOffset2);
|
||||
}
|
||||
|
||||
private Pair<TextRange, TextRange> findCommentBlock(TextRange range, String commentPrefix, String commentSuffix) {
|
||||
private Couple<TextRange> findCommentBlock(TextRange range, String commentPrefix, String commentSuffix) {
|
||||
CharSequence chars = myDocument.getCharsSequence();
|
||||
int startOffset = range.getStartOffset();
|
||||
boolean endsProperly = CharArrayUtil.regionMatches(chars, range.getEndOffset() - commentSuffix.length(), commentSuffix);
|
||||
@@ -639,7 +639,7 @@ public class CommentByBlockCommentHandler implements CodeInsightActionHandler {
|
||||
end = new TextRange(range.getEndOffset(), range.getEndOffset());
|
||||
}
|
||||
|
||||
return new Pair<TextRange, TextRange>(start, end);
|
||||
return Couple.newOne(start, end);
|
||||
}
|
||||
|
||||
public void uncommentRange(TextRange range, String commentPrefix, String commentSuffix, Commenter commenter) {
|
||||
@@ -657,7 +657,7 @@ public class CommentByBlockCommentHandler implements CodeInsightActionHandler {
|
||||
String text = myDocument.getCharsSequence().subSequence(range.getStartOffset(), range.getEndOffset()).toString();
|
||||
int startOffset = range.getStartOffset();
|
||||
//boolean endsProperly = CharArrayUtil.regionMatches(chars, range.getEndOffset() - commentSuffix.length(), commentSuffix);
|
||||
List<Pair<TextRange, TextRange>> ranges = new ArrayList<Pair<TextRange, TextRange>>();
|
||||
List<Couple<TextRange>> ranges = new ArrayList<Couple<TextRange>>();
|
||||
|
||||
int position = 0;
|
||||
while (true) {
|
||||
@@ -668,13 +668,13 @@ public class CommentByBlockCommentHandler implements CodeInsightActionHandler {
|
||||
position = start;
|
||||
int end = getNearest(text, commentSuffix, position + commentPrefix.length()) + commentSuffix.length();
|
||||
position = end;
|
||||
Pair<TextRange, TextRange> pair =
|
||||
Couple<TextRange> pair =
|
||||
findCommentBlock(new TextRange(start + startOffset, end + startOffset), commentPrefix, commentSuffix);
|
||||
ranges.add(pair);
|
||||
}
|
||||
|
||||
for (int i = ranges.size() - 1; i >= 0; i--) {
|
||||
Pair<TextRange, TextRange> toDelete = ranges.get(i);
|
||||
Couple<TextRange> toDelete = ranges.get(i);
|
||||
myDocument.deleteString(toDelete.first.getStartOffset(), toDelete.first.getEndOffset());
|
||||
int shift = toDelete.first.getEndOffset() - toDelete.first.getStartOffset();
|
||||
myDocument.deleteString(toDelete.second.getStartOffset() - shift, toDelete.second.getEndOffset() - shift);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.codeInsight.template;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.PairProcessor;
|
||||
@@ -27,7 +28,7 @@ import java.util.Map;
|
||||
|
||||
public abstract class TemplateManager {
|
||||
public static TemplateManager getInstance(Project project) {
|
||||
return project.getComponent(TemplateManager.class);
|
||||
return ServiceManager.getService(project, TemplateManager.class);
|
||||
}
|
||||
|
||||
public abstract void startTemplate(@NotNull Editor editor, @NotNull Template template);
|
||||
|
||||
+22
-16
@@ -125,10 +125,15 @@ public class PostfixLiveTemplate extends CustomLiveTemplateBase {
|
||||
if (postfixTemplate != null) {
|
||||
final PsiFile file = callback.getContext().getContainingFile();
|
||||
if (isApplicableTemplate(provider, key, file, editor)) {
|
||||
int currentOffset = editor.getCaretModel().getOffset();
|
||||
PsiElement newContext = deleteTemplateKey(file, editor.getDocument(), currentOffset, key);
|
||||
newContext = provider.preExpand(editor, newContext, currentOffset, key);
|
||||
expandTemplate(postfixTemplate, editor, newContext);
|
||||
int offset = deleteTemplateKey(file, editor, key);
|
||||
try {
|
||||
provider.preExpand(file, editor);
|
||||
PsiElement context = CustomTemplateCallback.getContext(file, positiveOffset(offset));
|
||||
expandTemplate(postfixTemplate, editor, context);
|
||||
}
|
||||
finally {
|
||||
provider.afterExpand(file, editor);
|
||||
}
|
||||
}
|
||||
// don't care about errors in multiCaret mode
|
||||
else if (editor.getCaretModel().getAllCarets().size() == 1) {
|
||||
@@ -224,26 +229,25 @@ public class PostfixLiveTemplate extends CustomLiveTemplateBase {
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
private static PsiElement deleteTemplateKey(@NotNull final PsiFile file,
|
||||
@NotNull final Document document,
|
||||
final int currentOffset,
|
||||
@NotNull final String key) {
|
||||
private static int deleteTemplateKey(@NotNull final PsiFile file, @NotNull final Editor editor, @NotNull final String key) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
|
||||
final int startOffset = currentOffset - key.length();
|
||||
final int currentOffset = editor.getCaretModel().getOffset();
|
||||
final int newOffset = currentOffset - key.length();
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
|
||||
public void run() {
|
||||
document.deleteString(startOffset, currentOffset);
|
||||
Document document = editor.getDocument();
|
||||
document.deleteString(newOffset, currentOffset);
|
||||
editor.getCaretModel().moveToOffset(newOffset);
|
||||
PsiDocumentManager.getInstance(file.getProject()).commitDocument(document);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return CustomTemplateCallback.getContext(file, startOffset > 0 ? startOffset - 1 : startOffset);
|
||||
return newOffset;
|
||||
}
|
||||
|
||||
private static Condition<PostfixTemplate> createIsApplicationTemplateFunction(@NotNull PostfixTemplateProvider provider,
|
||||
@@ -263,14 +267,14 @@ public class PostfixLiveTemplate extends CustomLiveTemplateBase {
|
||||
return Condition.FALSE;
|
||||
}
|
||||
|
||||
copyFile = provider.preCheck(editor, copyFile, newOffset);
|
||||
copyFile = provider.preCheck(copyFile, editor, newOffset);
|
||||
copyDocument = copyFile.getViewProvider().getDocument();
|
||||
if (copyDocument == null) {
|
||||
//noinspection unchecked
|
||||
return Condition.FALSE;
|
||||
}
|
||||
|
||||
final PsiElement context = CustomTemplateCallback.getContext(copyFile, newOffset > 0 ? newOffset - 1 : newOffset);
|
||||
final PsiElement context = CustomTemplateCallback.getContext(copyFile, positiveOffset(newOffset));
|
||||
final Document finalCopyDocument = copyDocument;
|
||||
return new Condition<PostfixTemplate>() {
|
||||
@Override
|
||||
@@ -280,7 +284,6 @@ public class PostfixLiveTemplate extends CustomLiveTemplateBase {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static PsiFile copyFile(@NotNull PsiFile file, @NotNull StringBuilder fileContentWithoutKey) {
|
||||
final PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(file.getProject());
|
||||
@@ -299,7 +302,6 @@ public class PostfixLiveTemplate extends CustomLiveTemplateBase {
|
||||
return createIsApplicationTemplateFunction(provider, key, file, editor).value(getTemplate(provider, key));
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
private static Set<String> getKeys(@NotNull PostfixTemplateProvider provider) {
|
||||
Set<String> result = ContainerUtil.newHashSet();
|
||||
@@ -323,4 +325,8 @@ public class PostfixLiveTemplate extends CustomLiveTemplateBase {
|
||||
private static Language getLanguage(@NotNull CustomTemplateCallback callback) {
|
||||
return callback.getContext().getLanguage();
|
||||
}
|
||||
|
||||
private static int positiveOffset(int offset) {
|
||||
return offset > 0 ? offset - 1 : offset;
|
||||
}
|
||||
}
|
||||
|
||||
+25
-8
@@ -17,7 +17,6 @@ package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -37,16 +36,34 @@ public interface PostfixTemplateProvider {
|
||||
boolean isTerminalSymbol(char currentChar);
|
||||
|
||||
/**
|
||||
* Prepare original file content for template expanding
|
||||
* Return context after transformation
|
||||
* Prepare file for template expanding. Running on EDT.
|
||||
* E.g. java postfix templates adds semicolon after caret in order to simplify context checking.
|
||||
*
|
||||
* File content doesn't contain template's key, it is deleted just before this method invocation.
|
||||
*
|
||||
* Note that while postfix template is checking its availability the file parameter is a _COPY_ of the real file,
|
||||
* so you can do with it anything that you want, but in the same time it doesn't recommended to modify editor state because it's real.
|
||||
*/
|
||||
@NotNull
|
||||
PsiElement preExpand(@NotNull Editor editor, @NotNull PsiElement context, int offset, @NotNull String key);
|
||||
void preExpand(@NotNull PsiFile file, @NotNull Editor editor);
|
||||
|
||||
/**
|
||||
* Do some actions with the file content before check applicable.
|
||||
* Return copyFile or another copy of file after processing
|
||||
* Invoked after template finished (doesn't matter if it finished successfully or not).
|
||||
* E.g. java postfix template use this method for deleting inserted semicolon.
|
||||
*/
|
||||
void afterExpand(@NotNull PsiFile file, @NotNull Editor editor);
|
||||
|
||||
/**
|
||||
* Prepare file for checking availability of templates.
|
||||
* Almost the same as {@link this#preExpand(com.intellij.psi.PsiFile, com.intellij.openapi.editor.Editor)} with several differences:
|
||||
* 1. Processes copy of file. So implementations can modify it without corrupting the real file.
|
||||
* 2. Could be invoked from anywhere (EDT, write-action, read-action, completion-thread etc.). So implementations should make
|
||||
* additional effort to make changes in file.
|
||||
*
|
||||
* Content of file copy doesn't contain template's key, it is deleted just before this method invocation.
|
||||
*
|
||||
* NOTE: editor is real (not copy) and it doesn't represents the copyFile.
|
||||
* So it's safer to use currentOffset parameter instead of offset from editor. Do not modify text via editor.
|
||||
*/
|
||||
@NotNull
|
||||
PsiFile preCheck(@NotNull Editor editor, @NotNull PsiFile copyFile, int currentOffset);
|
||||
PsiFile preCheck(@NotNull PsiFile copyFile, @NotNull Editor realEditor, int currentOffset);
|
||||
}
|
||||
|
||||
@@ -709,7 +709,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
TokenInfo token = myTokens.get(i);
|
||||
final HyperlinkInfo info = token.getHyperlinkInfo();
|
||||
if (info != null) {
|
||||
myHyperlinks.addHyperlink(token.startOffset, token.endOffset, null, info);
|
||||
myHyperlinks.createHyperlink(token.startOffset, token.endOffset, null, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,33 +157,32 @@ class RunConfigurable extends BaseConfigurable {
|
||||
final DefaultMutableTreeNode parent = (DefaultMutableTreeNode)node.getParent();
|
||||
final Object userObject = node.getUserObject();
|
||||
Boolean shared = null;
|
||||
final String name = RunConfigurable.getName(userObject);
|
||||
if (userObject instanceof ConfigurationType) {
|
||||
final ConfigurationType configurationType = (ConfigurationType)userObject;
|
||||
append(configurationType.getDisplayName(), parent.isRoot() ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
append(name, parent.isRoot() ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
setIcon(configurationType.getIcon());
|
||||
}
|
||||
else if (userObject == DEFAULTS) {
|
||||
append("Defaults", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
|
||||
append(name, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
|
||||
setIcon(AllIcons.General.Settings);
|
||||
}
|
||||
else if (userObject instanceof String) {//Folders
|
||||
append((String)userObject, SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
append(name, SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
setIcon(AllIcons.Nodes.Folder);
|
||||
}
|
||||
else if (userObject instanceof ConfigurationFactory) {
|
||||
append(((ConfigurationFactory)userObject).getName());
|
||||
append(name);
|
||||
setIcon(((ConfigurationFactory)userObject).getIcon());
|
||||
}
|
||||
else {
|
||||
final RunManagerImpl runManager = getRunManager();
|
||||
RunnerAndConfigurationSettings configuration = null;
|
||||
String name = null;
|
||||
if (userObject instanceof SingleConfigurationConfigurable) {
|
||||
final SingleConfigurationConfigurable<?> settings = (SingleConfigurationConfigurable)userObject;
|
||||
RunnerAndConfigurationSettings configurationSettings;
|
||||
configurationSettings = settings.getSettings();
|
||||
configuration = configurationSettings;
|
||||
name = settings.getNameText();
|
||||
shared = settings.isStoreProjectConfiguration();
|
||||
setIcon(ProgramRunnerUtil.getConfigurationIcon(configurationSettings, !settings.isValid()));
|
||||
}
|
||||
@@ -192,7 +191,6 @@ class RunConfigurable extends BaseConfigurable {
|
||||
shared = runManager.isConfigurationShared(settings);
|
||||
setIcon(RunManagerEx.getInstanceEx(myProject).getConfigurationIcon(settings));
|
||||
configuration = settings;
|
||||
name = configuration.getName();
|
||||
}
|
||||
if (configuration != null) {
|
||||
append(name, configuration.isTemporary()
|
||||
@@ -510,6 +508,25 @@ class RunConfigurable extends BaseConfigurable {
|
||||
myRightPanel.repaint();
|
||||
}
|
||||
|
||||
private static String getName(Object userObject) {
|
||||
if (userObject instanceof ConfigurationType) {
|
||||
return ((ConfigurationType)userObject).getDisplayName();
|
||||
}
|
||||
if (userObject == DEFAULTS) {
|
||||
return "Defaults";
|
||||
}
|
||||
if (userObject instanceof ConfigurationFactory) {
|
||||
return ((ConfigurationFactory)userObject).getName();
|
||||
}
|
||||
if (userObject instanceof SingleConfigurationConfigurable) {
|
||||
return ((SingleConfigurationConfigurable)userObject).getNameText();
|
||||
}
|
||||
if (userObject instanceof RunnerAndConfigurationSettingsImpl) {
|
||||
return ((RunnerAndConfigurationSettingsImpl)userObject).getName();
|
||||
}
|
||||
return String.valueOf(userObject);//Folder objects are strings
|
||||
}
|
||||
|
||||
private JPanel createLeftPanel() {
|
||||
initTree();
|
||||
MyRemoveAction removeAction = new MyRemoveAction();
|
||||
@@ -519,12 +536,15 @@ class RunConfigurable extends BaseConfigurable {
|
||||
.setAddAction(myAddAction).setAddActionName(ExecutionBundle.message("add.new.run.configuration.acrtion.name"))
|
||||
.setRemoveAction(removeAction).setRemoveActionUpdater(removeAction)
|
||||
.setRemoveActionName(ExecutionBundle.message("remove.run.configuration.action.name"))
|
||||
.setMoveUpAction(moveUpAction).setMoveUpActionName(ExecutionBundle.message("move.up.action.name")).setMoveUpActionUpdater(moveUpAction)
|
||||
.setMoveDownAction(moveDownAction).setMoveDownActionName(ExecutionBundle.message("move.down.action.name")).setMoveDownActionUpdater(moveDownAction)
|
||||
.setMoveUpAction(moveUpAction).setMoveUpActionName(ExecutionBundle.message("move.up.action.name")).setMoveUpActionUpdater(
|
||||
moveUpAction)
|
||||
.setMoveDownAction(moveDownAction).setMoveDownActionName(ExecutionBundle.message("move.down.action.name")).setMoveDownActionUpdater(
|
||||
moveDownAction)
|
||||
.addExtraAction(AnActionButton.fromAction(new MyCopyAction()))
|
||||
.addExtraAction(AnActionButton.fromAction(new MySaveAction()))
|
||||
.addExtraAction(AnActionButton.fromAction(new MyEditDefaultsAction()))
|
||||
.addExtraAction(AnActionButton.fromAction(new MyCreateFolderAction()))
|
||||
.addExtraAction(AnActionButton.fromAction(new MySortFolderAction()))
|
||||
.setButtonComparator(ExecutionBundle.message("add.new.run.configuration.acrtion.name"),
|
||||
ExecutionBundle.message("remove.run.configuration.action.name"),
|
||||
ExecutionBundle.message("copy.configuration.action.name"),
|
||||
@@ -1027,12 +1047,14 @@ class RunConfigurable extends BaseConfigurable {
|
||||
return RunManager.suggestUniqueName(str, currentNames);
|
||||
}
|
||||
|
||||
private SingleConfigurationConfigurable<RunConfiguration> createNewConfiguration(final RunnerAndConfigurationSettings settings, final DefaultMutableTreeNode node) {
|
||||
private SingleConfigurationConfigurable<RunConfiguration> createNewConfiguration(final RunnerAndConfigurationSettings settings,
|
||||
final DefaultMutableTreeNode node,
|
||||
DefaultMutableTreeNode selectedNode) {
|
||||
final SingleConfigurationConfigurable<RunConfiguration> configurationConfigurable =
|
||||
SingleConfigurationConfigurable.editSettings(settings, null);
|
||||
installUpdateListeners(configurationConfigurable);
|
||||
DefaultMutableTreeNode nodeToAdd = new DefaultMutableTreeNode(configurationConfigurable);
|
||||
myTreeModel.insertNodeInto(nodeToAdd, node, node.getChildCount());
|
||||
myTreeModel.insertNodeInto(nodeToAdd, node, node.getIndex(selectedNode) + 1);
|
||||
TreeUtil.selectNode(myTree, nodeToAdd);
|
||||
return configurationConfigurable;
|
||||
}
|
||||
@@ -1062,7 +1084,7 @@ class RunConfigurable extends BaseConfigurable {
|
||||
if (factory instanceof ConfigurationFactoryEx) {
|
||||
((ConfigurationFactoryEx)factory).onNewConfigurationCreated(settings.getConfiguration());
|
||||
}
|
||||
createNewConfiguration(settings, node);
|
||||
createNewConfiguration(settings, node, selectedNode);
|
||||
}
|
||||
|
||||
private class MyToolbarAddAction extends AnAction implements AnActionButtonRunnable {
|
||||
@@ -1372,7 +1394,7 @@ class RunConfigurable extends BaseConfigurable {
|
||||
if (factory instanceof ConfigurationFactoryEx) {
|
||||
((ConfigurationFactoryEx)factory).onConfigurationCopied(settings.getConfiguration());
|
||||
}
|
||||
final SingleConfigurationConfigurable<RunConfiguration> configurable = createNewConfiguration(settings, typeNode);
|
||||
final SingleConfigurationConfigurable<RunConfiguration> configurable = createNewConfiguration(settings, typeNode, getSelectedNode());
|
||||
IdeFocusManager.getInstance(myProject).requestFocus(configurable.getNameTextField(), true);
|
||||
configurable.getNameTextField().setSelectionStart(0);
|
||||
configurable.getNameTextField().setSelectionEnd(copyName.length());
|
||||
@@ -1608,6 +1630,71 @@ class RunConfigurable extends BaseConfigurable {
|
||||
}
|
||||
}
|
||||
|
||||
private class MySortFolderAction extends AnAction implements Comparator<DefaultMutableTreeNode>{
|
||||
private MySortFolderAction() {
|
||||
super(ExecutionBundle.message("run.configuration.sort.folder.text"),
|
||||
ExecutionBundle.message("run.configuration.sort.folder.description"), AllIcons.Icons.Inspector.SortByName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(DefaultMutableTreeNode node1, DefaultMutableTreeNode node2) {
|
||||
NodeKind kind1 = getKind(node1);
|
||||
NodeKind kind2 = getKind(node2);
|
||||
if (kind1 == FOLDER) {
|
||||
return (kind2 == FOLDER) ? node1.getParent().getIndex(node1) - node2.getParent().getIndex(node2) : -1;
|
||||
}
|
||||
if (kind2 == FOLDER) {
|
||||
return 1;
|
||||
}
|
||||
String name1 = getName(node1.getUserObject());
|
||||
String name2 = getName(node2.getUserObject());
|
||||
if (kind1 == TEMPORARY_CONFIGURATION) {
|
||||
return (kind2 == TEMPORARY_CONFIGURATION) ? name1.compareTo(name2) : 1;
|
||||
}
|
||||
if (kind2 == TEMPORARY_CONFIGURATION) {
|
||||
return -1;
|
||||
}
|
||||
return name1.compareTo(name2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final DefaultMutableTreeNode[] selectedNodes = getSelectedNodes();
|
||||
List<DefaultMutableTreeNode> foldersToSort = new ArrayList<DefaultMutableTreeNode>();
|
||||
for (DefaultMutableTreeNode node : selectedNodes) {
|
||||
NodeKind kind = getKind(node);
|
||||
if (kind == CONFIGURATION_TYPE || kind == FOLDER) {
|
||||
foldersToSort.add(node);
|
||||
}
|
||||
}
|
||||
for (DefaultMutableTreeNode folderNode : foldersToSort) {
|
||||
List<DefaultMutableTreeNode> children = new ArrayList<DefaultMutableTreeNode>();
|
||||
for (int i = 0; i < folderNode.getChildCount(); i++) {
|
||||
DefaultMutableTreeNode child = (DefaultMutableTreeNode)folderNode.getChildAt(i);
|
||||
children.add(child);
|
||||
}
|
||||
Collections.sort(children, this);
|
||||
for (DefaultMutableTreeNode child : children) {
|
||||
folderNode.add(child);
|
||||
}
|
||||
myTreeModel.nodeStructureChanged(folderNode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
final DefaultMutableTreeNode[] selectedNodes = getSelectedNodes();
|
||||
for (DefaultMutableTreeNode node : selectedNodes) {
|
||||
NodeKind kind = getKind(node);
|
||||
if (kind == CONFIGURATION_TYPE || kind == FOLDER) {
|
||||
e.getPresentation().setEnabled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
e.getPresentation().setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static ConfigurationType getType(DefaultMutableTreeNode node) {
|
||||
while (node != null) {
|
||||
@@ -1627,7 +1714,7 @@ class RunConfigurable extends BaseConfigurable {
|
||||
@Nullable
|
||||
private DefaultMutableTreeNode getSelectedNode() {
|
||||
DefaultMutableTreeNode[] nodes = myTree.getSelectedNodes(DefaultMutableTreeNode.class, null);
|
||||
return nodes.length > 1 ? nodes[0] : null;
|
||||
return nodes.length >= 1 ? nodes[0] : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -36,8 +36,8 @@ public class ApplyIntentionAction extends AnAction {
|
||||
private final Editor myEditor;
|
||||
private final PsiFile myFile;
|
||||
|
||||
public ApplyIntentionAction(HighlightInfo.IntentionActionDescriptor descriptor, Editor editor, PsiFile file) {
|
||||
super(descriptor.getAction().getText());
|
||||
public ApplyIntentionAction(final HighlightInfo.IntentionActionDescriptor descriptor, String text, Editor editor, PsiFile file) {
|
||||
super(text);
|
||||
myDescriptor = descriptor;
|
||||
myEditor = editor;
|
||||
myFile = file;
|
||||
@@ -76,7 +76,14 @@ public class ApplyIntentionAction extends AnAction {
|
||||
|
||||
final ApplyIntentionAction[] result = new ApplyIntentionAction[actions.size()];
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i] = new ApplyIntentionAction(actions.get(i), editor, file);
|
||||
final HighlightInfo.IntentionActionDescriptor descriptor = actions.get(i);
|
||||
final String actionText = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
return descriptor.getAction().getText();
|
||||
}
|
||||
});
|
||||
result[i] = new ApplyIntentionAction(descriptor, actionText, editor, file);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+1
-4
@@ -63,21 +63,18 @@ public class ChangeSignatureGestureDetector extends PsiTreeChangeAdapter impleme
|
||||
private final PsiManager myPsiManager;
|
||||
private final FileEditorManager myFileEditorManager;
|
||||
private final Project myProject;
|
||||
private final TemplateManager myTemplateManager;
|
||||
private final PsiDocumentManager myPsiDocumentManager;
|
||||
|
||||
public ChangeSignatureGestureDetector(final PsiDocumentManager psiDocumentManager,
|
||||
final FileDocumentManager documentManager,
|
||||
final PsiManager psiManager,
|
||||
final FileEditorManager fileEditorManager,
|
||||
final TemplateManager templateManager,
|
||||
final Project project) {
|
||||
myDocumentManager = documentManager;
|
||||
myPsiDocumentManager = psiDocumentManager;
|
||||
myPsiManager = psiManager;
|
||||
myFileEditorManager = fileEditorManager;
|
||||
myProject = project;
|
||||
myTemplateManager = templateManager;
|
||||
myPsiManager.addPsiTreeChangeListener(this, this);
|
||||
EditorFactory.getInstance().addEditorFactoryListener(this, this);
|
||||
Disposer.register(this, new Disposable() {
|
||||
@@ -184,7 +181,7 @@ public class ChangeSignatureGestureDetector extends PsiTreeChangeAdapter impleme
|
||||
final MyDocumentChangeAdapter changeBean = myListenerMap.get(file.getVirtualFile());
|
||||
if (changeBean != null && changeBean.getInitialText() != null) {
|
||||
final Editor editor = myFileEditorManager.getSelectedTextEditor();
|
||||
if (editor != null && myTemplateManager.getActiveTemplate(editor) != null) return;
|
||||
if (editor != null && TemplateManager.getInstance(myProject).getActiveTemplate(editor) != null) return;
|
||||
final LanguageChangeSignatureDetector detector = LanguageChangeSignatureDetectors.INSTANCE.forLanguage(child.getLanguage());
|
||||
if (detector == null) return;
|
||||
if (detector.ignoreChanges(child)) return;
|
||||
|
||||
@@ -60,7 +60,7 @@ public class TextFieldWithAutoCompletion<T> extends LanguageTextField {
|
||||
public TextFieldWithAutoCompletion(final Project project,
|
||||
@NotNull final TextFieldWithAutoCompletionListProvider<T> provider,
|
||||
final boolean showAutocompletionIsAvailableHint, @Nullable final String text) {
|
||||
super(PlainTextLanguage.INSTANCE, project, text == null ? "" : text);
|
||||
super(project == null ? null : PlainTextLanguage.INSTANCE, project, text == null ? "" : text);
|
||||
|
||||
myShowAutocompletionIsAvailableHint = showAutocompletionIsAvailableHint;
|
||||
myProvider = provider;
|
||||
|
||||
@@ -230,8 +230,7 @@ public final class MapIndexStorage<Key, Value> implements IndexStorage<Key, Valu
|
||||
if (useCachedHashIds && id == myLastScannedId) {
|
||||
try {
|
||||
hashMaskSet = loadHashedIds(fileWithCaches);
|
||||
} catch (IOException ex) {
|
||||
LOG.info(ex);
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -184,11 +184,22 @@ public class EditorHyperlinkSupport {
|
||||
return getHyperlinkAt(myEditor.logicalPositionToOffset(new LogicalPosition(line, col)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated for binary compatibility with older plugins
|
||||
* @see #createHyperlink(int, int, com.intellij.openapi.editor.markup.TextAttributes, com.intellij.execution.filters.HyperlinkInfo)
|
||||
*/
|
||||
public void addHyperlink(final int highlightStartOffset,
|
||||
final int highlightEndOffset,
|
||||
@Nullable final TextAttributes highlightAttributes,
|
||||
@NotNull final HyperlinkInfo hyperlinkInfo) {
|
||||
createHyperlink(highlightStartOffset, highlightEndOffset, highlightAttributes, hyperlinkInfo);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public RangeHighlighter addHyperlink(final int highlightStartOffset,
|
||||
final int highlightEndOffset,
|
||||
@Nullable final TextAttributes highlightAttributes,
|
||||
@NotNull final HyperlinkInfo hyperlinkInfo) {
|
||||
public RangeHighlighter createHyperlink(final int highlightStartOffset,
|
||||
final int highlightEndOffset,
|
||||
@Nullable final TextAttributes highlightAttributes,
|
||||
@NotNull final HyperlinkInfo hyperlinkInfo) {
|
||||
TextAttributes textAttributes = highlightAttributes != null ? highlightAttributes : getHyperlinkAttributes();
|
||||
final RangeHighlighter highlighter = myEditor.getMarkupModel().addRangeHighlighter(highlightStartOffset,
|
||||
highlightEndOffset,
|
||||
@@ -231,7 +242,7 @@ public class EditorHyperlinkSupport {
|
||||
if (result != null) {
|
||||
for (Filter.ResultItem resultItem : result.getResultItems()) {
|
||||
if (resultItem.hyperlinkInfo != null) {
|
||||
addHyperlink(resultItem.highlightStartOffset, resultItem.highlightEndOffset, resultItem.highlightAttributes, resultItem.hyperlinkInfo);
|
||||
createHyperlink(resultItem.highlightStartOffset, resultItem.highlightEndOffset, resultItem.highlightAttributes, resultItem.hyperlinkInfo);
|
||||
}
|
||||
else if (resultItem.highlightAttributes != null) {
|
||||
addHighlighter(resultItem.highlightStartOffset, resultItem.highlightEndOffset, resultItem.highlightAttributes);
|
||||
|
||||
@@ -151,7 +151,7 @@ class EventLogConsole {
|
||||
|
||||
for (Pair<TextRange, HyperlinkInfo> link : pair.links) {
|
||||
final RangeHighlighter rangeHighlighter = myHyperlinkSupport.getValue()
|
||||
.addHyperlink(link.first.getStartOffset() + msgStart, link.first.getEndOffset() + msgStart, null, link.second);
|
||||
.createHyperlink(link.first.getStartOffset() + msgStart, link.first.getEndOffset() + msgStart, null, link.second);
|
||||
if (link.second instanceof EventLog.ShowBalloon) {
|
||||
((EventLog.ShowBalloon)link.second).setRangeHighlighter(rangeHighlighter);
|
||||
}
|
||||
|
||||
+3
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -19,13 +19,12 @@ import com.intellij.featureStatistics.FeatureUsageTracker;
|
||||
import com.intellij.ide.diff.DirDiffSettings;
|
||||
import com.intellij.ide.diff.VirtualFileDiffElement;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.diff.DirDiffManager;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -33,7 +32,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class CompareDirectoriesAction extends AnAction {
|
||||
public class CompareDirectoriesAction extends DumbAwareAction {
|
||||
|
||||
public static final String LAST_USED_KEY = "dir.diff.last.used.directory";
|
||||
|
||||
|
||||
+4
-4
@@ -23,7 +23,7 @@ import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.keymap.MacKeymapUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
@@ -58,11 +58,11 @@ public class EditorEmptyTextPainter {
|
||||
|
||||
advertiseActions(splitters, painter);
|
||||
|
||||
painter.draw(g, new PairFunction<Integer, Integer, Pair<Integer, Integer>>() {
|
||||
painter.draw(g, new PairFunction<Integer, Integer, Couple<Integer>>() {
|
||||
@Override
|
||||
public Pair<Integer, Integer> fun(Integer width, Integer height) {
|
||||
public Couple<Integer> fun(Integer width, Integer height) {
|
||||
Dimension s = splitters.getSize();
|
||||
return Pair.create((s.width - width) / 2, (s.height - height) / 2);
|
||||
return Couple.newOne((s.width - width) / 2, (s.height - height) / 2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class EditorNotificationsImpl extends EditorNotifications {
|
||||
|
||||
public EditorNotificationsImpl(Project project) {
|
||||
super(project);
|
||||
myUpdateMerger = new MergingUpdateQueue("EditorNotifications update merger", 100, true, null);
|
||||
myUpdateMerger = new MergingUpdateQueue("EditorNotifications update merger", 100, true, null, project);
|
||||
MessageBusConnection connection = project.getMessageBus().connect(project);
|
||||
connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerAdapter() {
|
||||
@Override
|
||||
|
||||
@@ -339,9 +339,8 @@ public class MacFileChooserDialogImpl implements PathChooserDialog {
|
||||
bar.disableUpdates();
|
||||
}
|
||||
|
||||
final ID delegate = invoke(Foundation.getObjcClass("NSOpenPanelDelegate_"), "new");
|
||||
// Release in OPEN_PANEL_DID_END panel
|
||||
Foundation.cfRetain(delegate);
|
||||
final ID delegate = invoke(Foundation.getObjcClass("NSOpenPanelDelegate_"), "new");
|
||||
ourImplMap.put(delegate, impl);
|
||||
|
||||
final ID select = toSelect == null ? null : Foundation.nsString(toSelect);
|
||||
|
||||
@@ -58,6 +58,8 @@ run.configuration.edit.default.configuration.settings.text=Edit Defaults
|
||||
run.configuration.edit.default.configuration.settings.description=Edit defaults settings
|
||||
run.configuration.create.folder.text=Create New Folder
|
||||
run.configuration.create.folder.description=Create new folder
|
||||
run.configuration.sort.folder.text=Sort Configurations
|
||||
run.configuration.sort.folder.description=Sort configurations alphabetically
|
||||
run.configuration.create.folder.description.move=Move into new folder
|
||||
run.configuration.rename.folder=Rename folder ''{0}''
|
||||
run.configuration.rename.folder.disclaimer=Note: empty folders won't be saved
|
||||
|
||||
@@ -381,6 +381,8 @@
|
||||
key="templates.settings.page.title" bundle="messages.CodeInsightBundle"/>
|
||||
<lookup.actionProvider implementation="com.intellij.codeInsight.template.impl.LiveTemplateLookupActionProvider"/>
|
||||
<documentationProvider implementation="com.intellij.codeInsight.template.impl.LiveTemplateDocumentationProvider"/>
|
||||
<projectService serviceInterface="com.intellij.codeInsight.template.TemplateManager"
|
||||
serviceImplementation="com.intellij.codeInsight.template.impl.TemplateManagerImpl"/>
|
||||
|
||||
<!-- File Templates-->
|
||||
<applicationConfigurable instance="com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable" id="fileTemplates"
|
||||
|
||||
@@ -186,11 +186,6 @@
|
||||
<skipForDefaultProject/>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<interface-class>com.intellij.codeInsight.template.TemplateManager</interface-class>
|
||||
<implementation-class>com.intellij.codeInsight.template.impl.TemplateManagerImpl</implementation-class>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<implementation-class>com.intellij.util.indexing.FileBasedIndexProjectHandler</implementation-class>
|
||||
</component>
|
||||
|
||||
@@ -19,6 +19,8 @@ package com.intellij.openapi.util;
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class Couple<T> extends Pair<T, T> {
|
||||
private static final Couple EMPTY_COUPLE = newOne(null, null);
|
||||
|
||||
public Couple(T first, T second) {
|
||||
super(first, second);
|
||||
}
|
||||
@@ -26,4 +28,9 @@ public class Couple<T> extends Pair<T, T> {
|
||||
public static <T> Couple<T> newOne(T first, T second) {
|
||||
return new Couple<T>(first, second);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> Couple<T> getEmpty() {
|
||||
return EMPTY_COUPLE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.execution.rmi;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.ThrowableComputable;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ConcurrentFactoryMap;
|
||||
@@ -37,10 +37,10 @@ public class RemoteUtil {
|
||||
RemoteUtil() {
|
||||
}
|
||||
|
||||
private static final ConcurrentFactoryMap<Pair<Class<?>, Class<?>>, Map<Method, Method>> ourRemoteToLocalMap =
|
||||
new ConcurrentFactoryMap<Pair<Class<?>, Class<?>>, Map<Method, Method>>() {
|
||||
private static final ConcurrentFactoryMap<Couple<Class<?>>, Map<Method, Method>> ourRemoteToLocalMap =
|
||||
new ConcurrentFactoryMap<Couple<Class<?>>, Map<Method, Method>>() {
|
||||
@Override
|
||||
protected Map<Method, Method> create(Pair<Class<?>, Class<?>> key) {
|
||||
protected Map<Method, Method> create(Couple<Class<?>> key) {
|
||||
final THashMap<Method, Method> map = new THashMap<Method, Method>();
|
||||
for (Method method : key.second.getMethods()) {
|
||||
Method m = null;
|
||||
@@ -208,7 +208,7 @@ public class RemoteUtil {
|
||||
return method.invoke(myRemote, args);
|
||||
}
|
||||
else {
|
||||
Method m = ourRemoteToLocalMap.get(Pair.<Class<?>, Class<?>>create(myRemote.getClass(), myClazz)).get(method);
|
||||
Method m = ourRemoteToLocalMap.get(Couple.newOne(myRemote.getClass(), myClazz)).get(method);
|
||||
if (m == null) throw new NoSuchMethodError(method.getName() + " in " + myRemote.getClass());
|
||||
try {
|
||||
return handleRemoteResult(m.invoke(myRemote, args), method.getReturnType(), myLoader, false);
|
||||
|
||||
@@ -163,8 +163,8 @@ public class Foundation {
|
||||
}
|
||||
|
||||
byte[] utf16Bytes = s.getBytes("UTF-16LE");
|
||||
return invoke(invoke("NSString", "alloc"), "initWithBytes:length:encoding:", utf16Bytes, utf16Bytes.length,
|
||||
convertCFEncodingToNS(FoundationLibrary.kCFStringEncodingUTF16LE));
|
||||
return invoke(invoke(invoke("NSString", "alloc"), "initWithBytes:length:encoding:", utf16Bytes, utf16Bytes.length,
|
||||
convertCFEncodingToNS(FoundationLibrary.kCFStringEncodingUTF16LE)), "autorelease");
|
||||
}
|
||||
catch (UnsupportedEncodingException x) {
|
||||
throw new RuntimeException(x);
|
||||
|
||||
@@ -450,8 +450,8 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <K, V> Map<K,Pair<V,V>> diff(@NotNull Map<K, V> map1, @NotNull Map<K, V> map2) {
|
||||
final Map<K, Pair<V,V>> res = newHashMap();
|
||||
public static <K, V> Map<K,Couple<V>> diff(@NotNull Map<K, V> map1, @NotNull Map<K, V> map2) {
|
||||
final Map<K, Couple<V>> res = newHashMap();
|
||||
final Set<K> keys = newHashSet();
|
||||
keys.addAll(map1.keySet());
|
||||
keys.addAll(map2.keySet());
|
||||
@@ -459,7 +459,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
V v1 = map1.get(k);
|
||||
V v2 = map2.get(k);
|
||||
if (!(v1 == v2 || v1 != null && v1.equals(v2))) {
|
||||
res.put(k, Pair.create(v1, v2));
|
||||
res.put(k, Couple.newOne(v1, v2));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.util.graph;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import gnu.trove.TIntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class DFSTBuilder<Node> {
|
||||
private final Map<Node, Integer> myNodeToNNumber;
|
||||
private Map<Node, Integer> myNodeToTNumber;
|
||||
private final Node[] myInvN;
|
||||
private Pair<Node,Node> myBackEdge = null;
|
||||
private Couple<Node> myBackEdge = null;
|
||||
|
||||
private Comparator<Node> myComparator = null;
|
||||
private boolean myNBuilt = false;
|
||||
@@ -99,7 +99,7 @@ public class DFSTBuilder<Node> {
|
||||
Node prev = it.next();
|
||||
Integer prevNumber = myNodeToNNumber.get(prev);
|
||||
if (prevNumber != null && prevNumber.intValue() > nNumber) {
|
||||
myBackEdge = new Pair<Node, Node> (node, prev);
|
||||
myBackEdge = Couple.newOne(node, prev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -159,7 +159,7 @@ public class DFSTBuilder<Node> {
|
||||
myTBuilt = true;
|
||||
}
|
||||
|
||||
public Pair<Node, Node> getCircularDependency() {
|
||||
public Couple<Node> getCircularDependency() {
|
||||
buildDFST();
|
||||
return myBackEdge;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.util.io;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
@@ -88,7 +88,7 @@ public class URLUtil {
|
||||
|
||||
@NotNull
|
||||
private static InputStream openJarStream(@NotNull URL url) throws IOException {
|
||||
Pair<String, String> paths = splitJarUrl(url.getFile());
|
||||
Couple<String> paths = splitJarUrl(url.getFile());
|
||||
if (paths == null) {
|
||||
throw new MalformedURLException(url.getFile());
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class URLUtil {
|
||||
* E.g. "jar:file:///path/to/jar.jar!/resource.xml" is converted into ["/path/to/jar.jar", "resource.xml"].
|
||||
*/
|
||||
@Nullable
|
||||
public static Pair<String, String> splitJarUrl(@NotNull String url) {
|
||||
public static Couple<String> splitJarUrl(@NotNull String url) {
|
||||
int pivot = url.indexOf(JAR_SEPARATOR);
|
||||
if (pivot < 0) return null;
|
||||
|
||||
@@ -137,7 +137,7 @@ public class URLUtil {
|
||||
}
|
||||
}
|
||||
|
||||
return Pair.create(jarPath, resourcePath);
|
||||
return Couple.newOne(jarPath, resourcePath);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.util.ui;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -47,18 +47,18 @@ public class Centerizer extends JPanel {
|
||||
|
||||
final Dimension size = getSize();
|
||||
|
||||
final Pair<Integer, Integer> x = getFit(compSize.width, size.width);
|
||||
final Pair<Integer, Integer> y = getFit(compSize.height, size.height);
|
||||
final Couple<Integer> x = getFit(compSize.width, size.width);
|
||||
final Couple<Integer> y = getFit(compSize.height, size.height);
|
||||
|
||||
c.setBounds(x.first.intValue(), y.first.intValue(), x.second.intValue(), y.second.intValue());
|
||||
}
|
||||
|
||||
private static Pair<Integer, Integer> getFit(int compSize, int containerSize) {
|
||||
private static Couple<Integer> getFit(int compSize, int containerSize) {
|
||||
if (compSize >= containerSize) {
|
||||
return new Pair<Integer, Integer>(0, compSize);
|
||||
return Couple.newOne(0, compSize);
|
||||
} else {
|
||||
final int position = containerSize / 2 - compSize / 2;
|
||||
return new Pair<Integer, Integer>(position, compSize);
|
||||
return Couple.newOne(position, compSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2463,7 +2463,7 @@ public class UIUtil {
|
||||
/**
|
||||
* _position(block width, block height) => (x, y) of the block
|
||||
*/
|
||||
public void draw(@NotNull final Graphics g, final PairFunction<Integer, Integer, Pair<Integer, Integer>> _position) {
|
||||
public void draw(@NotNull final Graphics g, final PairFunction<Integer, Integer, Couple<Integer>> _position) {
|
||||
final int[] maxWidth = {0};
|
||||
final int[] height = {0};
|
||||
final int[] maxBulletWidth = {0};
|
||||
@@ -2493,7 +2493,7 @@ public class UIUtil {
|
||||
}
|
||||
});
|
||||
|
||||
final Pair<Integer, Integer> position = _position.fun(maxWidth[0] + 20, height[0]);
|
||||
final Couple<Integer> position = _position.fun(maxWidth[0] + 20, height[0]);
|
||||
assert position != null;
|
||||
|
||||
final int[] yOffset = {position.getSecond()};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.intellij.util.xmlb;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -218,21 +219,21 @@ class BeanBinding implements Binding {
|
||||
}
|
||||
|
||||
private static void collectPropertyAccessors(Class<?> aClass, List<Accessor> accessors) {
|
||||
final Map<String, Pair<Method, Method>> candidates = ContainerUtil.newTreeMap(); // (name,(getter,setter))
|
||||
final Map<String, Couple<Method>> candidates = ContainerUtil.newTreeMap(); // (name,(getter,setter))
|
||||
for (Method method : aClass.getMethods()) {
|
||||
if (!Modifier.isPublic(method.getModifiers())) continue;
|
||||
final Pair<String, Boolean> propertyData = getPropertyData(method.getName()); // (name,isSetter)
|
||||
if (propertyData == null || propertyData.first.equals(CLASS_PROPERTY)) continue;
|
||||
if (method.getParameterTypes().length != (propertyData.second ? 1 : 0)) continue;
|
||||
|
||||
Pair<Method, Method> candidate = candidates.get(propertyData.first);
|
||||
if (candidate == null) candidate = Pair.empty();
|
||||
Couple<Method> candidate = candidates.get(propertyData.first);
|
||||
if (candidate == null) candidate = Couple.getEmpty();
|
||||
if ((propertyData.second ? candidate.second : candidate.first) != null) continue;
|
||||
candidate = Pair.create(propertyData.second ? candidate.first : method, propertyData.second ? method : candidate.second);
|
||||
candidate = Couple.newOne(propertyData.second ? candidate.first : method, propertyData.second ? method : candidate.second);
|
||||
candidates.put(propertyData.first, candidate);
|
||||
}
|
||||
for (Map.Entry<String, Pair<Method, Method>> candidate: candidates.entrySet()) {
|
||||
final Pair<Method, Method> methods = candidate.getValue(); // (getter,setter)
|
||||
for (Map.Entry<String, Couple<Method>> candidate: candidates.entrySet()) {
|
||||
final Couple<Method> methods = candidate.getValue(); // (getter,setter)
|
||||
if (methods.first != null && methods.second != null &&
|
||||
methods.first.getReturnType().equals(methods.second.getParameterTypes()[0]) &&
|
||||
XmlSerializerImpl.findAnnotation(methods.first.getAnnotations(), Transient.class) == null &&
|
||||
|
||||
@@ -59,7 +59,7 @@ public class GraphColorManagerImpl implements GraphColorManager {
|
||||
@Override
|
||||
public JBColor getColorOfBranch(int headCommit) {
|
||||
Collection<VcsRef> refs = myRefsModel.refsToCommit(headCommit);
|
||||
if (!checkEmptiness(refs, headCommit)) {
|
||||
if (isEmptyRefs(refs, headCommit)) {
|
||||
return DEFAULT_COLOR;
|
||||
}
|
||||
VcsRef firstRef = getRefManager(refs).sort(refs).get(0);
|
||||
@@ -68,15 +68,15 @@ public class GraphColorManagerImpl implements GraphColorManager {
|
||||
return new JBColor(color, color);
|
||||
}
|
||||
|
||||
private boolean checkEmptiness(@NotNull Collection<VcsRef> refs, int head) {
|
||||
private boolean isEmptyRefs(@NotNull Collection<VcsRef> refs, int head) {
|
||||
if (refs.isEmpty()) {
|
||||
if (!myErrorWasReported.containsKey(head)) {
|
||||
myErrorWasReported.put(head, head);
|
||||
LOG.error("No references found at head " + head + " which corresponds to hash " + myHashGetter.fun(head));
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -94,17 +94,21 @@ public class GraphColorManagerImpl implements GraphColorManager {
|
||||
|
||||
Collection<VcsRef> refs1 = myRefsModel.refsToCommit(head1);
|
||||
Collection<VcsRef> refs2 = myRefsModel.refsToCommit(head2);
|
||||
if (!checkEmptiness(refs1, head1)) {
|
||||
boolean firstEmpty = isEmptyRefs(refs1, head1);
|
||||
boolean secondEmpty = isEmptyRefs(refs2, head2);
|
||||
if (firstEmpty && secondEmpty) {
|
||||
return 0;
|
||||
}
|
||||
if (firstEmpty) {
|
||||
return -1;
|
||||
}
|
||||
if (!checkEmptiness(refs2, head2)) {
|
||||
if (secondEmpty) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
VcsLogRefManager refManager1 = getRefManager(refs1);
|
||||
VcsLogRefManager refManager2 = getRefManager(refs2);
|
||||
if (!refManager1.equals(refManager2)) {
|
||||
LOG.debug("Different ref managers (and therefore different VCSs) are not comparable");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="openapi" />
|
||||
<orderEntry type="module" module-name="testFramework-java" scope="TEST" />
|
||||
<orderEntry type="module" module-name="idea-tests" scope="TEST" />
|
||||
<orderEntry type="module" module-name="lang-impl" />
|
||||
<orderEntry type="module" module-name="testFramework" />
|
||||
<orderEntry type="module" module-name="execution-impl" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<project name="Layout IdeaTestAssistant plugin distribution" default="layout">
|
||||
<target name="layout">
|
||||
<layout todir="${deploy}/plugins" xmlns="antlib:jetbrains.antlayout">
|
||||
<dir name="IdeaTestAssistant">
|
||||
<dir name="lib">
|
||||
<jar name="IdeaTestAssistant.jar">
|
||||
<module name="IdeaTestAssistant"/>
|
||||
</jar>
|
||||
</dir>
|
||||
</dir>
|
||||
</layout>
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,39 +0,0 @@
|
||||
<idea-plugin>
|
||||
<id>com.intellij.testAssistant</id>
|
||||
<name>IDEA Test Assistant</name>
|
||||
<description>Assists in writing and maintaining tests for IntelliJ IDEA's code</description>
|
||||
<version>1.0.0</version>
|
||||
<vendor url="http://www.jetbrains.com" logo="/general/ijLogo.png">JetBrains</vendor>
|
||||
|
||||
<actions>
|
||||
<action id="TestData.Navigate"
|
||||
class="com.intellij.testAssistant.NavigateToTestDataAction"
|
||||
text="Navigate to testdata" use-shortcut-of="GotoRelated">
|
||||
</action>
|
||||
<action id="DumpCleanTestData" internal="true" class="com.intellij.internal.DumpCleanHighlightingTestdataAction">
|
||||
<add-to-group group-id="Internal.Dump"/>
|
||||
</action>
|
||||
<group>
|
||||
<reference id="TestData.Navigate"/>
|
||||
<add-to-group anchor="first" group-id="TestTreePopupMenu"/>
|
||||
</group>
|
||||
</actions>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<errorHandler implementation="com.intellij.diagnostic.ITNReporter"/>
|
||||
<codeInsight.lineMarkerProvider language="JAVA" implementationClass="com.intellij.testAssistant.TestDataLineMarkerProvider"/>
|
||||
<codeInsight.lineMarkerProvider language="Groovy" implementationClass="com.intellij.testAssistant.TestDataLineMarkerProvider"/>
|
||||
<fileEditorProvider implementation="com.intellij.testAssistant.TestDataGroupEditorProvider"/>
|
||||
<gotoRelatedProvider implementation="com.intellij.testAssistant.TestDataAsRelatedFileProvider"/>
|
||||
<gotoRelatedProvider implementation="com.intellij.testAssistant.TestCaseAsRelatedFileProvider"/>
|
||||
<psi.referenceContributor implementation="com.intellij.testAssistant.TestDataReferenceContributor"/>
|
||||
<getDataRule key="Location" implementationClass="com.intellij.testAssistant.TestLocationDataRule"/>
|
||||
</extensions>
|
||||
|
||||
<project-components>
|
||||
<component>
|
||||
<implementation-class>com.intellij.testAssistant.TestDataHighlightingPassFactory</implementation-class>
|
||||
</component>
|
||||
</project-components>
|
||||
</idea-plugin>
|
||||
|
||||
+1
-1
@@ -1405,7 +1405,7 @@ redundant.method.override.display.name=Method is identical to its super method
|
||||
redundant.method.override.problem.descriptor=Method <code>#ref()</code> is identical to its super method #loc
|
||||
redundant.method.override.quickfix=Remove redundant method
|
||||
refused.bequest.problem.descriptor=Method <code>#ref()</code> ignores defined method in superclass #loc
|
||||
refused.bequest.ignore.empty.super.methods.option=Ignore empty super methods (degrades performance of this inspection)
|
||||
refused.bequest.ignore.empty.super.methods.option=Ignore empty super methods
|
||||
overly.complex.boolean.expression.ignore.option=Ignore pure conjunctions and disjunctions
|
||||
pointless.indexof.comparison.display.name=Pointless 'indexOf()' comparison
|
||||
pointless.indexof.comparison.always.true.problem.descriptor=<code>#ref</code> is always true #loc
|
||||
|
||||
+48
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2014 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,23 +15,60 @@
|
||||
*/
|
||||
package com.siyeh.ig.inheritance;
|
||||
|
||||
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.xml.util.XmlStringUtil;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.psiutils.ClassUtils;
|
||||
import com.siyeh.ig.psiutils.TestUtils;
|
||||
import com.siyeh.ig.ui.ExternalizableStringSet;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class RefusedBequestInspection extends BaseInspection {
|
||||
public class RefusedBequestInspectionBase extends BaseInspection {
|
||||
|
||||
@SuppressWarnings("PublicField") public boolean ignoreEmptySuperMethods = false;
|
||||
|
||||
@SuppressWarnings("PublicField") final ExternalizableStringSet annotations =
|
||||
new ExternalizableStringSet("javax.annotation.OverridingMethodsMustInvokeSuper");
|
||||
|
||||
@SuppressWarnings("PublicField") boolean onlyReportWhenAnnotated = false;
|
||||
|
||||
@Override
|
||||
public void writeSettings(@NotNull Element node) throws WriteExternalException {
|
||||
super.writeSettings(node);
|
||||
if (onlyReportWhenAnnotated) {
|
||||
node.addContent(new Element("option").setAttribute("name", "onlyReportWhenAnnotated").
|
||||
setAttribute("value", String.valueOf(onlyReportWhenAnnotated)));
|
||||
}
|
||||
if (!annotations.hasDefaultValues()) {
|
||||
final Element element = new Element("option").setAttribute("name", "annotations");
|
||||
final Element valueElement = new Element("value");
|
||||
annotations.writeExternal(valueElement);
|
||||
node.addContent(element.addContent(valueElement));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSettings(@NotNull Element node) throws InvalidDataException {
|
||||
super.readSettings(node);
|
||||
for (Element option : node.getChildren("option")) {
|
||||
if ("onlyReportWhenAnnotated".equals(option.getAttributeValue("name"))) {
|
||||
onlyReportWhenAnnotated = Boolean.parseBoolean(option.getAttributeValue("value"));
|
||||
}
|
||||
else if ("annotations".equals(option.getAttributeValue("name"))) {
|
||||
final Element value = option.getChild("value");
|
||||
if (value != null) {
|
||||
annotations.readExternal(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
@@ -44,14 +81,6 @@ public class RefusedBequestInspection extends BaseInspection {
|
||||
return InspectionGadgetsBundle.message("refused.bequest.problem.descriptor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent createOptionsPanel() {
|
||||
//noinspection HardCodedStringLiteral
|
||||
return new SingleCheckboxOptionsPanel(
|
||||
XmlStringUtil.wrapInHtml(InspectionGadgetsBundle.message("refused.bequest.ignore.empty.super.methods.option"))
|
||||
, this, "ignoreEmptySuperMethods");
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new RefusedBequestVisitor();
|
||||
@@ -84,6 +113,11 @@ public class RefusedBequestInspection extends BaseInspection {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (onlyReportWhenAnnotated) {
|
||||
if (!AnnotationUtil.isAnnotated(leastConcreteSuperMethod, annotations)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (TestUtils.isJUnit4BeforeOrAfterMethod(method)) {
|
||||
return;
|
||||
}
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011 Bas Leijdekkers
|
||||
* Copyright 2011-2014 Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -61,7 +61,7 @@ public class ExternalizableStringSet extends OrderedSet<String>
|
||||
}
|
||||
*/
|
||||
|
||||
private boolean hasDefaultValues() {
|
||||
public boolean hasDefaultValues() {
|
||||
if (size() != defaultValues.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.siyeh.ig.inheritance;
|
||||
|
||||
import com.intellij.codeInspection.util.SpecialAnnotationsUtil;
|
||||
import com.intellij.util.ui.CheckBox;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class RefusedBequestInspection extends RefusedBequestInspectionBase {
|
||||
|
||||
@Override
|
||||
public JComponent createOptionsPanel() {
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
final JPanel annotationsListControl = SpecialAnnotationsUtil.createSpecialAnnotationsListControl(annotations, null);
|
||||
final JCheckBox checkBox1 = new CheckBox("Only report when super method is annotated by:", this, "onlyReportWhenAnnotated");
|
||||
final CheckBox checkBox2 = new CheckBox(InspectionGadgetsBundle.message("refused.bequest.ignore.empty.super.methods.option"),
|
||||
this, "ignoreEmptySuperMethods");
|
||||
|
||||
panel.add(checkBox1, BorderLayout.NORTH);
|
||||
panel.add(annotationsListControl, BorderLayout.CENTER);
|
||||
panel.add(checkBox2, BorderLayout.SOUTH);
|
||||
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,10 @@ may represent a failure of abstraction, and can lead to hard-to-trace bugs. Meth
|
||||
from <b>java.lang.Object</b> are not reported by this inspection.
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
Use the first checkbox below to only warn when the super method is annotated by an annotation specified in the table below.
|
||||
<p>
|
||||
Use the second checkbox below to ignore super methods when they are empty. Enabling this option can be processor intensive.
|
||||
<p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.lang.ant.AntBundle;
|
||||
import com.intellij.lang.ant.AntSupport;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.references.PomService;
|
||||
@@ -75,7 +76,7 @@ class AntDomTargetReference extends AntDomReferenceBase implements BindablePsiRe
|
||||
final Map<String, AntDomTarget> variants = result.getVariants();
|
||||
String newName = null;
|
||||
if (!variants.isEmpty()) {
|
||||
List<Pair<String, String>> prefixNamePairs = null;
|
||||
List<Couple<String>> prefixNamePairs = null;
|
||||
for (Map.Entry<String, AntDomTarget> entry : variants.entrySet()) {
|
||||
final AntDomTarget candidateTarget = entry.getValue();
|
||||
if (pointingToTarget.equals(candidateTarget)) {
|
||||
@@ -84,14 +85,14 @@ class AntDomTargetReference extends AntDomReferenceBase implements BindablePsiRe
|
||||
if (candidateName.endsWith(candidateTargetName)) {
|
||||
final String prefix = candidateName.substring(0, candidateName.length() - candidateTargetName.length());
|
||||
if (prefixNamePairs == null) {
|
||||
prefixNamePairs = new ArrayList<Pair<String, String>>(); // lazy init
|
||||
prefixNamePairs = new ArrayList<Couple<String>>(); // lazy init
|
||||
}
|
||||
prefixNamePairs.add(new Pair<String, String>(prefix, candidateName));
|
||||
prefixNamePairs.add(Couple.newOne(prefix, candidateName));
|
||||
}
|
||||
}
|
||||
}
|
||||
final String currentRefText = getCanonicalText();
|
||||
for (Pair<String, String> pair : prefixNamePairs) {
|
||||
for (Couple<String> pair : prefixNamePairs) {
|
||||
final String prefix = pair.getFirst();
|
||||
final String effectiveName = pair.getSecond();
|
||||
if (currentRefText.startsWith(prefix)) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user