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:
+116
-60
@@ -17,6 +17,7 @@ package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.ChangeContextUtil;
|
||||
import com.intellij.codeInsight.daemon.GroupNames;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil;
|
||||
import com.intellij.codeInsight.intention.HighPriorityAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -25,14 +26,18 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.controlFlow.AnalysisCanceledException;
|
||||
import com.intellij.psi.controlFlow.ControlFlow;
|
||||
import com.intellij.psi.controlFlow.ControlFlowUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import com.intellij.util.containers.hash.LinkedHashMap;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -82,66 +87,11 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
|
||||
if (methods.length == 1 && aClass.getFields().length == 0) {
|
||||
final PsiCodeBlock body = methods[0].getBody();
|
||||
if (body != null) {
|
||||
final boolean [] bodyContainsForbiddenRefs = new boolean[1];
|
||||
final Set<PsiLocalVariable> locals = new HashSet<PsiLocalVariable>();
|
||||
body.accept(new JavaRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitMethodCallExpression(PsiMethodCallExpression methodCallExpression) {
|
||||
if (bodyContainsForbiddenRefs[0]) return;
|
||||
super.visitMethodCallExpression(methodCallExpression);
|
||||
final PsiMethod psiMethod = methodCallExpression.resolveMethod();
|
||||
if (psiMethod == methods[0] ||
|
||||
psiMethod != null &&
|
||||
!methodCallExpression.getMethodExpression().isQualified() &&
|
||||
"getClass".equals(psiMethod.getName()) &&
|
||||
psiMethod.getParameterList().getParametersCount() == 0) {
|
||||
bodyContainsForbiddenRefs[0] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitThisExpression(PsiThisExpression expression) {
|
||||
if (bodyContainsForbiddenRefs[0]) return;
|
||||
if (expression.getQualifier() == null) {
|
||||
bodyContainsForbiddenRefs[0] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSuperExpression(PsiSuperExpression expression) {
|
||||
if (bodyContainsForbiddenRefs[0]) return;
|
||||
if (expression.getQualifier() == null) {
|
||||
bodyContainsForbiddenRefs[0] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLocalVariable(PsiLocalVariable variable) {
|
||||
if (bodyContainsForbiddenRefs[0]) return;
|
||||
super.visitLocalVariable(variable);
|
||||
locals.add(variable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
if (bodyContainsForbiddenRefs[0]) return;
|
||||
super.visitReferenceExpression(expression);
|
||||
if (!(expression.getParent() instanceof PsiMethodCallExpression)) {
|
||||
final PsiField field = PsiTreeUtil.getParentOfType(expression, PsiField.class);
|
||||
if (field != null) {
|
||||
final PsiElement resolved = expression.resolve();
|
||||
if (resolved instanceof PsiField &&
|
||||
!((PsiField)resolved).hasInitializer() &&
|
||||
((PsiField)resolved).getContainingClass() == field.getContainingClass()) {
|
||||
bodyContainsForbiddenRefs[0] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!bodyContainsForbiddenRefs[0]) {
|
||||
final ForbiddenRefsChecker checker = new ForbiddenRefsChecker(methods[0], aClass);
|
||||
body.accept(checker);
|
||||
if (!checker.hasForbiddenRefs()) {
|
||||
PsiResolveHelper helper = PsiResolveHelper.SERVICE.getInstance(body.getProject());
|
||||
for (PsiLocalVariable local : locals) {
|
||||
for (PsiLocalVariable local : checker.getLocals()) {
|
||||
final String localName = local.getName();
|
||||
if (localName != null && helper.resolveReferencedVariable(localName, aClass) != null) return;
|
||||
}
|
||||
@@ -327,4 +277,110 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
|
||||
return parameterType + parameterName;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ForbiddenRefsChecker extends JavaRecursiveElementWalkingVisitor {
|
||||
private boolean myBodyContainsForbiddenRefs;
|
||||
private final Set<PsiLocalVariable> myLocals = ContainerUtilRt.newHashSet(5);
|
||||
|
||||
private final PsiMethod myMethod;
|
||||
private final PsiAnonymousClass myAnonymClass;
|
||||
|
||||
public ForbiddenRefsChecker(PsiMethod method,
|
||||
PsiAnonymousClass aClass) {
|
||||
myMethod = method;
|
||||
myAnonymClass = aClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMethodCallExpression(PsiMethodCallExpression methodCallExpression) {
|
||||
if (myBodyContainsForbiddenRefs) return;
|
||||
|
||||
super.visitMethodCallExpression(methodCallExpression);
|
||||
final PsiMethod psiMethod = methodCallExpression.resolveMethod();
|
||||
if (psiMethod == myMethod ||
|
||||
psiMethod != null &&
|
||||
!methodCallExpression.getMethodExpression().isQualified() &&
|
||||
"getClass".equals(psiMethod.getName()) &&
|
||||
psiMethod.getParameterList().getParametersCount() == 0) {
|
||||
myBodyContainsForbiddenRefs = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitThisExpression(PsiThisExpression expression) {
|
||||
if (myBodyContainsForbiddenRefs) return;
|
||||
|
||||
if (expression.getQualifier() == null) {
|
||||
myBodyContainsForbiddenRefs = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSuperExpression(PsiSuperExpression expression) {
|
||||
if (myBodyContainsForbiddenRefs) return;
|
||||
|
||||
if (expression.getQualifier() == null) {
|
||||
myBodyContainsForbiddenRefs = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLocalVariable(PsiLocalVariable variable) {
|
||||
if (myBodyContainsForbiddenRefs) return;
|
||||
|
||||
super.visitLocalVariable(variable);
|
||||
myLocals.add(variable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
if (myBodyContainsForbiddenRefs) return;
|
||||
|
||||
super.visitReferenceExpression(expression);
|
||||
if (!(expression.getParent() instanceof PsiMethodCallExpression)) {
|
||||
final PsiField field = PsiTreeUtil.getParentOfType(expression, PsiField.class);
|
||||
if (field != null) {
|
||||
final PsiElement resolved = expression.resolve();
|
||||
if (resolved instanceof PsiField && ((PsiField)resolved).getContainingClass() == field.getContainingClass()) {
|
||||
final PsiExpression initializer = ((PsiField)resolved).getInitializer();
|
||||
if (initializer == null ||
|
||||
initializer.getTextOffset() > myAnonymClass.getTextOffset() && !((PsiField)resolved).hasModifierProperty(PsiModifier.STATIC)) {
|
||||
myBodyContainsForbiddenRefs = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final PsiMethod method = PsiTreeUtil.getParentOfType(myAnonymClass, PsiMethod.class);
|
||||
if (method != null && method.isConstructor()) {
|
||||
final PsiElement resolved = expression.resolve();
|
||||
if (resolved instanceof PsiField &&
|
||||
((PsiField)resolved).hasModifierProperty(PsiModifier.FINAL) &&
|
||||
((PsiField)resolved).getContainingClass() == method.getContainingClass()) {
|
||||
try {
|
||||
final PsiCodeBlock constructorBody = method.getBody();
|
||||
if (constructorBody != null) {
|
||||
final ControlFlow flow = HighlightControlFlowUtil.getControlFlowNoConstantEvaluate(constructorBody);
|
||||
final int startOffset = flow.getStartOffset(myAnonymClass);
|
||||
final Collection<PsiVariable> writtenVariables = ControlFlowUtil.getWrittenVariables(flow, 0, startOffset, false);
|
||||
if (!writtenVariables.contains(resolved)) {
|
||||
myBodyContainsForbiddenRefs = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (AnalysisCanceledException e) {
|
||||
myBodyContainsForbiddenRefs = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasForbiddenRefs() {
|
||||
return myBodyContainsForbiddenRefs;
|
||||
}
|
||||
|
||||
public Set<PsiLocalVariable> getLocals() {
|
||||
return myLocals;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -395,7 +395,7 @@ public class NullableStuffInspectionBase extends BaseJavaBatchLocalInspectionToo
|
||||
parameters[i].getNameIdentifier(); //be sure that corresponding tree element available
|
||||
PsiAnnotation annotation = AnnotationUtil.findAnnotation(parameters[i], nullableManager.getNotNulls());
|
||||
PsiElement psiElement = annotation;
|
||||
if (!annotation.isPhysical()) {
|
||||
if (annotation == null || !annotation.isPhysical()) {
|
||||
psiElement = parameters[i].getNameIdentifier();
|
||||
if (psiElement == null) continue;
|
||||
}
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ import com.intellij.codeInsight.completion.CompletionResultSet;
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CustomShortcutSet;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorFontType;
|
||||
@@ -556,7 +556,7 @@ public class JavaChangeSignatureDialog extends ChangeSignatureDialogBase<Paramet
|
||||
}
|
||||
|
||||
if (item.parameter.oldParameterIndex < 0) {
|
||||
item.parameter.defaultValue = ApplicationManager.getApplication().runWriteAction(new Computable<String>() {
|
||||
item.parameter.defaultValue = WriteCommandAction.runWriteCommandAction(myProject, new Computable<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
return JavaCodeStyleManager.getInstance(myProject).qualifyClassReferences(item.defaultValueCodeFragment).getText();
|
||||
|
||||
+2
-6
@@ -36,7 +36,6 @@ import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.controlFlow.ControlFlowUtil;
|
||||
import com.intellij.psi.impl.source.PsiImmediateClassType;
|
||||
import com.intellij.psi.impl.source.resolve.DefaultParameterTypeInferencePolicy;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.PropertyUtil;
|
||||
@@ -469,12 +468,9 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor {
|
||||
final PsiTypeParameter[] methodTypeParameters = getMethod().getTypeParameters();
|
||||
if (methodTypeParameters.length > 0) {
|
||||
List<String> typeSignature = new ArrayList<String>();
|
||||
final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(getMethod().getProject()).getResolveHelper();
|
||||
final PsiSubstitutor substitutor = methodCallExpression.resolveMethodGenerics().getSubstitutor();
|
||||
for (final PsiTypeParameter typeParameter : methodTypeParameters) {
|
||||
final PsiType type = resolveHelper.inferTypeForMethodTypeParameter(typeParameter, getMethod().getParameterList().getParameters(),
|
||||
methodCallExpression.getArgumentList().getExpressions(),
|
||||
PsiSubstitutor.EMPTY, methodCallExpression,
|
||||
DefaultParameterTypeInferencePolicy.INSTANCE);
|
||||
final PsiType type = substitutor.substitute(typeParameter);
|
||||
if (type == null || PsiType.NULL.equals(type)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class LambdaUtil {
|
||||
context instanceof PsiExpressionList ||
|
||||
context instanceof PsiParenthesizedExpression ||
|
||||
context instanceof PsiArrayInitializerExpression ||
|
||||
context instanceof PsiConditionalExpression;
|
||||
context instanceof PsiConditionalExpression && PsiTreeUtil.getParentOfType(context, PsiTypeCastExpression.class) == null;
|
||||
}
|
||||
|
||||
public static boolean isLambdaFullyInferred(PsiLambdaExpression expression, PsiType functionalInterfaceType) {
|
||||
|
||||
+12
-5
@@ -49,6 +49,8 @@ public class InferenceSession {
|
||||
private static final Logger LOG = Logger.getInstance("#" + InferenceSession.class.getName());
|
||||
public static final Key<PsiType> LOWER_BOUND = Key.create("LowBound");
|
||||
|
||||
private static final Key<Boolean> ERASED = Key.create("UNCHECKED_CONVERSION");
|
||||
|
||||
private final Map<PsiTypeParameter, InferenceVariable> myInferenceVariables = new LinkedHashMap<PsiTypeParameter, InferenceVariable>();
|
||||
private final List<ConstraintFormula> myConstraints = new ArrayList<ConstraintFormula>();
|
||||
|
||||
@@ -286,6 +288,9 @@ public class InferenceSession {
|
||||
|
||||
final PsiSubstitutor substitutor = resolveBounds(myInferenceVariables.values(), mySiteSubstitutor);
|
||||
if (substitutor != null) {
|
||||
if (myContext != null) {
|
||||
myContext.putUserData(ERASED, myErased);
|
||||
}
|
||||
mySiteSubstitutor = substitutor;
|
||||
for (PsiTypeParameter parameter : substitutor.getSubstitutionMap().keySet()) {
|
||||
final InferenceVariable variable = getInferenceVariable(parameter);
|
||||
@@ -396,9 +401,6 @@ public class InferenceSession {
|
||||
myConstraints.add(new TypeCompatibilityConstraint(targetType, PsiUtil.captureToplevelWildcards(substitutor.substitute(inferenceVariable.getParameter()), myContext)));
|
||||
}
|
||||
else {
|
||||
if (targetType instanceof PsiClassType && ((PsiClassType)targetType).isRaw()) {
|
||||
setErased();
|
||||
}
|
||||
if (FunctionalInterfaceParameterizationUtil.isWildcardParameterized(returnType)) {
|
||||
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(returnType);
|
||||
final PsiClass psiClass = resolveResult.getElement();
|
||||
@@ -419,7 +421,7 @@ public class InferenceSession {
|
||||
myConstraints.add(new TypeCompatibilityConstraint(targetType, substitutedCapture));
|
||||
}
|
||||
} else {
|
||||
myConstraints.add(new TypeCompatibilityConstraint(myErased ? TypeConversionUtil.erasure(targetType) : targetType, returnType));
|
||||
myConstraints.add(new TypeCompatibilityConstraint(targetType, myErased ? TypeConversionUtil.erasure(returnType) : returnType));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -470,7 +472,7 @@ public class InferenceSession {
|
||||
}
|
||||
|
||||
private static boolean hasWildcardParameterization(InferenceVariable inferenceVariable, PsiClassType targetType) {
|
||||
if (FunctionalInterfaceParameterizationUtil.isWildcardParameterized(targetType)) {
|
||||
if (!FunctionalInterfaceParameterizationUtil.isWildcardParameterized(targetType)) {
|
||||
final List<PsiType> bounds = inferenceVariable.getBounds(InferenceBound.LOWER);
|
||||
final Processor<Pair<PsiType, PsiType>> differentParameterizationProcessor = new Processor<Pair<PsiType, PsiType>>() {
|
||||
@Override
|
||||
@@ -1198,4 +1200,9 @@ public class InferenceSession {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean wasUncheckedConversionPerformed(PsiElement call) {
|
||||
final Boolean erased = call.getUserData(ERASED);
|
||||
return erased != null && erased.booleanValue();
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -19,6 +19,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.InferenceBound;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.InferenceVariable;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
|
||||
import java.util.List;
|
||||
@@ -94,6 +95,9 @@ public class StrictSubtypingConstraint implements ConstraintFormula {
|
||||
if (!(myS instanceof PsiClassType)) return false;
|
||||
PsiClassType.ClassResolveResult SResult = ((PsiClassType)myS).resolveGenerics();
|
||||
PsiClass SClass = SResult.getElement();
|
||||
if (((PsiClassType)myT).isRaw()) {
|
||||
return SClass != null && InheritanceUtil.isInheritorOrSelf(SClass, CClass, true);
|
||||
}
|
||||
final PsiSubstitutor tSubstitutor = TResult.getSubstitutor();
|
||||
final PsiSubstitutor sSubstitutor = SClass != null ? TypeConversionUtil.getClassSubstitutor(CClass, SClass, SResult.getSubstitutor()) : null;
|
||||
if (sSubstitutor != null) {
|
||||
|
||||
+10
-6
@@ -176,8 +176,8 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
|
||||
PsiParameter parameter = lambdaParameters[lambdaParamIdx];
|
||||
final PsiTypeElement typeElement = parameter.getTypeElement();
|
||||
if (typeElement != null) {
|
||||
final PsiType lambdaFormalType = typeElement.getType();
|
||||
final PsiType methodParameterType = parameterTypes[lambdaParamIdx];
|
||||
final PsiType lambdaFormalType = toArray(typeElement.getType());
|
||||
final PsiType methodParameterType = toArray(parameterTypes[lambdaParamIdx]);
|
||||
if (!lambdaFormalType.equals(methodParameterType)) {
|
||||
return false;
|
||||
}
|
||||
@@ -186,10 +186,7 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
|
||||
|
||||
if (checkReturnType) {
|
||||
final String uniqueVarName = JavaCodeStyleManager.getInstance(getProject()).suggestUniqueVariableName("l", this, true);
|
||||
String canonicalText = leftType.getCanonicalText();
|
||||
if (leftType instanceof PsiEllipsisType) {
|
||||
canonicalText = ((PsiEllipsisType)leftType).toArrayType().getCanonicalText();
|
||||
}
|
||||
final String canonicalText = toArray(leftType).getCanonicalText();
|
||||
final PsiStatement assignmentFromText = JavaPsiFacade.getElementFactory(getProject())
|
||||
.createStatementFromText(canonicalText + " " + uniqueVarName + " = " + getText(), this);
|
||||
final PsiLocalVariable localVariable = (PsiLocalVariable)((PsiDeclarationStatement)assignmentFromText).getDeclaredElements()[0];
|
||||
@@ -201,4 +198,11 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static PsiType toArray(PsiType paramType) {
|
||||
if (paramType instanceof PsiEllipsisType) {
|
||||
return ((PsiEllipsisType)paramType).toArrayType();
|
||||
}
|
||||
return paramType;
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -24,6 +24,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.DebugUtil;
|
||||
import com.intellij.psi.impl.PsiImplUtil;
|
||||
import com.intellij.psi.impl.source.resolve.JavaResolveCache;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession;
|
||||
import com.intellij.psi.impl.source.tree.ChildRole;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
@@ -208,6 +209,12 @@ public class PsiMethodCallExpressionImpl extends ExpressionPsiElement implements
|
||||
PsiSubstitutor substitutor) {
|
||||
PsiType substitutedReturnType = substitutor.substitute(ret);
|
||||
if (substitutedReturnType == null) return TypeConversionUtil.erasure(ret);
|
||||
if (InferenceSession.wasUncheckedConversionPerformed(call)) {
|
||||
// 18.5.2
|
||||
// if unchecked conversion was necessary, then this substitution provides the parameter types of the invocation type,
|
||||
// while the return type and thrown types are given by the erasure of m's type (without applying θ').
|
||||
return TypeConversionUtil.erasure(substitutedReturnType);
|
||||
}
|
||||
if (PsiUtil.isRawSubstitutor(method, substitutor)) {
|
||||
final PsiType returnTypeErasure = TypeConversionUtil.erasure(ret);
|
||||
if (Comparing.equal(TypeConversionUtil.erasure(substitutedReturnType), returnTypeErasure)) {
|
||||
|
||||
+2
-13
@@ -367,7 +367,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
boolean toFilter = false;
|
||||
for (CandidateInfo conflict : conflicts) {
|
||||
ProgressManager.checkCanceled();
|
||||
@MethodCandidateInfo.ApplicabilityLevelConstant final int level = preferVarargs((MethodCandidateInfo)conflict);
|
||||
@MethodCandidateInfo.ApplicabilityLevelConstant final int level = ((MethodCandidateInfo)conflict).getPertinentApplicabilityLevel();
|
||||
if (maxApplicabilityLevel > 0 && maxApplicabilityLevel != level) {
|
||||
toFilter = true;
|
||||
}
|
||||
@@ -380,7 +380,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
for (Iterator<CandidateInfo> iterator = conflicts.iterator(); iterator.hasNext();) {
|
||||
ProgressManager.checkCanceled();
|
||||
CandidateInfo info = iterator.next();
|
||||
final int level = preferVarargs((MethodCandidateInfo)info);
|
||||
final int level = ((MethodCandidateInfo)info).getPertinentApplicabilityLevel();
|
||||
if (level < maxApplicabilityLevel) {
|
||||
iterator.remove();
|
||||
}
|
||||
@@ -390,17 +390,6 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
return maxApplicabilityLevel;
|
||||
}
|
||||
|
||||
private static int preferVarargs(MethodCandidateInfo info) {
|
||||
final int level = info.getPertinentApplicabilityLevel();
|
||||
if (level == MethodCandidateInfo.ApplicabilityLevel.FIXED_ARITY) {
|
||||
final PsiMethod psiMethod = info.getElement();
|
||||
if (psiMethod != null && psiMethod.isVarArgs() && JavaVersionService.getInstance().isAtLeast(psiMethod, JavaSdkVersion.JDK_1_7)) {
|
||||
return level + 1;
|
||||
}
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
private static int getCheckAccessLevel(MethodCandidateInfo method){
|
||||
boolean visible = method.isAccessible();
|
||||
return visible ? 1 : 0;
|
||||
|
||||
+1
-1
@@ -12,6 +12,6 @@ class C<T extends A & B>
|
||||
{
|
||||
void bar(T x)
|
||||
{
|
||||
x.foo(null);
|
||||
x.foo<error descr="Ambiguous method call: both 'A.foo(String[]...)' and 'B.foo(String[])' match">(null)</error>;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -7,8 +7,8 @@ public class Sample {
|
||||
<B> B bar(G<B> gb) {return null;}
|
||||
|
||||
void f(G1 g1) {
|
||||
<error descr="Incompatible types. Found: 'B', required: 'Sample.G<java.lang.String>'">G<String> l11 = bar(g1);</error>
|
||||
<error descr="Incompatible types. Found: 'B', required: 'java.lang.String'">String l1 = bar(g1);</error>
|
||||
<error descr="Incompatible types. Found: 'java.lang.Object', required: 'Sample.G<java.lang.String>'">G<String> l11 = bar(g1);</error>
|
||||
<error descr="Incompatible types. Found: 'java.lang.Object', required: 'java.lang.String'">String l1 = bar(g1);</error>
|
||||
Object o = bar(g1);
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
class Main {
|
||||
|
||||
{
|
||||
foo(bar(String.class));
|
||||
}
|
||||
|
||||
<T extends String> T bar(Class<T> cf) {
|
||||
return null;
|
||||
}
|
||||
|
||||
<K extends String> K foo(K vo) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+1
@@ -23,5 +23,6 @@ interface II {
|
||||
class Test1 {
|
||||
void bar(boolean b){
|
||||
II ik = b ? (s)-> true : (s)->false;
|
||||
II ik1 = (II)(b ? <error descr="Lambda expression not expected here">(s)-> true</error> : <error descr="Lambda expression not expected here">(s)->false</error>);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
interface Var {
|
||||
void var(int[] ps);
|
||||
}
|
||||
class Abc {
|
||||
void foo() {
|
||||
Var var = (int... ps) -> {};
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class Test {
|
||||
interface I<K> {}
|
||||
|
||||
{
|
||||
I i = foo(TreeMap::new);
|
||||
}
|
||||
|
||||
<M extends Map<Integer, Integer>> I<M> foo(Supplier<M> mapFactory) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with lambda" "true"
|
||||
class HelloLambda {
|
||||
final int x;
|
||||
|
||||
HelloLambda() {
|
||||
x = 1;
|
||||
Runnable r = () -> {
|
||||
System.out.println(x);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// "Replace with lambda" "true"
|
||||
class HelloLambda {
|
||||
private final Runnable r = () -> {
|
||||
System.out.println(x);
|
||||
};
|
||||
private static int x = 0;
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// "Replace with lambda" "false"
|
||||
class HelloLambda {
|
||||
final int x;
|
||||
|
||||
HelloLambda() {
|
||||
Runnable r = new Runn<caret>able() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println(x);
|
||||
|
||||
}
|
||||
};
|
||||
x = 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// "Replace with lambda" "true"
|
||||
class HelloLambda {
|
||||
final int x;
|
||||
|
||||
HelloLambda() {
|
||||
x = 1;
|
||||
Runnable r = new Runn<caret>able() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println(x);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with lambda" "false"
|
||||
class HelloLambda {
|
||||
private final Runnable r = new Run<caret>nable() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println(x);
|
||||
}
|
||||
};
|
||||
private int x = 0;
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with lambda" "true"
|
||||
class HelloLambda {
|
||||
private final Runnable r = new Run<caret>nable() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println(x);
|
||||
}
|
||||
};
|
||||
private static int x = 0;
|
||||
}
|
||||
+12
@@ -1384,6 +1384,18 @@ class Foo {{
|
||||
doMultiCaretTest()
|
||||
}
|
||||
|
||||
public void testFinishWithEqualsWhenMultipleCaretsAreEnabled() {
|
||||
EditorTestUtil.enableMultipleCarets()
|
||||
try {
|
||||
configureByFile("SpacesAroundEq.java");
|
||||
type('=');
|
||||
checkResultByFile("SpacesAroundEq_after.java");
|
||||
}
|
||||
finally {
|
||||
EditorTestUtil.disableMultipleCarets()
|
||||
}
|
||||
}
|
||||
|
||||
public void "test complete lowercase class name"() {
|
||||
myFixture.addClass("package foo; public class myClass {}")
|
||||
myFixture.configureByText "a.java", """
|
||||
|
||||
+4
@@ -152,6 +152,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNestedCalls1() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
+4
@@ -130,6 +130,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA117124() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
+4
@@ -169,6 +169,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testRawTargetType() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
@@ -7,10 +7,12 @@ package com.intellij.refactoring;
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.TargetElementUtilBase;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.refactoring.extractMethodObject.ExtractMethodObjectHandler;
|
||||
import com.intellij.refactoring.extractMethodObject.ExtractMethodObjectProcessor;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ExtractMethodObjectTest extends LightRefactoringTestCase {
|
||||
@@ -120,4 +122,9 @@ public class ExtractMethodObjectTest extends LightRefactoringTestCase {
|
||||
public void testWithPrivateMethodWhichCantBeMoved() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return IdeaTestUtil.getMockJdk18();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ package com.intellij.refactoring;
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.analysis.AnalysisScope;
|
||||
import com.intellij.codeInsight.TargetElementUtilBase;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMember;
|
||||
import com.intellij.refactoring.util.duplicates.MethodDuplicatesHandler;
|
||||
@@ -51,4 +52,9 @@ public abstract class FindMethodDuplicatesBaseTest extends LightCodeInsightTestC
|
||||
}
|
||||
|
||||
protected abstract String getTestFilePath();
|
||||
|
||||
@Override
|
||||
protected LanguageLevel getLanguageLevel() {
|
||||
return LanguageLevel.JDK_1_7;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ package com.intellij.refactoring.inline;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.TargetElementUtilBase;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
@@ -26,6 +27,7 @@ import com.intellij.refactoring.BaseRefactoringProcessor;
|
||||
import com.intellij.refactoring.LightRefactoringTestCase;
|
||||
import com.intellij.refactoring.MockInlineMethodOptions;
|
||||
import com.intellij.refactoring.util.InlineUtil;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -299,4 +301,9 @@ public class InlineMethodTest extends LightRefactoringTestCase {
|
||||
new InlineMethodProcessor(getProject(), method, refExpr, myEditor, options.isInlineThisOnly(), nonCode, nonCode);
|
||||
processor.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return IdeaTestUtil.getMockJdk18();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,4 +201,8 @@ public class QualifiedName {
|
||||
public int hashCode() {
|
||||
return myComponents.hashCode();
|
||||
}
|
||||
|
||||
public QualifiedName subQualifiedName(int fromIndex, int toIndex) {
|
||||
return fromComponents(myComponents.subList(fromIndex, toIndex));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ import com.intellij.psi.util.CachedValuesManager;
|
||||
import com.intellij.psi.util.PsiModificationTracker;
|
||||
import com.intellij.util.CachedValuesManagerImpl;
|
||||
import com.intellij.util.messages.impl.MessageBusImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.picocontainer.PicoContainer;
|
||||
|
||||
public class CoreProjectEnvironment {
|
||||
private final Disposable myParentDisposable;
|
||||
@@ -54,7 +56,7 @@ public class CoreProjectEnvironment {
|
||||
public CoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) {
|
||||
myParentDisposable = parentDisposable;
|
||||
myEnvironment = applicationEnvironment;
|
||||
myProject = new MockProject(myEnvironment.getApplication().getPicoContainer(), myParentDisposable);
|
||||
myProject = createProject(myEnvironment.getApplication().getPicoContainer(), myParentDisposable);
|
||||
|
||||
preregisterServices();
|
||||
|
||||
@@ -84,6 +86,10 @@ public class CoreProjectEnvironment {
|
||||
myProject.registerService(DumbService.class, new MockDumbService(myProject));
|
||||
}
|
||||
|
||||
protected MockProject createProject(PicoContainer parent, @NotNull Disposable parentDisposable) {
|
||||
return new MockProject(parent, parentDisposable);
|
||||
}
|
||||
|
||||
protected ProjectScopeBuilder createProjectScopeBuilder() {
|
||||
return new CoreProjectScopeBuilder(myProject, myFileIndexFacade);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public class PluginManagerCore {
|
||||
return ourDisabledPlugins;
|
||||
}
|
||||
|
||||
private static boolean isBrokenPlugin(IdeaPluginDescriptor descriptor) {
|
||||
public static boolean isBrokenPlugin(IdeaPluginDescriptor descriptor) {
|
||||
return getBrokenPluginVersions().get(descriptor.getPluginId().getIdString()).contains(descriptor.getVersion());
|
||||
}
|
||||
|
||||
|
||||
@@ -60,9 +60,9 @@ class ConsoleGutterComponent extends JComponent implements MouseMotionListener {
|
||||
});
|
||||
}
|
||||
|
||||
public void updateSize() {
|
||||
public void updateSize(int start, int end) {
|
||||
int oldAnnotationsWidth = maxAnnotationWidth;
|
||||
computeMaxAnnotationWidth();
|
||||
computeMaxAnnotationWidth(start, end);
|
||||
if (oldAnnotationsWidth != maxAnnotationWidth || myLastPreferredHeight != editor.getPreferredHeight()) {
|
||||
fireResized();
|
||||
}
|
||||
@@ -73,7 +73,7 @@ class ConsoleGutterComponent extends JComponent implements MouseMotionListener {
|
||||
processComponentEvent(new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED));
|
||||
}
|
||||
|
||||
private void computeMaxAnnotationWidth() {
|
||||
private void computeMaxAnnotationWidth(int start, int end) {
|
||||
gutterContentProvider.beforeUiComponentUpdate(editor);
|
||||
|
||||
if (!gutterContentProvider.hasText()) {
|
||||
@@ -82,10 +82,10 @@ class ConsoleGutterComponent extends JComponent implements MouseMotionListener {
|
||||
}
|
||||
|
||||
FontMetrics fontMetrics = editor.getFontMetrics(Font.PLAIN);
|
||||
int lineCount = editor.getDocument().getLineCount();
|
||||
int lineCount = Math.min(end, editor.getDocument().getLineCount());
|
||||
int gutterSize = 0;
|
||||
for (int i = 0; i < lineCount; i++) {
|
||||
String text = gutterContentProvider.getText(i, editor);
|
||||
for (int line = start; line < lineCount; line++) {
|
||||
String text = gutterContentProvider.getText(line, editor);
|
||||
if (text != null) {
|
||||
gutterSize = Math.max(gutterSize, fontMetrics.stringWidth(text));
|
||||
}
|
||||
@@ -94,7 +94,9 @@ class ConsoleGutterComponent extends JComponent implements MouseMotionListener {
|
||||
if (gutterSize != 0) {
|
||||
gutterSize += lineEndInset;
|
||||
}
|
||||
maxAnnotationWidth = gutterSize;
|
||||
maxAnnotationWidth = Math.max(gutterSize, maxAnnotationWidth);
|
||||
|
||||
editor.getSettings().setAdditionalColumnsCount(1 + (maxAnnotationWidth / EditorUtil.getSpaceWidth(Font.PLAIN, editor)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -125,7 +125,7 @@ public final class LanguageConsoleBuilder {
|
||||
return new Pair<AnAction, ConsoleHistoryController>(action, historyController);
|
||||
}
|
||||
|
||||
public LanguageConsoleBuilder historyAnnotation(@Nullable GutterContentProvider value) {
|
||||
public LanguageConsoleBuilder gutterContentProvider(@Nullable GutterContentProvider value) {
|
||||
gutterContentProvider = value;
|
||||
return this;
|
||||
}
|
||||
@@ -196,6 +196,11 @@ public final class LanguageConsoleBuilder {
|
||||
this.psiFileFactory = psiFileFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isHistoryViewerForceAdditionalColumnsUsage() {
|
||||
return gutterContentProvider == null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected PsiFile createFile(@NotNull LightVirtualFile virtualFile, @NotNull Document document, @NotNull Project project) {
|
||||
@@ -288,7 +293,7 @@ public final class LanguageConsoleBuilder {
|
||||
private final ConsoleIconGutterComponent lineStartGutter;
|
||||
private final ConsoleGutterComponent lineEndGutter;
|
||||
|
||||
private Runnable gutterSizeUpdater;
|
||||
private Task gutterSizeUpdater;
|
||||
private RangeHighlighterEx lineSeparatorPainter;
|
||||
|
||||
public GutterUpdateScheduler(@NotNull ConsoleIconGutterComponent lineStartGutter, @NotNull ConsoleGutterComponent lineEndGutter) {
|
||||
@@ -333,7 +338,7 @@ public final class LanguageConsoleBuilder {
|
||||
int startDocLine = document.getLineNumber(event.getOffset());
|
||||
int endDocLine = document.getLineNumber(event.getOffset() + event.getNewLength());
|
||||
if (event.getOldLength() > event.getNewLength() || startDocLine != endDocLine || StringUtil.indexOf(event.getOldFragment(), '\n') != -1) {
|
||||
updateGutterSize();
|
||||
updateGutterSize(0, Integer.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
else if (event.getOldLength() > 0) {
|
||||
@@ -342,6 +347,8 @@ public final class LanguageConsoleBuilder {
|
||||
}
|
||||
|
||||
private void documentCleared() {
|
||||
gutterSizeUpdater = null;
|
||||
|
||||
assert gutterContentProvider != null;
|
||||
gutterContentProvider.documentCleared(getHistoryViewer());
|
||||
}
|
||||
@@ -358,26 +365,38 @@ public final class LanguageConsoleBuilder {
|
||||
else {
|
||||
addLineSeparatorPainterIfNeed();
|
||||
}
|
||||
updateGutterSize();
|
||||
updateGutterSize(0, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
private void updateGutterSize() {
|
||||
private void updateGutterSize(int start, int end) {
|
||||
if (gutterSizeUpdater != null) {
|
||||
gutterSizeUpdater.start = Math.min(start, gutterSizeUpdater.start);
|
||||
gutterSizeUpdater.end = Math.max(end, gutterSizeUpdater.end);
|
||||
return;
|
||||
}
|
||||
|
||||
gutterSizeUpdater = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!getHistoryViewer().isDisposed()) {
|
||||
lineStartGutter.updateSize();
|
||||
lineEndGutter.updateSize();
|
||||
}
|
||||
gutterSizeUpdater = null;
|
||||
}
|
||||
};
|
||||
gutterSizeUpdater = new Task(start, end);
|
||||
SwingUtilities.invokeLater(gutterSizeUpdater);
|
||||
}
|
||||
|
||||
private final class Task implements Runnable {
|
||||
private int start;
|
||||
private int end;
|
||||
|
||||
public Task(int start, int end) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!getHistoryViewer().isDisposed()) {
|
||||
lineStartGutter.updateSize();
|
||||
lineEndGutter.updateSize(start, end);
|
||||
}
|
||||
gutterSizeUpdater = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final class LineSeparatorPainter extends RangeMarkerImpl implements RangeHighlighterEx, Getter<RangeHighlighterEx> {
|
||||
|
||||
@@ -682,6 +682,10 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
|
||||
return ObjectUtils.assertNotNull(PsiManager.getInstance(project).findFile(virtualFile));
|
||||
}
|
||||
|
||||
boolean isHistoryViewerForceAdditionalColumnsUsage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private class MyLayout extends AbstractLayoutManager {
|
||||
@Override
|
||||
public Dimension preferredLayoutSize(final Container parent) {
|
||||
@@ -713,9 +717,11 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
|
||||
// deal with width
|
||||
final int width = Math.max(editorSize.width, historySize.width);
|
||||
newEditorSize.width = width + editor.getScrollPane().getHorizontalScrollBar().getHeight();
|
||||
history.getSoftWrapModel().forceAdditionalColumnsUsage();
|
||||
editor.getSettings().setAdditionalColumnsCount(2 + (width - editorSize.width) / EditorUtil.getSpaceWidth(Font.PLAIN, editor));
|
||||
history.getSettings().setAdditionalColumnsCount(2 + (width - historySize.width) / EditorUtil.getSpaceWidth(Font.PLAIN, history));
|
||||
if (isHistoryViewerForceAdditionalColumnsUsage()) {
|
||||
history.getSoftWrapModel().forceAdditionalColumnsUsage();
|
||||
editor.getSettings().setAdditionalColumnsCount(2 + (width - editorSize.width) / EditorUtil.getSpaceWidth(Font.PLAIN, editor));
|
||||
history.getSettings().setAdditionalColumnsCount(2 + (width - historySize.width) / EditorUtil.getSpaceWidth(Font.PLAIN, history));
|
||||
}
|
||||
|
||||
// deal with height
|
||||
if (historySize.width == 0) {
|
||||
|
||||
@@ -220,7 +220,7 @@ public class SearchResults implements DocumentListener {
|
||||
@Override
|
||||
public void run() {
|
||||
Project project = getProject();
|
||||
if (project != null && project.isDisposed()) return;
|
||||
if (myDisposed || project != null && project.isDisposed()) return;
|
||||
int[] starts = new int[0];
|
||||
int[] ends = new int[0];
|
||||
try {
|
||||
|
||||
+24
-18
@@ -51,7 +51,7 @@ public class TypedAction {
|
||||
|
||||
private static class Handler implements TypedActionHandler {
|
||||
@Override
|
||||
public void execute(@NotNull Editor editor, char charTyped, @NotNull DataContext dataContext) {
|
||||
public void execute(@NotNull final Editor editor, char charTyped, @NotNull DataContext dataContext) {
|
||||
if (editor.isViewer()) return;
|
||||
|
||||
Document doc = editor.getDocument();
|
||||
@@ -64,7 +64,18 @@ public class TypedAction {
|
||||
try {
|
||||
final String str = String.valueOf(charTyped);
|
||||
CommandProcessor.getInstance().setCurrentCommandName(EditorBundle.message("typing.in.editor.command.name"));
|
||||
EditorModificationUtil.typeInStringAtCaretHonorBlockSelection(editor, str, true);
|
||||
|
||||
if (editor.getCaretModel().getAllCarets().size() == 1) { // temporary fix for completion - going forward we shouldn't use this check
|
||||
EditorModificationUtil.typeInStringAtCaretHonorBlockSelection(editor, str, true);
|
||||
}
|
||||
else {
|
||||
editor.getCaretModel().runForEachCaret(new CaretAction() {
|
||||
@Override
|
||||
public void perform(Caret caret) {
|
||||
EditorModificationUtil.typeInStringAtCaretHonorBlockSelection(editor, str, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (ReadOnlyFragmentModificationException e) {
|
||||
EditorActionManager.getInstance().getReadonlyFragmentModificationHandler(doc).handle(e);
|
||||
@@ -127,22 +138,17 @@ public class TypedAction {
|
||||
ApplicationManager.getApplication().runWriteAction(new DocumentRunnable(myEditor.getDocument(), myEditor.getProject()) {
|
||||
@Override
|
||||
public void run() {
|
||||
myEditor.getCaretModel().runForEachCaret(new CaretAction() {
|
||||
@Override
|
||||
public void perform(Caret caret) {
|
||||
Document doc = myEditor.getDocument();
|
||||
doc.startGuardedBlockChecking();
|
||||
try {
|
||||
getHandler().execute(myEditor, myCharTyped, myDataContext);
|
||||
}
|
||||
catch (ReadOnlyFragmentModificationException e) {
|
||||
EditorActionManager.getInstance().getReadonlyFragmentModificationHandler(doc).handle(e);
|
||||
}
|
||||
finally {
|
||||
doc.stopGuardedBlockChecking();
|
||||
}
|
||||
}
|
||||
});
|
||||
Document doc = myEditor.getDocument();
|
||||
doc.startGuardedBlockChecking();
|
||||
try {
|
||||
getHandler().execute(myEditor, myCharTyped, myDataContext);
|
||||
}
|
||||
catch (ReadOnlyFragmentModificationException e) {
|
||||
EditorActionManager.getInstance().getReadonlyFragmentModificationHandler(doc).handle(e);
|
||||
}
|
||||
finally {
|
||||
doc.stopGuardedBlockChecking();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.registry.RegistryValue;
|
||||
import com.intellij.openapi.util.registry.RegistryValueListener;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -187,23 +188,15 @@ public class KeymapUtil {
|
||||
@NotNull
|
||||
public static String getFirstKeyboardShortcutText(@NotNull String actionId) {
|
||||
Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(actionId);
|
||||
for (Shortcut shortcut : shortcuts) {
|
||||
if (shortcut instanceof KeyboardShortcut) {
|
||||
return getShortcutText(shortcut);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
KeyboardShortcut shortcut = ContainerUtil.findInstance(shortcuts, KeyboardShortcut.class);
|
||||
return shortcut == null? "" : getShortcutText(shortcut);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getFirstKeyboardShortcutText(@NotNull AnAction action) {
|
||||
Shortcut[] shortcuts = action.getShortcutSet().getShortcuts();
|
||||
for (Shortcut shortcut : shortcuts) {
|
||||
if (shortcut instanceof KeyboardShortcut) {
|
||||
return getShortcutText(shortcut);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
KeyboardShortcut shortcut = ContainerUtil.findInstance(shortcuts, KeyboardShortcut.class);
|
||||
return shortcut == null ? "" : getShortcutText(shortcut);
|
||||
}
|
||||
|
||||
public static String getShortcutsText(Shortcut[] shortcuts) {
|
||||
|
||||
@@ -37,4 +37,5 @@ public interface ToolWindowId {
|
||||
String DUPLICATES = UIBundle.message("tool.window.name.module.duplicates");
|
||||
String DOCUMENTATION = UIBundle.message("tool.window.name.documentation");
|
||||
String TASKS = UIBundle.message("tool.window.name.tasks");
|
||||
String DATABASE_VIEW = UIBundle.message("tool.window.name.database");
|
||||
}
|
||||
@@ -197,7 +197,7 @@ public class CertificatesManager implements ApplicationComponent, PersistentStat
|
||||
Application app = ApplicationManager.getApplication();
|
||||
final CountDownLatch proceeded = new CountDownLatch(1);
|
||||
final AtomicBoolean accepted = new AtomicBoolean();
|
||||
app.invokeLater(new Runnable() {
|
||||
Runnable showDialog = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
@@ -211,7 +211,13 @@ public class CertificatesManager implements ApplicationComponent, PersistentStat
|
||||
proceeded.countDown();
|
||||
}
|
||||
}
|
||||
}, ModalityState.any());
|
||||
};
|
||||
if (app.isDispatchThread()) {
|
||||
showDialog.run();
|
||||
}
|
||||
else {
|
||||
app.invokeLater(showDialog, ModalityState.any());
|
||||
}
|
||||
try {
|
||||
proceeded.await();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.ide.actions;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class MoveTabDownAction extends SplitAction {
|
||||
protected MoveTabDownAction() {
|
||||
super(SwingConstants.HORIZONTAL, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.ide.actions;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class MoveTabRightAction extends SplitAction {
|
||||
protected MoveTabRightAction() {
|
||||
super(SwingConstants.VERTICAL, true);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,44 +15,52 @@
|
||||
*/
|
||||
package com.intellij.ide.actions;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
|
||||
import com.intellij.openapi.fileEditor.impl.EditorWindow;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
import javax.swing.*;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
/**
|
||||
* @author Vladimir Kondratyev
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public abstract class SplitAction extends AnAction implements DumbAware {
|
||||
private final int myOrientation;
|
||||
private final boolean myCloseSource;
|
||||
|
||||
protected SplitAction(final int orientation){
|
||||
protected SplitAction(final int orientation) {
|
||||
this(orientation, false);
|
||||
}
|
||||
|
||||
protected SplitAction(final int orientation, boolean closeSource) {
|
||||
myOrientation = orientation;
|
||||
myCloseSource = closeSource;
|
||||
}
|
||||
|
||||
public void actionPerformed(final AnActionEvent event) {
|
||||
final Project project = CommonDataKeys.PROJECT.getData(event.getDataContext());
|
||||
final Project project = event.getData(CommonDataKeys.PROJECT);
|
||||
final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
|
||||
final EditorWindow window = EditorWindow.DATA_KEY.getData(event.getDataContext());
|
||||
final EditorWindow window = event.getData(EditorWindow.DATA_KEY);
|
||||
final VirtualFile file = event.getData(CommonDataKeys.VIRTUAL_FILE);
|
||||
|
||||
fileEditorManager.createSplitter(myOrientation, window);
|
||||
|
||||
if (myCloseSource && window != null && file != null) {
|
||||
window.closeFile(file, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void update(final AnActionEvent event) {
|
||||
final Project project = CommonDataKeys.PROJECT.getData(event.getDataContext());
|
||||
final Presentation presentation = event.getPresentation();
|
||||
presentation.setText (myOrientation == SwingConstants.VERTICAL
|
||||
? IdeBundle.message("action.split.vertically")
|
||||
: IdeBundle.message("action.split.horizontally"));
|
||||
if (project == null) {
|
||||
presentation.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
|
||||
presentation.setEnabled(fileEditorManager.hasOpenedFile ());
|
||||
final Project project = event.getData(CommonDataKeys.PROJECT);
|
||||
final EditorWindow window = event.getData(EditorWindow.DATA_KEY);
|
||||
final int minimum = myCloseSource ? 2 : 1;
|
||||
final boolean enabled = project != null
|
||||
&& window != null
|
||||
&& window.getTabCount() >= minimum;
|
||||
event.getPresentation().setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,6 @@ class AvailablePluginColumnInfo extends PluginManagerColumnInfo {
|
||||
|
||||
@Override
|
||||
public TableCellRenderer getRenderer(final IdeaPluginDescriptor pluginDescriptor) {
|
||||
return new PluginsTableRenderer(pluginDescriptor);
|
||||
return new PluginsTableRenderer(pluginDescriptor, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -642,7 +642,7 @@ public class InstalledPluginsTableModel extends PluginTableModel {
|
||||
|
||||
@Override
|
||||
public TableCellRenderer getRenderer(final IdeaPluginDescriptor pluginDescriptor) {
|
||||
return new PluginsTableRenderer(pluginDescriptor);
|
||||
return new PluginsTableRenderer(pluginDescriptor, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -115,7 +115,13 @@ public class PluginHeaderPanel {
|
||||
myVersion.setText("Version: " + (version == null ? "N/A" : version));
|
||||
myUpdated.setVisible(false);
|
||||
if (!plugin.isBundled()) {
|
||||
myActionId = ((IdeaPluginDescriptorImpl)plugin).isDeleted() ? ACTION_ID.RESTART : ACTION_ID.UNINSTALL;
|
||||
if (((IdeaPluginDescriptorImpl)plugin).isDeleted()) {
|
||||
myActionId = ACTION_ID.RESTART;
|
||||
} else if (InstalledPluginsTableModel.hasNewerVersion(plugin.getPluginId())) {
|
||||
myActionId = ACTION_ID.UPDATE;
|
||||
} else {
|
||||
myActionId = ACTION_ID.UNINSTALL;
|
||||
}
|
||||
}
|
||||
if (myActionId == ACTION_ID.RESTART && myManager != null && !myManager.isRequireShutdown()) {
|
||||
myActionId = null;
|
||||
@@ -167,7 +173,7 @@ public class PluginHeaderPanel {
|
||||
|
||||
private Color getButtonForeground() {
|
||||
switch (myActionId) {
|
||||
case UPDATE: return new JBColor(Gray._0, Gray._20);
|
||||
case UPDATE: return new JBColor(Gray._0, Gray._210);
|
||||
case INSTALL: return new JBColor(Gray._255, Gray._210);
|
||||
case UNINSTALL: return new JBColor(Gray._0, Gray._140);
|
||||
case RESTART:
|
||||
@@ -179,7 +185,7 @@ public class PluginHeaderPanel {
|
||||
|
||||
private Paint getBackgroundPaint() {
|
||||
switch (myActionId) {
|
||||
case UPDATE: return new JBColor(new Color(209, 190, 114), new Color(132, 116, 66));
|
||||
case UPDATE: return new JBColor(new Color(209, 190, 114), new Color(49, 98, 49));
|
||||
case INSTALL: return new JBColor(new Color(0x4DA864), new Color(49, 98, 49));
|
||||
case UNINSTALL: return UIUtil.isUnderDarcula()
|
||||
? new GradientPaint(0, 0, UIManager.getColor("Button.darcula.color1"),
|
||||
@@ -216,7 +222,7 @@ public class PluginHeaderPanel {
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
switch (myActionId) {
|
||||
case UPDATE: return AllIcons.Actions.Refresh;
|
||||
case UPDATE: return AllIcons.General.DownloadPlugin;
|
||||
case INSTALL: return AllIcons.General.DownloadPlugin;
|
||||
case UNINSTALL: return AllIcons.Actions.Delete;
|
||||
case RESTART: return AllIcons.Actions.Restart;
|
||||
@@ -230,7 +236,6 @@ public class PluginHeaderPanel {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch (myActionId) {
|
||||
case UPDATE:
|
||||
break;
|
||||
case INSTALL:
|
||||
new ActionInstallPlugin(myManager.getAvailable(), myManager.getInstalled()).install(new Runnable() {
|
||||
@Override
|
||||
|
||||
@@ -29,14 +29,14 @@
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="cebe0" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<grid id="cebe0" binding="myInfoPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties>
|
||||
<opaque value="false"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="80605" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="80605" binding="myBottomPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints border-constraint="South"/>
|
||||
<properties>
|
||||
|
||||
@@ -43,10 +43,13 @@ public class PluginsTableRenderer extends DefaultTableCellRenderer {
|
||||
|
||||
private JLabel myCategory;
|
||||
private JPanel myRightPanel;
|
||||
private JPanel myBottomPanel;
|
||||
private JPanel myInfoPanel;
|
||||
private final IdeaPluginDescriptor myPluginDescriptor;
|
||||
|
||||
public PluginsTableRenderer(IdeaPluginDescriptor pluginDescriptor) {
|
||||
public PluginsTableRenderer(IdeaPluginDescriptor pluginDescriptor, boolean showFullInfo) {
|
||||
myPluginDescriptor = pluginDescriptor;
|
||||
boolean myShowFullInfo = showFullInfo;
|
||||
|
||||
final Font smallFont;
|
||||
if (SystemInfo.isMac) {
|
||||
@@ -61,9 +64,14 @@ public class PluginsTableRenderer extends DefaultTableCellRenderer {
|
||||
myStatus.setText("");
|
||||
myCategory.setText("");
|
||||
myLastUpdated.setFont(smallFont);
|
||||
if (! (pluginDescriptor instanceof PluginNode)) {
|
||||
if (!myShowFullInfo || !(pluginDescriptor instanceof PluginNode)) {
|
||||
myPanel.remove(myRightPanel);
|
||||
}
|
||||
|
||||
if (!myShowFullInfo) {
|
||||
myInfoPanel.remove(myBottomPanel);
|
||||
}
|
||||
|
||||
myPanel.setBorder(UIUtil.isRetina() ? new EmptyBorder(4,3,4,3) : new EmptyBorder(2,3,2,3));
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.fileEditor.impl;
|
||||
|
||||
import com.intellij.ide.actions.ActivateToolWindowAction;
|
||||
import com.intellij.ide.actions.ShowFilePathAction;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.actionSystem.Shortcut;
|
||||
@@ -87,7 +88,7 @@ public class EditorEmptyTextPainter {
|
||||
|
||||
protected void appendToolWindow(UIUtil.TextPainter painter, String action, String toolWindowId, EditorsSplitters splitters) {
|
||||
if (!isToolwindowVisible(splitters, toolWindowId)) {
|
||||
String activateActionId = "Activate" + toolWindowId + "ToolWindow";
|
||||
String activateActionId = ActivateToolWindowAction.getActionIdForToolWindow(toolWindowId);
|
||||
appendAction(painter, action, getActionShortcutText(activateActionId));
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -28,12 +28,11 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import com.intellij.openapi.fileTypes.FileTypeFactory;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.startup.StartupActivity;
|
||||
import com.intellij.openapi.updateSettings.impl.*;
|
||||
import com.intellij.openapi.updateSettings.impl.PluginDownloader;
|
||||
import com.intellij.openapi.updateSettings.impl.UpdateSettings;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -134,6 +133,8 @@ public class PluginsAdvertiser implements StartupActivity {
|
||||
if (loadedPlugin != null && fromServerPluginDescription != null &&
|
||||
StringUtil.compareVersionNumbers(loadedPlugin.getVersion(), fromServerPluginDescription.getVersion()) >= 0) continue;
|
||||
|
||||
if (fromServerPluginDescription != null && PluginManagerCore.isBrokenPlugin(fromServerPluginDescription)) continue;
|
||||
|
||||
final JsonElement ext = jsonObject.get("implementationName");
|
||||
final String extension = StringUtil.unquoteString(ext.toString());
|
||||
Set<Plugin> pluginIds = result.get(extension);
|
||||
|
||||
@@ -141,10 +141,7 @@ class VirtualFileImpl extends HttpVirtualFile {
|
||||
|
||||
@Override
|
||||
public VirtualFile[] getChildren() {
|
||||
if (myFileInfo == null) {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -834,6 +834,10 @@ action.SplitVertically.text=Split _Vertically
|
||||
action.SplitVertically.description=Split editor area into 2 tab groups and move the current tab to the right group
|
||||
action.SplitHorizontally.text=Split _Horizontally
|
||||
action.SplitHorizontally.description=Split editor area into 2 tab groups and move the current tab to the bottom group
|
||||
action.MoveTabRight.text=Move Right
|
||||
action.MoveTabRight.description=Split editor area into 2 tab groups and move the current tab to the right group and close the left editor
|
||||
action.MoveTabDown.text=Move Down
|
||||
action.MoveTabDown.description=Split editor area into 2 tab groups and move the current tab to the bottom group and close the top editor
|
||||
action.ChangeSplitOrientation.text=Change Splitter O_rientation
|
||||
action.ChangeSplitOrientation.description=Changes orientation of splitter
|
||||
action.Unsplit.text=Un_split
|
||||
|
||||
@@ -54,6 +54,7 @@ tool.window.name.dependency.viewer=Dependency Viewer
|
||||
tool.window.name.version.control=Version Control
|
||||
tool.window.name.module.dependencies=Module Dependencies
|
||||
tool.window.name.tasks=Time Tracking
|
||||
tool.window.name.database=Database
|
||||
tool.window.move.to.action.group.name=Move to
|
||||
tool.window.move.to.top.action.name=Top
|
||||
tool.window.move.to.left.action.name=Left
|
||||
|
||||
@@ -376,6 +376,8 @@
|
||||
<action id="ReopenClosedTab" class="com.intellij.openapi.fileEditor.impl.ReopenClosedTabAction" />
|
||||
<action id="SplitVertically" class="com.intellij.ide.actions.SplitVerticallyAction" icon="AllIcons.Actions.SplitVertically"/>
|
||||
<action id="SplitHorizontally" class="com.intellij.ide.actions.SplitHorizontallyAction" icon="AllIcons.Actions.SplitHorizontally"/>
|
||||
<action id="MoveTabRight" class="com.intellij.ide.actions.MoveTabRightAction"/>
|
||||
<action id="MoveTabDown" class="com.intellij.ide.actions.MoveTabDownAction"/>
|
||||
<action id="ChangeSplitOrientation" class="com.intellij.ide.actions.ChangeSplitterOrientationAction"/>
|
||||
<action id="Unsplit" class="com.intellij.ide.actions.UnsplitAction"/>
|
||||
<action id="UnsplitAll" class="com.intellij.ide.actions.UnsplitAllAction"/>
|
||||
@@ -478,6 +480,8 @@
|
||||
<separator/>
|
||||
<reference ref="SplitVertically"/>
|
||||
<reference ref="SplitHorizontally"/>
|
||||
<reference ref="MoveTabRight"/>
|
||||
<reference ref="MoveTabDown"/>
|
||||
<action id="MoveEditorToOppositeTabGroup" class="com.intellij.openapi.fileEditor.impl.MoveEditorToOppositeTabGroupAction"/>
|
||||
<action id="OpenEditorInOppositeTabGroup" class="com.intellij.openapi.fileEditor.impl.OpenEditorInOppositeTabGroupAction"/>
|
||||
<reference ref="ChangeSplitOrientation"/>
|
||||
|
||||
@@ -2635,7 +2635,7 @@ public class StringUtil extends StringUtilRt {
|
||||
* i.e. when java.util.regex.Pattern match goes out of control.
|
||||
*/
|
||||
public abstract static class BombedCharSequence implements CharSequence {
|
||||
private CharSequence delegate;
|
||||
private final CharSequence delegate;
|
||||
private int i = 0;
|
||||
|
||||
public BombedCharSequence(@NotNull CharSequence sequence) {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class PatienceIntLCS {
|
||||
return;
|
||||
}
|
||||
|
||||
int startOffset = matchForward(0, 0);
|
||||
int startOffset = matchForward(myStart1, myStart2);
|
||||
int start1 = myStart1 + startOffset;
|
||||
int start2 = myStart2 + startOffset;
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.util.diff;
|
||||
|
||||
import gnu.trove.TIntArrayList;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
@@ -33,6 +34,7 @@ class Reindexer {
|
||||
return new int[][]{discarded1, discard(discarded1, ints2, 1)};
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
void idInit(int length1, int length2) {
|
||||
myOriginalLengths[0] = length1;
|
||||
myOriginalLengths[1] = length2;
|
||||
@@ -41,12 +43,14 @@ class Reindexer {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
int originalLength = myOriginalLengths[j];
|
||||
myOldIndecies[j] = new int[originalLength];
|
||||
for (int i = 0; i < originalLength; i++)
|
||||
for (int i = 0; i < originalLength; i++) {
|
||||
myOldIndecies[j][i] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int restoreIndex(int index, int array) {
|
||||
@TestOnly
|
||||
int restoreIndex(int index, int array) {
|
||||
return myOldIndecies[array][index];
|
||||
}
|
||||
|
||||
@@ -75,50 +79,58 @@ class Reindexer {
|
||||
}
|
||||
|
||||
public void reindex(BitSet[] discardedChanges, LCSBuilder builder) {
|
||||
BitSet changes1 = new BitSet(myOriginalLengths[0]);
|
||||
BitSet changes2 = new BitSet(myOriginalLengths[1]);
|
||||
BitSet changes1;
|
||||
BitSet changes2;
|
||||
|
||||
if (myDiscardedLengths[0] == myOriginalLengths[0] && myDiscardedLengths[0] == myOriginalLengths[0]) {
|
||||
changes1 = discardedChanges[0];
|
||||
changes2 = discardedChanges[1];
|
||||
}
|
||||
else {
|
||||
changes1 = new BitSet(myOriginalLengths[0]);
|
||||
changes2 = new BitSet(myOriginalLengths[1]);
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
while (x < myDiscardedLengths[0] || y < myDiscardedLengths[1]) {
|
||||
if ((x < myDiscardedLengths[0] && y < myDiscardedLengths[1]) && !discardedChanges[0].get(x) && !discardedChanges[1].get(y)) {
|
||||
x = increment(myOldIndecies[0], x, changes1, myOriginalLengths[0]);
|
||||
y = increment(myOldIndecies[1], y, changes2, myOriginalLengths[1]);
|
||||
continue;
|
||||
}
|
||||
if (discardedChanges[0].get(x)) {
|
||||
changes1.set(getOriginal(myOldIndecies[0], x));
|
||||
x = increment(myOldIndecies[0], x, changes1, myOriginalLengths[0]);
|
||||
continue;
|
||||
}
|
||||
if (discardedChanges[1].get(y)) {
|
||||
changes2.set(getOriginal(myOldIndecies[1], y));
|
||||
y = increment(myOldIndecies[1], y, changes2, myOriginalLengths[1]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (myDiscardedLengths[0] == 0) {
|
||||
changes1.set(0, myOriginalLengths[0]);
|
||||
}
|
||||
else {
|
||||
changes1.set(0, myOldIndecies[0][0]);
|
||||
}
|
||||
if (myDiscardedLengths[1] == 0) {
|
||||
changes2.set(0, myOriginalLengths[1]);
|
||||
}
|
||||
else {
|
||||
changes2.set(0, myOldIndecies[1][0]);
|
||||
}
|
||||
}
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
while (x < myDiscardedLengths[0] || y < myDiscardedLengths[1]) {
|
||||
if ((x < myDiscardedLengths[0] && y < myDiscardedLengths[1]) && !discardedChanges[0].get(x) && !discardedChanges[1].get(y)) {
|
||||
x = increment(myOldIndecies[0], x, changes1, myOriginalLengths[0]);
|
||||
y = increment(myOldIndecies[1], y, changes2, myOriginalLengths[1]);
|
||||
continue;
|
||||
}
|
||||
if (discardedChanges[0].get(x)) {
|
||||
changes1.set(getOriginal(myOldIndecies[0], x));
|
||||
x = increment(myOldIndecies[0], x, changes1, myOriginalLengths[0]);
|
||||
continue;
|
||||
}
|
||||
if (discardedChanges[1].get(y)) {
|
||||
changes2.set(getOriginal(myOldIndecies[1], y));
|
||||
y = increment(myOldIndecies[1], y, changes2, myOriginalLengths[1]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (myDiscardedLengths[0] == 0) {
|
||||
changes1.set(0, myOriginalLengths[0]);
|
||||
}
|
||||
else {
|
||||
changes1.set(0, myOldIndecies[0][0]);
|
||||
}
|
||||
if (myDiscardedLengths[1] == 0) {
|
||||
changes2.set(0, myOriginalLengths[1]);
|
||||
}
|
||||
else {
|
||||
changes2.set(0, myOldIndecies[1][0]);
|
||||
}
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
while (x < myOriginalLengths[0] && y < myOriginalLengths[1]) {
|
||||
int startX = x;
|
||||
while (x < myOriginalLengths[0] && y < myOriginalLengths[1] && !changes1.get(x) && !changes2.get(y)) {
|
||||
x++;
|
||||
y++;
|
||||
}
|
||||
if (x> startX) builder.addEqual(x - startX);
|
||||
if (x > startX) builder.addEqual(x - startX);
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
while (x < myOriginalLengths[0] && changes1.get(x)) {
|
||||
|
||||
@@ -70,6 +70,13 @@ public class PatienceIntLCSTest extends TestCase {
|
||||
new int[]{0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1});
|
||||
}
|
||||
|
||||
public void testBug1() throws FilesTooBigForDiffException {
|
||||
BitSet[] change = buildChange(new int[]{2, 3, 4, 6, 7, 8, 9, 11, 12, 4, 6, 11, 15},
|
||||
new int[]{2, 3, 6, 7, 8, 9, 6, 11, 12, 4, 11, 15, 6});
|
||||
checkChange(change, new int[]{0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
|
||||
new int[]{0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0});
|
||||
}
|
||||
|
||||
public void testInnerChunks1() throws FilesTooBigForDiffException {
|
||||
BitSet[] change = buildChange(new int[]{0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0}, new int[]{1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1});
|
||||
checkChange(change, new int[]{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}, new int[]{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1});
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class XKeywordValuePresentation extends XValuePresentation {
|
||||
private final String myValue;
|
||||
|
||||
public XKeywordValuePresentation(String value) {
|
||||
public XKeywordValuePresentation(@NotNull String value) {
|
||||
myValue = value;
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.xdebugger.frame.presentation;
|
||||
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -71,6 +72,8 @@ public abstract class XValuePresentation {
|
||||
*/
|
||||
void renderKeywordValue(@NotNull String value);
|
||||
|
||||
void renderValue(@NotNull String value, @Nullable TextAttributesKey key);
|
||||
|
||||
/**
|
||||
* Appends {@code value} surrounded by quotes to the node text colored as a string
|
||||
* @param value value to be shown
|
||||
|
||||
+6
@@ -19,6 +19,7 @@ import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.xdebugger.frame.presentation.XValuePresentation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -39,5 +40,10 @@ public abstract class XValueTextRendererBase implements XValuePresentation.XValu
|
||||
renderRawValue(value, DefaultLanguageHighlighterColors.KEYWORD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void renderValue(@NotNull String value, @Nullable TextAttributesKey key) {
|
||||
renderRawValue(value, key);
|
||||
}
|
||||
|
||||
protected abstract void renderRawValue(@NotNull String value, @NotNull TextAttributesKey key);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
<orderEntry type="module" module-name="xml" />
|
||||
<orderEntry type="module" module-name="vcs-log-api" />
|
||||
<orderEntry type="module" module-name="vcs-log-impl" />
|
||||
<orderEntry type="module" module-name="jira" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -94,7 +94,9 @@ public class GithubApiUtil {
|
||||
@Nullable String requestBody,
|
||||
@NotNull Collection<Header> headers,
|
||||
@NotNull HttpVerb verb) throws IOException {
|
||||
LOG.assertTrue(!EventQueue.isDispatchThread() || ApplicationManager.getApplication().isUnitTestMode(), "Network operation in EDT");
|
||||
if (EventQueue.isDispatchThread() && !ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
LOG.warn("Network operation in EDT");
|
||||
}
|
||||
|
||||
HttpMethod method = null;
|
||||
try {
|
||||
|
||||
@@ -164,6 +164,7 @@ getters
|
||||
giud
|
||||
globals
|
||||
google
|
||||
gzip
|
||||
gruntfile
|
||||
hardcoded
|
||||
hardlink
|
||||
|
||||
Reference in New Issue
Block a user