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:
@@ -59,6 +59,7 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
@@ -169,6 +170,26 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
return myModuleBytecodeTarget;
|
||||
}
|
||||
|
||||
public void setBytecodeTargetLevel(Module module, String level) {
|
||||
final String previous;
|
||||
if (StringUtil.isEmpty(level)) {
|
||||
previous = myModuleBytecodeTarget.remove(module.getName());
|
||||
}
|
||||
else {
|
||||
previous = myModuleBytecodeTarget.put(module.getName(), level);
|
||||
}
|
||||
if (!Comparing.equal(previous, level)) {
|
||||
final Project project = module.getProject();
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
if (!project.isDisposed()) {
|
||||
CompileServerManager.getInstance().sendReloadRequest(project);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getBytecodeTargetLevel(Module module) {
|
||||
|
||||
@@ -2316,9 +2316,6 @@ public class CompileDriver {
|
||||
|
||||
private boolean validateCompilerConfiguration(final CompileScope scope, boolean checkOutputAndSourceIntersection) {
|
||||
try {
|
||||
if (useOutOfProcessBuild()) {
|
||||
return true;
|
||||
}
|
||||
final Module[] scopeModules = scope.getAffectedModules()/*ModuleManager.getInstance(myProject).getModules()*/;
|
||||
final List<String> modulesWithoutOutputPathSpecified = new ArrayList<String>();
|
||||
boolean isProjectCompilePathSpecified = true;
|
||||
|
||||
@@ -525,7 +525,7 @@ public class BuildManager implements ApplicationComponent{
|
||||
}
|
||||
|
||||
final String defaultCharset = EncodingManager.getInstance().getDefaultCharsetName();
|
||||
if (defaultCharset != null) {
|
||||
if (!StringUtil.isEmpty(defaultCharset)) {
|
||||
cmdBuilder.setGlobalEncoding(defaultCharset);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ public abstract class CompilerConfiguration {
|
||||
@Nullable
|
||||
public abstract String getBytecodeTargetLevel(Module module);
|
||||
|
||||
public abstract void setBytecodeTargetLevel(Module module, String level);
|
||||
|
||||
public static CompilerConfiguration getInstance(Project project) {
|
||||
return project.getComponent(CompilerConfiguration.class);
|
||||
}
|
||||
@@ -72,5 +74,4 @@ public abstract class CompilerConfiguration {
|
||||
public abstract boolean isAnnotationProcessingEnabled(Module module);
|
||||
|
||||
public abstract String getGeneratedSourceDirName(Module module);
|
||||
|
||||
}
|
||||
@@ -77,6 +77,19 @@ public class ConstructorInsertHandler implements InsertHandler<LookupElementDeco
|
||||
psiClass.getTypeParameters().length > 0 &&
|
||||
((PsiTypeLookupItem)delegate).calcGenerics(position, context).isEmpty() &&
|
||||
context.getCompletionChar() != '(';
|
||||
|
||||
if (context.getDocument().getTextLength() > context.getTailOffset() &&
|
||||
context.getDocument().getCharsSequence().charAt(context.getTailOffset()) == '<') {
|
||||
PsiJavaCodeReferenceElement ref = PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), context.getTailOffset(), PsiJavaCodeReferenceElement.class, false);
|
||||
if (ref != null) {
|
||||
PsiReferenceParameterList parameterList = ref.getParameterList();
|
||||
if (parameterList != null && context.getTailOffset() == parameterList.getTextRange().getStartOffset()) {
|
||||
context.getDocument().deleteString(parameterList.getTextRange().getStartOffset(), parameterList.getTextRange().getEndOffset());
|
||||
context.commitDocument();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delegate.handleInsert(context);
|
||||
PostprocessReformattingAspect.getInstance(context.getProject()).doPostponedFormatting(context.getFile().getViewProvider());
|
||||
}
|
||||
@@ -85,6 +98,7 @@ public class ConstructorInsertHandler implements InsertHandler<LookupElementDeco
|
||||
PsiTypeLookupItem.addImportForItem(context, psiClass);
|
||||
}
|
||||
|
||||
|
||||
insertParentheses(context, delegate, psiClass, !inAnonymous && isAbstract);
|
||||
|
||||
if (inAnonymous) {
|
||||
|
||||
@@ -60,7 +60,7 @@ public class JavaCompletionSorting {
|
||||
|
||||
List<LookupElementWeigher> afterNegativeStats = new ArrayList<LookupElementWeigher>();
|
||||
if (!smart) {
|
||||
ContainerUtil.addIfNotNull(afterNegativeStats, preferStatics(position));
|
||||
ContainerUtil.addIfNotNull(afterNegativeStats, preferStatics(position, expectedTypes));
|
||||
}
|
||||
afterNegativeStats.add(new PreferLocalVariablesLiteralsAndAnnoMethodsWeigher(type, position));
|
||||
ContainerUtil.addIfNotNull(afterNegativeStats, recursion(parameters, expectedTypes));
|
||||
@@ -126,7 +126,7 @@ public class JavaCompletionSorting {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static LookupElementWeigher preferStatics(PsiElement position) {
|
||||
private static LookupElementWeigher preferStatics(PsiElement position, final ExpectedTypeInfo[] infos) {
|
||||
if (PsiTreeUtil.getParentOfType(position, PsiDocComment.class) != null) {
|
||||
return null;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public class JavaCompletionSorting {
|
||||
if (o instanceof PsiKeyword) return -3;
|
||||
if (!(o instanceof PsiMember)) return 0;
|
||||
|
||||
if (((PsiMember)o).hasModifierProperty(PsiModifier.STATIC)) {
|
||||
if (((PsiMember)o).hasModifierProperty(PsiModifier.STATIC) && !hasNonVoid(infos)) {
|
||||
if (o instanceof PsiMethod) return -5;
|
||||
if (o instanceof PsiField) return -4;
|
||||
}
|
||||
@@ -179,14 +179,7 @@ public class JavaCompletionSorting {
|
||||
}
|
||||
}
|
||||
|
||||
boolean hasNonVoid = false;
|
||||
for (ExpectedTypeInfo info : expectedInfos) {
|
||||
if (!PsiType.VOID.equals(info.getType())) {
|
||||
hasNonVoid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasNonVoid) {
|
||||
if (hasNonVoid(expectedInfos)) {
|
||||
if (item.getObject() instanceof PsiKeyword) {
|
||||
String keyword = ((PsiKeyword)item.getObject()).getText();
|
||||
if (PsiKeyword.NEW.equals(keyword) || PsiKeyword.NULL.equals(keyword)) {
|
||||
@@ -201,6 +194,16 @@ public class JavaCompletionSorting {
|
||||
return ExpectedTypeMatching.normal;
|
||||
}
|
||||
|
||||
private static boolean hasNonVoid(ExpectedTypeInfo[] expectedInfos) {
|
||||
boolean hasNonVoid = false;
|
||||
for (ExpectedTypeInfo info : expectedInfos) {
|
||||
if (!PsiType.VOID.equals(info.getType())) {
|
||||
hasNonVoid = true;
|
||||
}
|
||||
}
|
||||
return hasNonVoid;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getLookupObjectName(Object o) {
|
||||
if (o instanceof PsiVariable) {
|
||||
|
||||
+6
-10
@@ -62,17 +62,13 @@ public class JavaCompletionStatistician extends CompletionStatistician{
|
||||
if (o instanceof PsiMember) {
|
||||
final boolean isClass = o instanceof PsiClass;
|
||||
if (qualifierType != null) {
|
||||
if (type == CompletionType.SMART) {
|
||||
String context;
|
||||
if (isClass) {
|
||||
context = JavaStatisticsManager.getAfterNewKey(qualifierType);
|
||||
} else {
|
||||
context = JavaStatisticsManager.getMemberUseKey1(qualifierType);
|
||||
}
|
||||
return new StatisticsInfo(context, JavaStatisticsManager.getMemberUseKey2((PsiMember)o));
|
||||
String context;
|
||||
if (isClass) {
|
||||
context = JavaStatisticsManager.getAfterNewKey(qualifierType);
|
||||
} else {
|
||||
context = JavaStatisticsManager.getMemberUseKey1(qualifierType);
|
||||
}
|
||||
if (!isClass && type == CompletionType.BASIC) return JavaStatisticsManager.createInfo(qualifierType, (PsiMember)o);
|
||||
return StatisticsInfo.EMPTY;
|
||||
return new StatisticsInfo(context, JavaStatisticsManager.getMemberUseKey2((PsiMember)o));
|
||||
}
|
||||
|
||||
if (isClass) {
|
||||
|
||||
+15
-1
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.lookup.LookupElementWeigher;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.filters.getters.MembersGetter;
|
||||
import com.intellij.psi.util.PropertyUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
@@ -30,11 +31,13 @@ import java.util.Set;
|
||||
*/
|
||||
public class PreferLocalVariablesLiteralsAndAnnoMethodsWeigher extends LookupElementWeigher {
|
||||
private final CompletionType myCompletionType;
|
||||
private final PsiElement myPosition;
|
||||
private final Set<PsiField> myNonInitializedFields;
|
||||
|
||||
public PreferLocalVariablesLiteralsAndAnnoMethodsWeigher(CompletionType completionType, PsiElement position) {
|
||||
super("local");
|
||||
myCompletionType = completionType;
|
||||
myPosition = position;
|
||||
myNonInitializedFields = JavaCompletionProcessor.getNonInitializedFields(position);
|
||||
}
|
||||
|
||||
@@ -60,7 +63,10 @@ public class PreferLocalVariablesLiteralsAndAnnoMethodsWeigher extends LookupEle
|
||||
|
||||
if (object instanceof PsiKeyword) {
|
||||
String keyword = ((PsiKeyword)object).getText();
|
||||
if (PsiKeyword.RETURN.equals(keyword) || PsiKeyword.ELSE.equals(keyword) || PsiKeyword.FINALLY.equals(keyword)) {
|
||||
if (PsiKeyword.RETURN.equals(keyword) && isLastStatement(PsiTreeUtil.getParentOfType(myPosition, PsiStatement.class))) {
|
||||
return MyResult.probableKeyword;
|
||||
}
|
||||
if (PsiKeyword.ELSE.equals(keyword) || PsiKeyword.FINALLY.equals(keyword)) {
|
||||
return MyResult.probableKeyword;
|
||||
}
|
||||
}
|
||||
@@ -118,4 +124,12 @@ public class PreferLocalVariablesLiteralsAndAnnoMethodsWeigher extends LookupEle
|
||||
|
||||
return MyResult.normal;
|
||||
}
|
||||
|
||||
private static boolean isLastStatement(PsiStatement statement) {
|
||||
if (statement == null || !(statement.getParent() instanceof PsiCodeBlock)) {
|
||||
return true;
|
||||
}
|
||||
PsiStatement[] siblings = ((PsiCodeBlock)statement.getParent()).getStatements();
|
||||
return statement == siblings[siblings.length - 1];
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -390,7 +390,7 @@ public class GenericsHighlightUtil {
|
||||
if (extendFrom == null) return null;
|
||||
HighlightInfo errorResult = null;
|
||||
if (!extendFrom.isInterface() && referenceElements.length != 0 && element != referenceElements[0]) {
|
||||
final String description = HighlightClassUtil.INTERFACE_EXPECTED;
|
||||
String description = JavaErrorMessages.message("interface.expected");
|
||||
errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, element, description);
|
||||
PsiClassType type =
|
||||
JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory().createType(extendFrom, resolveResult.getSubstitutor());
|
||||
|
||||
+34
-28
@@ -60,9 +60,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class HighlightClassUtil {
|
||||
public static final String INTERFACE_EXPECTED = JavaErrorMessages.message("interface.expected");
|
||||
public static final String NO_INTERFACE_EXPECTED = JavaErrorMessages.message("no.interface.expected");
|
||||
private static final String STATIC_DECLARATION_IN_INNER_CLASS = JavaErrorMessages.message("static.declaration.in.inner.class");
|
||||
private static final QuickFixFactory QUICK_FIX_FACTORY = QuickFixFactory.getInstance();
|
||||
|
||||
/**
|
||||
@@ -280,9 +277,8 @@ public class HighlightClassUtil {
|
||||
if (PsiUtil.isCompileTimeConstant(field)) {
|
||||
return null;
|
||||
}
|
||||
HighlightInfo errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
|
||||
keyword,
|
||||
STATIC_DECLARATION_IN_INNER_CLASS);
|
||||
String message = JavaErrorMessages.message("static.declaration.in.inner.class");
|
||||
HighlightInfo errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, keyword, message);
|
||||
IntentionAction fix1 = QUICK_FIX_FACTORY.createModifierListFix(field, PsiModifier.STATIC, false, false);
|
||||
QuickFixAction.registerQuickFixAction(errorResult, fix1);
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(field.getContainingClass(), PsiModifier.STATIC, true, false);
|
||||
@@ -297,9 +293,8 @@ public class HighlightClassUtil {
|
||||
}
|
||||
PsiMethod method = (PsiMethod)keyword.getParent().getParent();
|
||||
if (PsiUtilCore.hasErrorElementChild(method)) return null;
|
||||
HighlightInfo errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
|
||||
keyword,
|
||||
STATIC_DECLARATION_IN_INNER_CLASS);
|
||||
String message = JavaErrorMessages.message("static.declaration.in.inner.class");
|
||||
HighlightInfo errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, keyword, message);
|
||||
IntentionAction fix1 = QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.STATIC, false, false);
|
||||
QuickFixAction.registerQuickFixAction(errorResult, fix1);
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix((PsiClass)keyword.getParent().getParent().getParent(), PsiModifier.STATIC, true, false);
|
||||
@@ -314,9 +309,8 @@ public class HighlightClassUtil {
|
||||
}
|
||||
PsiClassInitializer initializer = (PsiClassInitializer)keyword.getParent().getParent();
|
||||
if (PsiUtilCore.hasErrorElementChild(initializer)) return null;
|
||||
HighlightInfo errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
|
||||
keyword,
|
||||
STATIC_DECLARATION_IN_INNER_CLASS);
|
||||
String message = JavaErrorMessages.message("static.declaration.in.inner.class");
|
||||
HighlightInfo errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, keyword, message);
|
||||
IntentionAction fix1 = QUICK_FIX_FACTORY.createModifierListFix(initializer, PsiModifier.STATIC, false, false);
|
||||
QuickFixAction.registerQuickFixAction(errorResult, fix1);
|
||||
PsiClass owner = (PsiClass)keyword.getParent().getParent().getParent();
|
||||
@@ -364,7 +358,8 @@ public class HighlightClassUtil {
|
||||
if (textRange == null) {
|
||||
textRange = HighlightNamesUtil.getClassDeclarationTextRange(aClass);
|
||||
}
|
||||
HighlightInfo errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, textRange, STATIC_DECLARATION_IN_INNER_CLASS);
|
||||
String message = JavaErrorMessages.message("static.declaration.in.inner.class");
|
||||
HighlightInfo errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, textRange, message);
|
||||
if (context != keyword) {
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.STATIC, false, false);
|
||||
QuickFixAction.registerQuickFixAction(errorResult, fix);
|
||||
@@ -425,9 +420,8 @@ public class HighlightClassUtil {
|
||||
HighlightInfo errorResult = null;
|
||||
PsiClass extendFrom = (PsiClass)resolveResult.getElement();
|
||||
if (extendFrom.isInterface() != mustBeInterface) {
|
||||
errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
|
||||
ref,
|
||||
mustBeInterface ? INTERFACE_EXPECTED : NO_INTERFACE_EXPECTED);
|
||||
String message = JavaErrorMessages.message(mustBeInterface ? "interface.expected" : "no.interface.expected");
|
||||
errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, ref, message);
|
||||
PsiClassType type =
|
||||
JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory().createType(ref);
|
||||
QuickFixAction.registerQuickFixAction(errorResult, new ChangeExtendsToImplementsFix(aClass, type));
|
||||
@@ -640,7 +634,8 @@ public class HighlightClassUtil {
|
||||
}
|
||||
|
||||
|
||||
public static HighlightInfo checkQualifiedNewOfStaticClass(PsiNewExpression expression) {
|
||||
@Nullable
|
||||
public static HighlightInfo checkQualifiedNew(PsiNewExpression expression) {
|
||||
PsiExpression qualifier = expression.getQualifier();
|
||||
if (qualifier == null) return null;
|
||||
PsiType type = expression.getType();
|
||||
@@ -652,18 +647,28 @@ public class HighlightClassUtil {
|
||||
return info;
|
||||
}
|
||||
PsiClass aClass = PsiUtil.resolveClassInType(type);
|
||||
if (aClass != null && aClass.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
|
||||
expression,
|
||||
JavaErrorMessages.message("qualified.new.of.static.class"));
|
||||
if (!aClass.isEnum()) {
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.STATIC, false, false);
|
||||
QuickFixAction.registerQuickFixAction(info, fix);
|
||||
HighlightInfo info = null;
|
||||
if (aClass != null) {
|
||||
if (aClass.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
|
||||
expression,
|
||||
JavaErrorMessages.message("qualified.new.of.static.class"));
|
||||
if (!aClass.isEnum()) {
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.STATIC, false, false);
|
||||
QuickFixAction.registerQuickFixAction(info, fix);
|
||||
}
|
||||
|
||||
} else if (aClass instanceof PsiAnonymousClass) {
|
||||
final PsiClass baseClass = PsiUtil.resolveClassInType(((PsiAnonymousClass)aClass).getBaseClassType());
|
||||
if (baseClass != null && baseClass.isInterface()) {
|
||||
info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
|
||||
expression,
|
||||
"Anonymous class implements interface; cannot have qualifier for new");
|
||||
}
|
||||
}
|
||||
QuickFixAction.registerQuickFixAction(info, new RemoveNewQualifierFix(expression, aClass));
|
||||
return info;
|
||||
}
|
||||
return null;
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
@@ -840,8 +845,9 @@ public class HighlightClassUtil {
|
||||
}
|
||||
PsiModifierListOwner staticParent = PsiUtil.getEnclosingStaticElement(place, outerClass);
|
||||
if (staticParent != null) {
|
||||
String description = JavaErrorMessages.message("cannot.be.referenced.from.static.context",
|
||||
outerClass == null ? "" : HighlightUtil.formatClass(outerClass) + "." + PsiKeyword.THIS);
|
||||
String element = outerClass == null ? "" : HighlightUtil.formatClass(outerClass) + "." +
|
||||
(place instanceof PsiSuperExpression ? PsiKeyword.SUPER : PsiKeyword.THIS);
|
||||
String description = JavaErrorMessages.message("cannot.be.referenced.from.static.context", element);
|
||||
HighlightInfo highlightInfo = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, elementToHighlight, description);
|
||||
// make context not static or referenced class static
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(staticParent, PsiModifier.STATIC, false, false);
|
||||
|
||||
+16
-13
@@ -838,14 +838,19 @@ public class HighlightMethodUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
static HighlightInfo checkMethodCanHaveBody(PsiMethod method) {
|
||||
if (method.getBody() == null) return null;
|
||||
PsiClass aClass = method.getContainingClass();
|
||||
|
||||
String message = null;
|
||||
if (aClass != null && aClass.isInterface()) {
|
||||
message = JavaErrorMessages.message("interface.methods.cannot.have.body");
|
||||
if (!PsiUtil.isExtensionMethod(method)) {
|
||||
message = JavaErrorMessages.message("interface.methods.cannot.have.body");
|
||||
}
|
||||
else {
|
||||
return HighlightUtil.checkExtensionMethodsFeature(method);
|
||||
}
|
||||
}
|
||||
else if (method.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
message = JavaErrorMessages.message("abstract.methods.cannot.have.a.body");
|
||||
@@ -853,21 +858,19 @@ public class HighlightMethodUtil {
|
||||
else if (method.hasModifierProperty(PsiModifier.NATIVE)) {
|
||||
message = JavaErrorMessages.message("native.methods.cannot.have.a.body");
|
||||
}
|
||||
if (message == null) return null;
|
||||
|
||||
if (message != null) {
|
||||
TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method);
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, textRange, message);
|
||||
QuickFixAction.registerQuickFixAction(info, new DeleteMethodBodyFix(method));
|
||||
if (method.hasModifierProperty(PsiModifier.ABSTRACT) && aClass != null && !aClass.isInterface()) {
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.ABSTRACT, false, false);
|
||||
QuickFixAction.registerQuickFixAction(info, fix);
|
||||
}
|
||||
return info;
|
||||
TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method);
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, textRange, message);
|
||||
QuickFixAction.registerQuickFixAction(info, new DeleteMethodBodyFix(method));
|
||||
if (method.hasModifierProperty(PsiModifier.ABSTRACT) && aClass != null && !aClass.isInterface()) {
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.ABSTRACT, false, false);
|
||||
QuickFixAction.registerQuickFixAction(info, fix);
|
||||
}
|
||||
return null;
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
static HighlightInfo checkConstructorCallMustBeFirstStatement(PsiReferenceExpression expression) {
|
||||
PsiElement methodCall = expression.getParent();
|
||||
if (!HighlightUtil.isSuperOrThisMethodCall(methodCall)) return null;
|
||||
|
||||
@@ -78,7 +78,7 @@ public class HighlightUtil {
|
||||
private static final Map<String, Set<String>> ourClassInitializerIncompatibleModifiers;
|
||||
private static final Set<String> ourConstructorNotAllowedModifiers;
|
||||
|
||||
@NonNls private static final String SERIAL_VERSION_UID_FIELD_NAME = "serialVersionUID";
|
||||
@NonNls public static final String SERIAL_VERSION_UID_FIELD_NAME = "serialVersionUID";
|
||||
@NonNls private static final String SERIAL_PERSISTENT_FIELDS_FIELD_NAME = "serialPersistentFields";
|
||||
private static final QuickFixFactory QUICK_FIX_FACTORY = QuickFixFactory.getInstance();
|
||||
|
||||
@@ -1328,14 +1328,13 @@ public class HighlightUtil {
|
||||
}
|
||||
if (aClass == null) return null;
|
||||
if (qualifier != null && aClass.isInterface()) {
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, qualifier, HighlightClassUtil.NO_INTERFACE_EXPECTED);
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, qualifier, JavaErrorMessages.message("no.interface.expected"));
|
||||
}
|
||||
if (!HighlightClassUtil.hasEnclosingInstanceInScope(aClass, expr, false)) {
|
||||
return HighlightClassUtil.reportIllegalEnclosingUsage(expr, null, aClass, expr);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
static String buildProblemWithStaticDescription(PsiElement refElement) {
|
||||
@@ -2481,7 +2480,8 @@ public class HighlightUtil {
|
||||
VARARGS(LanguageLevel.JDK_1_5, "feature.varargs"),
|
||||
DIAMOND_TYPES(LanguageLevel.JDK_1_7, "feature.diamond.types"),
|
||||
MULTI_CATCH(LanguageLevel.JDK_1_7, "feature.multi.catch"),
|
||||
TRY_WITH_RESOURCES(LanguageLevel.JDK_1_7, "feature.try.with.resources");
|
||||
TRY_WITH_RESOURCES(LanguageLevel.JDK_1_7, "feature.try.with.resources"),
|
||||
EXTENSION_METHODS(LanguageLevel.JDK_1_8, "feature.extension.methods");
|
||||
|
||||
private final LanguageLevel level;
|
||||
private final String key;
|
||||
@@ -2544,4 +2544,9 @@ public class HighlightUtil {
|
||||
public static HighlightInfo checkTryWithResourcesFeature(final PsiResourceVariable resourceVariable) {
|
||||
return checkFeature(resourceVariable.getParent(), Feature.TRY_WITH_RESOURCES);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkExtensionMethodsFeature(final PsiMethod method) {
|
||||
return checkFeature(method, Feature.EXTENSION_METHODS);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -698,7 +698,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override public void visitNewExpression(PsiNewExpression expression) {
|
||||
myHolder.add(HighlightUtil.checkUnhandledExceptions(expression, null));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkAnonymousInheritFinal(expression));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkQualifiedNewOfStaticClass(expression));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkQualifiedNew(expression));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkCreateInnerClassFromStaticContext(expression));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkTypeParameterInstantiation(expression));
|
||||
try {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.codeInsight.folding.impl;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.CollectHighlightsUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
|
||||
import com.intellij.codeInsight.folding.JavaCodeFoldingSettings;
|
||||
import com.intellij.codeInsight.generation.OverrideImplementUtil;
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -43,7 +44,6 @@ import com.intellij.psi.util.PropertyUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -565,9 +565,15 @@ public class JavaFoldingBuilder extends CustomFoldingBuilder implements DumbAwar
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasOnlyOneMethod(@NotNull PsiAnonymousClass anonymousClass) {
|
||||
if (anonymousClass.getFields().length != 0) {
|
||||
return false;
|
||||
private static boolean hasOnlyOneMethod(@NotNull PsiAnonymousClass anonymousClass, boolean checkResolve) {
|
||||
PsiField[] fields = anonymousClass.getFields();
|
||||
if (fields.length != 0) {
|
||||
if (fields.length == 1 && HighlightUtil.SERIAL_VERSION_UID_FIELD_NAME.equals(fields[0].getName()) &&
|
||||
fields[0].hasModifierProperty(PsiModifier.STATIC)) {
|
||||
//ok
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (anonymousClass.getInitializers().length != 0) {
|
||||
return false;
|
||||
@@ -576,7 +582,20 @@ public class JavaFoldingBuilder extends CustomFoldingBuilder implements DumbAwar
|
||||
return false;
|
||||
}
|
||||
|
||||
return anonymousClass.getMethods().length == 1;
|
||||
if (anonymousClass.getMethods().length != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (checkResolve) {
|
||||
PsiReferenceList throwsList = anonymousClass.getMethods()[0].getThrowsList();
|
||||
for (PsiClassType type : throwsList.getReferencedTypes()) {
|
||||
if (type.resolve() == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean addClosureFolding(final PsiClass aClass, final Document document, final List<FoldingDescriptor> foldElements,
|
||||
@@ -594,7 +613,7 @@ public class JavaFoldingBuilder extends CustomFoldingBuilder implements DumbAwar
|
||||
final PsiExpressionList argumentList = expression.getArgumentList();
|
||||
if (argumentList != null && argumentList.getExpressions().length == 0) {
|
||||
final PsiMethod[] methods = anonymousClass.getMethods();
|
||||
if (hasOnlyOneMethod(anonymousClass) && (quick || seemsLikeLambda(anonymousClass.getBaseClassType().resolve()))) {
|
||||
if (hasOnlyOneMethod(anonymousClass, !quick) && (quick || seemsLikeLambda(anonymousClass.getBaseClassType().resolve()))) {
|
||||
final PsiMethod method = methods[0];
|
||||
final PsiCodeBlock body = method.getBody();
|
||||
if (body != null) {
|
||||
@@ -626,35 +645,13 @@ public class JavaFoldingBuilder extends CustomFoldingBuilder implements DumbAwar
|
||||
if (lastLineEnd > 0 && seq.charAt(lastLineEnd) == '\n') lastLineEnd--;
|
||||
if (lastLineEnd < firstLineStart) return false;
|
||||
|
||||
final String baseClassName = quick ?
|
||||
anonymousClass.getBaseClassReference().getReferenceName() :
|
||||
ObjectUtils.assertNotNull(anonymousClass.getBaseClassType().resolve()).getName();
|
||||
if (lastLineEnd >= seq.length() || firstLineStart >= seq.length() || firstLineStart < 0) {
|
||||
LOG.error("llE=" + lastLineEnd + "; fLS=" + firstLineStart + "; len=" + seq.length() + "rE=" + rangeEnd + "; class=" +
|
||||
baseClassName);
|
||||
}
|
||||
|
||||
final String params = StringUtil.join(method.getParameterList().getParameters(), new Function<PsiParameter, String>() {
|
||||
@Override
|
||||
public String fun(final PsiParameter psiParameter) {
|
||||
String typeName;
|
||||
if (quick) {
|
||||
PsiTypeElement typeElement = psiParameter.getTypeElement();
|
||||
assert typeElement != null;
|
||||
typeName = typeElement.getText();
|
||||
}
|
||||
else {
|
||||
typeName = psiParameter.getType().getPresentableText();
|
||||
}
|
||||
int genStart = typeName.indexOf('<');
|
||||
int genEnd = typeName.lastIndexOf('>');
|
||||
if (genStart > 0 && genEnd > 0) {
|
||||
typeName = typeName.substring(0, genStart) + typeName.substring(genEnd + 1);
|
||||
}
|
||||
return typeName + " " + psiParameter.getName();
|
||||
return psiParameter.getName();
|
||||
}
|
||||
}, ", ");
|
||||
@NonNls final String lambdas = baseClassName + "(" + params + ") {";
|
||||
@NonNls final String lambdas = "{" + params + " =>";
|
||||
|
||||
final int closureStart = expression.getTextRange().getStartOffset();
|
||||
final int closureEnd = expression.getTextRange().getEndOffset();
|
||||
|
||||
+7
-2
@@ -35,7 +35,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
abstract class GenerateGetterSetterHandlerBase extends GenerateMembersHandlerBase {
|
||||
public abstract class GenerateGetterSetterHandlerBase extends GenerateMembersHandlerBase {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.generation.GenerateGetterSetterHandlerBase");
|
||||
|
||||
static {
|
||||
@@ -44,7 +44,7 @@ abstract class GenerateGetterSetterHandlerBase extends GenerateMembersHandlerBas
|
||||
public Collection<EncapsulatableClassMember> fun(PsiClass s) {
|
||||
if (s.getLanguage() != StdLanguages.JAVA) return Collections.emptyList();
|
||||
final List<EncapsulatableClassMember> result = new ArrayList<EncapsulatableClassMember>();
|
||||
for(PsiField field: s.getFields()) {
|
||||
for (PsiField field : s.getFields()) {
|
||||
if (!(field instanceof PsiEnumConstant)) {
|
||||
result.add(new PsiFieldMember(field));
|
||||
}
|
||||
@@ -75,6 +75,11 @@ abstract class GenerateGetterSetterHandlerBase extends GenerateMembersHandlerBas
|
||||
protected abstract String getNothingFoundMessage();
|
||||
protected abstract String getNothingAcceptedMessage();
|
||||
|
||||
public boolean canBeAppliedTo(PsiClass targetClass) {
|
||||
final ClassMember[] allMembers = getAllOriginalMembers(targetClass);
|
||||
return allMembers != null && allMembers.length != 0;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ClassMember[] getAllOriginalMembers(final PsiClass aClass) {
|
||||
final List<EncapsulatableClassMember> list = GenerateAccessorProviderRegistrar.getEncapsulatableClassMembers(aClass);
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public class JavaImplementMethodsHandler implements LanguageCodeInsightActionHan
|
||||
}
|
||||
|
||||
PsiClass aClass = OverrideImplementUtil.getContextClass(file.getProject(), editor, file, false);
|
||||
return aClass != null;
|
||||
return aClass != null && !OverrideImplementUtil.getMethodSignaturesToImplement(aClass).isEmpty();
|
||||
}
|
||||
|
||||
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
|
||||
|
||||
+13
-3
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.generation;
|
||||
|
||||
import com.intellij.codeInsight.hint.HintManager;
|
||||
import com.intellij.lang.LanguageCodeInsightActionHandler;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -28,14 +29,23 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class JavaOverrideMethodsHandler implements LanguageCodeInsightActionHandler {
|
||||
public boolean isValidFor(final Editor editor, final PsiFile file) {
|
||||
return file instanceof PsiJavaFile && OverrideImplementUtil.getContextClass(file.getProject(), editor, file, true) != null;
|
||||
if (!(file instanceof PsiJavaFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PsiClass aClass = OverrideImplementUtil.getContextClass(file.getProject(), editor, file, true);
|
||||
return aClass != null && !OverrideImplementUtil.getMethodSignaturesToOverride(aClass).isEmpty();
|
||||
}
|
||||
|
||||
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
|
||||
PsiClass aClass = OverrideImplementUtil.getContextClass(project, editor, file, true);
|
||||
if (aClass != null) {
|
||||
OverrideImplementUtil.chooseAndOverrideMethods(project, editor, aClass);
|
||||
if (aClass == null) return;
|
||||
|
||||
if (OverrideImplementUtil.getMethodSignaturesToOverride(aClass).isEmpty()) {
|
||||
HintManager.getInstance().showErrorHint(editor, "No methods to override have been found");
|
||||
return;
|
||||
}
|
||||
OverrideImplementUtil.chooseAndOverrideMethods(project, editor, aClass);
|
||||
}
|
||||
|
||||
public boolean startInWriteAction() {
|
||||
|
||||
+2
-3
@@ -21,10 +21,9 @@ import com.intellij.codeInsight.generation.GenerateGetterHandler;
|
||||
* Action group which contains Generate... actions
|
||||
* Available in the Java code editor context only
|
||||
* @author Alexey Kudravtsev
|
||||
*/
|
||||
public class GenerateGetterAction extends BaseGenerateAction {
|
||||
*/
|
||||
public class GenerateGetterAction extends GenerateGetterSetterBaseAction {
|
||||
public GenerateGetterAction() {
|
||||
super(new GenerateGetterHandler());
|
||||
}
|
||||
|
||||
}
|
||||
+1
-2
@@ -22,9 +22,8 @@ import com.intellij.codeInsight.generation.GenerateGetterAndSetterHandler;
|
||||
* Available in the Java code editor context only
|
||||
* @author Alexey Kudravtsev
|
||||
*/
|
||||
public class GenerateGetterAndSetterAction extends BaseGenerateAction {
|
||||
public class GenerateGetterAndSetterAction extends GenerateGetterSetterBaseAction {
|
||||
public GenerateGetterAndSetterAction() {
|
||||
super(new GenerateGetterAndSetterHandler());
|
||||
}
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.generation.actions;
|
||||
|
||||
import com.intellij.codeInsight.generation.GenerateGetterSetterHandlerBase;
|
||||
import com.intellij.psi.PsiClass;
|
||||
|
||||
/**
|
||||
* Action group which contains Generate... actions
|
||||
* Available in the Java code editor context only
|
||||
* @author Danila Ponomarenko
|
||||
*/
|
||||
public abstract class GenerateGetterSetterBaseAction extends BaseGenerateAction {
|
||||
public GenerateGetterSetterBaseAction(GenerateGetterSetterHandlerBase handler) {
|
||||
super(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isValidForClass(PsiClass targetClass) {
|
||||
final GenerateGetterSetterHandlerBase handler = (GenerateGetterSetterHandlerBase)getHandler();
|
||||
return handler.canBeAppliedTo(targetClass);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -22,7 +22,7 @@ import com.intellij.codeInsight.generation.GenerateSetterHandler;
|
||||
* Available in the Java code editor context only
|
||||
* @author Alexey Kudravtsev
|
||||
*/
|
||||
public class GenerateSetterAction extends BaseGenerateAction {
|
||||
public class GenerateSetterAction extends GenerateGetterSetterBaseAction {
|
||||
public GenerateSetterAction() {
|
||||
super(new GenerateSetterHandler());
|
||||
}
|
||||
|
||||
@@ -725,12 +725,8 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
if (!myHasDirtyFields) return;
|
||||
|
||||
myHasDirtyFields = false;
|
||||
DfaVariableValue[] fields = runner.getFields();
|
||||
for (DfaVariableValue field : fields) {
|
||||
boolean resetNullability = isNotNull(field);
|
||||
for (DfaVariableValue field : runner.getFields()) {
|
||||
flushVariable(field);
|
||||
if (resetNullability) {
|
||||
}
|
||||
getVariableState(field).setNullable(false);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -30,6 +30,7 @@ import com.intellij.analysis.AnalysisScope;
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInsight.daemon.GroupNames;
|
||||
import com.intellij.codeInsight.daemon.ImplicitUsageProvider;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.codeInspection.ex.*;
|
||||
@@ -266,7 +267,7 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool {
|
||||
|
||||
private static boolean isSerializationImplicitlyUsedField(PsiField field) {
|
||||
@NonNls final String name = field.getName();
|
||||
if (!"serialVersionUID".equals(name) && !"serialPersistentFields".equals(name)) return false;
|
||||
if (!HighlightUtil.SERIAL_VERSION_UID_FIELD_NAME.equals(name) && !"serialPersistentFields".equals(name)) return false;
|
||||
if (!field.hasModifierProperty(PsiModifier.STATIC)) return false;
|
||||
PsiClass aClass = field.getContainingClass();
|
||||
return aClass == null || isSerializable(aClass, null);
|
||||
|
||||
@@ -318,7 +318,9 @@ public final class PsiUtil extends PsiUtilCore {
|
||||
@PsiModifier.ModifierConstant
|
||||
@Nullable
|
||||
public static String getAccessModifier(int accessLevel) {
|
||||
return accessLevel > accessModifiers.length ? null : accessModifiers[accessLevel - 1];
|
||||
@SuppressWarnings("UnnecessaryLocalVariable") @PsiModifier.ModifierConstant
|
||||
final String modifier = accessLevel > accessModifiers.length ? null : accessModifiers[accessLevel - 1];
|
||||
return modifier;
|
||||
}
|
||||
|
||||
private static final String[] accessModifiers = {
|
||||
@@ -952,4 +954,12 @@ public final class PsiUtil extends PsiUtilCore {
|
||||
public static boolean isIgnoredName(@Nullable final String name) {
|
||||
return "ignore".equals(name) || "ignored".equals(name);
|
||||
}
|
||||
|
||||
public static boolean isExtensionMethod(@Nullable final PsiMethod method) {
|
||||
if (method == null) return false;
|
||||
final PsiCodeBlock body = method.getBody();
|
||||
if (body == null) return false;
|
||||
final PsiElement previous = PsiTreeUtil.skipSiblingsBackward(body, PsiComment.class, PsiWhiteSpace.class);
|
||||
return isJavaToken(previous, JavaTokenType.DEFAULT_KEYWORD);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,13 +264,31 @@ public class PsiSuperMethodImplUtil {
|
||||
PsiMethod superMethod = superSignatureHierarchical.getMethod();
|
||||
PsiClass superClass = superMethod.getContainingClass();
|
||||
PsiClass containingClass = hierarchicalMethodSignature.getMethod().getContainingClass();
|
||||
return !superMethod.isConstructor()
|
||||
&& !aClass.equals(superClass)
|
||||
&& PsiUtil.isAccessible(superMethod, aClass, aClass)
|
||||
&& MethodSignatureUtil.isSubsignature(superSignatureHierarchical, hierarchicalMethodSignature)
|
||||
&& superClass != null
|
||||
&& (containingClass != null && containingClass.isInterface() == superClass.isInterface() || superClass.isInterface() || "java.lang.Object".equals(superClass.getQualifiedName()))
|
||||
;
|
||||
if (!superMethod.isConstructor()) {
|
||||
if (!aClass.equals(superClass)) {
|
||||
if (PsiUtil.isAccessible(superMethod, aClass, aClass)) {
|
||||
if (MethodSignatureUtil.isSubsignature(superSignatureHierarchical, hierarchicalMethodSignature)) {
|
||||
if (superClass != null) {
|
||||
if (superClass.isInterface() ||
|
||||
"java.lang.Object".equals(superClass.getQualifiedName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (containingClass != null) {
|
||||
if (!containingClass.isInterface()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!aClass.isInterface() && !InheritanceUtil.isInheritorOrSelf(superClass, containingClass, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static HierarchicalMethodSignatureImpl copy(HierarchicalMethodSignature hi) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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,6 @@ package com.intellij.psi.impl.cache;
|
||||
* @author max
|
||||
*/
|
||||
public interface ModifierFlags {
|
||||
// ---- The group equal to corresponding in ClsUtil.ACC_*
|
||||
int PUBLIC_MASK = 0x0001;
|
||||
int PRIVATE_MASK = 0x0002;
|
||||
int PROTECTED_MASK = 0x0004;
|
||||
@@ -31,9 +30,8 @@ public interface ModifierFlags {
|
||||
int TRANSIENT_MASK = 0x0080;
|
||||
int NATIVE_MASK = 0x0100;
|
||||
int INTERFACE_MASK = 0x0200;
|
||||
int DEFENDER_MASK = 0x0200;
|
||||
int ABSTRACT_MASK = 0x0400;
|
||||
// ---- End of the group equal to corresponding in ClsUtil.ACC_*
|
||||
|
||||
int STRICTFP_MASK = 0x0800;
|
||||
int PACKAGE_LOCAL_MASK = 0x1000;
|
||||
int DEPRECATED_MASK = 0x2000;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -30,12 +30,8 @@ import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.CharTable;
|
||||
import gnu.trove.TObjectIntHashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
@@ -123,7 +119,7 @@ public class RecordUtil {
|
||||
else if (parent instanceof PsiMethodStub) {
|
||||
if (grandParent instanceof PsiClassStub && ((PsiClassStub)grandParent).isInterface()) {
|
||||
alreadyPublic = true;
|
||||
alreadyAbstract = true;
|
||||
alreadyAbstract = !((PsiMethodStub)parent).isDefender();
|
||||
}
|
||||
}
|
||||
else if (parent instanceof PsiFieldStub) {
|
||||
@@ -143,27 +139,37 @@ public class RecordUtil {
|
||||
for (final LighterASTNode child : tree.getChildren(modList)) {
|
||||
final IElementType type = child.getTokenType();
|
||||
|
||||
if(type == JavaTokenType.PUBLIC_KEYWORD) {
|
||||
if (type == JavaTokenType.PUBLIC_KEYWORD) {
|
||||
alreadyPublic = true;
|
||||
} else if(type == JavaTokenType.PRIVATE_KEYWORD) {
|
||||
}
|
||||
else if (type == JavaTokenType.PRIVATE_KEYWORD) {
|
||||
packed |= ModifierFlags.PRIVATE_MASK;
|
||||
} else if(type == JavaTokenType.PROTECTED_KEYWORD) {
|
||||
}
|
||||
else if (type == JavaTokenType.PROTECTED_KEYWORD) {
|
||||
packed |= ModifierFlags.PROTECTED_MASK;
|
||||
} else if(type == JavaTokenType.ABSTRACT_KEYWORD) {
|
||||
alreadyAbstract =true;
|
||||
} else if (type == JavaTokenType.FINAL_KEYWORD) {
|
||||
}
|
||||
else if (type == JavaTokenType.ABSTRACT_KEYWORD) {
|
||||
alreadyAbstract = true;
|
||||
}
|
||||
else if (type == JavaTokenType.FINAL_KEYWORD) {
|
||||
alreadyFinal = true;
|
||||
} else if (type == JavaTokenType.STATIC_KEYWORD) {
|
||||
}
|
||||
else if (type == JavaTokenType.STATIC_KEYWORD) {
|
||||
alreadyStatic = true;
|
||||
} else if(type == JavaTokenType.NATIVE_KEYWORD) {
|
||||
}
|
||||
else if (type == JavaTokenType.NATIVE_KEYWORD) {
|
||||
packed |= ModifierFlags.NATIVE_MASK;
|
||||
} else if (type == JavaTokenType.SYNCHRONIZED_KEYWORD) {
|
||||
}
|
||||
else if (type == JavaTokenType.SYNCHRONIZED_KEYWORD) {
|
||||
packed |= ModifierFlags.SYNCHRONIZED_MASK;
|
||||
} else if (type == JavaTokenType.TRANSIENT_KEYWORD) {
|
||||
}
|
||||
else if (type == JavaTokenType.TRANSIENT_KEYWORD) {
|
||||
packed |= ModifierFlags.TRANSIENT_MASK;
|
||||
} else if (type == JavaTokenType.VOLATILE_KEYWORD) {
|
||||
}
|
||||
else if (type == JavaTokenType.VOLATILE_KEYWORD) {
|
||||
packed |= ModifierFlags.VOLATILE_MASK;
|
||||
} else if (type == JavaTokenType.STRICTFP_KEYWORD) {
|
||||
}
|
||||
else if (type == JavaTokenType.STRICTFP_KEYWORD) {
|
||||
packed |= ModifierFlags.STRICTFP_MASK;
|
||||
}
|
||||
}
|
||||
@@ -175,8 +181,7 @@ public class RecordUtil {
|
||||
|
||||
if ((packed & ModifierFlags.PRIVATE_MASK) == 0 &&
|
||||
(packed & ModifierFlags.PROTECTED_MASK) == 0 &&
|
||||
(packed & ModifierFlags.PUBLIC_MASK) == 0
|
||||
) {
|
||||
(packed & ModifierFlags.PUBLIC_MASK) == 0) {
|
||||
packed |= ModifierFlags.PACKAGE_LOCAL_MASK;
|
||||
}
|
||||
|
||||
@@ -217,62 +222,6 @@ public class RecordUtil {
|
||||
return (ourModifierNameToFlagMap.get(psiModifier) & packed) != 0;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
private static final Set<String>[] SET_INSTANCES = new Set[8 * 4];
|
||||
|
||||
private static final String[] VISIBILITY_MODIFIERS = {null, PsiModifier.PUBLIC, PsiModifier.PRIVATE, PsiModifier.PROTECTED};
|
||||
|
||||
private static final int[] MODIFIER_MAP = {0, 1, 2, -1, 3, -1, -1, -1, -1};
|
||||
|
||||
static {
|
||||
SET_INSTANCES[0] = Collections.emptySet();
|
||||
for (int i = 1; i < 4; i++) {
|
||||
SET_INSTANCES[i << 3] = Collections.singleton(VISIBILITY_MODIFIERS[i]);
|
||||
}
|
||||
|
||||
for (int i = 1; i < 8; i++) {
|
||||
int attr = i << 3;
|
||||
|
||||
Set<String> set = new LinkedHashSet<String>();
|
||||
if ((attr & ModifierFlags.STATIC_MASK) != 0) set.add(PsiModifier.STATIC);
|
||||
if ((attr & ModifierFlags.FINAL_MASK) != 0) set.add(PsiModifier.FINAL);
|
||||
if ((attr & (4 << 3)) != 0) set.add(PsiModifier.ABSTRACT);
|
||||
|
||||
if (set.size() == 1) set = Collections.singleton(set.iterator().next());
|
||||
|
||||
SET_INSTANCES[i] = set;
|
||||
|
||||
for (int k = 1; k < 4; k++) {
|
||||
Set<String> setWithModifier = new LinkedHashSet<String>();
|
||||
setWithModifier.add(VISIBILITY_MODIFIERS[k]);
|
||||
setWithModifier.addAll(set);
|
||||
assert setWithModifier.size() > 1;
|
||||
|
||||
SET_INSTANCES[(k << 3) + i] = setWithModifier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<String> getModifierSet(int modifiers) {
|
||||
assert (modifiers & ~(ModifierFlags.PUBLIC_MASK | ModifierFlags.PRIVATE_MASK | ModifierFlags.PROTECTED_MASK |
|
||||
ModifierFlags.FINAL_MASK | ModifierFlags.ABSTRACT_MASK | ModifierFlags.STATIC_MASK)) == 0;
|
||||
|
||||
int visibilityModifierIndex = MODIFIER_MAP[modifiers & 7];
|
||||
int index = ((modifiers >>> 3) & 3) + ((modifiers & ModifierFlags.ABSTRACT_MASK) >>> 8);
|
||||
if (visibilityModifierIndex != -1) {
|
||||
return SET_INSTANCES[index + (visibilityModifierIndex << 3)];
|
||||
}
|
||||
|
||||
Set<String> res = new LinkedHashSet<String>();
|
||||
if ((modifiers & ModifierFlags.PUBLIC_MASK) != 0) res.add(PsiModifier.PUBLIC);
|
||||
if ((modifiers & ModifierFlags.PRIVATE_MASK) != 0) res.add(PsiModifier.PRIVATE);
|
||||
if ((modifiers & ModifierFlags.PROTECTED_MASK) != 0) res.add(PsiModifier.PROTECTED);
|
||||
|
||||
res.addAll(SET_INSTANCES[index]);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public static String intern(final CharTable table, final LighterASTNode node) {
|
||||
assert node instanceof LighterASTTokenNode;
|
||||
return table.intern(((LighterASTTokenNode)node).getText()).toString();
|
||||
|
||||
@@ -58,6 +58,10 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
public static final String FLOAT_NEGATIVE_INF = "-1.0f / 0.0";
|
||||
public static final String FLOAT_NAN = "0.0f / 0.0";
|
||||
|
||||
@NonNls private static final String SYNTHETIC_CLASS_INIT_METHOD = "<clinit>";
|
||||
@NonNls private static final String SYNTHETIC_INIT_METHOD = "<init>";
|
||||
|
||||
private static final int ACC_DEFENDER = Opcodes.ACC_INTERFACE; // todo[r.sh] use right constant once ASM gets Java 8 support
|
||||
|
||||
private final InnerClassSourceStrategy<T> myInnersStrategy;
|
||||
private final StubElement myParent;
|
||||
@@ -65,8 +69,6 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
private final T mySource;
|
||||
private PsiModifierListStub myModList;
|
||||
private PsiClassStub myResult;
|
||||
@NonNls private static final String SYNTHETIC_CLINIT_METHOD = "<clinit>";
|
||||
@NonNls private static final String SYNTHETIC_INIT_METHOD = "<init>";
|
||||
private JavaLexer myLexer;
|
||||
|
||||
public StubBuildingVisitor(final T classSource, InnerClassSourceStrategy<T> innersStrategy, final StubElement parent, final int access) {
|
||||
@@ -174,20 +176,25 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
return convertedSuper;
|
||||
}
|
||||
|
||||
// for lexer, so need not to be precise
|
||||
private static LanguageLevel convertFromVersion(final int version) {
|
||||
if (version == Opcodes.V1_1 || version == Opcodes.V1_2 || version == Opcodes.V1_3) {
|
||||
return LanguageLevel.JDK_1_3;
|
||||
}
|
||||
switch (version) {
|
||||
case Opcodes.V1_1:
|
||||
case Opcodes.V1_2:
|
||||
case Opcodes.V1_3:
|
||||
return LanguageLevel.JDK_1_3;
|
||||
|
||||
if (version == Opcodes.V1_4) {
|
||||
return LanguageLevel.JDK_1_4;
|
||||
}
|
||||
case Opcodes.V1_4:
|
||||
return LanguageLevel.JDK_1_4;
|
||||
|
||||
if (version == Opcodes.V1_5 || version == Opcodes.V1_6) {
|
||||
return LanguageLevel.JDK_1_5;
|
||||
}
|
||||
case Opcodes.V1_5:
|
||||
case Opcodes.V1_6:
|
||||
case Opcodes.V1_7:
|
||||
return LanguageLevel.JDK_1_5;
|
||||
|
||||
return LanguageLevel.HIGHEST;
|
||||
default:
|
||||
return LanguageLevel.HIGHEST;
|
||||
}
|
||||
}
|
||||
|
||||
private static int packCommonFlags(final int access) {
|
||||
@@ -357,16 +364,17 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
// However Scala compiler erroneously generates ACC_BRIDGE instead of ACC_SYNTHETIC flag for in-trait implementation delegation. See IDEA-78649
|
||||
if (isSynthetic) return null;
|
||||
|
||||
if (SYNTHETIC_CLINIT_METHOD.equals(name)) return null;
|
||||
if (SYNTHETIC_CLASS_INIT_METHOD.equals(name)) return null;
|
||||
|
||||
boolean isDeprecated = (access & Opcodes.ACC_DEPRECATED) != 0;
|
||||
boolean isConstructor = SYNTHETIC_INIT_METHOD.equals(name);
|
||||
boolean isVarargs = (access & Opcodes.ACC_VARARGS) != 0;
|
||||
boolean isAnnotationMethod = myResult.isAnnotationType();
|
||||
boolean isDefender = (access & ACC_DEFENDER) != 0;
|
||||
|
||||
if (!isConstructor && !isCorrectName(name)) return null;
|
||||
|
||||
final byte flags = PsiMethodStubImpl.packFlags(isConstructor, isAnnotationMethod, isVarargs, isDeprecated, false);
|
||||
final byte flags = PsiMethodStubImpl.packFlags(isConstructor, isAnnotationMethod, isVarargs, isDeprecated, false, isDefender);
|
||||
|
||||
String canonicalMethodName = isConstructor ? myResult.getName() : name;
|
||||
final List<String> args = new ArrayList<String>();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -73,6 +73,7 @@ public abstract class JavaMethodElementType extends JavaStubElementType<PsiMetho
|
||||
boolean isVarArgs = false;
|
||||
boolean isDeprecatedByComment = false;
|
||||
boolean hasDeprecatedAnnotation = false;
|
||||
boolean isDefender = false;
|
||||
String defValueText = null;
|
||||
|
||||
boolean expectingDef = false;
|
||||
@@ -102,16 +103,20 @@ public abstract class JavaMethodElementType extends JavaStubElementType<PsiMetho
|
||||
else if (type == JavaTokenType.DEFAULT_KEYWORD) {
|
||||
expectingDef = true;
|
||||
}
|
||||
else if (expectingDef && !ElementType.JAVA_COMMENT_OR_WHITESPACE_BIT_SET.contains(type) &&
|
||||
type != JavaTokenType.SEMICOLON && type != JavaElementType.CODE_BLOCK) {
|
||||
defValueText = LightTreeUtil.toFilteredString(tree, child, null);
|
||||
else if (expectingDef && !ElementType.JAVA_COMMENT_OR_WHITESPACE_BIT_SET.contains(type) && type != JavaTokenType.SEMICOLON) {
|
||||
if (type != JavaElementType.CODE_BLOCK) {
|
||||
defValueText = LightTreeUtil.toFilteredString(tree, child, null);
|
||||
}
|
||||
else {
|
||||
isDefender = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final TypeInfo typeInfo = isConstructor ? TypeInfo.createConstructorType() : TypeInfo.create(tree, node, parentStub);
|
||||
final boolean isAnno = (node.getTokenType() == JavaElementType.ANNOTATION_METHOD);
|
||||
final byte flags = PsiMethodStubImpl.packFlags(isConstructor, isAnno, isVarArgs, isDeprecatedByComment, hasDeprecatedAnnotation);
|
||||
final byte flags = PsiMethodStubImpl.packFlags(isConstructor, isAnno, isVarArgs, isDeprecatedByComment, hasDeprecatedAnnotation, isDefender);
|
||||
|
||||
return new PsiMethodStubImpl(parentStub, StringRef.fromString(name), typeInfo, flags, StringRef.fromString(defValueText));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -29,6 +29,7 @@ public interface PsiMethodStub extends NamedStub<PsiMethod> {
|
||||
boolean isConstructor();
|
||||
boolean isVarArgs();
|
||||
boolean isAnnotationMethod();
|
||||
boolean isDefender();
|
||||
|
||||
@Nullable String getDefaultValueText();
|
||||
@NotNull TypeInfo getReturnTypeText(boolean doResolve);
|
||||
|
||||
+18
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -43,6 +43,7 @@ public class PsiMethodStubImpl extends StubBase<PsiMethod> implements PsiMethodS
|
||||
private static final int ANNOTATION = 0x04;
|
||||
private static final int DEPRECATED = 0x08;
|
||||
private static final int DEPRECATED_ANNOTATION = 0x10;
|
||||
private static final int DEFENDER = 0x20;
|
||||
|
||||
|
||||
public PsiMethodStubImpl(final StubElement parent,
|
||||
@@ -88,6 +89,11 @@ public class PsiMethodStubImpl extends StubBase<PsiMethod> implements PsiMethodS
|
||||
return isAnnotationMethod(myFlags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefender() {
|
||||
return (myFlags & DEFENDER) != 0;
|
||||
}
|
||||
|
||||
public static boolean isAnnotationMethod(final byte flags) {
|
||||
return (flags & ANNOTATION) != 0;
|
||||
}
|
||||
@@ -145,13 +151,19 @@ public class PsiMethodStubImpl extends StubBase<PsiMethod> implements PsiMethodS
|
||||
myDefaultValueText = StringRef.fromString(defaultValueText);
|
||||
}
|
||||
|
||||
public static byte packFlags(boolean isConstructor, boolean isAnnotationMethod, boolean isVarargs, boolean isDeprecated, boolean hasDeprecatedAnnotation) {
|
||||
public static byte packFlags(boolean isConstructor,
|
||||
boolean isAnnotationMethod,
|
||||
boolean isVarargs,
|
||||
boolean isDeprecated,
|
||||
boolean hasDeprecatedAnnotation,
|
||||
boolean isDefender) {
|
||||
byte flags = 0;
|
||||
if (isConstructor) flags |= CONSTRUCTOR;
|
||||
if (isAnnotationMethod) flags |= ANNOTATION;
|
||||
if (isVarargs) flags |= VARARGS;
|
||||
if (isDeprecated) flags |= DEPRECATED;
|
||||
if (hasDeprecatedAnnotation) flags |= DEPRECATED_ANNOTATION;
|
||||
if (isDefender) flags |= DEFENDER;
|
||||
return flags;
|
||||
}
|
||||
|
||||
@@ -179,6 +191,10 @@ public class PsiMethodStubImpl extends StubBase<PsiMethod> implements PsiMethodS
|
||||
builder.append(" default=").append(defaultValue);
|
||||
}
|
||||
|
||||
if (isDefender()) {
|
||||
builder.append(" default {}");
|
||||
}
|
||||
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -37,7 +37,7 @@ import java.io.IOException;
|
||||
* @author max
|
||||
*/
|
||||
public class JavaFileElementType extends ILightStubFileElementType<PsiJavaFileStub> {
|
||||
public static final int STUB_VERSION = 9;
|
||||
public static final int STUB_VERSION = 10;
|
||||
|
||||
public JavaFileElementType() {
|
||||
super("java.FILE", JavaLanguage.INSTANCE);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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,6 +31,7 @@ import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiAnnotationImpl;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -151,7 +152,7 @@ public class PsiModifierListImpl extends JavaStubPsiElement<PsiModifierListStub>
|
||||
return false;
|
||||
}
|
||||
if (type == JavaTokenType.ABSTRACT_KEYWORD) {
|
||||
return true;
|
||||
return !PsiUtil.isExtensionMethod((PsiMethod)parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,6 +349,7 @@ feature.static.imports=Static imports
|
||||
feature.for.each=For-each loops
|
||||
feature.varargs=Variable arity methods
|
||||
feature.diamond.types=Diamond types
|
||||
feature.try.with.resources=Try-with-resources
|
||||
feature.multi.catch=Multi-catches
|
||||
feature.try.with.resources=Try-with-resources
|
||||
feature.extension.methods=Extension methods
|
||||
insufficient.language.level={0} are not supported at this language level
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class Bar {
|
||||
{
|
||||
Koo<String> hs = new Ko<caret><StringX>();
|
||||
}
|
||||
}
|
||||
class Koo<X> {}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class Bar {
|
||||
{
|
||||
Koo<String> hs = new Koo<String>()<caret>;
|
||||
}
|
||||
}
|
||||
class Koo<X> {}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Util {
|
||||
void foo(int reaction, boolean rezet) {
|
||||
re<caret>
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class Foo {
|
||||
String s = Util.se<caret>
|
||||
}
|
||||
|
||||
class Util {
|
||||
public static final String serial = "serialVersionUID";
|
||||
|
||||
public static Runnable superExpressionInIllegalContext() {}
|
||||
|
||||
}
|
||||
+22
-9
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
*/
|
||||
|
||||
// illegal method calls
|
||||
|
||||
class A {
|
||||
@@ -48,14 +64,12 @@ class CX {
|
||||
|
||||
|
||||
class c {
|
||||
c() {
|
||||
c() {}
|
||||
|
||||
}
|
||||
class inner {
|
||||
class ininner {}
|
||||
}
|
||||
|
||||
|
||||
static void f() {
|
||||
<error descr="'c.this' cannot be referenced from a static context">new inner()</error>;
|
||||
}
|
||||
@@ -88,21 +102,20 @@ class DCC {
|
||||
}
|
||||
|
||||
public DCC(int i, int z) {
|
||||
<error descr="Method call expected">DCC(i)</error>;
|
||||
<error descr="Method call expected">DCC(i)</error>;
|
||||
}
|
||||
void f() {
|
||||
<error descr="Method call expected">DCC(1)</error>;
|
||||
new DCC(1);
|
||||
}
|
||||
{
|
||||
<error descr="Qualifier must be an expression">java</error>.toString();
|
||||
}
|
||||
|
||||
{
|
||||
<error descr="Qualifier must be an expression">java</error>.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class ThisExpression {
|
||||
static String foo() {
|
||||
System.out.println(<error descr="'ThisExpression.this' cannot be referenced from a static context">this</error>);
|
||||
return <error descr="'ThisExpression.this' cannot be referenced from a static context">this</error>.toString();
|
||||
return <error descr="'ThisExpression.super' cannot be referenced from a static context">super</error>.toString();
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -17,3 +17,16 @@ class b extends A {
|
||||
static class c {}
|
||||
}
|
||||
|
||||
|
||||
class WithAnonym {
|
||||
interface I {
|
||||
}
|
||||
class Inner{}
|
||||
}
|
||||
|
||||
class WithAnonymInheritor extends WithAnonym {
|
||||
{
|
||||
<error descr="Anonymous class implements interface; cannot have qualifier for new">this.new I() {}</error>;
|
||||
this.new Inner() {};
|
||||
}
|
||||
}
|
||||
+4
@@ -38,4 +38,8 @@ class UnsupportedFeatures {
|
||||
|
||||
try <error descr="Try-with-resources are not supported at this language level">(Reader r = new FileReader("/dev/null"))</error> { }
|
||||
}
|
||||
|
||||
interface I {
|
||||
<error descr="Extension methods are not supported at this language level">void m() default { }</error>
|
||||
}
|
||||
}
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
*/
|
||||
|
||||
class C {
|
||||
interface I {
|
||||
void m() default { }
|
||||
}
|
||||
|
||||
void test() {
|
||||
new I(){}.m();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
abstract class A {
|
||||
public abstract D foo();
|
||||
}
|
||||
|
||||
interface B {
|
||||
F foo();
|
||||
}
|
||||
|
||||
class C extends A implements B {
|
||||
public F foo() {
|
||||
<selection>return null; //To change body of implemented methods use File | Settings | File Templates.</selection>
|
||||
}
|
||||
}
|
||||
|
||||
class D {}
|
||||
class F extends D {}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
abstract class A {
|
||||
public abstract D foo();
|
||||
}
|
||||
|
||||
interface B {
|
||||
F foo();
|
||||
}
|
||||
|
||||
class C extends A implements B {
|
||||
<caret>
|
||||
}
|
||||
|
||||
class D {}
|
||||
class F extends D {}
|
||||
@@ -36,6 +36,7 @@ public class OverrideImplementTest extends LightCodeInsightTestCase {
|
||||
public void testTestMissed() throws Exception { doTest(false); }
|
||||
public void testWildcard() throws Exception { doTest(false); }
|
||||
public void testTypeParam() throws Exception { doTest(false); }
|
||||
public void testInterfaceAndAbstractClass() throws Exception { doTest(false); }
|
||||
|
||||
public void testLongFinalParameterList() throws Exception {
|
||||
CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject()).clone();
|
||||
|
||||
+18
-2
@@ -8,11 +8,11 @@ package com.intellij.codeInsight.completion;
|
||||
import com.intellij.JavaTestUtil
|
||||
import com.intellij.codeInsight.CodeInsightSettings
|
||||
import com.intellij.codeInsight.lookup.LookupElement
|
||||
import com.intellij.codeInsight.lookup.LookupElementPresentation
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl
|
||||
import com.intellij.ide.ui.UISettings
|
||||
import com.intellij.psi.PsiClass
|
||||
import com.intellij.psi.PsiMethod
|
||||
import com.intellij.codeInsight.lookup.LookupElementPresentation
|
||||
|
||||
public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
private static final String BASE_PATH = "/codeInsight/completion/normalSorting";
|
||||
@@ -87,7 +87,7 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
final String path = getTestName(false) + ".java";
|
||||
myFixture.configureByFile(path);
|
||||
myFixture.complete(CompletionType.BASIC, 2);
|
||||
assertPreferredItems(0, "booleanMethod", "voidMethod", "registerNatives", "BOOLEAN", "AN_OBJECT");
|
||||
assertPreferredItems(0, "BOOLEAN", "booleanMethod", "AN_OBJECT", "voidMethod", "registerNatives");
|
||||
}
|
||||
|
||||
public void testDispreferDeclared() throws Throwable {
|
||||
@@ -314,4 +314,20 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
checkPreferredItems 0, 'noo', 'new', 'null', 'noo2', 'notify', 'notifyAll'
|
||||
}
|
||||
|
||||
public void testPreferBetterMatchingConstantToMethods() {
|
||||
checkPreferredItems 0, 'serial', 'superExpressionInIllegalContext'
|
||||
}
|
||||
|
||||
public void testJComponentAddNewWithStats() throws Throwable {
|
||||
final LookupImpl lookup = invokeCompletion("/../smartTypeSorting/JComponentAddNew.java");
|
||||
assertPreferredItems(0, "FooBean3", "JComponent", "Component");
|
||||
incUseCount(lookup, 2); //Component
|
||||
assertPreferredItems(0, "Component", "FooBean3", "JComponent");
|
||||
}
|
||||
|
||||
public void testDispreferReturnBeforeStatement() {
|
||||
checkPreferredItems 0, 'reaction', 'rezet', 'return'
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -1339,6 +1339,7 @@ public class ListUtils {
|
||||
public void testInterfaceImplementationNoCast() { doTest() }
|
||||
public void testStaticallyImportedMethodsBeforeExpression() { doTest() }
|
||||
public void testInnerChainedReturnType() { doTest() }
|
||||
public void testOverwriteGenericsAfterNew() { doTest('\n') }
|
||||
|
||||
private CommonCodeStyleSettings getCodeStyleSettings() {
|
||||
return CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE);
|
||||
|
||||
+43
-165
@@ -57,126 +57,36 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
};
|
||||
}
|
||||
|
||||
public void testAllJava15Features() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testEnumSyntheticMethods() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDuplicateAnnotations() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testSwitchByString() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testSwitchByInaccessibleEnum() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondPos1() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondPos2() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondPos3() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondPos4() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondPos5() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
|
||||
public void testDiamondPos6() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondPos7() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg15() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondPos9() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg1() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg2() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg3() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg4() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg5() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg6() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg7() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg8() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg9() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg10() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg11() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg12() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg13() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondNeg14() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondMisc() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testHighlightInaccessibleFromClassModifierList() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
public void testAllJava15Features() throws Exception { doTest(false, false); }
|
||||
public void testEnumSyntheticMethods() throws Exception { doTest(false, false); }
|
||||
public void testDuplicateAnnotations() throws Exception { doTest(false, false); }
|
||||
public void testSwitchByString() throws Exception { doTest(false, false); }
|
||||
public void testSwitchByInaccessibleEnum() throws Exception { doTest(false, false); }
|
||||
public void testDiamondPos1() throws Exception { doTest(false, false); }
|
||||
public void testDiamondPos2() throws Exception { doTest(false, false); }
|
||||
public void testDiamondPos3() throws Exception { doTest(false, false); }
|
||||
public void testDiamondPos4() throws Exception { doTest(false, false); }
|
||||
public void testDiamondPos5() throws Exception { doTest(false, false); }
|
||||
public void testDiamondPos6() throws Exception { doTest(false, false); }
|
||||
public void testDiamondPos7() throws Exception { doTest(false, false); }
|
||||
public void testDiamondNeg15() throws Exception { doTest(false, false); }
|
||||
public void testDiamondPos9() throws Exception { doTest(false, false); }
|
||||
public void testDiamondNeg1() throws Exception { doTest(false, false); }
|
||||
public void testDiamondNeg2() throws Exception { doTest(false, false); }
|
||||
public void testDiamondNeg3() throws Exception { doTest(false, false); }
|
||||
public void testDiamondNeg4() throws Exception { doTest(false, false); }
|
||||
public void testDiamondNeg5() throws Exception { doTest(false, false); }
|
||||
public void testDiamondNeg6() throws Exception { doTest(false, false); }
|
||||
public void testDiamondNeg7() throws Exception { doTest(false, false); }
|
||||
public void testDiamondNeg8() throws Exception { doTest(false, false); }
|
||||
public void testDiamondNeg9() throws Exception { doTest(false, false); }
|
||||
public void testDiamondNeg10() throws Exception { doTest(false, false); }
|
||||
public void testDiamondNeg11() throws Exception { doTest(false, false); }
|
||||
public void testDiamondNeg12() throws Exception { doTest(false, false); }
|
||||
public void testDiamondNeg13() throws Exception { doTest(false, false); }
|
||||
public void testDiamondNeg14() throws Exception { doTest(false, false); }
|
||||
public void testDiamondMisc() throws Exception { doTest(false, false); }
|
||||
public void testHighlightInaccessibleFromClassModifierList() throws Exception { doTest(false, false); }
|
||||
|
||||
public void testDynamicallyAddIgnoredAnnotations() throws Exception {
|
||||
ExtensionPoint<EntryPoint> point = Extensions.getRootArea().getExtensionPoint(ExtensionPoints.DEAD_CODE_TOOL);
|
||||
@@ -242,46 +152,21 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testNumericLiterals() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testMultiCatch() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testTryWithResources() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
public void testNumericLiterals() throws Exception { doTest(false, false); }
|
||||
public void testMultiCatch() throws Exception { doTest(false, false); }
|
||||
public void testTryWithResources() throws Exception { doTest(false, false); }
|
||||
|
||||
public void testTryWithResourcesWarn() throws Exception {
|
||||
enableInspectionTool(new DefUseInspection());
|
||||
doTest(true, false);
|
||||
}
|
||||
|
||||
public void testSafeVarargsApplicability() throws Exception {
|
||||
doTest(true, false);
|
||||
}
|
||||
|
||||
public void testUncheckedGenericsArrayCreation() throws Exception {
|
||||
doTest(true, false);
|
||||
}
|
||||
|
||||
public void testPreciseRethrow() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testImprovedCatchAnalysis() throws Exception {
|
||||
doTest(true, false);
|
||||
}
|
||||
|
||||
public void testJavacQuirks() throws Exception {
|
||||
doTest(true, false);
|
||||
}
|
||||
|
||||
public void testPolymorphicTypeCast() throws Exception {
|
||||
doTest(true, false);
|
||||
}
|
||||
public void testSafeVarargsApplicability() throws Exception { doTest(true, false); }
|
||||
public void testUncheckedGenericsArrayCreation() throws Exception { doTest(true, false); }
|
||||
public void testPreciseRethrow() throws Exception { doTest(false, false); }
|
||||
public void testImprovedCatchAnalysis() throws Exception { doTest(true, false); }
|
||||
public void testJavacQuirks() throws Exception { doTest(true, false); }
|
||||
public void testPolymorphicTypeCast() throws Exception { doTest(true, false); }
|
||||
|
||||
public void testErasureClashConfusion() throws Exception {
|
||||
enableInspectionTool(new UnusedDeclarationInspection());
|
||||
@@ -293,16 +178,9 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
doTest(true, false);
|
||||
}
|
||||
|
||||
public void testSuperBound() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testExtendsBound() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testSuperBound() throws Exception { doTest(false, false); }
|
||||
public void testExtendsBound() throws Exception { doTest(false, false); }
|
||||
public void testIDEA84533() throws Exception { doTest(false, false); }
|
||||
|
||||
public void testClassLiteral() throws Exception { doTest(false, false);}
|
||||
public void testClassLiteral() throws Exception { doTest(false, false); }
|
||||
public void testExtensionMethods() throws Exception { doTest(false, false); }
|
||||
}
|
||||
|
||||
|
||||
@@ -174,6 +174,7 @@ class Test {
|
||||
class Test {
|
||||
void test() {
|
||||
new Runnable() {
|
||||
static final long serialVersionUID = 42L;
|
||||
public void run() {
|
||||
System.out.println(<caret>);
|
||||
}
|
||||
@@ -195,6 +196,23 @@ class Test {
|
||||
assert closureStartFold
|
||||
}
|
||||
|
||||
public void "test no closure folding when the method throws an unresolved exception"() {
|
||||
def text = """\
|
||||
class Test {
|
||||
void test() { new Runnable() {
|
||||
public void run() throws Asadfsdafdfasd {
|
||||
System.out.println(<caret>);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
configure text
|
||||
def foldingModel = myFixture.editor.foldingModel as FoldingModelImpl
|
||||
assert !foldingModel.getCollapsedRegionAtOffset(text.indexOf("Runnable"))
|
||||
}
|
||||
|
||||
public void testFindInFolding() {
|
||||
def text = """\
|
||||
class Test {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -32,7 +32,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.io.File;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
|
||||
public class JavaStubBuilderTest extends LightIdeaTestCase {
|
||||
private static final StubBuilder NEW_BUILDER = new JavaLightStubBuilder();
|
||||
|
||||
@@ -40,7 +39,7 @@ public class JavaStubBuilderTest extends LightIdeaTestCase {
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
doTest("@interface A { int i() default 42; }\n class C { void m(int p) throws E { } }", null); // warm up
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.HIGHEST);
|
||||
}
|
||||
|
||||
public void testEmpty() {
|
||||
@@ -112,6 +111,10 @@ public class JavaStubBuilderTest extends LightIdeaTestCase {
|
||||
" public C() throws Exception { }\n" +
|
||||
" public abstract void m(final int i, int[] a1, int a2[], int[] a3[]);\n" +
|
||||
" private static int v2a(int... v) [] { return v; }\n" +
|
||||
"}\n" +
|
||||
"interface I {\n" +
|
||||
" void m1();\n" +
|
||||
" void m2() default { }\n" +
|
||||
"}",
|
||||
|
||||
"PsiJavaFileStub []\n" +
|
||||
@@ -160,6 +163,21 @@ public class JavaStubBuilderTest extends LightIdeaTestCase {
|
||||
" PARAMETER_LIST:PsiParameterListStub\n" +
|
||||
" PARAMETER:PsiParameterStub[v:int...]\n" +
|
||||
" MODIFIER_LIST:PsiModifierListStub[mask=4096]\n" +
|
||||
" THROWS_LIST:PsiRefListStub[THROWS_LIST:]\n" +
|
||||
" CLASS:PsiClassStub[interface name=I fqn=I]\n" +
|
||||
" MODIFIER_LIST:PsiModifierListStub[mask=5120]\n" +
|
||||
" TYPE_PARAMETER_LIST:PsiTypeParameterListStub\n" +
|
||||
" EXTENDS_LIST:PsiRefListStub[EXTENDS_LIST:]\n" +
|
||||
" IMPLEMENTS_LIST:PsiRefListStub[IMPLEMENTS_LIST:]\n" +
|
||||
" METHOD:PsiMethodStub[m1:void]\n" +
|
||||
" MODIFIER_LIST:PsiModifierListStub[mask=1025]\n" +
|
||||
" TYPE_PARAMETER_LIST:PsiTypeParameterListStub\n" +
|
||||
" PARAMETER_LIST:PsiParameterListStub\n" +
|
||||
" THROWS_LIST:PsiRefListStub[THROWS_LIST:]\n" +
|
||||
" METHOD:PsiMethodStub[m2:void default {}]\n" +
|
||||
" MODIFIER_LIST:PsiModifierListStub[mask=1]\n" +
|
||||
" TYPE_PARAMETER_LIST:PsiTypeParameterListStub\n" +
|
||||
" PARAMETER_LIST:PsiParameterListStub\n" +
|
||||
" THROWS_LIST:PsiRefListStub[THROWS_LIST:]\n");
|
||||
}
|
||||
|
||||
@@ -393,7 +411,7 @@ public class JavaStubBuilderTest extends LightIdeaTestCase {
|
||||
final String lightStr2 = DebugUtil.stubTreeToString(lighterTree2);
|
||||
if (tree != null) {
|
||||
System.out.println("light=" + t1 + "mks, heavy=" + t2 + "mks");
|
||||
if (!"".equals(tree)) {
|
||||
if (!tree.isEmpty()) {
|
||||
assertEquals("light tree differs", tree, lightStr);
|
||||
assertEquals("light tree (2nd) differs", tree, lightStr2);
|
||||
}
|
||||
|
||||
+1
-6
@@ -74,18 +74,13 @@ public class IntroduceVariableMultifileTest extends MultiFileTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public void testDummy() {
|
||||
|
||||
}
|
||||
|
||||
PerformAction createAction(final String className, final IntroduceVariableBase testMe) {
|
||||
return new PerformAction() {
|
||||
@Override
|
||||
public void performAction(VirtualFile vroot, VirtualFile rootAfter) {
|
||||
final JavaPsiFacade psiManager = getJavaFacade();
|
||||
final PsiClass aClass = psiManager.findClass(className, GlobalSearchScope.allScope(myProject));
|
||||
assertTrue(aClass != null);
|
||||
assertTrue(className + " class not found", aClass != null);
|
||||
final PsiFile containingFile = aClass.getContainingFile();
|
||||
final VirtualFile virtualFile = containingFile.getVirtualFile();
|
||||
assertTrue(virtualFile != null);
|
||||
|
||||
+1
-4
@@ -53,10 +53,7 @@ public class BaseGenerateAction extends CodeInsightAction {
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
|
||||
PsiClass targetClass = getTargetClass(editor, file);
|
||||
if (targetClass == null) return false;
|
||||
if (!isValidForClass(targetClass)) return false; //?
|
||||
|
||||
return true;
|
||||
return targetClass != null && isValidForClass(targetClass);
|
||||
}
|
||||
|
||||
protected boolean isValidForClass(final PsiClass targetClass) {
|
||||
|
||||
@@ -477,7 +477,7 @@ final class BuildSession implements Runnable, CanceledStatus {
|
||||
final String loadPath = isDirectoryBased(projectFile) ? new File(projectFile, IDEA_PROJECT_DIRNAME).getPath() : projectPath;
|
||||
IdeaProjectLoader.loadFromPath(project, loadPath, myPathVars, null, new SystemOutErrorReporter(false));
|
||||
final String globalEncoding = myGlobalEncoding;
|
||||
if (globalEncoding != null && project.getProjectCharset() == null) {
|
||||
if (!StringUtil.isEmpty(globalEncoding) && project.getProjectCharset() == null) {
|
||||
project.setProjectCharset(globalEncoding);
|
||||
}
|
||||
project.getIgnoredFilePatterns().loadFromString(myIgnorePatterns);
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.execution;
|
||||
import com.intellij.execution.configurations.ConfigurationFactory;
|
||||
import com.intellij.execution.configurations.ConfigurationType;
|
||||
import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.execution.configurations.RunProfile;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -45,7 +46,7 @@ public abstract class RunManager {
|
||||
|
||||
public abstract boolean isTemporary(@NotNull RunConfiguration configuration);
|
||||
|
||||
public abstract void makeStable(@Nullable RunConfiguration configuration);
|
||||
public abstract void makeStable(@NotNull RunConfiguration configuration);
|
||||
|
||||
@Nullable
|
||||
public abstract RunnerAndConfigurationSettings getSelectedConfiguration();
|
||||
@@ -58,4 +59,7 @@ public abstract class RunManager {
|
||||
|
||||
@NotNull
|
||||
public abstract RunnerAndConfigurationSettings[] getConfigurationSettings(@NotNull ConfigurationType type);
|
||||
|
||||
public abstract void refreshUsagesList(RunProfile profile);
|
||||
|
||||
}
|
||||
|
||||
@@ -75,6 +75,11 @@ public abstract class GenericProgramRunner<Settings extends JDOMExternalizable>
|
||||
return;
|
||||
}
|
||||
|
||||
RunnerSettings runnerSettings = env.getRunnerSettings();
|
||||
if (runnerSettings != null) {
|
||||
RunManager.getInstance(project).refreshUsagesList(runnerSettings.getRunProfile());
|
||||
}
|
||||
|
||||
ExecutionManager.getInstance(project).startRunProfile(new RunProfileStarter() {
|
||||
@Override
|
||||
public RunContentDescriptor execute(@NotNull Project project,
|
||||
|
||||
+5
@@ -47,4 +47,9 @@ public class CodeCompletionGroup extends DefaultActionGroup implements DumbAware
|
||||
|
||||
presentation.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableIfNoVisibleChildren() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,9 +186,10 @@ public class RunConfigurationAction extends ComboBoxAction implements DumbAware
|
||||
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
final Project project = e.getData(PlatformDataKeys.PROJECT);
|
||||
if (project != null) {
|
||||
RunConfiguration configuration = chooseTempConfiguration(project);
|
||||
if (project != null && configuration != null) {
|
||||
final RunManager runManager = RunManager.getInstance(project);
|
||||
runManager.makeStable(chooseTempConfiguration(project));
|
||||
runManager.makeStable(configuration);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ public class ProjectRunConfigurationManager implements ProjectComponent, Persist
|
||||
}
|
||||
|
||||
if (configuration != null) {
|
||||
existing.add(RunManagerImpl.getUniqueName(configuration));
|
||||
existing.add(RunManagerImpl.getUniqueName(configuration.getConfiguration()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,10 +54,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import javax.swing.tree.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@@ -518,7 +515,19 @@ class RunConfigurable extends BaseConfigurable {
|
||||
updateActiveConfigurationFromSelected();
|
||||
|
||||
final RunManagerImpl manager = getRunManager();
|
||||
final ConfigurationType[] configurationTypes = manager.getConfigurationFactories();
|
||||
final ConfigurationType[] types = manager.getConfigurationFactories();
|
||||
List<ConfigurationType> configurationTypes = new ArrayList<ConfigurationType>();
|
||||
for (int i = 0; i < myRoot.getChildCount(); i++) {
|
||||
final DefaultMutableTreeNode node = (DefaultMutableTreeNode)myRoot.getChildAt(i);
|
||||
if (node.getUserObject() instanceof ConfigurationType) {
|
||||
configurationTypes.add((ConfigurationType)node.getUserObject());
|
||||
}
|
||||
}
|
||||
for (ConfigurationType type : types) {
|
||||
if (!configurationTypes.contains(type))
|
||||
configurationTypes.add(type);
|
||||
}
|
||||
|
||||
for (ConfigurationType configurationType : configurationTypes) {
|
||||
applyByType(configurationType);
|
||||
}
|
||||
@@ -1092,6 +1101,23 @@ class RunConfigurable extends BaseConfigurable {
|
||||
final RunnerAndConfigurationSettings originalConfiguration = configurationConfigurable.getSettings();
|
||||
if (getRunManager().isTemporary(originalConfiguration)) {
|
||||
getRunManager().makeStable(originalConfiguration.getConfiguration());
|
||||
final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)myTree.getSelectionPath().getLastPathComponent();
|
||||
MutableTreeNode parent = (MutableTreeNode)treeNode.getParent();
|
||||
int initialPosition = parent.getIndex(treeNode);
|
||||
int position = parent.getIndex(treeNode);
|
||||
DefaultMutableTreeNode node = treeNode.getPreviousSibling();
|
||||
while (node != null) {
|
||||
RunnerAndConfigurationSettings settings = getSettings(node);
|
||||
if (settings != null && settings.isTemporary()) {
|
||||
position--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
node = node.getPreviousSibling();
|
||||
}
|
||||
for (int i = 0; i < initialPosition - position; i++) {
|
||||
TreeUtil.moveSelectedRow(myTree, -1);
|
||||
}
|
||||
}
|
||||
myTree.repaint();
|
||||
}
|
||||
@@ -1139,20 +1165,20 @@ class RunConfigurable extends BaseConfigurable {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private RunnerAndConfigurationSettings getSettings(DefaultMutableTreeNode treeNode) {
|
||||
if (treeNode == null)
|
||||
return null;
|
||||
RunnerAndConfigurationSettings settings = null;
|
||||
if (treeNode.getUserObject() instanceof SingleConfigurationConfigurable) {
|
||||
settings = (RunnerAndConfigurationSettings)((SingleConfigurationConfigurable)treeNode.getUserObject()).getSettings();
|
||||
}
|
||||
if (treeNode.getUserObject() instanceof RunnerAndConfigurationSettings) {
|
||||
settings = (RunnerAndConfigurationSettings)treeNode.getUserObject();
|
||||
}
|
||||
return settings;
|
||||
@Nullable
|
||||
private static RunnerAndConfigurationSettings getSettings(DefaultMutableTreeNode treeNode) {
|
||||
if (treeNode == null)
|
||||
return null;
|
||||
RunnerAndConfigurationSettings settings = null;
|
||||
if (treeNode.getUserObject() instanceof SingleConfigurationConfigurable) {
|
||||
settings = (RunnerAndConfigurationSettings)((SingleConfigurationConfigurable)treeNode.getUserObject()).getSettings();
|
||||
}
|
||||
if (treeNode.getUserObject() instanceof RunnerAndConfigurationSettings) {
|
||||
settings = (RunnerAndConfigurationSettings)treeNode.getUserObject();
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
private static class RunConfigurationBean {
|
||||
|
||||
@@ -59,6 +59,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
|
||||
@NonNls
|
||||
protected static final String CONFIGURATION = "configuration";
|
||||
protected static final String RECENT = "recent_temporary";
|
||||
private ConfigurationType[] myTypes;
|
||||
private final RunManagerConfig myConfig;
|
||||
@NonNls
|
||||
@@ -70,6 +71,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
|
||||
private List<Element> myUnknownElements = null;
|
||||
private JDOMExternalizableStringList myOrder = new JDOMExternalizableStringList();
|
||||
private final ArrayList<RunConfiguration> myRecentlyUsedTemporaries = new ArrayList<RunConfiguration>();
|
||||
private boolean myOrdered = true;
|
||||
|
||||
private final EventDispatcher<RunManagerListener> myDispatcher = EventDispatcher.create(RunManagerListener.class);
|
||||
@@ -243,7 +245,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
List<BeforeRunTask> tasks, boolean addEnabledTemplateTasksIfAbsent) {
|
||||
final RunConfiguration configuration = settings.getConfiguration();
|
||||
|
||||
Integer existingId = findConfigurationIdByUniqueName(getUniqueName(settings));
|
||||
Integer existingId = findConfigurationIdByUniqueName(getUniqueName(configuration));
|
||||
Integer newId = configuration.getUniqueID();
|
||||
RunnerAndConfigurationSettings existingSettings = null;
|
||||
|
||||
@@ -252,14 +254,17 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
mySharedConfigurations.remove(existingId);
|
||||
}
|
||||
|
||||
if (mySelectedConfigurationId != null && mySelectedConfigurationId.equals(existingId)) setSelectedConfigurationId(newId);
|
||||
if (mySelectedConfigurationId != null && mySelectedConfigurationId.equals(existingId)) {
|
||||
setSelectedConfigurationId(newId);
|
||||
}
|
||||
myConfigurations.put(newId, settings);
|
||||
if (existingId == null) {
|
||||
refreshUsagesList(configuration);
|
||||
}
|
||||
checkRecentsLimit();
|
||||
|
||||
mySharedConfigurations.put(newId, shared);
|
||||
setBeforeRunTasks(configuration, tasks, addEnabledTemplateTasksIfAbsent);
|
||||
saveOrder();
|
||||
myOrdered = false;
|
||||
|
||||
if (existingSettings == settings) {
|
||||
myDispatcher.getMulticaster().runConfigurationChanged(settings);
|
||||
@@ -269,12 +274,23 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshUsagesList(RunProfile profile) {
|
||||
if (profile instanceof RunConfiguration && isTemporary((RunConfiguration)profile)) {
|
||||
myRecentlyUsedTemporaries.remove((RunConfiguration)profile);
|
||||
myRecentlyUsedTemporaries.add(0, (RunConfiguration)profile);
|
||||
while(myRecentlyUsedTemporaries.size() > getConfig().getRecentsLimit()) {
|
||||
myRecentlyUsedTemporaries.remove(myRecentlyUsedTemporaries.size() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void checkRecentsLimit() {
|
||||
List<RunnerAndConfigurationSettings> removed = new ArrayList<RunnerAndConfigurationSettings>();
|
||||
while (getTempConfigurations().length > getConfig().getRecentsLimit()) {
|
||||
for (Iterator<Map.Entry<Integer, RunnerAndConfigurationSettings>> it = myConfigurations.entrySet().iterator(); it.hasNext(); ) {
|
||||
Map.Entry<Integer, RunnerAndConfigurationSettings> entry = it.next();
|
||||
if (entry.getValue().isTemporary()) {
|
||||
if (entry.getValue().isTemporary() && !myRecentlyUsedTemporaries.contains(entry.getValue().getConfiguration())) {
|
||||
removed.add(entry.getValue());
|
||||
it.remove();
|
||||
break;
|
||||
@@ -292,13 +308,12 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
myOrder.clear();
|
||||
for (RunnerAndConfigurationSettings each : myConfigurations.values()) {
|
||||
if (each.getType() instanceof UnknownConfigurationType) continue;
|
||||
myOrder.add(getUniqueName(each));
|
||||
myOrder.add(getUniqueName(each.getConfiguration()));
|
||||
}
|
||||
}
|
||||
|
||||
static String getUniqueName(@NotNull RunnerAndConfigurationSettings settings) {
|
||||
RunConfiguration config = settings.getConfiguration();
|
||||
return config.getType().getDisplayName() + "." + settings.getName() +
|
||||
static String getUniqueName(@NotNull RunConfiguration config) {
|
||||
return config.getType().getDisplayName() + "." + config.getName() +
|
||||
(config instanceof UnknownRunConfiguration ? config.getUniqueID() : "");
|
||||
}
|
||||
|
||||
@@ -348,7 +363,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
List<Pair<String, RunnerAndConfigurationSettings>> order
|
||||
= new ArrayList<Pair<String, RunnerAndConfigurationSettings>>(myConfigurations.size());
|
||||
for (RunnerAndConfigurationSettings each : myConfigurations.values()) {
|
||||
order.add(Pair.create(getUniqueName(each), each));
|
||||
order.add(Pair.create(getUniqueName(each.getConfiguration()), each));
|
||||
}
|
||||
myConfigurations.clear();
|
||||
|
||||
@@ -428,11 +443,20 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
//temp && stable configurations, !unknown
|
||||
for (RunnerAndConfigurationSettings each : myConfigurations.values()) {
|
||||
if (each.getType() instanceof UnknownConfigurationType) continue;
|
||||
order.add(getUniqueName(each));
|
||||
order.add(getUniqueName(each.getConfiguration()));
|
||||
}
|
||||
|
||||
order.writeExternal(parentNode);
|
||||
|
||||
final JDOMExternalizableStringList recentList = new JDOMExternalizableStringList();
|
||||
for (RunConfiguration each : myRecentlyUsedTemporaries) {
|
||||
if (each.getType() instanceof UnknownConfigurationType) continue;
|
||||
recentList.add(getUniqueName(each));
|
||||
}
|
||||
final Element recent = new Element(RECENT);
|
||||
parentNode.addContent(recent);
|
||||
recentList.writeExternal(recent);
|
||||
|
||||
if (myUnknownElements != null) {
|
||||
for (Element unloadedElement : myUnknownElements) {
|
||||
parentNode.addContent((Element)unloadedElement.clone());
|
||||
@@ -448,7 +472,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
}
|
||||
RunnerAndConfigurationSettings selected = getSelectedConfiguration();
|
||||
if (selected != null) {
|
||||
parentNode.setAttribute(SELECTED_ATTR, getUniqueName(selected));
|
||||
parentNode.setAttribute(SELECTED_ATTR, getUniqueName(selected.getConfiguration()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,6 +557,18 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
}
|
||||
|
||||
myOrder.readExternal(parentNode);
|
||||
myRecentlyUsedTemporaries.clear();
|
||||
Element recentNode = parentNode.getChild(RECENT);
|
||||
if (recentNode != null) {
|
||||
JDOMExternalizableStringList list = new JDOMExternalizableStringList();
|
||||
list.readExternal(recentNode);
|
||||
for (String name : list) {
|
||||
Integer id = findConfigurationIdByUniqueName(name);
|
||||
if (id != null) {
|
||||
myRecentlyUsedTemporaries.add(myConfigurations.get(id).getConfiguration());
|
||||
}
|
||||
}
|
||||
}
|
||||
myOrdered = false;
|
||||
|
||||
myLoadedSelectedConfigurationUniqueName = parentNode.getAttributeValue(SELECTED_ATTR);
|
||||
@@ -551,7 +587,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
if (myLoadedSelectedConfigurationUniqueName == null
|
||||
&& config != null
|
||||
&& Boolean.valueOf(element.getAttributeValue(SELECTED_ATTR)).booleanValue()) {
|
||||
myLoadedSelectedConfigurationUniqueName = getUniqueName(config);
|
||||
myLoadedSelectedConfigurationUniqueName = getUniqueName(config.getConfiguration());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -564,7 +600,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
private Integer findConfigurationIdByUniqueName(@Nullable String selectedUniqueName) {
|
||||
if (selectedUniqueName != null) {
|
||||
for (RunnerAndConfigurationSettings each : myConfigurations.values()) {
|
||||
if (selectedUniqueName.equals(getUniqueName(each))) {
|
||||
if (selectedUniqueName.equals(getUniqueName(each.getConfiguration()))) {
|
||||
return each.getConfiguration().getUniqueID();
|
||||
}
|
||||
}
|
||||
@@ -589,6 +625,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
mySelectedConfigurationId = null;
|
||||
myLoadedSelectedConfigurationUniqueName = null;
|
||||
myIdToIcon.clear();
|
||||
myRecentlyUsedTemporaries.clear();
|
||||
fireRunConfigurationsRemoved(configurations);
|
||||
}
|
||||
|
||||
@@ -728,11 +765,13 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
return configurations.toArray(new RunConfiguration[configurations.size()]);
|
||||
}
|
||||
|
||||
public void makeStable(@Nullable RunConfiguration configuration) {
|
||||
public void makeStable(@NotNull RunConfiguration configuration) {
|
||||
RunnerAndConfigurationSettings settings = getSettings(configuration);
|
||||
if (settings != null) {
|
||||
invalidateConfigurationIcon(settings);
|
||||
settings.setTemporary(false);
|
||||
myRecentlyUsedTemporaries.remove(configuration);
|
||||
setOrdered(false);
|
||||
fireRunConfigurationChanged(settings);
|
||||
}
|
||||
}
|
||||
@@ -926,11 +965,11 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
void removeNotExistingSharedConfigurations(final Set<String> existing) {
|
||||
List<RunnerAndConfigurationSettings> removed = new ArrayList<RunnerAndConfigurationSettings>();
|
||||
for (Iterator<Map.Entry<Integer, RunnerAndConfigurationSettings>> it = myConfigurations.entrySet().iterator(); it.hasNext(); ) {
|
||||
Map.Entry<Integer, RunnerAndConfigurationSettings> c = it.next();
|
||||
final RunnerAndConfigurationSettings o = c.getValue();
|
||||
if (!o.isTemplate() && isConfigurationShared(o) && !existing.contains(getUniqueName(o))) {
|
||||
removed.add(o);
|
||||
invalidateConfigurationIcon(o);
|
||||
Map.Entry<Integer, RunnerAndConfigurationSettings> entry = it.next();
|
||||
final RunnerAndConfigurationSettings settings = entry.getValue();
|
||||
if (!settings.isTemplate() && isConfigurationShared(settings) && !existing.contains(getUniqueName(settings.getConfiguration()))) {
|
||||
removed.add(settings);
|
||||
invalidateConfigurationIcon(settings);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
@@ -938,13 +977,12 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
}
|
||||
|
||||
public void fireRunConfigurationChanged(@NotNull RunnerAndConfigurationSettings settings) {
|
||||
myOrdered = false;
|
||||
invalidateConfigurationIcon(settings);
|
||||
myDispatcher.getMulticaster().runConfigurationChanged(settings);
|
||||
}
|
||||
|
||||
private void fireRunConfigurationsRemoved(@NotNull List<RunnerAndConfigurationSettings> removed) {
|
||||
myOrdered = false;
|
||||
myRecentlyUsedTemporaries.removeAll(removed);
|
||||
for (RunnerAndConfigurationSettings settings : removed) {
|
||||
myDispatcher.getMulticaster().runConfigurationRemoved(settings);
|
||||
}
|
||||
|
||||
+16
-6
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
package com.intellij.formatting;
|
||||
|
||||
import com.intellij.diagnostic.LogMessageEx;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -85,12 +87,20 @@ public abstract class AbstractBlockAlignmentProcessor implements BlockAlignmentP
|
||||
// alignment of blocks located before them and post error every time we detect endless cycle.
|
||||
Set<LeafBlockWrapper> blocksCausedRealignment = context.backwardShiftedAlignedBlocks.get(offsetResponsibleBlock);
|
||||
if (blocksCausedRealignment != null && blocksCausedRealignment.contains(context.targetBlock)) {
|
||||
LOG.error(String.format("Please create dedicated ticket at the tracker with the content of the current editor attached%n%n"
|
||||
+ "Formatting error - code block %s is set to be shifted right because of its alignment with "
|
||||
+ "block %s more than once. I.e. moving the former block because of alignment algorithm causes "
|
||||
+ "subsequent block to be shifted right as well - cyclic dependency.%nDebug info: %s",
|
||||
offsetResponsibleBlock.getTextRange(), context.targetBlock.getTextRange(), context.targetBlock.getDebugInfo()
|
||||
));
|
||||
StringBuilder messageBuilder = new StringBuilder();
|
||||
TextRange targetRange = context.targetBlock.getTextRange();
|
||||
messageBuilder.append(
|
||||
String.format("Formatting error - code block %s is set to be shifted right because of its alignment with "
|
||||
+ "block %s more than once. I.e. moving the former block because of alignment algorithm causes "
|
||||
+ "subsequent block to be shifted right as well - cyclic dependency.",
|
||||
offsetResponsibleBlock.getTextRange(), targetRange
|
||||
));
|
||||
messageBuilder.append(context.targetBlock.getDebugInfo());
|
||||
messageBuilder.append("\nBlock content: '")
|
||||
.append(context.document.getText().substring(targetRange.getStartOffset(), targetRange.getEndOffset()))
|
||||
.append("'\n");
|
||||
messageBuilder.append("Note: document text is attached to this report.");
|
||||
LogMessageEx.error(LOG, messageBuilder.toString(), context.document.getText());
|
||||
blocksCausedRealignment.add(context.targetBlock);
|
||||
return Result.UNABLE_TO_ALIGN_BACKWARD_BLOCK;
|
||||
}
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.openapi.application;
|
||||
|
||||
import org.jdom.Attribute;
|
||||
|
||||
/**
|
||||
* Since SSR inspections can be stored in inspection profiles and loaded by users who don't have the SSR plugin installed, unfortunately
|
||||
* this must be in the platform and not in the SSR plugin.
|
||||
*
|
||||
* @author yole
|
||||
*/
|
||||
public class StructuralSearchPathMacroFilter extends PathMacroFilter {
|
||||
@Override
|
||||
public boolean skipPathMacros(Attribute attribute) {
|
||||
final String parentName = attribute.getParent().getName();
|
||||
if ("replaceConfiguration".equals(parentName) || "searchConfiguration".equals(parentName)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -378,7 +378,7 @@ public class FileReferenceSet {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Collection<PsiFileSystemItem> getAbsoluteTopLevelDirLocations(final @NotNull PsiFile file) {
|
||||
public static Collection<PsiFileSystemItem> getAbsoluteTopLevelDirLocations(final @NotNull PsiFile file) {
|
||||
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (virtualFile == null) {
|
||||
|
||||
@@ -129,8 +129,10 @@ public class SafeDeleteHandler implements RefactoringActionHandler {
|
||||
|
||||
};
|
||||
|
||||
SafeDeleteDialog dialog = new SafeDeleteDialog(project, elementsToDelete, callback);
|
||||
dialog.show();
|
||||
if (elementsToDelete.length > 0) {
|
||||
SafeDeleteDialog dialog = new SafeDeleteDialog(project, elementsToDelete, callback);
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,4 +188,8 @@ public abstract class ActionGroup extends AnAction {
|
||||
public boolean hideIfNoVisibleChildren() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean disableIfNoVisibleChildren() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,6 +320,17 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
|
||||
if (orientation == SwingConstants.VERTICAL) {
|
||||
return super.getScrollableUnitIncrement(visibleRect, orientation, direction);
|
||||
}
|
||||
else { // if orientation == SwingConstants.HORIZONTAL
|
||||
// use smooth editor-like scrolling
|
||||
return SwingUtilities.computeStringWidth(getFontMetrics(getFont()), " ");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doLayout() {
|
||||
super.doLayout();
|
||||
|
||||
@@ -93,8 +93,7 @@ public class TableView<Item> extends BaseTableView implements ItemsProvider, Sel
|
||||
int[] sizeMode = new int[columns.length];
|
||||
int[] headers = new int[columns.length];
|
||||
int[] widths = new int[columns.length];
|
||||
int fixedWidth = 0;
|
||||
int varWidth = 0;
|
||||
int allColumnWidth = 0;
|
||||
int varCount = 0;
|
||||
|
||||
// calculate
|
||||
@@ -132,18 +131,18 @@ public class TableView<Item> extends BaseTableView implements ItemsProvider, Sel
|
||||
widths[i] = getFontMetrics(getFont()).stringWidth(preferredValue) + columnInfo.getAdditionalWidth();
|
||||
varCount ++;
|
||||
}
|
||||
if (sizeMode[i] == 0) {
|
||||
fixedWidth += widths[i];
|
||||
}
|
||||
else {
|
||||
varWidth += widths[i];
|
||||
}
|
||||
allColumnWidth += widths[i];
|
||||
}
|
||||
|
||||
// apply: distribute available space between resizable columns but no more than *4 times.
|
||||
// apply: distribute available space between resizable columns
|
||||
// and make sure that header will fit as well
|
||||
int viewWidth = getParent() != null? getParent().getWidth() : getWidth();
|
||||
int addendum = varCount > 0 && viewWidth > fixedWidth + varWidth? (viewWidth - fixedWidth - varWidth) / varCount : 0;
|
||||
double gold = 0.5 * (3 - Math.sqrt(5));
|
||||
int addendum = varCount == 0 || viewWidth < allColumnWidth ?
|
||||
0 : (int)((allColumnWidth < gold * viewWidth ? gold * viewWidth :
|
||||
allColumnWidth < (1 - gold) * viewWidth ? (1 - gold) * viewWidth :
|
||||
viewWidth) - allColumnWidth) / varCount;
|
||||
|
||||
for (int i=0 ; i<columns.length; i ++) {
|
||||
TableColumn column = getColumnModel().getColumn(i);
|
||||
int width = widths[i];
|
||||
@@ -153,12 +152,12 @@ public class TableView<Item> extends BaseTableView implements ItemsProvider, Sel
|
||||
column.setMinWidth(width);
|
||||
}
|
||||
else if (sizeMode[i] == 2) {
|
||||
width = Math.max(width + Math.min(addendum, 4 * width), headers[i]);
|
||||
width = Math.max(width + addendum, headers[i]);
|
||||
column.setPreferredWidth(width);
|
||||
column.setMaxWidth(width);
|
||||
}
|
||||
else if (sizeMode[i] == 3) {
|
||||
width = Math.max(width + Math.min(addendum, 4 * width), headers[i]);
|
||||
width = Math.max(width + addendum, headers[i]);
|
||||
column.setPreferredWidth(width);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,7 @@ import com.intellij.ui.GuiUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
/**
|
||||
@@ -93,6 +91,14 @@ public class IOExceptionDialog extends JDialog {
|
||||
setLocation((parentSize.width - ownSize.width) / 2, (parentSize.height - ownSize.height) / 2);
|
||||
|
||||
pack();
|
||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
cancelPressed = true;
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -338,7 +338,7 @@ public class EditorHyperlinkSupport {
|
||||
action.consume(next);
|
||||
linkFollowed(editor, ranges, next);
|
||||
}
|
||||
}, i, ranges.size());
|
||||
}, newIndex == -1 ? -1 : newIndex + 1, ranges.size());
|
||||
}
|
||||
|
||||
// todo fix link followed here!
|
||||
|
||||
@@ -130,14 +130,14 @@ public class Utils{
|
||||
if (child instanceof ActionGroup) {
|
||||
ActionGroup actionGroup = (ActionGroup)child;
|
||||
if (actionGroup.isPopup()) { // popup menu has its own presentation
|
||||
// disable group if it contains no visible actions
|
||||
final boolean visibleChildren = hasVisibleChildren(actionGroup, presentationFactory, context, place);
|
||||
if (actionGroup.hideIfNoVisibleChildren() && !visibleChildren) {
|
||||
continue;
|
||||
}
|
||||
if (!actionGroup.canBePerformed(context) && !visibleChildren) {
|
||||
presentation.setEnabled(false);
|
||||
if (actionGroup.disableIfNoVisibleChildren()) {
|
||||
final boolean visibleChildren = hasVisibleChildren(actionGroup, presentationFactory, context, place);
|
||||
if (actionGroup.hideIfNoVisibleChildren() && !visibleChildren) {
|
||||
continue;
|
||||
}
|
||||
presentation.setEnabled(actionGroup.canBePerformed(context) || visibleChildren);
|
||||
}
|
||||
|
||||
list.add(child);
|
||||
}
|
||||
else {
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -86,7 +86,8 @@ public final class RequestFocusInEditorComponentCmd extends FinalizableCommand{
|
||||
return;
|
||||
}
|
||||
|
||||
if (owner instanceof IdeFrameImpl && IdeFrameImpl.getActiveFrame() != owner) {
|
||||
final Window activeFrame = IdeFrameImpl.getActiveFrame();
|
||||
if (activeFrame != null && owner instanceof IdeFrameImpl && activeFrame != owner) {
|
||||
myDoneCallback.setRejected();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -772,4 +772,5 @@
|
||||
order="first, before commitCompletion"/>
|
||||
|
||||
<pathMacroFilter implementation="com.intellij.execution.configuration.RunConfigurationPathMacroFilter"/>
|
||||
<pathMacroFilter implementation="com.intellij.openapi.application.StructuralSearchPathMacroFilter"/>
|
||||
</extensions>
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.intellij.execution.*;
|
||||
import com.intellij.execution.configurations.ConfigurationFactory;
|
||||
import com.intellij.execution.configurations.ConfigurationType;
|
||||
import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.execution.configurations.RunProfile;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -46,7 +47,7 @@ public class MockRunManager extends RunManagerEx {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeStable(RunConfiguration configuration) {
|
||||
public void makeStable(@NotNull RunConfiguration configuration) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -164,4 +165,8 @@ public class MockRunManager extends RunManagerEx {
|
||||
@Override
|
||||
public void removeRunManagerListener(RunManagerListener listener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshUsagesList(RunProfile profile) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,12 +52,12 @@ public class IdeaTextPatchBuilder {
|
||||
|
||||
for (VcsRoot root : byRoots.keySet()) {
|
||||
final Collection<Change> rootChanges = byRoots.get(root);
|
||||
if (root.vcs == null || root.vcs.getOutgoingChangesProvider() == null) {
|
||||
if (root.getVcs() == null || root.getVcs().getOutgoingChangesProvider() == null) {
|
||||
addConvertChanges(rootChanges, result);
|
||||
continue;
|
||||
}
|
||||
final VcsOutgoingChangesProvider<?> provider = root.vcs.getOutgoingChangesProvider();
|
||||
final Collection<Change> basedOnLocal = provider.filterLocalChangesBasedOnLocalCommits(rootChanges, root.path);
|
||||
final VcsOutgoingChangesProvider<?> provider = root.getVcs().getOutgoingChangesProvider();
|
||||
final Collection<Change> basedOnLocal = provider.filterLocalChangesBasedOnLocalCommits(rootChanges, root.getPath());
|
||||
rootChanges.removeAll(basedOnLocal);
|
||||
addConvertChanges(rootChanges, result);
|
||||
|
||||
|
||||
@@ -17,18 +17,31 @@
|
||||
package com.intellij.openapi.vcs;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class VcsRoot {
|
||||
public final AbstractVcs vcs;
|
||||
public final VirtualFile path;
|
||||
|
||||
@Nullable private final AbstractVcs myVcs;
|
||||
@Nullable private final VirtualFile myPath;
|
||||
|
||||
private int hashcode;
|
||||
|
||||
public VcsRoot(final AbstractVcs vcs, final VirtualFile path) {
|
||||
this.vcs = vcs;
|
||||
this.path = path;
|
||||
public VcsRoot(@Nullable AbstractVcs vcs, @Nullable VirtualFile path) {
|
||||
myVcs = vcs;
|
||||
myPath = path;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public AbstractVcs getVcs() {
|
||||
return myVcs;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public VirtualFile getPath() {
|
||||
return myPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,26 +51,22 @@ public class VcsRoot {
|
||||
|
||||
VcsRoot root = (VcsRoot)o;
|
||||
|
||||
if (path != null ? !path.equals(root.path) : root.path != null) return false;
|
||||
if (vcs != null ? !vcs.getName().equals(root.vcs.getName()) : root.vcs != null) return false;
|
||||
if (myPath != null ? !myPath.equals(root.myPath) : root.myPath != null) return false;
|
||||
if (myVcs != null ? !myVcs.equals(root.myVcs) : root.myVcs != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (hashcode == 0) {
|
||||
hashcode = vcs != null ? vcs.getName().hashCode() : 0;
|
||||
hashcode = 31 * hashcode + (path != null ? path.hashCode() : 0);
|
||||
hashcode = myVcs != null ? myVcs.hashCode() : 0;
|
||||
hashcode = 31 * hashcode + (myPath != null ? myPath.hashCode() : 0);
|
||||
}
|
||||
return hashcode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VcsRoot{" +
|
||||
"vcs=" + vcs +
|
||||
", path=" + path +
|
||||
'}';
|
||||
return String.format("VcsRoot{vcs=%s, path=%s}", myVcs, myPath);
|
||||
}
|
||||
}
|
||||
+15
-15
@@ -91,14 +91,14 @@ public class TriggerAdditionOrDeletion {
|
||||
if (myPreparedDeletion != null) {
|
||||
for (Map.Entry<VcsRoot, Collection<FilePath>> entry : myPreparedDeletion.entrySet()) {
|
||||
final VcsRoot vcsRoot = entry.getKey();
|
||||
final CheckinEnvironment localChangesProvider = vcsRoot.vcs.getCheckinEnvironment();
|
||||
final CheckinEnvironment localChangesProvider = vcsRoot.getVcs().getCheckinEnvironment();
|
||||
if (localChangesProvider == null) continue;
|
||||
final Collection<FilePath> filePaths = entry.getValue();
|
||||
if (vcsRoot.vcs.fileListenerIsSynchronous()) {
|
||||
if (vcsRoot.getVcs().fileListenerIsSynchronous()) {
|
||||
myAffected.addAll(filePaths);
|
||||
continue;
|
||||
}
|
||||
askUserIfNeededDeletion(vcsRoot.vcs, (List<FilePath>)filePaths);
|
||||
askUserIfNeededDeletion(vcsRoot.getVcs(), (List<FilePath>)filePaths);
|
||||
myAffected.addAll(filePaths);
|
||||
localChangesProvider.scheduleMissingFileForDeletion((List<FilePath>)filePaths);
|
||||
}
|
||||
@@ -106,14 +106,14 @@ public class TriggerAdditionOrDeletion {
|
||||
if (myPreparedAddition != null) {
|
||||
for (Map.Entry<VcsRoot, Collection<FilePath>> entry : myPreparedAddition.entrySet()) {
|
||||
final VcsRoot vcsRoot = entry.getKey();
|
||||
final CheckinEnvironment localChangesProvider = vcsRoot.vcs.getCheckinEnvironment();
|
||||
final CheckinEnvironment localChangesProvider = vcsRoot.getVcs().getCheckinEnvironment();
|
||||
if (localChangesProvider == null) continue;
|
||||
final Collection<FilePath> filePaths = entry.getValue();
|
||||
if (vcsRoot.vcs.fileListenerIsSynchronous()) {
|
||||
if (vcsRoot.getVcs().fileListenerIsSynchronous()) {
|
||||
myAffected.addAll(filePaths);
|
||||
continue;
|
||||
}
|
||||
askUserIfNeededAddition(vcsRoot.vcs, (List<FilePath>)filePaths);
|
||||
askUserIfNeededAddition(vcsRoot.getVcs(), (List<FilePath>)filePaths);
|
||||
myAffected.addAll(filePaths);
|
||||
localChangesProvider.scheduleUnversionedFilesForAddition(ObjectsConvertor.fp2vf(filePaths));
|
||||
}
|
||||
@@ -128,10 +128,10 @@ public class TriggerAdditionOrDeletion {
|
||||
final MultiMap<VcsRoot, FilePath> map = sortByVcsRoots.sort(myDeleted);
|
||||
myPreparedDeletion = new MultiMap<VcsRoot, FilePath>();
|
||||
for (VcsRoot vcsRoot : map.keySet()) {
|
||||
if (vcsRoot != null && vcsRoot.vcs != null) {
|
||||
final CheckinEnvironment localChangesProvider = vcsRoot.vcs.getCheckinEnvironment();
|
||||
if (vcsRoot != null && vcsRoot.getVcs() != null) {
|
||||
final CheckinEnvironment localChangesProvider = vcsRoot.getVcs().getCheckinEnvironment();
|
||||
if (localChangesProvider == null) continue;
|
||||
final boolean takeDirs = vcsRoot.vcs.areDirectoriesVersionedItems();
|
||||
final boolean takeDirs = vcsRoot.getVcs().areDirectoriesVersionedItems();
|
||||
|
||||
final Collection<FilePath> files = map.get(vcsRoot);
|
||||
final List<FilePath> toBeDeleted = new LinkedList<FilePath>();
|
||||
@@ -142,7 +142,7 @@ public class TriggerAdditionOrDeletion {
|
||||
}
|
||||
}
|
||||
if (toBeDeleted.isEmpty()) return;
|
||||
if (! vcsRoot.vcs.fileListenerIsSynchronous()) {
|
||||
if (! vcsRoot.getVcs().fileListenerIsSynchronous()) {
|
||||
for (FilePath filePath : toBeDeleted) {
|
||||
myVcsFileListenerContextHelper.ignoreDeleted(filePath);
|
||||
}
|
||||
@@ -159,15 +159,15 @@ public class TriggerAdditionOrDeletion {
|
||||
final MultiMap<VcsRoot, FilePath> map = sortByVcsRoots.sort(myExisting);
|
||||
myPreparedAddition = new MultiMap<VcsRoot, FilePath>();
|
||||
for (VcsRoot vcsRoot : map.keySet()) {
|
||||
if (vcsRoot != null && vcsRoot.vcs != null) {
|
||||
final CheckinEnvironment localChangesProvider = vcsRoot.vcs.getCheckinEnvironment();
|
||||
if (vcsRoot != null && vcsRoot.getVcs() != null) {
|
||||
final CheckinEnvironment localChangesProvider = vcsRoot.getVcs().getCheckinEnvironment();
|
||||
if (localChangesProvider == null) continue;
|
||||
final boolean takeDirs = vcsRoot.vcs.areDirectoriesVersionedItems();
|
||||
final boolean takeDirs = vcsRoot.getVcs().areDirectoriesVersionedItems();
|
||||
|
||||
final Collection<FilePath> files = map.get(vcsRoot);
|
||||
final List<FilePath> toBeAdded;
|
||||
if (takeDirs) {
|
||||
final RecursiveCheckAdder adder = new RecursiveCheckAdder(vcsRoot.path);
|
||||
final RecursiveCheckAdder adder = new RecursiveCheckAdder(vcsRoot.getPath());
|
||||
for (FilePath file : files) {
|
||||
adder.process(file);
|
||||
}
|
||||
@@ -184,7 +184,7 @@ public class TriggerAdditionOrDeletion {
|
||||
return;
|
||||
}
|
||||
Collections.sort(toBeAdded, FilePathByPathComparator.getInstance());
|
||||
if (! vcsRoot.vcs.fileListenerIsSynchronous()) {
|
||||
if (! vcsRoot.getVcs().fileListenerIsSynchronous()) {
|
||||
for (FilePath filePath : toBeAdded) {
|
||||
myVcsFileListenerContextHelper.ignoreAdded(filePath.getVirtualFile());
|
||||
}
|
||||
|
||||
@@ -58,13 +58,13 @@ public class DirtBuilder implements DirtBuilderReader {
|
||||
}
|
||||
|
||||
public void addDirtyFile(final VcsRoot root) {
|
||||
if (myFileTypeManager.isFileIgnored(root.path.getName())) return;
|
||||
myFiles.add(new FilePathUnderVcs(new FilePathImpl(root.path), root.vcs));
|
||||
if (myFileTypeManager.isFileIgnored(root.getPath().getName())) return;
|
||||
myFiles.add(new FilePathUnderVcs(new FilePathImpl(root.getPath()), root.getVcs()));
|
||||
}
|
||||
|
||||
public void addDirtyDirRecursively(final VcsRoot root) {
|
||||
if (myFileTypeManager.isFileIgnored(root.path.getName())) return;
|
||||
myDirs.add(new FilePathUnderVcs(new FilePathImpl(root.path), root.vcs));
|
||||
if (myFileTypeManager.isFileIgnored(root.getPath().getName())) return;
|
||||
myDirs.add(new FilePathUnderVcs(new FilePathImpl(root.getPath()), root.getVcs()));
|
||||
}
|
||||
|
||||
public void addDirtyFile(final FilePathUnderVcs root) {
|
||||
|
||||
@@ -33,8 +33,8 @@ public class FilePathUnderVcs {
|
||||
}
|
||||
|
||||
FilePathUnderVcs(final VcsRoot root) {
|
||||
myPath = new FilePathImpl(root.path);
|
||||
myVcs = root.vcs;
|
||||
myPath = new FilePathImpl(root.getPath());
|
||||
myVcs = root.getVcs();
|
||||
}
|
||||
|
||||
public FilePath getPath() {
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.openapi.vcs.changes;
|
||||
|
||||
import com.intellij.lifecycle.AtomicSectionsAware;
|
||||
import com.intellij.lifecycle.PeriodicalTasksCloser;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -128,7 +127,7 @@ public class RemoteRevisionsCache implements PlusMinus<Pair<String, AbstractVcs>
|
||||
final VcsRoot[] roots = myVcsManager.getAllVcsRoots();
|
||||
synchronized (myLock) {
|
||||
for (VcsRoot root : roots) {
|
||||
final AbstractVcs vcs = root.vcs;
|
||||
final AbstractVcs vcs = root.getVcs();
|
||||
if (! myKinds.containsKey(vcs.getName())) {
|
||||
myKinds.put(vcs.getName(), vcs.getRemoteDifferenceStrategy());
|
||||
}
|
||||
|
||||
+6
-6
@@ -96,8 +96,8 @@ public class RemoteRevisionsNumbersCache implements ChangesOnServerTracker {
|
||||
for (Iterator<Map.Entry<VcsRoot, LazyRefreshingSelfQueue>> iterator = copyMap.entrySet().iterator(); iterator.hasNext();) {
|
||||
final Map.Entry<VcsRoot, LazyRefreshingSelfQueue> entry = iterator.next();
|
||||
final VcsRoot key = entry.getKey();
|
||||
final boolean backgroundOperationsAllowed = key.vcs.isVcsBackgroundOperationsAllowed(key.path);
|
||||
LOG.debug("backgroundOperationsAllowed: " + backgroundOperationsAllowed + " for " + key.vcs.getName() + ", " + key.path.getPath());
|
||||
final boolean backgroundOperationsAllowed = key.getVcs().isVcsBackgroundOperationsAllowed(key.getPath());
|
||||
LOG.debug("backgroundOperationsAllowed: " + backgroundOperationsAllowed + " for " + key.getVcs().getName() + ", " + key.getPath().getPath());
|
||||
if (! backgroundOperationsAllowed) {
|
||||
iterator.remove();
|
||||
}
|
||||
@@ -232,7 +232,7 @@ public class RemoteRevisionsNumbersCache implements ChangesOnServerTracker {
|
||||
//todo check canceled - check VCS's ready for asynchronous queries
|
||||
final VirtualFile vf = myLfs.refreshAndFindFileByIoFile(new File(s));
|
||||
final ItemLatestState state;
|
||||
final DiffProvider diffProvider = myVcsRoot.vcs.getDiffProvider();
|
||||
final DiffProvider diffProvider = myVcsRoot.getVcs().getDiffProvider();
|
||||
if (vf == null) {
|
||||
// doesnt matter if directory or not
|
||||
state = diffProvider.getLastRevision(FilePathImpl.createForDeletedFile(new File(s), false));
|
||||
@@ -262,11 +262,11 @@ public class RemoteRevisionsNumbersCache implements ChangesOnServerTracker {
|
||||
}
|
||||
|
||||
public Boolean compute() {
|
||||
final AbstractVcs vcs = myVcsRoot.vcs;
|
||||
final AbstractVcs vcs = myVcsRoot.getVcs();
|
||||
// won't be called in parallel for same vcs -> just synchronized map is ok
|
||||
final String vcsName = vcs.getName();
|
||||
LOG.debug("should update for: " + vcsName + " root: " + myVcsRoot.path.getPath());
|
||||
final VcsRevisionNumber latestNew = vcs.getDiffProvider().getLatestCommittedRevision(myVcsRoot.path);
|
||||
LOG.debug("should update for: " + vcsName + " root: " + myVcsRoot.getPath().getPath());
|
||||
final VcsRevisionNumber latestNew = vcs.getDiffProvider().getLatestCommittedRevision(myVcsRoot.getPath());
|
||||
|
||||
final VcsRevisionNumber latestKnown = myLatestRevisionsMap.get(vcsName);
|
||||
// not known
|
||||
|
||||
+3
-3
@@ -135,12 +135,12 @@ public class RemoteRevisionsStateCache implements ChangesOnServerTracker {
|
||||
for (VcsRoot vcsRoot : dirty.keySet()) {
|
||||
// todo - actually it means nothing since the only known VCS to use this scheme is Git and now it always allow
|
||||
// todo - background operations. when it changes, develop more flexible behavior here
|
||||
if (! vcsRoot.vcs.isVcsBackgroundOperationsAllowed(vcsRoot.path)) continue;
|
||||
final TreeDiffProvider provider = vcsRoot.vcs.getTreeDiffProvider();
|
||||
if (! vcsRoot.getVcs().isVcsBackgroundOperationsAllowed(vcsRoot.getPath())) continue;
|
||||
final TreeDiffProvider provider = vcsRoot.getVcs().getTreeDiffProvider();
|
||||
if (provider == null) continue;
|
||||
|
||||
final Collection<String> paths = dirty.get(vcsRoot);
|
||||
final Collection<String> remotelyChanged = provider.getRemotelyChanged(vcsRoot.path, paths);
|
||||
final Collection<String> remotelyChanged = provider.getRemotelyChanged(vcsRoot.getPath(), paths);
|
||||
for (String path : paths) {
|
||||
results.put(path, new Pair<Boolean, VcsRoot>(remotelyChanged.contains(path), vcsRoot));
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.Processor;
|
||||
@@ -307,16 +308,16 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
|
||||
if (myProject.isDisposed()) return Boolean.FALSE;
|
||||
final VcsRoot rootObject = myVcsManager.getVcsRootObjectFor(path);
|
||||
if (vcsConsumer != null && rootObject != null) {
|
||||
vcsConsumer.consume(rootObject.vcs);
|
||||
vcsConsumer.consume(rootObject.getVcs());
|
||||
}
|
||||
if (rootObject == null || rootObject.vcs != myVcs) {
|
||||
if (rootObject == null || rootObject.getVcs() != myVcs) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
final VirtualFile vcsRoot = rootObject.path;
|
||||
final VirtualFile vcsRoot = rootObject.getPath();
|
||||
if (vcsRoot != null) {
|
||||
for (VirtualFile contentRoot : myAffectedContentRoots) {
|
||||
if (VfsUtil.isAncestor(contentRoot, vcsRoot, false)) {
|
||||
if (VfsUtilCore.isAncestor(contentRoot, vcsRoot, false)) {
|
||||
THashSet<FilePath> dirsByRoot = myDirtyDirectoriesRecursively.get(contentRoot);
|
||||
if (dirsByRoot != null) {
|
||||
for (FilePath filePath : dirsByRoot) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.openapi.vcs.changes.ChangesUtil;
|
||||
import com.intellij.openapi.vcs.changes.ContentRevision;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -87,9 +88,9 @@ public class LocalChangesUnderRoots {
|
||||
}
|
||||
VirtualFile rootCandidate = null;
|
||||
for (VcsRoot root : myRoots) {
|
||||
if (VfsUtil.isAncestor(root.path, vf, false)) {
|
||||
if (rootCandidate == null || VfsUtil.isAncestor(rootCandidate, root.path, true)) { // in the case of nested roots choose the closest root
|
||||
rootCandidate = root.path;
|
||||
if (VfsUtilCore.isAncestor(root.getPath(), vf, false)) {
|
||||
if (rootCandidate == null || VfsUtil.isAncestor(rootCandidate, root.getPath(), true)) { // in the case of nested roots choose the closest root
|
||||
rootCandidate = root.getPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,8 +92,8 @@ public class VcsRootIterator {
|
||||
final String ourPath = myRoot.getUrl();
|
||||
|
||||
for (VcsRoot root : allRoots) {
|
||||
if (Comparing.equal(root.vcs.getName(), myVcsName)) continue;
|
||||
final String url = root.path.getUrl();
|
||||
if (Comparing.equal(root.getVcs().getName(), myVcsName)) continue;
|
||||
final String url = root.getPath().getUrl();
|
||||
if (url.startsWith(ourPath)) {
|
||||
myExcludedByOtherVcss.add(url);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.siyeh;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
@@ -57,7 +58,7 @@ public class HardcodedMethodConstants {
|
||||
public static final String PRINT_STACK_TRACE = "printStackTrace";
|
||||
public static final String REMOVE = "remove";
|
||||
public static final String RUN = "run";
|
||||
public static final String SERIAL_VERSION_UID = "serialVersionUID";
|
||||
public static final String SERIAL_VERSION_UID = HighlightUtil.SERIAL_VERSION_UID_FIELD_NAME;
|
||||
public static final String SET = "set";
|
||||
public static final String SIZE = "size";
|
||||
public static final String STARTS_WITH = "startsWith";
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ class ConstantExpressionPredicate implements PsiElementPredicate {
|
||||
}
|
||||
final PsiPolyadicExpression expression = (PsiPolyadicExpression)element;
|
||||
final PsiType expressionType = expression.getType();
|
||||
if (expressionType.equalsToText("java.lang.String")) {
|
||||
if (expressionType == null || expressionType.equalsToText("java.lang.String")) {
|
||||
// intention disabled for string concatenations because of performance issues on
|
||||
// relatively common large string expressions.
|
||||
return false;
|
||||
|
||||
+2
-2
@@ -73,10 +73,10 @@ class ConstantSubexpressionPredicate implements PsiElementPredicate {
|
||||
if (currentToken == token) {
|
||||
final String binaryExpressionText = operands[i - 1].getText() + ' ' + token.getText() + ' ' + operand.getText();
|
||||
final PsiElementFactory factory = JavaPsiFacade.getElementFactory(expression.getProject());
|
||||
return (PsiBinaryExpression)factory.createExpressionFromText(binaryExpressionText, expression);
|
||||
return (PsiPolyadicExpression)factory.createExpressionFromText(binaryExpressionText, expression);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
private static boolean isPartOfLargerExpression(PsiPolyadicExpression expression) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<depends>com.intellij.ui-designer-new</depends>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<errorHandler implementation="com.intellij.diagnostic.ITNReporter"/>
|
||||
<fileEditorProvider implementation="com.intellij.android.designer.AndroidDesignerEditorProvider"/>
|
||||
|
||||
<projectService serviceInterface="com.intellij.android.designer.profile.ProfileList"
|
||||
|
||||
@@ -100,12 +100,16 @@ public class GitRepositoryManagerImpl extends AbstractProjectComponent implement
|
||||
public GitRepository getRepositoryForFile(@NotNull VirtualFile file) {
|
||||
final VcsRoot vcsRoot = myVcsManager.getVcsRootObjectFor(file);
|
||||
if (vcsRoot == null) { return null; }
|
||||
final AbstractVcs vcs = vcsRoot.vcs;
|
||||
final AbstractVcs vcs = vcsRoot.getVcs();
|
||||
if (!myVcs.equals(vcs)) {
|
||||
LOG.info(String.format("getRepositoryForFile returned non-Git (%s) root for file %s", vcs != null ? vcs.getDisplayName() : vcs, file));
|
||||
if (vcs != null) {
|
||||
// if null, the file is just not under version control, nothing interesting;
|
||||
// otherwise log, because Git method is requested not for a Git-controlled file
|
||||
LOG.info(String.format("getRepositoryForFile returned non-Git (%s) root for file %s", vcs.getDisplayName(), file));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return getRepositoryForRoot(vcsRoot.path);
|
||||
return getRepositoryForRoot(vcsRoot.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -114,7 +114,7 @@ abstract class GitChangesCollector {
|
||||
|
||||
protected void addToPaths(FilePath pathToAdd, List<String> paths) {
|
||||
VcsRoot fileRoot = myVcsManager.getVcsRootObjectFor(pathToAdd);
|
||||
if (fileRoot != null && fileRoot.vcs != null && fileRoot.vcs.equals(myVcs) && myVcsRoot.equals(fileRoot.path)) {
|
||||
if (fileRoot != null && fileRoot.getVcs() != null && myVcs.equals(fileRoot.getVcs()) && myVcsRoot.equals(fileRoot.getPath())) {
|
||||
paths.add(pathToAdd.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.psi.JavaDirectoryService;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.GroovyBundle;
|
||||
@@ -112,6 +113,7 @@ public class NewGroovyClassAction extends JavaCreateTemplateInPackageAction<GrTy
|
||||
final String fileName = className + NewGroovyActionBase.GROOVY_EXTENSION;
|
||||
final PsiFile fromTemplate = GroovyTemplatesFactory.createFromTemplate(dir, className, fileName, templateName);
|
||||
if (fromTemplate instanceof GroovyFile) {
|
||||
CodeStyleManager.getInstance(fromTemplate.getManager()).reformat(fromTemplate);
|
||||
return ((GroovyFile)fromTemplate).getTypeDefinitions()[0];
|
||||
}
|
||||
final String description = fromTemplate.getFileType().getDescription();
|
||||
|
||||
@@ -34,10 +34,7 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyRecursiveElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrForStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrIfStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrWhileStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
|
||||
|
||||
/**
|
||||
@@ -118,7 +115,7 @@ public class GroovyBraceEnforcer extends GroovyRecursiveElementVisitor {
|
||||
}
|
||||
|
||||
private void processStatement(GrStatement statement, GrStatement blockCandidate, int options) {
|
||||
if (blockCandidate instanceof GrCodeBlock || blockCandidate == null) return;
|
||||
if (blockCandidate instanceof GrCodeBlock || blockCandidate instanceof GrBlockStatement || blockCandidate == null) return;
|
||||
if (options == CommonCodeStyleSettings.FORCE_BRACES_ALWAYS ||
|
||||
options == CommonCodeStyleSettings.FORCE_BRACES_IF_MULTILINE && PostFormatProcessorHelper.isMultiline(statement)) {
|
||||
replaceWithBlock(statement, blockCandidate);
|
||||
|
||||
+4
@@ -78,6 +78,10 @@ public abstract class GroovySpacingProcessorBasic {
|
||||
return LAZY_SPACING;
|
||||
}
|
||||
|
||||
if (leftType == GROOVY_DOC_COMMENT) {
|
||||
return COMMON_SPACING_WITH_NL;
|
||||
}
|
||||
|
||||
//For type parameters
|
||||
if (mLT == leftType && right instanceof GrTypeParameter ||
|
||||
mGT == rightType && left instanceof GrTypeParameter ||
|
||||
|
||||
@@ -29,8 +29,8 @@ public class GroovyUnwrapDescriptor extends UnwrapDescriptorBase {
|
||||
new GroovyForUnwrapper(),
|
||||
new GroovyCatchRemover(),
|
||||
new GroovyBracesUnwrapper(),
|
||||
new GroovyElseRemover(),
|
||||
new GroovyElseUnwrapper(),
|
||||
new GroovyElseRemover(),
|
||||
new GroovyConditionalUnwrapper(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -231,6 +231,7 @@ public abstract class GroovyCompilerTestCase extends JavaCodeInsightFixtureTestC
|
||||
}
|
||||
}
|
||||
});
|
||||
touch(file.getVirtualFile());
|
||||
}
|
||||
|
||||
protected void setFileName(final PsiFile bar, final String name) {
|
||||
|
||||
@@ -332,8 +332,8 @@ public abstract class HgUtil {
|
||||
public static @NotNull List<VirtualFile> getHgRepositories(@NotNull Project project) {
|
||||
final List<VirtualFile> repos = new LinkedList<VirtualFile>();
|
||||
for (VcsRoot root : ProjectLevelVcsManager.getInstance(project).getAllVcsRoots()) {
|
||||
if (HgVcs.VCS_NAME.equals(root.vcs.getName())) {
|
||||
repos.add(root.path);
|
||||
if (HgVcs.VCS_NAME.equals(root.getVcs().getName())) {
|
||||
repos.add(root.getPath());
|
||||
}
|
||||
}
|
||||
return repos;
|
||||
|
||||
@@ -24,6 +24,7 @@ package com.wrq.rearranger;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.psi.PsiModifier
|
||||
import com.intellij.testFramework.PlatformTestUtil
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
import com.wrq.rearranger.settings.CommentRule
|
||||
import com.wrq.rearranger.settings.RearrangerSettings
|
||||
@@ -36,7 +37,6 @@ import com.wrq.rearranger.util.SettingsConfigurationBuilder
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import org.jetbrains.annotations.Nullable
|
||||
import com.wrq.rearranger.util.java.*
|
||||
import com.intellij.testFramework.PlatformTestUtil
|
||||
|
||||
/** JUnit tests for the rearranger plugin. */
|
||||
class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
@@ -136,7 +136,7 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
doTest('RearrangementTest', 'RearrangementResult9') {
|
||||
methodRule.create {
|
||||
target([ MethodType.GETTER_OR_SETTER, MethodType.OTHER ])
|
||||
sort(SortType.BY_NAME)
|
||||
'sort by'( SortOption.BY_NAME )
|
||||
} } }
|
||||
|
||||
public final void testSimpleComment() throws Exception {
|
||||
@@ -197,11 +197,11 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
}
|
||||
fieldRule.create {
|
||||
modifier([ PsiModifier.PUBLIC, PsiModifier.STATIC, PsiModifier.FINAL ])
|
||||
sort( SortType.BY_NAME )
|
||||
'sort by'( SortOption.BY_NAME )
|
||||
}
|
||||
fieldRule.create {
|
||||
modifier([ PsiModifier.PUBLIC, PsiModifier.STATIC ])
|
||||
sort( SortType.BY_NAME )
|
||||
'sort by'( SortOption.BY_NAME )
|
||||
}
|
||||
commentRule.create {
|
||||
comment('//************************************** PUBLIC FIELDS *****************************************',
|
||||
@@ -210,7 +210,7 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
}
|
||||
fieldRule.create {
|
||||
modifier( PsiModifier.PUBLIC )
|
||||
sort( SortType.BY_NAME )
|
||||
'sort by'( SortOption.BY_NAME )
|
||||
}
|
||||
commentRule.create {
|
||||
comment('//*********************************** PROTECTED/PACKAGE FIELDS **************************************',
|
||||
@@ -219,15 +219,15 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
}
|
||||
fieldRule.create {
|
||||
modifier([ PsiModifier.PROTECTED, PsiModifier.PACKAGE_LOCAL, PsiModifier.STATIC, PsiModifier.FINAL ])
|
||||
sort( SortType.BY_NAME )
|
||||
'sort by'( SortOption.BY_NAME )
|
||||
}
|
||||
fieldRule.create {
|
||||
modifier([ PsiModifier.PROTECTED, PsiModifier.PACKAGE_LOCAL, PsiModifier.STATIC ])
|
||||
sort( SortType.BY_NAME )
|
||||
'sort by'( SortOption.BY_NAME )
|
||||
}
|
||||
fieldRule.create {
|
||||
modifier([ PsiModifier.PROTECTED, PsiModifier.PACKAGE_LOCAL ])
|
||||
sort( SortType.BY_NAME )
|
||||
'sort by'( SortOption.BY_NAME )
|
||||
}
|
||||
commentRule.create {
|
||||
comment('//************************************** PRIVATE FIELDS *****************************************',
|
||||
@@ -236,7 +236,7 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
}
|
||||
fieldRule.create {
|
||||
modifier( PsiModifier.PRIVATE )
|
||||
sort( SortType.BY_NAME )
|
||||
'sort by'( SortOption.BY_NAME )
|
||||
}
|
||||
commentRule.create {
|
||||
comment('//************************************** CONSTRUCTORS ************************************* ',
|
||||
@@ -256,11 +256,11 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
methodRule.create {
|
||||
modifier( PsiModifier.PUBLIC )
|
||||
target( MethodType.GETTER_OR_SETTER )
|
||||
sort( SortType.BY_NAME )
|
||||
'sort by'( SortOption.BY_NAME )
|
||||
}
|
||||
methodRule.create {
|
||||
target( MethodType.GETTER_OR_SETTER )
|
||||
sort( SortType.BY_NAME )
|
||||
'sort by'( SortOption.BY_NAME )
|
||||
}
|
||||
def text = '//************************************** PUBLIC METHODS ************************************* '
|
||||
if (doublePublicMethods) {
|
||||
@@ -272,7 +272,7 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
}
|
||||
methodRule.create {
|
||||
modifier( PsiModifier.PUBLIC )
|
||||
sort( SortType.BY_NAME )
|
||||
'sort by'( SortOption.BY_NAME )
|
||||
}
|
||||
commentRule.create {
|
||||
comment('//********************************* PACKAGE/PROTECTED METHODS ******************************** ',
|
||||
@@ -281,7 +281,7 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
}
|
||||
methodRule.create {
|
||||
modifier([ PsiModifier.PROTECTED, PsiModifier.PACKAGE_LOCAL ])
|
||||
sort( SortType.BY_NAME )
|
||||
'sort by'( SortOption.BY_NAME )
|
||||
}
|
||||
commentRule.create {
|
||||
comment('//************************************** PRIVATE METHODS *************************************',
|
||||
@@ -290,14 +290,14 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
}
|
||||
methodRule.create {
|
||||
modifier( PsiModifier.PRIVATE )
|
||||
sort( SortType.BY_NAME )
|
||||
'sort by'( SortOption.BY_NAME )
|
||||
}
|
||||
commentRule.create {
|
||||
comment('//************************************** INNER CLASSES ************************************* ',
|
||||
condition: CommentRule.EMIT_IF_ITEMS_MATCH_SUBSEQUENT_RULE, 'all subsequent': true, 'all preceding': true,
|
||||
'subsequent rules to match': 1, 'preceding rules to match': 1)
|
||||
}
|
||||
innerClassRule.create { sort(SortType.BY_NAME ) }
|
||||
innerClassRule.create { 'sort by'(SortOption.BY_NAME ) }
|
||||
|
||||
mySettings.extractedMethodsSettings.moveExtractedMethods = false
|
||||
if (doGlobalPattern) {
|
||||
@@ -463,7 +463,7 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
methodRule.create { target( MethodType.CONSTRUCTOR ) }
|
||||
methodRule.create {
|
||||
target( MethodType.GETTER_OR_SETTER )
|
||||
sort( SortType.BY_NAME )
|
||||
'sort by'( SortOption.BY_NAME )
|
||||
} } }
|
||||
|
||||
public final void testKeepGSWithProperty() throws Exception {
|
||||
@@ -476,7 +476,7 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
methodRule.create { target(MethodType.CONSTRUCTOR) }
|
||||
methodRule.create {
|
||||
target( MethodType.GETTER_OR_SETTER )
|
||||
sort( SortType.BY_NAME )
|
||||
'sort by'( SortOption.BY_NAME )
|
||||
} } }
|
||||
|
||||
public final void testKeepGSWithPropertyElseTogether() throws Exception {
|
||||
@@ -495,14 +495,14 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
name: GetterSetterDefinition.GETTER_NAME_CORRECT_PREFIX,
|
||||
body: GetterSetterDefinition.GETTER_BODY_IMMATERIAL
|
||||
)
|
||||
setterCriteria(
|
||||
'setter criteria'(
|
||||
name: GetterSetterDefinition.SETTER_NAME_CORRECT_PREFIX,
|
||||
body: GetterSetterDefinition.SETTER_BODY_IMMATERIAL
|
||||
)
|
||||
sort( SortType.BY_NAME )
|
||||
'sort by'( SortOption.BY_NAME )
|
||||
}
|
||||
commentRule.create { comment('// Other Methods', condition: CommentRule.EMIT_ALWAYS) }
|
||||
methodRule.create { sort( SortType.BY_NAME ) }
|
||||
methodRule.create { 'sort by'( SortOption.BY_NAME ) }
|
||||
} }
|
||||
|
||||
public final void testKeepOverloadsTogetherOriginalOrder() throws Exception {
|
||||
@@ -527,7 +527,7 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
public final void testMultipleFieldDecl() throws Exception {
|
||||
doTest('RearrangementTest21', 'RearrangementResult21') {
|
||||
fieldRule.create { sort( SortType.BY_NAME ) }
|
||||
fieldRule.create { 'sort by'( SortOption.BY_NAME ) }
|
||||
} }
|
||||
|
||||
public final void testRemoveBlankLines() throws Exception {
|
||||
@@ -641,7 +641,7 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
name: GetterSetterDefinition.GETTER_NAME_CORRECT_PREFIX,
|
||||
body: GetterSetterDefinition.GETTER_BODY_RETURNS
|
||||
)
|
||||
setterCriteria(
|
||||
'setter criteria'(
|
||||
name: GetterSetterDefinition.SETTER_NAME_CORRECT_PREFIX,
|
||||
body: GetterSetterDefinition.SETTER_BODY_IMMATERIAL
|
||||
) }
|
||||
@@ -691,7 +691,7 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
} } }
|
||||
|
||||
public void testSpacingOptions() throws Exception {
|
||||
/**
|
||||
/*
|
||||
* From Thomas Singer:
|
||||
* I've enabled
|
||||
* - Force 0 blank lines before class close brace "}"
|
||||
@@ -869,202 +869,103 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
fieldRule.create { }
|
||||
} }
|
||||
|
||||
// public void testExcludeFromExtraction() throws Exception {
|
||||
// configureByFile("/com/wrq/rearranger/RearrangementTest36.java");
|
||||
// final PsiFile file = getFile();
|
||||
// final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(file);
|
||||
// final RearrangerActionHandler rah = new RearrangerActionHandler();
|
||||
// rah.rearrangeDocument(getProject(), file, rs, doc);
|
||||
// super.checkResultByFile("/com/wrq/rearranger/RearrangementTest36.java");
|
||||
// }
|
||||
//
|
||||
// public void testInterferingGSNames() throws Exception {
|
||||
// configureByFile("/com/wrq/rearranger/RearrangementTest37.java");
|
||||
// final PsiFile file = getFile();
|
||||
// final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(file);
|
||||
// final RearrangerActionHandler rah = new RearrangerActionHandler();
|
||||
// rs.setKeepGettersSettersTogether(true);
|
||||
// rs.getDefaultGSDefinition().setGetterBodyCriterion(GetterSetterDefinition.GETTER_BODY_IMMATERIAL);
|
||||
// rs.getDefaultGSDefinition().setGetterNameCriterion(GetterSetterDefinition.GETTER_NAME_CORRECT_PREFIX);
|
||||
// rs.getDefaultGSDefinition().setSetterBodyCriterion(GetterSetterDefinition.SETTER_BODY_IMMATERIAL);
|
||||
// rs.getDefaultGSDefinition().setSetterNameCriterion(GetterSetterDefinition.GETTER_NAME_CORRECT_PREFIX);
|
||||
// rah.rearrangeDocument(getProject(), file, rs, doc);
|
||||
// super.checkResultByFile("/com/wrq/rearranger/RearrangementResult37.java");
|
||||
// }
|
||||
//
|
||||
// public void testInterferingGSNamesNoKGSTogether() throws Exception {
|
||||
// configureByFile("/com/wrq/rearranger/RearrangementTest37.java");
|
||||
// final PsiFile file = getFile();
|
||||
// final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(file);
|
||||
// final RearrangerActionHandler rah = new RearrangerActionHandler();
|
||||
// rs.setKeepGettersSettersTogether(false);
|
||||
// rs.getDefaultGSDefinition().setGetterBodyCriterion(GetterSetterDefinition.GETTER_BODY_IMMATERIAL);
|
||||
// rs.getDefaultGSDefinition().setGetterNameCriterion(GetterSetterDefinition.GETTER_NAME_CORRECT_PREFIX);
|
||||
// rs.getDefaultGSDefinition().setSetterBodyCriterion(GetterSetterDefinition.SETTER_BODY_IMMATERIAL);
|
||||
// rs.getDefaultGSDefinition().setSetterNameCriterion(GetterSetterDefinition.GETTER_NAME_CORRECT_PREFIX);
|
||||
// rah.rearrangeDocument(getProject(), file, rs, doc);
|
||||
// super.checkResultByFile("/com/wrq/rearranger/RearrangementTest37.java");
|
||||
// }
|
||||
//
|
||||
// public void testRemoveBlankLineInsideMethodBug() throws Exception {
|
||||
// configureByFile("/com/wrq/rearranger/RearrangementTest38.java");
|
||||
// final PsiFile file = getFile();
|
||||
// final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(file);
|
||||
// File settingsFile = new File(InteractiveTest.DEFAULT_CONFIGURATION_ROOT +
|
||||
// "/test/testData/com/wrq/rearranger/RearrangementTest38cfg.xml");
|
||||
// rs = RearrangerSettings.getSettingsFromFile(settingsFile);
|
||||
// rs.setAskBeforeRearranging(false);
|
||||
// final RearrangerActionHandler rah = new RearrangerActionHandler();
|
||||
// rah.rearrangeDocument(getProject(), file, rs, doc);
|
||||
// super.checkResultByFile("/com/wrq/rearranger/RearrangementTest38.java");
|
||||
// }
|
||||
//
|
||||
// public void testSortFieldsByTypeAndName() throws Exception {
|
||||
// configureByFile("/com/wrq/rearranger/RearrangementTest39.java");
|
||||
// final PsiFile file = getFile();
|
||||
// final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(file);
|
||||
// final RearrangerActionHandler rah = new RearrangerActionHandler();
|
||||
// FieldAttributes fa = new FieldAttributes();
|
||||
// fa.getSortAttr().setByType(true);
|
||||
// fa.getSortAttr().setByName(true);
|
||||
// rs.addItem(fa, 0);
|
||||
// rah.rearrangeDocument(getProject(), file, rs, doc);
|
||||
// super.checkResultByFile("/com/wrq/rearranger/RearrangementResult39B.java");
|
||||
// }
|
||||
//
|
||||
// public void testSortFieldsByType() throws Exception {
|
||||
// configureByFile("/com/wrq/rearranger/RearrangementTest39.java");
|
||||
// final PsiFile file = getFile();
|
||||
// final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(file);
|
||||
// final RearrangerActionHandler rah = new RearrangerActionHandler();
|
||||
// FieldAttributes fa = new FieldAttributes();
|
||||
// fa.getSortAttr().setByType(true);
|
||||
// fa.getSortAttr().setByName(false);
|
||||
// rs.addItem(fa, 0);
|
||||
// rah.rearrangeDocument(getProject(), file, rs, doc);
|
||||
// super.checkResultByFile("/com/wrq/rearranger/RearrangementResult39C.java");
|
||||
// }
|
||||
//
|
||||
// public void testSortFieldsByTypeICAndName() throws Exception {
|
||||
// configureByFile("/com/wrq/rearranger/RearrangementTest39.java");
|
||||
// final PsiFile file = getFile();
|
||||
// final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(file);
|
||||
// final RearrangerActionHandler rah = new RearrangerActionHandler();
|
||||
// FieldAttributes fa = new FieldAttributes();
|
||||
// fa.getSortAttr().setByType(true);
|
||||
// fa.getSortAttr().setTypeCaseInsensitive(true);
|
||||
// fa.getSortAttr().setByName(true);
|
||||
// rs.addItem(fa, 0);
|
||||
// rah.rearrangeDocument(getProject(), file, rs, doc);
|
||||
// super.checkResultByFile("/com/wrq/rearranger/RearrangementResult39.java");
|
||||
// }
|
||||
//
|
||||
// public void testSortFieldsByTypeIC() throws Exception {
|
||||
// configureByFile("/com/wrq/rearranger/RearrangementTest39.java");
|
||||
// final PsiFile file = getFile();
|
||||
// final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(file);
|
||||
// final RearrangerActionHandler rah = new RearrangerActionHandler();
|
||||
// FieldAttributes fa = new FieldAttributes();
|
||||
// fa.getSortAttr().setByType(true);
|
||||
// fa.getSortAttr().setTypeCaseInsensitive(true);
|
||||
// fa.getSortAttr().setByName(false);
|
||||
// rs.addItem(fa, 0);
|
||||
// rah.rearrangeDocument(getProject(), file, rs, doc);
|
||||
// super.checkResultByFile("/com/wrq/rearranger/RearrangementResult39A.java");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * test detection of method overrides/overridden/implements/implemented attributes.
|
||||
// *
|
||||
// * @throws Exception test exception
|
||||
// */
|
||||
// public void testOverImpl() throws Exception {
|
||||
// configureByFile("/com/wrq/rearranger/RearrangementTest40.java");
|
||||
// final PsiFile file = getFile();
|
||||
// final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(file);
|
||||
// final RearrangerActionHandler rah = new RearrangerActionHandler();
|
||||
// rah.rearrangeDocument(getProject(), file, rs, doc);
|
||||
// super.checkResultByFile("/com/wrq/rearranger/RearrangementResult40.java");
|
||||
// }
|
||||
//
|
||||
// public final void testRemoveBlankLinesBeforeMethod() throws Exception {
|
||||
// configureByFile("/com/wrq/rearranger/RearrangementTest41.java");
|
||||
// final PsiFile file = getFile();
|
||||
// final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(file);
|
||||
// final RearrangerActionHandler rah = new RearrangerActionHandler();
|
||||
// rs.getAfterClassLBrace().setForce(true);
|
||||
// rs.getAfterClassLBrace().setnBlankLines(0);
|
||||
// rs.getBeforeMethodLBrace().setForce(true);
|
||||
// rs.getBeforeMethodLBrace().setnBlankLines(0);
|
||||
// rs.getAfterMethodLBrace().setForce(true);
|
||||
// rs.getAfterMethodLBrace().setnBlankLines(0);
|
||||
// rs.getBeforeMethodRBrace().setForce(true);
|
||||
// rs.getBeforeMethodRBrace().setnBlankLines(0);
|
||||
// rs.getAfterMethodRBrace().setForce(true);
|
||||
// rs.getAfterMethodRBrace().setnBlankLines(0);
|
||||
// rs.getBeforeClassRBrace().setForce(true);
|
||||
// rs.getBeforeClassRBrace().setnBlankLines(0);
|
||||
// rs.getAfterClassRBrace().setForce(true);
|
||||
// rs.getAfterClassRBrace().setnBlankLines(0);
|
||||
// rs.setRemoveBlanksInsideCodeBlocks(true);
|
||||
// rah.rearrangeDocument(getProject(), file, rs, doc);
|
||||
// super.checkResultByFile("/com/wrq/rearranger/RearrangementResult41.java");
|
||||
// }
|
||||
//
|
||||
// public final void testEnumClass() throws Exception {
|
||||
// final Project project = getProject();
|
||||
// final LanguageLevelProjectExtension llpExtension = LanguageLevelProjectExtension.getInstance(project);
|
||||
// LanguageLevel oldLevel = llpExtension.getLanguageLevel();
|
||||
// llpExtension.setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
// configureByFile("/com/wrq/rearranger/RearrangementTest42.java");
|
||||
// final PsiFile file = getFile();
|
||||
// final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(file);
|
||||
// final RearrangerActionHandler rah = new RearrangerActionHandler();
|
||||
// rah.rearrangeDocument(getProject(), file, rs, doc);
|
||||
// super.checkResultByFile("/com/wrq/rearranger/RearrangementResult42.java");
|
||||
// llpExtension.setLanguageLevel(oldLevel);
|
||||
// }
|
||||
//
|
||||
// public final void testNumParameters() throws Exception {
|
||||
// configureByFile("/com/wrq/rearranger/RearrangementTest43.java");
|
||||
// final PsiFile file = getFile();
|
||||
// final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(file);
|
||||
// final RearrangerActionHandler rah = new RearrangerActionHandler();
|
||||
// MethodAttributes ma;
|
||||
// ma = new MethodAttributes();
|
||||
// ma.getMinParamsAttr().setMatch(true);
|
||||
// ma.getMinParamsAttr().setValue(2);
|
||||
// ma.getMaxParamsAttr().setMatch(true);
|
||||
// ma.getMaxParamsAttr().setValue(3);
|
||||
// rs.addItem(ma, 0);
|
||||
// ma = new MethodAttributes();
|
||||
// ma.getMinParamsAttr().setMatch(true);
|
||||
// ma.getMinParamsAttr().setValue(1);
|
||||
// rs.addItem(ma, 1);
|
||||
// rah.rearrangeDocument(getProject(), file, rs, doc);
|
||||
// super.checkResultByFile("/com/wrq/rearranger/RearrangementResult43.java");
|
||||
// }
|
||||
//
|
||||
// public final void testGeneratedComment() throws Exception {
|
||||
// configureByFile("/com/wrq/rearranger/RearrangementTest44.java");
|
||||
// final PsiFile file = getFile();
|
||||
// final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(file);
|
||||
// final RearrangerActionHandler rah = new RearrangerActionHandler();
|
||||
// CommentRule cr = new CommentRule();
|
||||
// CommentFillString cfs = cr.getCommentFillString();
|
||||
// cfs.setFillString("-+");
|
||||
// cfs.setUseProjectWidthForFill(false);
|
||||
// cfs.setFillWidth(30);
|
||||
// cr.setEmitCondition(CommentRule.EMIT_ALWAYS);
|
||||
// cr.setCommentText("// %FS% METHODS %FS%");
|
||||
// rs.addItem(cr, 0);
|
||||
// MethodAttributes ma;
|
||||
// ma = new MethodAttributes(); // match all methods
|
||||
// rs.addItem(ma, 1);
|
||||
// rah.rearrangeDocument(getProject(), file, rs, doc);
|
||||
// super.checkResultByFile("/com/wrq/rearranger/RearrangementResult44.java");
|
||||
// }
|
||||
//
|
||||
public void testExcludeFromExtraction() throws Exception { doTest('RearrangementTest36', 'RearrangementTest36') }
|
||||
|
||||
public void testInterferingGSNames() throws Exception {
|
||||
doTest('RearrangementTest37', 'RearrangementResult37') {
|
||||
settings.configure {
|
||||
'keep together'( 'getters and setters' )
|
||||
'getter criteria'(
|
||||
name: GetterSetterDefinition.GETTER_NAME_CORRECT_PREFIX,
|
||||
body: GetterSetterDefinition.GETTER_BODY_IMMATERIAL
|
||||
)
|
||||
'setter criteria'(
|
||||
name: GetterSetterDefinition.SETTER_NAME_CORRECT_PREFIX,
|
||||
body: GetterSetterDefinition.SETTER_BODY_IMMATERIAL
|
||||
)
|
||||
} } }
|
||||
|
||||
public void testInterferingGSNamesNoKGSTogether() throws Exception {
|
||||
doTest('RearrangementTest37', 'RearrangementTest37') {
|
||||
settings.configure {
|
||||
'getter criteria'(
|
||||
name: GetterSetterDefinition.GETTER_NAME_CORRECT_PREFIX,
|
||||
body: GetterSetterDefinition.GETTER_BODY_IMMATERIAL
|
||||
)
|
||||
'setter criteria'(
|
||||
name: GetterSetterDefinition.SETTER_NAME_CORRECT_PREFIX,
|
||||
body: GetterSetterDefinition.SETTER_BODY_IMMATERIAL
|
||||
)
|
||||
} } }
|
||||
|
||||
public void testRemoveBlankLineInsideMethodBug() throws Exception {
|
||||
doTest('RearrangementTest38', 'RearrangementTest38') {
|
||||
setupSettings('/test/testData/com/wrq/rearranger/RearrangementTest38cfg.xml')
|
||||
} }
|
||||
|
||||
public void testSortFieldsByTypeAndName() throws Exception {
|
||||
doTest('RearrangementTest39', 'RearrangementResult39B') {
|
||||
fieldRule.create {
|
||||
'sort by'([ SortOption.BY_NAME, SortOption.BY_TYPE ])
|
||||
} } }
|
||||
|
||||
public void testSortFieldsByType() throws Exception {
|
||||
doTest('RearrangementTest39', 'RearrangementResult39C') {
|
||||
fieldRule.create {
|
||||
'sort by' SortOption.BY_TYPE
|
||||
'not sort by' SortOption.BY_NAME
|
||||
}
|
||||
} }
|
||||
|
||||
public void testSortFieldsByTypeICAndName() throws Exception {
|
||||
doTest('RearrangementTest39', 'RearrangementResult39') {
|
||||
fieldRule.create {
|
||||
'sort by'([ SortOption.BY_NAME, SortOption.BY_TYPE, SortOption.TYPE_CASE_INSENSITIVE ])
|
||||
} } }
|
||||
|
||||
public void testSortFieldsByTypeIC() throws Exception {
|
||||
doTest('RearrangementTest39', 'RearrangementResult39A') {
|
||||
fieldRule.create {
|
||||
'sort by'([ SortOption.BY_TYPE, SortOption.TYPE_CASE_INSENSITIVE ])
|
||||
'not sort by' SortOption.BY_NAME
|
||||
} } }
|
||||
|
||||
/**
|
||||
* test detection of method overrides/overridden/implements/implemented attributes.
|
||||
*
|
||||
* @throws Exception test exception
|
||||
*/
|
||||
public void testOverImpl() throws Exception { doTest('RearrangementTest40', 'RearrangementResult40') }
|
||||
|
||||
public final void testRemoveBlankLinesBeforeMethod() throws Exception {
|
||||
doTest('RearrangementTest41', 'RearrangementResult41') {
|
||||
spacingRule.create {
|
||||
spacing(anchor: [ SpacingAnchor.AFTER_CLASS_LBRACE, SpacingAnchor.BEFORE_METHOD_LBRACE, SpacingAnchor.AFTER_METHOD_LBRACE,
|
||||
SpacingAnchor.BEFORE_METHOD_RBRACE, SpacingAnchor.AFTER_METHOD_RBRACE, SpacingAnchor.BEFORE_CLASS_RBRACE,
|
||||
SpacingAnchor.AFTER_CLASS_RBRACE],
|
||||
lines: 0, 'remove blank lines': true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void testEnumClass() throws Exception { doTest('RearrangementTest42', 'RearrangementResult42') }
|
||||
|
||||
public final void testNumParameters() throws Exception {
|
||||
doTest('RearrangementTest43', 'RearrangementResult43') {
|
||||
methodRule.create {
|
||||
'arguments number' ( from: 2, to: 3)
|
||||
}
|
||||
methodRule.create {
|
||||
'arguments number' ( from: 1)
|
||||
} } }
|
||||
|
||||
public final void testGeneratedComment() throws Exception {
|
||||
doTest('RearrangementTest44', 'RearrangementResult44') {
|
||||
commentRule.comment('// %FS% METHODS %FS%', condition: CommentRule.EMIT_ALWAYS, 'fill string': '-+',
|
||||
'use project width for fill': false, 'fill width': 30)
|
||||
methodRule.create { } // match all methods
|
||||
} }
|
||||
|
||||
// public void testEnum1() throws Exception {
|
||||
// final Project project = getProject();
|
||||
// final LanguageLevelProjectExtension llpExtension = LanguageLevelProjectExtension.getInstance(project);
|
||||
@@ -1360,7 +1261,6 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
doTest(srcFileName, expectedResultFileName, 'java', adjustment)
|
||||
}
|
||||
|
||||
|
||||
private void doTest(@NotNull String srcFileName, @Nullable String expectedResultFileName, @Nullable String extension,
|
||||
@Nullable Closure adjustment = null)
|
||||
{
|
||||
|
||||
@@ -13,11 +13,18 @@ class CommentRuleBuilder extends AbstractRuleBuilder<CommentRule> {
|
||||
{
|
||||
registerHandler(RearrangerTestDsl.COMMENT, { data, attributes, rule ->
|
||||
rule.commentText = data
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.CONDITION, attributes, 'emitCondition', rule)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.ALL_SUBSEQUENT, attributes, 'allSubsequentRules', rule)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.ALL_PRECEDING, attributes, 'allPrecedingRules', rule)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.SUBSEQUENT_RULES_TO_MATCH, attributes, 'NSubsequentRulesToMatch', rule)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.PRECEDING_RULES_TO_MATCH, attributes, 'NPrecedingRulesToMatch', rule)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.CONDITION, attributes, 'emitCondition', rule)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.ALL_SUBSEQUENT, attributes, 'allSubsequentRules', rule)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.ALL_PRECEDING, attributes, 'allPrecedingRules', rule)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.SUBSEQUENT_RULES_TO_MATCH, attributes, 'NSubsequentRulesToMatch', rule)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.PRECEDING_RULES_TO_MATCH, attributes, 'NPrecedingRulesToMatch', rule)
|
||||
|
||||
def fillString = rule.commentFillString
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.USE_PROJECT_WIDTH_FOR_COMMENT_FILL, attributes, 'useProjectWidthForFill', fillString)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.FILL_WIDTH, attributes, 'fillWidth', fillString)
|
||||
if (attributes[RearrangerTestDsl.FILL_STRING.value]) {
|
||||
rule.commentFillString.fillString = attributes[RearrangerTestDsl.FILL_STRING.value]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,11 @@ public enum RearrangerTestDsl {
|
||||
TARGET,
|
||||
TYPE,
|
||||
RETURN_TYPE("return type"),
|
||||
SORT,
|
||||
SORT("sort by"),
|
||||
NOT_SORT("not sort by"),
|
||||
COMMENT,
|
||||
GETTER_CRITERIA("getter criteria"),
|
||||
SETTER_CRITERIA("setterCriteria"),
|
||||
SETTER_CRITERIA("setter criteria"),
|
||||
SPACING,
|
||||
PRECEDING_COMMENT("preceding comment"),
|
||||
TRAILING_COMMENT("trailing comment"),
|
||||
@@ -56,7 +57,13 @@ public enum RearrangerTestDsl {
|
||||
BELOW_FIRST_CALLER("below first caller"),
|
||||
NON_PRIVATE_TREATMENT("non-private treatment"),
|
||||
REARRANGE_INNER_CLASSES("rearranger inner classes"),
|
||||
CLASS_COMMENT("class comment");
|
||||
CLASS_COMMENT("class comment"),
|
||||
ARGUMENTS_NUMBER("arguments number"),
|
||||
FROM,
|
||||
TO,
|
||||
FILL_STRING("fill string"),
|
||||
USE_PROJECT_WIDTH_FOR_COMMENT_FILL("use project width for fill"),
|
||||
FILL_WIDTH("fill width");
|
||||
|
||||
@NotNull private final String myValue;
|
||||
|
||||
|
||||
+8
@@ -68,6 +68,14 @@ class SettingsConfigurationBuilder extends BuilderSupport {
|
||||
setIf(RearrangerTestDsl.ORDER, attributes, 'overloadedOrder', settings)
|
||||
setIf(RearrangerTestDsl.KEEP_TOGETHER, attributes, 'keepOverloadedMethodsTogether', settings)
|
||||
break
|
||||
case RearrangerTestDsl.GETTER_CRITERIA.value:
|
||||
setIf(RearrangerTestDsl.NAME, attributes, 'getterNameCriterion', settings.defaultGSDefinition)
|
||||
setIf(RearrangerTestDsl.BODY, attributes, 'getterBodyCriterion', settings.defaultGSDefinition)
|
||||
break
|
||||
case RearrangerTestDsl.SETTER_CRITERIA.value:
|
||||
setIf(RearrangerTestDsl.NAME, attributes, 'setterNameCriterion', settings.defaultGSDefinition)
|
||||
setIf(RearrangerTestDsl.BODY, attributes, 'setterBodyCriterion', settings.defaultGSDefinition)
|
||||
break
|
||||
default:
|
||||
setIf(RearrangerTestDsl.REARRANGE_INNER_CLASSES, attributes, 'rearrangeInnerClasses', settings)
|
||||
if (attributes[RearrangerTestDsl.CLASS_COMMENT.value]) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user