Merge remote-tracking branch 'origin/master'

This commit is contained in:
Roman Shevchenko
2014-09-16 10:50:24 +04:00
57 changed files with 753 additions and 223 deletions
@@ -19,19 +19,24 @@ import com.intellij.debugger.DebuggerInvocationUtil;
import com.intellij.debugger.EvaluatingComputable;
import com.intellij.debugger.engine.ContextUtil;
import com.intellij.debugger.engine.DebugProcess;
import com.intellij.debugger.engine.SuspendContextImpl;
import com.intellij.debugger.engine.evaluation.*;
import com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator;
import com.intellij.debugger.engine.evaluation.expression.Modifier;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.debugger.jdi.VirtualMachineProxyImpl;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.util.Computable;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiCodeFragment;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiJavaFile;
import com.intellij.refactoring.extractMethodObject.ExtractLightMethodObjectHandler;
import com.intellij.util.PathsList;
import com.sun.jdi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.org.objectweb.asm.ClassReader;
@@ -84,19 +89,27 @@ public class CompilingEvaluator implements ExpressionEvaluator {
@Override
public Value evaluate(final EvaluationContext evaluationContext) throws EvaluateException {
DebugProcess process = evaluationContext.getDebugProcess();
ThreadReference threadReference = evaluationContext.getSuspendContext().getThread().getThreadReference();
ClassLoaderReference classLoader;
try {
DebugProcess process = evaluationContext.getDebugProcess();
ThreadReference threadReference = evaluationContext.getSuspendContext().getThread().getThreadReference();
classLoader = getClassLoader(evaluationContext);
}
catch (Exception e) {
throw new EvaluateException("Error creating evaluation class loader: " + e, e);
}
ClassLoaderReference classLoader = getClassLoader(evaluationContext);
Collection<OutputFileObject> classes = compile();
Collection<OutputFileObject> classes = compile();
ClassType mainClass = defineClasses(classes, evaluationContext, process, threadReference, classLoader);
//Method foo = mainClass.methodsByName(GEN_METHOD_NAME).get(0);
//return mainClass.invokeMethod(threadReference, foo, Collections.<Value>emptyList() ,ClassType.INVOKE_SINGLE_THREADED);
try {
defineClasses(classes, evaluationContext, process, threadReference, classLoader);
}
catch (Exception e) {
throw new EvaluateException("Error during classes definition " + e, e);
}
try {
// invoke base evaluator on call code
final Project project = myPsiContext.getProject();
ExpressionEvaluator evaluator =
@@ -115,7 +128,7 @@ public class CompilingEvaluator implements ExpressionEvaluator {
return evaluator.evaluate(evaluationContext);
}
catch (Exception e) {
throw new EvaluateException(e.getMessage());
throw new EvaluateException("Error during generated code invocation " + e, e);
}
}
@@ -126,8 +139,16 @@ public class CompilingEvaluator implements ExpressionEvaluator {
ClassType loaderClass = (ClassType)process.findClass(context, "java.net.URLClassLoader", context.getClassLoader());
Method ctorMethod = loaderClass.concreteMethodByName("<init>", "([Ljava/net/URL;Ljava/lang/ClassLoader;)V");
ThreadReference threadReference = context.getSuspendContext().getThread().getThreadReference();
return (ClassLoaderReference)loaderClass.newInstance(threadReference, ctorMethod,
Arrays.asList(createURLArray(context), context.getClassLoader()), ClassType.INVOKE_SINGLE_THREADED);
ClassLoaderReference reference = (ClassLoaderReference)loaderClass.newInstance(threadReference, ctorMethod,
Arrays.asList(createURLArray(context),
context.getClassLoader()),
ClassType.INVOKE_SINGLE_THREADED);
keep(reference, context);
return reference;
}
private static void keep(ObjectReference reference, EvaluationContext context) {
((SuspendContextImpl)context.getSuspendContext()).keep(reference);
}
private ClassType defineClasses(Collection<OutputFileObject> classes,
@@ -144,11 +165,13 @@ public class CompilingEvaluator implements ExpressionEvaluator {
((ClassType)classLoader.referenceType()).concreteMethodByName("defineClass", "(Ljava/lang/String;[BII)Ljava/lang/Class;");
byte[] bytes = changeSuperToMagicAccessor(cls.toByteArray());
ArrayList<Value> args = new ArrayList<Value>();
args.add(proxy.mirrorOf(cls.myOrigName));
StringReference name = proxy.mirrorOf(cls.myOrigName);
keep(name, context);
args.add(name);
args.add(mirrorOf(bytes, context, process));
args.add(proxy.mirrorOf(0));
args.add(proxy.mirrorOf(bytes.length));
classLoader.invokeMethod(threadReference, defineMethod, args, ClassType.INVOKE_SINGLE_THREADED);
process.invokeMethod(context, classLoader, defineMethod, args);
}
}
return (ClassType)process.findClass(context, getGenClassFullName(), classLoader);
@@ -173,7 +196,7 @@ public class CompilingEvaluator implements ExpressionEvaluator {
throws EvaluateException, InvalidTypeException, ClassNotLoadedException {
ArrayType arrayClass = (ArrayType)process.findClass(context, "byte[]", context.getClassLoader());
ArrayReference reference = process.newInstance(arrayClass, bytes.length);
reference.disableCollection();
keep(reference, context);
for (int i = 0; i < bytes.length; i++) {
reference.setValue(i, ((VirtualMachineProxyImpl)process.getVirtualMachineProxy()).mirrorOf(bytes[i]));
}
@@ -287,11 +310,15 @@ public class CompilingEvaluator implements ExpressionEvaluator {
DebugProcess process = context.getDebugProcess();
ArrayType arrayType = (ArrayType)process.findClass(context, "java.net.URL[]", context.getClassLoader());
ArrayReference arrayRef = arrayType.newInstance(1);
keep(arrayRef, context);
ClassType classType = (ClassType)process.findClass(context, "java.net.URL", context.getClassLoader());
VirtualMachineProxyImpl proxy = (VirtualMachineProxyImpl)process.getVirtualMachineProxy();
ThreadReference threadReference = context.getSuspendContext().getThread().getThreadReference();
StringReference url = proxy.mirrorOf("file:a");
keep(url, context);
ObjectReference reference = classType.newInstance(threadReference, classType.concreteMethodByName("<init>", "(Ljava/lang/String;)V"),
Arrays.asList(proxy.mirrorOf("file:a")), ClassType.INVOKE_SINGLE_THREADED);
Arrays.asList(url), ClassType.INVOKE_SINGLE_THREADED);
keep(reference, context);
arrayRef.setValues(Arrays.asList(reference));
return arrayRef;
}
@@ -302,10 +329,23 @@ public class CompilingEvaluator implements ExpressionEvaluator {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
MemoryFileManager manager = new MemoryFileManager(compiler);
DiagnosticCollector<JavaFileObject> diagnostic = new DiagnosticCollector<JavaFileObject>();
if (!compiler.getTask(null, manager, diagnostic, null, null, Arrays
.asList(new SourceFileObject(getMainClassName(), JavaFileObject.Kind.SOURCE, getClassCode()))).call()) {
// TODO: show only errors
throw new EvaluateException(diagnostic.getDiagnostics().get(0).toString());
Module module = ModuleUtilCore.findModuleForPsiElement(myPsiContext);
PathsList cp = null;
if (module != null) {
cp = ModuleRootManager.getInstance(module).orderEntries().compileOnly().recursively().exportedOnly().withoutSdk().getPathsList();
}
if (!compiler.getTask(null,
manager,
diagnostic,
cp != null ? Arrays.asList("-cp", cp.getPathsString()) : null,
null,
Arrays.asList(new SourceFileObject(getMainClassName(), JavaFileObject.Kind.SOURCE, getClassCode()))
).call()) {
StringBuilder res = new StringBuilder("Compilation failed:\n");
for (Diagnostic<? extends JavaFileObject> d : diagnostic.getDiagnostics()) {
res.append(d);
}
throw new EvaluateException(res.toString());
}
return manager.classes;
}
@@ -16,11 +16,15 @@
package com.intellij.codeInsight;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.RecursionGuard;
import com.intellij.openapi.util.RecursionManager;
import com.intellij.psi.*;
import com.intellij.psi.controlFlow.*;
import com.intellij.psi.impl.PsiImplUtil;
import com.intellij.psi.infos.CandidateInfo;
import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.scope.MethodProcessorSetupFailedException;
import com.intellij.psi.scope.processor.MethodResolverProcessor;
import com.intellij.psi.scope.util.PsiScopesUtil;
@@ -41,6 +45,7 @@ import java.util.*;
*/
public class ExceptionUtil {
@NonNls private static final String CLONE_METHOD_NAME = "clone";
public static final RecursionGuard ourThrowsGuard = RecursionManager.createGuard("checkedExceptionsGuard");
private ExceptionUtil() {}
@@ -412,48 +417,66 @@ public class ExceptionUtil {
return Collections.emptyList();
}
final PsiSubstitutor substitutor = result.getSubstitutor();
final PsiClassType[] thrownExceptions = method.getThrowsList().getReferencedTypes();
if (thrownExceptions.length == 0) {
return Collections.emptyList();
}
final PsiSubstitutor substitutor = getSubstitutor(result, methodCall);
if (!isArrayClone(method, methodCall) && methodCall instanceof PsiMethodCallExpression) {
final PsiClassType[] thrownExceptions = method.getThrowsList().getReferencedTypes();
if (thrownExceptions.length > 0) {
final PsiFile containingFile = (containingMethod == null ? methodCall : containingMethod).getContainingFile();
final MethodResolverProcessor processor = new MethodResolverProcessor((PsiMethodCallExpression)methodCall, containingFile);
try {
PsiScopesUtil.setupAndRunProcessor(processor, methodCall, false);
final List<Pair<PsiMethod, PsiSubstitutor>> candidates = ContainerUtil.mapNotNull(
processor.getResults(), new Function<CandidateInfo, Pair<PsiMethod, PsiSubstitutor>>() {
@Override
public Pair<PsiMethod, PsiSubstitutor> fun(CandidateInfo info) {
PsiElement element = info.getElement();
if (element instanceof PsiMethod &&
MethodSignatureUtil.areSignaturesEqual(method, (PsiMethod)element) &&
!MethodSignatureUtil.isSuperMethod((PsiMethod)element, method)) {
return Pair.create((PsiMethod)element, info.getSubstitutor());
}
return null;
final PsiFile containingFile = (containingMethod == null ? methodCall : containingMethod).getContainingFile();
final MethodResolverProcessor processor = new MethodResolverProcessor((PsiMethodCallExpression)methodCall, containingFile);
try {
PsiScopesUtil.setupAndRunProcessor(processor, methodCall, false);
final List<Pair<PsiMethod, PsiSubstitutor>> candidates = ContainerUtil.mapNotNull(
processor.getResults(), new Function<CandidateInfo, Pair<PsiMethod, PsiSubstitutor>>() {
@Override
public Pair<PsiMethod, PsiSubstitutor> fun(CandidateInfo info) {
PsiElement element = info.getElement();
if (element instanceof PsiMethod &&
MethodSignatureUtil.areSignaturesEqual(method, (PsiMethod)element) &&
!MethodSignatureUtil.isSuperMethod((PsiMethod)element, method)) {
return Pair.create((PsiMethod)element, getSubstitutor(info, methodCall));
}
});
if (candidates.size() > 1) {
final List<PsiClassType> ex = collectSubstituted(substitutor, thrownExceptions);
for (Pair<PsiMethod, PsiSubstitutor> pair : candidates) {
final PsiClassType[] exceptions = pair.first.getThrowsList().getReferencedTypes();
if (exceptions.length == 0) {
return getUnhandledExceptions(methodCall, topElement, PsiSubstitutor.EMPTY, PsiClassType.EMPTY_ARRAY);
}
retainExceptions(ex, collectSubstituted(pair.second, exceptions));
}
return getUnhandledExceptions(methodCall, topElement, PsiSubstitutor.EMPTY, ex.toArray(new PsiClassType[ex.size()]));
return null;
}
});
if (candidates.size() > 1) {
final List<PsiClassType> ex = collectSubstituted(substitutor, thrownExceptions);
for (Pair<PsiMethod, PsiSubstitutor> pair : candidates) {
final PsiClassType[] exceptions = pair.first.getThrowsList().getReferencedTypes();
if (exceptions.length == 0) {
return getUnhandledExceptions(methodCall, topElement, PsiSubstitutor.EMPTY, PsiClassType.EMPTY_ARRAY);
}
retainExceptions(ex, collectSubstituted(pair.second, exceptions));
}
return getUnhandledExceptions(methodCall, topElement, PsiSubstitutor.EMPTY, ex.toArray(new PsiClassType[ex.size()]));
}
catch (MethodProcessorSetupFailedException ignore) {
return Collections.emptyList();
}
}
catch (MethodProcessorSetupFailedException ignore) {
return Collections.emptyList();
}
}
return getUnhandledExceptions(method, methodCall, topElement, substitutor);
}
private static PsiSubstitutor getSubstitutor(final JavaResolveResult result, PsiCallExpression methodCall) {
final PsiLambdaExpression expression = PsiTreeUtil.getParentOfType(methodCall, PsiLambdaExpression.class);
final PsiSubstitutor substitutor;
if (expression != null) {
substitutor = ourThrowsGuard.doPreventingRecursion(expression, false, new Computable<PsiSubstitutor>() {
@Override
public PsiSubstitutor compute() {
return result.getSubstitutor();
}
});
} else {
substitutor = result.getSubstitutor();
}
return substitutor == null ? ((MethodCandidateInfo)result).getSiteSubstitutor() : substitutor;
}
public static void retainExceptions(List<PsiClassType> ex, List<PsiClassType> thrownEx) {
final List<PsiClassType> replacement = new ArrayList<PsiClassType>();
for (Iterator<PsiClassType> iterator = ex.iterator(); iterator.hasNext(); ) {
@@ -278,7 +278,7 @@ public class InferenceSession {
//If the expression is a poly class instance creation expression (15.9) or a poly method invocation expression (15.12),
//the set contains all constraint formulas that would appear in the set C when determining the poly expression's invocation type.
final PsiMethod calledMethod = getCalledMethod((PsiCallExpression)arg);
if (PsiPolyExpressionUtil.isMethodCallPolyExpression(arg, calledMethod)) {
if (calledMethod != null && PsiPolyExpressionUtil.isMethodCallPolyExpression(arg, calledMethod)) {
collectAdditionalConstraints(additionalConstraints, (PsiCallExpression)arg);
}
} else if (arg instanceof PsiLambdaExpression) {
@@ -294,12 +294,32 @@ public class InferenceSession {
return null;
}
boolean found = false;
for (PsiExpression expression : argumentList.getExpressions()) {
expression = PsiUtil.skipParenthesizedExprDown(expression);
if (expression instanceof PsiConditionalExpression ||
expression instanceof PsiCallExpression ||
expression instanceof PsiLambdaExpression ||
expression instanceof PsiMethodReferenceExpression) {
found = true;
break;
}
}
if (!found) {
return null;
}
MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
if (properties != null) {
return properties.getMethod();
}
final JavaResolveResult resolveResult = getMethodResult(arg);
return resolveResult instanceof MethodCandidateInfo ? (PsiMethod)resolveResult.getElement() : null;
if (resolveResult instanceof MethodCandidateInfo) {
return (PsiMethod)resolveResult.getElement();
}
else {
return null;
}
}
private void collectLambdaReturnExpression(Set<ConstraintFormula> additionalConstraints,
@@ -319,7 +339,7 @@ public class InferenceSession {
PsiType functionalType) {
if (returnExpression instanceof PsiCallExpression) {
final PsiMethod calledMethod = getCalledMethod((PsiCallExpression)returnExpression);
if (PsiPolyExpressionUtil.isMethodCallPolyExpression(returnExpression, calledMethod)) {
if (calledMethod != null && PsiPolyExpressionUtil.isMethodCallPolyExpression(returnExpression, calledMethod)) {
collectAdditionalConstraints(additionalConstraints, (PsiCallExpression)returnExpression);
}
}
@@ -365,7 +385,7 @@ public class InferenceSession {
};
MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
return properties != null ? null :
expression == null
expression == null || !PsiResolveHelper.ourGraphGuard.currentStack().contains(expression)
? computableResolve.compute()
: PsiResolveHelper.ourGraphGuard.doPreventingRecursion(expression, false, computableResolve);
}
@@ -17,6 +17,7 @@ package com.intellij.psi.impl.source.resolve.graphInference.constraints;
import com.intellij.codeInsight.ExceptionUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Computable;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession;
import com.intellij.psi.impl.source.resolve.graphInference.InferenceVariable;
@@ -101,9 +102,17 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai
final List<PsiType> thrownTypes = new ArrayList<PsiType>();
if (myExpression instanceof PsiLambdaExpression) {
PsiElement body = ((PsiLambdaExpression)myExpression).getBody();
final PsiElement body = ((PsiLambdaExpression)myExpression).getBody();
if (body != null) {
thrownTypes.addAll(ExceptionUtil.getUnhandledExceptions(body));
final List<PsiClassType> exceptions = ExceptionUtil.ourThrowsGuard.doPreventingRecursion(myExpression, false, new Computable<List<PsiClassType>>() {
@Override
public List<PsiClassType> compute() {
return ExceptionUtil.getUnhandledExceptions(body);
}
});
if (exceptions != null) {
thrownTypes.addAll(exceptions);
}
}
} else {
@@ -0,0 +1,24 @@
import java.util.List;
class Test {
interface A<T> {
T m(T t);
}
interface B<K> {
List<K> l(K k);
}
<F> F foo(A<F> a) {return null;}
<Bar> Bar bar(B<Bar> b) { return null;}
{
Integer i = foo(a -> bar(b -> asList(1, b)));
Integer i1 = foo(a -> bar(b -> asList(1, 1)));
}
<L> List<L> asList(L l, L l1) {
return null;
}
}
@@ -0,0 +1,29 @@
import java.io.IOException;
import java.util.List;
class Test {
interface A<T> {
T m(T t);
}
interface B<K> {
List<K> l(K k) throws IOException;
}
<F> F foo(A<F> a) {
return null;
}
<R> R bar(B<R> b) {
return null;
}
<Z> List<Z> baz(Z l) throws IOException{
return null;
}
{
Integer i = foo(a -> bar(b -> baz(b)));
}
}
@@ -16,14 +16,11 @@
package com.intellij.codeInsight.daemon.lambda;
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
import com.intellij.idea.Bombed;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NonNls;
import java.util.Calendar;
public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase {
@NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/graphInference";
@@ -47,12 +44,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
doTest();
}
@Bombed(day = 30, month = Calendar.SEPTEMBER)
public void testInferenceFromSiblings() throws Exception {
doTest();
}
@Bombed(day = 30, month = Calendar.SEPTEMBER)
public void testChainedInferenceTypeParamsOrderIndependent() throws Exception {
doTest();
}
@@ -15,10 +15,8 @@
*/
package com.intellij.codeInsight.daemon.lambda;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiExpression;
import com.intellij.psi.PsiIdentifier;
import com.intellij.psi.PsiType;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.testFramework.LightProjectDescriptor;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
import org.jetbrains.annotations.NotNull;
@@ -44,6 +42,39 @@ public class InferredTypeTest extends LightCodeInsightFixtureTestCase {
Assert.assertTrue(type.getCanonicalText(), type.equalsToText("java.util.List<java.lang.String>"));
}
public void testCashedTypes() throws Exception {
myFixture.configureByText("a.java", "import java.util.*;\n" +
"abstract class Main {\n" +
" void test(List<Integer> li) {\n" +
" foo(li, s -> <caret>s.substr(0), Collections.emptyList());\n" +
" }\n" +
" abstract <T, U> Collection<U> foo(Collection<T> coll, Fun<Stream<T>, U> f, List<U> it);" +
" interface Stream<T> {\n" +
" T substr(long startingOffset);\n" +
" }\n" +
" interface Fun<T, R> {\n" +
" R _(T t);\n" +
" }\n" +
"}\n");
final PsiElement elementAtCaret = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
Assert.assertTrue(elementAtCaret instanceof PsiIdentifier);
final PsiElement refExpr = elementAtCaret.getParent();
Assert.assertTrue(refExpr.toString(), refExpr instanceof PsiExpression);
final PsiType type = ((PsiExpression)refExpr).getType();
Assert.assertNotNull(refExpr.toString(), type);
Assert.assertTrue(type.getCanonicalText(), type.equalsToText("Stream<java.lang.Integer>"));
final PsiExpressionList expressionList = PsiTreeUtil.getParentOfType(refExpr, PsiExpressionList.class);
assertNotNull(expressionList);
final PsiExpression[] expressions = expressionList.getExpressions();
assertEquals(3, expressions.length);
final PsiType ensureNotCached = expressions[2].getType();
assertNotNull(ensureNotCached);
assertTrue(ensureNotCached.getCanonicalText(), ensureNotCached.equalsToText("java.util.List<java.lang.Integer>"));
}
@NotNull
@Override
protected LightProjectDescriptor getProjectDescriptor() {
@@ -0,0 +1,47 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.daemon.lambda;
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
public class NewInferenceCollectingAdditionalConstraintsTest extends LightDaemonAnalyzerTestCase {
@NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/additionalConstraints";
public void testInferenceFromNestedIn2LambdasCall() throws Exception {
doTest();
}
private void doTest() {
doTest(true);
}
private void doTest(boolean warnings) {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
}
@Override
protected Sdk getProjectJDK() {
return IdeaTestUtil.getMockJdk18();
}
}
@@ -73,23 +73,20 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA121315() { doTest(); }
public void testIDEA118965comment() { doTest(); }
public void testIDEA122074() { doTest(); }
@Bombed(day = 30, month = Calendar.SEPTEMBER)
public void testIDEA122084() { doTest(); }
public void testAdditionalConstraintDependsOnNonMentionedVars() { doTest(); }
public void testIDEA122616() { doTest(); }
public void testIDEA122700() { doTest(); }
public void testIDEA122406() { doTest(); }
public void testNestedCallsInsideLambdaReturnExpression() { doTest(); }
@Bombed(day = 30, month = Calendar.SEPTEMBER)
public void testIDEA123731() { doTest(); }
public void testIDEA123869() { doTest(); }
@Bombed(day = 30, month = Calendar.SEPTEMBER)
public void testIDEA123848() { doTest(); }
public void testOnlyLambdaAtTypeParameterPlace() { doTest(); }
public void testLiftedIntersectionType() { doTest(); }
public void testInferenceFromReturnStatements() { doTest(); }
public void testDownUpThroughLambdaReturnStatements() { doTest(); }
@Bombed(day = 30, month = Calendar.SEPTEMBER)
@Bombed(day = 30, month = Calendar.OCTOBER)
public void testIDEA124547() { doTest(); }
public void testIDEA118362() { doTest(); }
public void testIDEA126056() { doTest(); }
@@ -100,11 +97,14 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA124424() { doTest(); }
public void testNestedLambdaExpressions1() { doTest(); }
public void testNestedLambdaExpressionsNoFormalParams() { doTest(); }
@Bombed(day = 30, month = Calendar.SEPTEMBER)
public void testNestedLambdaExpressionsNoFormalParams1() { doTest(); }
public void testDeepNestedLambdaExpressionsNoFormalParams() { doTest(); }
public void testNestedLambdaExpressionsNoFormalParamsStopAtStandalone() { doTest(); }
public void testNestedLambdaCheckedExceptionsConstraints() throws Exception {
doTest();
}
public void testIDEA127596() throws Exception {
doTest();
}
@@ -128,7 +128,6 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
@Bombed(day = 30, month = Calendar.SEPTEMBER)
public void testIDEA126778() throws Exception {
doTest();
}
@@ -18,11 +18,10 @@ package com.intellij.application.options.codeStyle.arrangement.action;
import com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesControl;
import com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesModel;
import com.intellij.application.options.codeStyle.arrangement.match.EmptyArrangementRuleComponent;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.util.SystemInfoRt;
import com.intellij.util.IconUtil;
import gnu.trove.TIntArrayList;
import org.jetbrains.annotations.NotNull;
@@ -35,11 +34,7 @@ public class AddArrangementRuleAction extends AbstractArrangementRuleAction impl
public AddArrangementRuleAction() {
getTemplatePresentation().setText(ApplicationBundle.message("arrangement.action.rule.add.text"));
getTemplatePresentation().setDescription(ApplicationBundle.message("arrangement.action.rule.add.description"));
}
@Override
public void update(AnActionEvent e) {
e.getPresentation().setIcon(SystemInfoRt.isMac ? AllIcons.ToolbarDecorator.Mac.Add : AllIcons.ToolbarDecorator.Add);
getTemplatePresentation().setIcon(IconUtil.getAddIcon());
}
@Override
@@ -31,11 +31,11 @@ public class AddArrangementSectionRuleAction extends AddArrangementRuleAction {
public AddArrangementSectionRuleAction() {
getTemplatePresentation().setText(ApplicationBundle.message("arrangement.action.section.rule.add.text"));
getTemplatePresentation().setDescription(ApplicationBundle.message("arrangement.action.section.rule.add.description"));
getTemplatePresentation().setIcon(SystemInfoRt.isMac ? AllIcons.CodeStyle.Mac.AddNewSectionRule : AllIcons.CodeStyle.AddNewSectionRule);
}
@Override
public void update(AnActionEvent e) {
e.getPresentation().setIcon(SystemInfoRt.isMac ? AllIcons.CodeStyle.Mac.AddNewSectionRule : AllIcons.CodeStyle.AddNewSectionRule);
final ArrangementMatchingRulesControl control = ArrangementMatchingRulesControl.KEY.getData(e.getDataContext());
if (control == null) {
return;
@@ -20,6 +20,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Toggleable;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.openapi.project.DumbAware;
import com.intellij.util.IconUtil;
import gnu.trove.TIntArrayList;
/**
@@ -31,6 +32,7 @@ public class EditArrangementRuleAction extends AbstractArrangementRuleAction imp
public EditArrangementRuleAction() {
getTemplatePresentation().setText(ApplicationBundle.message("arrangement.action.rule.edit.text"));
getTemplatePresentation().setDescription(ApplicationBundle.message("arrangement.action.rule.edit.description"));
getTemplatePresentation().setIcon(IconUtil.getEditIcon());
}
@Override
@@ -20,6 +20,7 @@ import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.openapi.project.DumbAware;
import com.intellij.util.IconUtil;
import javax.swing.table.DefaultTableModel;
@@ -32,6 +33,7 @@ public class MoveArrangementGroupingRuleDownAction extends AnAction implements D
public MoveArrangementGroupingRuleDownAction() {
getTemplatePresentation().setText(ApplicationBundle.message("arrangement.action.rule.move.down.text"));
getTemplatePresentation().setDescription(ApplicationBundle.message("arrangement.action.rule.move.down.description"));
getTemplatePresentation().setIcon(IconUtil.getMoveDownIcon());
}
@Override
@@ -20,6 +20,7 @@ import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.openapi.project.DumbAware;
import com.intellij.util.IconUtil;
import javax.swing.table.DefaultTableModel;
@@ -32,6 +33,7 @@ public class MoveArrangementGroupingRuleUpAction extends AnAction implements Dum
public MoveArrangementGroupingRuleUpAction() {
getTemplatePresentation().setText(ApplicationBundle.message("arrangement.action.rule.move.up.text"));
getTemplatePresentation().setDescription(ApplicationBundle.message("arrangement.action.rule.move.up.description"));
getTemplatePresentation().setIcon(IconUtil.getMoveUpIcon());
}
@Override
@@ -17,6 +17,7 @@ package com.intellij.application.options.codeStyle.arrangement.action;
import com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesControl;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.util.IconUtil;
import gnu.trove.TIntArrayList;
import org.jetbrains.annotations.NotNull;
@@ -31,6 +32,7 @@ public class MoveArrangementMatchingRuleDownAction extends AbstractMoveArrangeme
public MoveArrangementMatchingRuleDownAction() {
getTemplatePresentation().setText(ApplicationBundle.message("arrangement.action.rule.move.down.text"));
getTemplatePresentation().setDescription(ApplicationBundle.message("arrangement.action.rule.move.down.description"));
getTemplatePresentation().setIcon(IconUtil.getMoveDownIcon());
}
@Override
@@ -17,6 +17,7 @@ package com.intellij.application.options.codeStyle.arrangement.action;
import com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesControl;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.util.IconUtil;
import gnu.trove.TIntArrayList;
import org.jetbrains.annotations.NotNull;
@@ -31,6 +32,7 @@ public class MoveArrangementMatchingRuleUpAction extends AbstractMoveArrangement
public MoveArrangementMatchingRuleUpAction() {
getTemplatePresentation().setText(ApplicationBundle.message("arrangement.action.rule.move.up.text"));
getTemplatePresentation().setDescription(ApplicationBundle.message("arrangement.action.rule.move.up.description"));
getTemplatePresentation().setIcon(IconUtil.getMoveUpIcon());
}
@Override
@@ -17,12 +17,11 @@ package com.intellij.application.options.codeStyle.arrangement.action;
import com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesControl;
import com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesModel;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.util.SystemInfoRt;
import com.intellij.util.IconUtil;
import gnu.trove.TIntArrayList;
/**
@@ -34,13 +33,13 @@ public class RemoveArrangementRuleAction extends AnAction implements DumbAware {
public RemoveArrangementRuleAction() {
getTemplatePresentation().setText(ApplicationBundle.message("arrangement.action.rule.remove.text"));
getTemplatePresentation().setDescription(ApplicationBundle.message("arrangement.action.rule.remove.description"));
getTemplatePresentation().setIcon(IconUtil.getRemoveIcon());
}
@Override
public void update(AnActionEvent e) {
ArrangementMatchingRulesControl control = ArrangementMatchingRulesControl.KEY.getData(e.getDataContext());
e.getPresentation().setEnabled(control != null && !control.getSelectedModelRows().isEmpty() && control.getEditingRow() == -1);
e.getPresentation().setIcon(SystemInfoRt.isMac ? AllIcons.ToolbarDecorator.Mac.Remove : AllIcons.ToolbarDecorator.Remove);
}
@Override
@@ -36,13 +36,13 @@ import java.util.List;
public class GotoRelatedSymbolAction extends AnAction {
@Override
public void update(AnActionEvent e) {
public void update(@NotNull AnActionEvent e) {
PsiElement element = getContextElement(e.getDataContext());
e.getPresentation().setEnabled(element != null);
}
@Override
public void actionPerformed(AnActionEvent e) {
public void actionPerformed(@NotNull AnActionEvent e) {
PsiElement element = getContextElement(e.getDataContext());
if (element == null) return;
@@ -70,7 +70,7 @@ public class GotoRelatedSymbolAction extends AnAction {
if (file != null && editor != null) {
return getContextElement(file, editor);
}
return element;
return element == null ? file : element;
}
@NotNull
@@ -97,6 +97,7 @@ import com.intellij.ui.components.panels.NonOpaquePanel;
import com.intellij.ui.popup.AbstractPopup;
import com.intellij.ui.popup.PopupPositionManager;
import com.intellij.util.*;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.Matcher;
import com.intellij.util.ui.EmptyIcon;
import com.intellij.util.ui.StatusText;
@@ -131,6 +132,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
private static final int MAX_RECENT_FILES = 10;
private static final int DEFAULT_MORE_STEP_COUNT = 15;
public static final int MAX_SEARCH_EVERYWHERE_HISTORY = 50;
public static final int MAX_TOP_HIT = 15;
private static final int POPUP_MAX_WIDTH = 600;
private static final Logger LOG = Logger.getInstance("#" + SearchEverywhereAction.class.getName());
@@ -265,6 +267,20 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
final Dimension size = super.getPreferredSize();
return new Dimension(Math.min(size.width - 2, POPUP_MAX_WIDTH), size.height);
}
@Override
public void clearSelection() {
//avoid blinking
}
@Override
public Object getSelectedValue() {
try {
return super.getSelectedValue();
} catch (Exception e) {
return null;
}
}
};
myList.setCellRenderer(myRenderer);
myList.addMouseListener(new MouseAdapter() {
@@ -1195,8 +1211,20 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
// this line must be called on EDT to avoid context switch at clear().append("text") Don't touch. Ask [kb]
myList.getEmptyText().setText("Searching...");
//noinspection unchecked
myList.setModel(myListModel);
myAlarm.cancelAllRequests();
if (myList.getModel() instanceof SearchListModel) {
//noinspection unchecked
myAlarm.addRequest(new Runnable() {
@Override
public void run() {
if (!myDone.isRejected()) {
myList.setModel(myListModel);
}
}
}, 100);
} else {
myList.setModel(myListModel);
}
}
});
@@ -1692,7 +1720,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
for (SearchTopHitProvider provider : SearchTopHitProvider.EP_NAME.getExtensions()) {
check();
provider.consumeTopHits(pattern, consumer);
provider.consumeTopHits(pattern, consumer, project);
}
if (elements.size() > 0) {
SwingUtilities.invokeLater(new Runnable() {
@@ -1701,7 +1729,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
if (isCanceled()) return;
for (Object element : elements.toArray()) {
for (Object element : new ArrayList(elements)) {
if (element instanceof AnAction) {
final AnAction action = (AnAction)element;
final AnActionEvent e = new AnActionEvent(myActionEvent.getInputEvent(),
@@ -1720,7 +1748,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
}
if (isCanceled() || elements.isEmpty()) return;
myListModel.titleIndex.topHit = myListModel.size();
for (Object element : elements) {
for (Object element : ContainerUtil.getFirstItems(elements, MAX_TOP_HIT)) {
myListModel.addElement(element);
}
}
@@ -31,7 +31,7 @@ public class IndentOptionsDetectorImpl implements IndentOptionsDetector {
private static Logger LOG = Logger.getInstance("#com.intellij.psi.codeStyle.CommonCodeStyleSettings.IndentOptionsDetector");
private static final double RATE_THRESHOLD = 0.8;
private static final int MIN_LINES_THRESHOLD = 50;
private static final int MIN_LINES_THRESHOLD = 20;
private static final int MAX_INDENT_TO_DETECT = 8;
private final PsiFile myFile;
@@ -62,16 +62,13 @@ public class IndentOptionsDetectorImpl implements IndentOptionsDetector {
int linesWithTabs = stats.getTotalLinesWithLeadingTabs();
int linesWithWhiteSpaceIndent = stats.getTotalLinesWithLeadingSpaces();
int totalLines = linesWithTabs + linesWithWhiteSpaceIndent;
double lineWithTabsRate = (double)linesWithTabs / totalLines;
if (linesWithTabs > MIN_LINES_THRESHOLD && lineWithTabsRate > RATE_THRESHOLD) {
if (linesWithTabs > linesWithWhiteSpaceIndent) {
if (!indentOptions.USE_TAB_CHARACTER) {
indentOptions.USE_TAB_CHARACTER = true;
LOG.info("Detected tab usage in" + myFile);
}
}
else if (linesWithWhiteSpaceIndent > MIN_LINES_THRESHOLD && (1 - lineWithTabsRate) > RATE_THRESHOLD) {
else if (linesWithWhiteSpaceIndent > MIN_LINES_THRESHOLD) {
int newIndentSize = getPositiveIndentSize(stats);
if (newIndentSize > 0) {
indentOptions.USE_TAB_CHARACTER = false;
@@ -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.
@@ -16,6 +16,7 @@
package com.intellij.ide;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Consumer;
@@ -24,7 +25,7 @@ import com.intellij.util.Consumer;
*/
public abstract class ActionsTopHitProvider implements SearchTopHitProvider {
@Override
public void consumeTopHits(String pattern, Consumer<Object> collector) {
public void consumeTopHits(String pattern, Consumer<Object> collector, Project project) {
final ActionManager actionManager = ActionManager.getInstance();
for (String[] strings : getActionsMatrix()) {
if (StringUtil.isBetween(pattern, strings[0], strings[1])) {
@@ -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.
@@ -16,6 +16,7 @@
package com.intellij.ide;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.project.Project;
import com.intellij.util.Consumer;
/**
@@ -24,5 +25,5 @@ import com.intellij.util.Consumer;
public interface SearchTopHitProvider {
ExtensionPointName<SearchTopHitProvider> EP_NAME = ExtensionPointName.create("com.intellij.search.topHitProvider");
void consumeTopHits(String pattern, Consumer<Object> collector);
void consumeTopHits(String pattern, Consumer<Object> collector, Project project);
}
@@ -75,7 +75,7 @@ public class ShowSettingsUtilImpl extends ShowSettingsUtil {
new IdeConfigurablesGroup()};
return Registry.is("ide.new.settings.dialog")
? new ConfigurableGroup[]{new SortedConfigurableGroup(getConfigurables(groups, true))}
? new ConfigurableGroup[]{new SortedConfigurableGroup(project, getConfigurables(groups, true))}
: groups;
}
@@ -0,0 +1,81 @@
/*
* 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.ui;
import com.intellij.ide.ui.search.BooleanOptionDescription;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* @author Konstantin Bulenkov
*/
public class EditorOptionsTopHitProvider extends OptionsTopHitProvider {
private static final Collection<BooleanOptionDescription> ourOptions = createOptions();
public EditorOptionsTopHitProvider() {
super("editor");
}
@NotNull
@Override
public Collection<BooleanOptionDescription> getOptions(Project project) {
return ourOptions;
}
private static Collection<BooleanOptionDescription> createOptions() {
final List<BooleanOptionDescription> options = new ArrayList<BooleanOptionDescription>();
options.add(editorMouse("IS_MOUSE_CLICK_SELECTION_HONORS_CAMEL_WORDS", "checkbox.honor.camelhumps.words.settings.on.double.click"));
options.add(editorMouse("IS_WHEEL_FONTCHANGE_ENABLED", SystemInfo.isMac
? "checkbox.enable.ctrl.mousewheel.changes.font.size.macos"
: "checkbox.enable.ctrl.mousewheel.changes.font.size"));
options.add(editorMouse("IS_DND_ENABLED", "checkbox.enable.drag.n.drop.functionality.in.editor"));
options.add(editorVirtualSpace("IS_ALL_SOFTWRAPS_SHOWN", "checkbox.show.all.softwraps"));
options.add(editorVirtualSpace("IS_VIRTUAL_SPACE", "checkbox.allow.placement.of.caret.after.end.of.line"));
options.add(editorVirtualSpace("IS_CARET_INSIDE_TABS", "checkbox.allow.placement.of.caret.inside.tabs"));
options.add(editorVirtualSpace("ADDITIONAL_PAGE_AT_BOTTOM", "checkbox.show.virtual.space.at.file.bottom"));
return options;
}
static EditorOptionDescription editor(String fieldName, String group, String property, String configurableId) {
String name = "";
if (!StringUtil.isEmpty(group)) {
name += group + ": ";
}
name += StringUtil.stripHtml(ApplicationBundle.message(property), false);
return new EditorOptionDescription(fieldName, name, configurableId);
}
static EditorOptionDescription editorMouse(String fieldName, String property) {
return editorBehavior(fieldName, "Mouse", property);
}
static EditorOptionDescription editorVirtualSpace(String fieldName, String property) {
return editorBehavior(fieldName, "Virtual Space", property);
}
static EditorOptionDescription editorBehavior(String fieldName, String group, String property) {
return editor(fieldName, group, property, "Editor.Behavior");
}
}
@@ -0,0 +1,47 @@
/*
* 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.ui;
import com.intellij.codeInspection.ex.Tools;
import com.intellij.ide.ui.search.BooleanOptionDescription;
import com.intellij.openapi.project.Project;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* @author Konstantin Bulenkov
*/
public class InspectionsTopHitProvider extends OptionsTopHitProvider {
public InspectionsTopHitProvider() {
super("inspections");
}
@NotNull
@Override
public Collection<BooleanOptionDescription> getOptions(Project project) {
ArrayList<BooleanOptionDescription> result = new ArrayList<BooleanOptionDescription>();
List<Tools> tools = InspectionProjectProfileManager.getInstance(project).getInspectionProfile().getAllEnabledInspectionTools(project);
for (Tools tool : tools) {
result.add(new ToolOptionDescription(tool, project));
}
return result;
}
}
@@ -0,0 +1,63 @@
/*
* 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.ui;
import com.intellij.ide.SearchTopHitProvider;
import com.intellij.ide.ui.search.BooleanOptionDescription;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.codeStyle.MinusculeMatcher;
import com.intellij.psi.codeStyle.NameUtil;
import com.intellij.util.Consumer;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.List;
/**
* @author Konstantin Bulenkov
*/
public abstract class OptionsTopHitProvider implements SearchTopHitProvider {
@NonNls private final String myId;
public OptionsTopHitProvider(String optionId) {
myId = optionId.toLowerCase();
}
@NotNull
public abstract Collection<BooleanOptionDescription> getOptions(Project project);
@Override
public final void consumeTopHits(@NonNls String pattern, Consumer<Object> collector, Project project) {
if (!pattern.startsWith("#")) return;
pattern = pattern.substring(1);
final List<String> parts = StringUtil.split(pattern, " ");
if (parts.size() == 0) return;
String id = parts.get(0);
if (myId.startsWith(id)) {
pattern = pattern.substring(id.length()).trim().toLowerCase();
final MinusculeMatcher matcher = NameUtil.buildMatcher("*" + pattern, NameUtil.MatchingCaseSensitivity.NONE);
for (BooleanOptionDescription option : getOptions(project)) {
if (matcher.matches(option.getOption())) {
collector.consume(option);
}
}
}
}
}
@@ -0,0 +1,47 @@
/*
* 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.ui;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.codeInspection.ex.Tools;
import com.intellij.ide.ui.search.BooleanOptionDescription;
import com.intellij.openapi.project.Project;
/**
* @author Konstantin Bulenkov
*/
public class ToolOptionDescription extends BooleanOptionDescription {
private final Tools myTool;
private final Project myProject;
public ToolOptionDescription(Tools tool, Project project) {
super(tool.getTool().getGroupDisplayName() + ": " + tool.getTool().getDisplayName() , "Errors");
myTool = tool;
myProject = project;
}
@Override
public boolean isOptionEnabled() {
return myTool.getDefaultState().isEnabled();
}
@Override
public void setOptionState(boolean enabled) {
myTool.getDefaultState().setEnabled(enabled);
DaemonCodeAnalyzer.getInstance(myProject).restart();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@ package com.intellij.ide.ui;
import com.intellij.ide.SearchTopHitProvider;
import com.intellij.ide.ui.search.OptionDescription;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Consumer;
@@ -37,7 +38,7 @@ public class UISimpleSettingsProvider implements SearchTopHitProvider {
@Override
public void consumeTopHits(String pattern, Consumer<Object> collector) {
public void consumeTopHits(String pattern, Consumer<Object> collector, Project project) {
pattern = pattern.trim().toLowerCase();
if (StringUtil.isBetween(pattern, "cyc", "cyclic ") || StringUtil.isBetween(pattern, "scr", "scroll ")) {
collector.consume(CYCLING_SCROLLING);
@@ -19,6 +19,7 @@ import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurableGroup;
import com.intellij.openapi.options.OptionsBundle;
import com.intellij.openapi.options.SearchableConfigurable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
@@ -35,52 +36,6 @@ public final class SortedConfigurableGroup
extends SearchableConfigurable.Parent.Abstract
implements SearchableConfigurable, ConfigurableGroup, Configurable.NoScroll {
public static ConfigurableGroup getGroup(Configurable... configurables) {
SortedConfigurableGroup root = new SortedConfigurableGroup("root");
HashMap<String, SortedConfigurableGroup> map = new HashMap<String, SortedConfigurableGroup>();
map.put("root", root);
for (Configurable configurable : configurables) {
int weight = 0;
String groupId = null;
if (configurable instanceof ConfigurableWrapper) {
ConfigurableWrapper wrapper = (ConfigurableWrapper)configurable;
weight = wrapper.getExtensionPoint().groupWeight;
groupId = wrapper.getExtensionPoint().groupId;
}
SortedConfigurableGroup composite = map.get(groupId);
if (composite == null) {
composite = new SortedConfigurableGroup(groupId);
map.put(groupId, composite);
}
composite.add(weight, configurable);
}
// process supported groups
root.add(60, map.remove("appearance"));
root.add(50, map.remove("editor"));
root.add(40, map.remove("project"));
SortedConfigurableGroup build = map.remove("build");
if (build == null) {
build = map.remove("build.tools");
}
else {
build.add(1000, map.remove("build.tools"));
}
root.add(30, build);
root.add(20, map.remove("language"));
root.add(10, map.remove("tools"));
root.add(-10, map.remove(null));
// process unsupported groups
if (1 < map.size()) {
for (SortedConfigurableGroup group : map.values()) {
if (root != group) {
group.myDisplayName = "Category: " + group.myGroupId;
root.add(0, group);
}
}
}
return root;
}
private final ArrayList<WeightConfigurable> myList = new ArrayList<WeightConfigurable>();
private final String myGroupId;
private String myDisplayName;
@@ -89,7 +44,7 @@ public final class SortedConfigurableGroup
myGroupId = groupId;
}
public SortedConfigurableGroup(Configurable... configurables) {
public SortedConfigurableGroup(Project project, Configurable... configurables) {
myGroupId = "root";
// create groups from configurations
HashMap<String, SortedConfigurableGroup> map = new HashMap<String, SortedConfigurableGroup>();
@@ -110,9 +65,15 @@ public final class SortedConfigurableGroup
composite.add(weight, configurable);
}
// process supported groups
add(60, map.remove("appearance"));
add(50, map.remove("editor"));
add(40, map.remove("project"));
add(70, map.remove("appearance"));
add(60, map.remove("editor"));
SortedConfigurableGroup projectGroup = map.remove("project");
if (projectGroup != null && project != null && !project.isDefault()) {
projectGroup.myDisplayName = StringUtil.first(
OptionsBundle.message("configurable.group.project.named.settings.display.name", project.getName()),
30, true);
}
add(40, projectGroup);
SortedConfigurableGroup build = map.remove("build");
if (build == null) {
build = map.remove("build.tools");
@@ -128,7 +89,7 @@ public final class SortedConfigurableGroup
if (1 < map.size()) {
for (SortedConfigurableGroup group : map.values()) {
if (this != group) {
group.myDisplayName = "Category: " + group.myGroupId;
group.myDisplayName = OptionsBundle.message("configurable.group.category.named.settings.display.name", group.myGroupId);
add(0, group);
}
}
@@ -198,7 +198,7 @@ options.xml.display.name=XML
settings.panel.title=Settings
configurable.group.appearance.settings.display.name=Appearance and Behavior
configurable.group.appearance.settings.display.name=Appearance \\& Behavior
configurable.group.appearance.settings.description=<html><body>\
Personalize IntelliJ appearance and behavior: change themes and font size, tune the keymap,\
configure plugins and system settings, such as password policies, HTTP proxy, updates and more.
@@ -207,9 +207,11 @@ configurable.group.editor.settings.description=<html><body>\
Personalize source code appearance by changing fonts, highlighting styles, indents, etc.\
Customize the Editor from line numbers, caret placement and tabs to source code inspections,\
setting up templates and file encodings.
configurable.group.project.settings.display.name=Current Project
configurable.group.category.named.settings.display.name=Category: {0}
configurable.group.project.named.settings.display.name=Project: {0}
configurable.group.project.settings.display.name=Default Project
configurable.group.project.settings.description=<html><body>\
Default view for Current Project
Project Settings
configurable.group.build.settings.display.name=Build, Execution, Deployment
configurable.group.build.settings.description=<html><body>\
Configure you project integration with different build tools (Maven, Gradle or Gant),\
@@ -217,7 +219,7 @@ configurable.group.build.settings.description=<html><body>\
configurable.group.build.tools.settings.display.name=Build Tools
configurable.group.build.tools.settings.description=<html><body>\
Configure your project integration with different build tools: Maven, Gradle or Gant.
configurable.group.language.settings.display.name=Languages and Frameworks
configurable.group.language.settings.display.name=Languages \\& Frameworks
configurable.group.language.settings.description=<html><body>\
Configure the settings related to specific frameworks and technologies used in your project.
configurable.group.tools.settings.display.name=Tools
@@ -221,7 +221,7 @@
<applicationConfigurable groupId="appearance" groupWeight="110" displayName="Notifications" instance="com.intellij.notification.impl.NotificationsConfigurable"/>
<!-- Plugins -->
<applicationConfigurable groupId="appearance" groupWeight="130" instance="com.intellij.ide.plugins.PluginManagerConfigurable" id="preferences.pluginManager"
<applicationConfigurable groupId="root" groupWeight="55" instance="com.intellij.ide.plugins.PluginManagerConfigurable" id="preferences.pluginManager"
displayName="Plugins"/>
<actionFromOptionDescriptorProvider implementation="com.intellij.ide.plugins.InstalledPluginsManagerMain$PluginsActionFromOptionDescriptorProvider"/>
<applicationConfigurable parentId="preferences.general" instance="com.intellij.util.net.HttpProxyConfigurable" id="http.proxy" displayName="HTTP Proxy"/>
@@ -329,6 +329,8 @@
implementationClass="com.intellij.codeStyle.InconsistentLineSeparatorsInspection"/>
<search.topHitProvider implementation="com.intellij.platform.DefaultPlatformTopHitProvider"/>
<search.topHitProvider implementation="com.intellij.ide.ui.UISimpleSettingsProvider"/>
<search.topHitProvider implementation="com.intellij.ide.ui.EditorOptionsTopHitProvider"/>
<search.topHitProvider implementation="com.intellij.ide.ui.InspectionsTopHitProvider"/>
<projectService serviceImplementation="com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.UnknownFeaturesCollector"/>
<postStartupActivity implementation="com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.PluginsAdvertiser" order="before OpenFilesActivity"/>
<actionPromoter implementation="com.intellij.ui.ToolbarDecoratorActionPromoter"/>
@@ -82,7 +82,7 @@
<programRunner implementation="com.intellij.execution.runners.BasicProgramRunner" order="last"/>
<projectConfigurable groupId="editor" groupWeight="160" displayName="Inspections" provider="com.intellij.profile.codeInspection.ui.ProjectInspectionToolsConfigurableProvider" order="before intentions"/>
<projectConfigurable groupId="project" instance="com.intellij.ide.util.scopeChooser.ScopeChooserConfigurable" id="project.scopes" key="scopes.display.name" bundle="messages.IdeBundle" />
<projectConfigurable groupId="appearance" instance="com.intellij.ide.util.scopeChooser.ScopeChooserConfigurable" id="project.scopes" key="scopes.display.name" bundle="messages.IdeBundle" />
<checkoutCompletedListener implementation="com.intellij.openapi.vcs.checkout.PlatformProjectCheckoutListener" id="PlatformProjectCheckoutListener"/>
@@ -844,24 +844,22 @@
<add-to-group group-id="MaintenanceGroup" anchor="last"/>
</action>
<action id="Arrangement.Rule.Add" class="com.intellij.application.options.codeStyle.arrangement.action.AddArrangementRuleAction"/>
<action id="Arrangement.Rule.Section.Add" class="com.intellij.application.options.codeStyle.arrangement.action.AddArrangementSectionRuleAction"/>
<action id="Arrangement.Rule.Remove" class="com.intellij.application.options.codeStyle.arrangement.action.RemoveArrangementRuleAction"/>
<action id="Arrangement.Rule.Add"
class="com.intellij.application.options.codeStyle.arrangement.action.AddArrangementRuleAction"/>
<action id="Arrangement.Rule.Section.Add"
class="com.intellij.application.options.codeStyle.arrangement.action.AddArrangementSectionRuleAction"/>
<action id="Arrangement.Rule.Remove"
class="com.intellij.application.options.codeStyle.arrangement.action.RemoveArrangementRuleAction"/>
<action id="Arrangement.Rule.Edit"
class="com.intellij.application.options.codeStyle.arrangement.action.EditArrangementRuleAction"
icon="AllIcons.Actions.Edit"/>
class="com.intellij.application.options.codeStyle.arrangement.action.EditArrangementRuleAction"/>
<action id="Arrangement.Rule.Match.Condition.Move.Up"
class="com.intellij.application.options.codeStyle.arrangement.action.MoveArrangementMatchingRuleUpAction"
icon="AllIcons.ToolbarDecorator.MoveUp"/>
class="com.intellij.application.options.codeStyle.arrangement.action.MoveArrangementMatchingRuleUpAction"/>
<action id="Arrangement.Rule.Match.Condition.Move.Down"
class="com.intellij.application.options.codeStyle.arrangement.action.MoveArrangementMatchingRuleDownAction"
icon="AllIcons.ToolbarDecorator.MoveDown"/>
class="com.intellij.application.options.codeStyle.arrangement.action.MoveArrangementMatchingRuleDownAction"/>
<action id="Arrangement.Rule.Group.Condition.Move.Up"
class="com.intellij.application.options.codeStyle.arrangement.action.MoveArrangementGroupingRuleUpAction"
icon="AllIcons.ToolbarDecorator.MoveUp"/>
class="com.intellij.application.options.codeStyle.arrangement.action.MoveArrangementGroupingRuleUpAction"/>
<action id="Arrangement.Rule.Group.Condition.Move.Down"
class="com.intellij.application.options.codeStyle.arrangement.action.MoveArrangementGroupingRuleDownAction"
icon="AllIcons.ToolbarDecorator.MoveDown"/>
class="com.intellij.application.options.codeStyle.arrangement.action.MoveArrangementGroupingRuleDownAction"/>
<group id="Arrangement.Rule.Match.Control.Context.Menu">
<reference ref="Arrangement.Rule.Add"/>
@@ -47,10 +47,11 @@ public class ReformatFilesWithFiltersTest extends LightPlatformTestCase {
@Override
public void tearDown() throws Exception {
registerCodeStyleManager(myRealCodeStyleManger);
LanguageFormatting.INSTANCE.removeExplicitExtension(PlainTextLanguage.INSTANCE, myMockPlainTextFormattingModelBuilder);
TestFileStructure.delete(myWorkingDirectory.getVirtualFile());
if (myRealCodeStyleManger != null) registerCodeStyleManager(myRealCodeStyleManger);
if (myMockPlainTextFormattingModelBuilder != null) {
LanguageFormatting.INSTANCE.removeExplicitExtension(PlainTextLanguage.INSTANCE, myMockPlainTextFormattingModelBuilder);
}
if (myWorkingDirectory != null) TestFileStructure.delete(myWorkingDirectory.getVirtualFile());
super.tearDown();
}
@@ -169,7 +169,7 @@ debugger.breakpoint.message.full.trace=false
debugger.breakpoint.message.full.trace.description='Log message to console' breakpoint action will out full stacktrace\
for the thread that hit the breakpoint.
debugger.batch.evaluation=false
debugger.compiling.evaluator=false
debugger.compiling.evaluator=true
debugger.watches.in.variables=false
analyze.exceptions.on.the.fly=false
@@ -35,7 +35,7 @@ public class CopyLineStatusRangeAction extends BaseLineStatusRangeAction {
}
public void actionPerformed(final AnActionEvent e) {
final String content = myLineStatusTracker.getVcsContent(myRange).toString();
final String content = myLineStatusTracker.getVcsContent(myRange) + "\n";
CopyPasteManager.getInstance().setContents(new StringSelection(content));
}
}
@@ -139,38 +139,29 @@ public class LineStatusTrackerDrawing {
}
public static void showActiveHint(final Range range, final Editor editor, final Point point, final LineStatusTracker tracker) {
final DefaultActionGroup group = new DefaultActionGroup();
final AnAction globalShowNextAction = ActionManager.getInstance().getAction("VcsShowNextChangeMarker");
final AnAction globalShowPrevAction = ActionManager.getInstance().getAction("VcsShowPrevChangeMarker");
final ShowPrevChangeMarkerAction localShowPrevAction = new ShowPrevChangeMarkerAction(tracker.getPrevRange(range), tracker, editor);
final ShowNextChangeMarkerAction localShowNextAction = new ShowNextChangeMarkerAction(tracker.getNextRange(range), tracker, editor);
final JComponent editorComponent = editor.getComponent();
localShowNextAction.registerCustomShortcutSet(localShowNextAction.getShortcutSet(), editorComponent);
localShowPrevAction.registerCustomShortcutSet(localShowPrevAction.getShortcutSet(), editorComponent);
group.add(localShowPrevAction);
group.add(localShowNextAction);
localShowNextAction.copyFrom(globalShowNextAction);
localShowPrevAction.copyFrom(globalShowPrevAction);
final RollbackLineStatusRangeAction rollback = new RollbackLineStatusRangeAction(tracker, range, editor);
final ShowLineStatusRangeDiffAction showDiff = new ShowLineStatusRangeDiffAction(tracker, range, editor);
final CopyLineStatusRangeAction copyRange = new CopyLineStatusRangeAction(tracker, range);
group.add(localShowPrevAction);
group.add(localShowNextAction);
group.add(rollback);
group.add(showDiff);
group.add(copyRange);
final JComponent editorComponent = editor.getComponent();
EmptyAction.setupAction(localShowPrevAction, "VcsShowPrevChangeMarker", editorComponent);
EmptyAction.setupAction(localShowNextAction, "VcsShowNextChangeMarker", editorComponent);
EmptyAction.setupAction(rollback, IdeActions.SELECTED_CHANGES_ROLLBACK, editorComponent);
EmptyAction.setupAction(showDiff, "ChangesView.Diff", editorComponent);
EmptyAction.setupAction(copyRange, IdeActions.ACTION_COPY, editorComponent);
final JComponent toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.FILEHISTORY_VIEW_TOOLBAR, group, true).getComponent();
final Color background = ((EditorEx)editor).getBackgroundColor();
@@ -207,6 +198,7 @@ public class LineStatusTrackerDrawing {
component.add(toolbarPanel, BorderLayout.NORTH);
if (range.getType() != Range.INSERTED) {
final DocumentEx doc = (DocumentEx) tracker.getVcsDocument();
final EditorEx uEditor = (EditorEx)EditorFactory.getInstance().createViewer(doc, tracker.getProject());
@@ -221,6 +213,7 @@ public class LineStatusTrackerDrawing {
EditorFactory.getInstance().releaseEditor(uEditor);
}
final List<AnAction> actionList = ActionUtil.getActions(editorComponent);
final LightweightHint lightweightHint = new LightweightHint(component);
HintListener closeListener = new HintListener() {
@@ -234,9 +227,10 @@ public class LineStatusTrackerDrawing {
};
lightweightHint.addHintListener(closeListener);
HintManagerImpl.getInstanceImpl().showEditorHint(lightweightHint, editor, point, HintManagerImpl.HIDE_BY_ANY_KEY | HintManagerImpl.HIDE_BY_TEXT_CHANGE |
HintManagerImpl.HIDE_BY_SCROLLING,
-1, false, new HintHint(editor, point));
HintManagerImpl.getInstanceImpl()
.showEditorHint(lightweightHint, editor, point,
HintManagerImpl.HIDE_BY_ANY_KEY | HintManagerImpl.HIDE_BY_TEXT_CHANGE | HintManagerImpl.HIDE_BY_SCROLLING,
-1, false, new HintHint(editor, point));
if (!lightweightHint.isVisible()) {
closeListener.hintHidden(null);
@@ -18,6 +18,7 @@ package org.zmlx.hg4idea.action;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.VcsNotifier;
import com.intellij.openapi.vcs.update.UpdatedFiles;
@@ -42,7 +43,7 @@ public class HgMerge extends HgAbstractGlobalSingleRepoAction {
final HgMergeDialog mergeDialog = new HgMergeDialog(project, repos, selectedRepo);
mergeDialog.show();
if (mergeDialog.isOK()) {
final String targetValue = mergeDialog.getTargetValue();
final String targetValue = StringUtil.escapeBackSlashes(mergeDialog.getTargetValue());
final VirtualFile repoRoot = mergeDialog.getRepository().getRoot();
new Task.Backgroundable(project, "Merging changes...") {
@Override
@@ -16,6 +16,7 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -37,7 +38,7 @@ public class HgUpdateToAction extends HgAbstractGlobalSingleRepoAction {
dialog.show();
if (dialog.isOK()) {
FileDocumentManager.getInstance().saveAllDocuments();
final String updateToValue = dialog.getTargetValue();
final String updateToValue = StringUtil.escapeBackSlashes(dialog.getTargetValue());
boolean clean = dialog.isRemoveLocalChanges();
String title = HgVcsMessages.message("hg4idea.progress.updatingTo", updateToValue);
runUpdateToInBackground(project, title, dialog.getRepository().getRoot(), updateToValue, clean);
@@ -82,7 +82,7 @@ public class HgCommonDialogWithChoices extends DialogWrapper {
return hgRepositorySelectorComponent.getRepository();
}
public String getTag() {
private String getTag() {
return (String)tagSelector.getSelectedItem();
}
@@ -90,7 +90,7 @@ public class HgCommonDialogWithChoices extends DialogWrapper {
return tagOption.isSelected();
}
public String getBranch() {
private String getBranch() {
return (String)branchSelector.getSelectedItem();
}
@@ -98,7 +98,11 @@ public class HgCommonDialogWithChoices extends DialogWrapper {
return branchOption.isSelected();
}
public String getBookmark() {
private boolean isRevisionSelected() {
return revisionOption.isSelected();
}
private String getBookmark() {
return (String)bookmarkSelector.getSelectedItem();
}
@@ -106,7 +110,7 @@ public class HgCommonDialogWithChoices extends DialogWrapper {
return bookmarkOption.isSelected();
}
public String getRevision() {
private String getRevision() {
return revisionTxt.getText();
}
@@ -141,11 +145,15 @@ public class HgCommonDialogWithChoices extends DialogWrapper {
}
public String getTargetValue() {
return isBranchSelected() ? getBranch() : isBookmarkSelected() ? getBookmark() : isTagSelected() ? getTag() : getRevision();
return isBranchSelected()
? "branch(\"" + getBranch() + "\")"
: isBookmarkSelected()
? "bookmark(\"" + getBookmark() + "\")"
: isTagSelected() ? "tag(\"" + getTag() + "\")" : "\"" + getRevision() + "\"";
}
protected ValidationInfo doValidate() {
String message = "You have to specify appropriate name or revision.";
return StringUtil.isEmptyOrSpaces(getTargetValue()) ? new ValidationInfo(message, myBranchesBorderPanel) : null;
return isRevisionSelected() && StringUtil.isEmptyOrSpaces(getRevision()) ? new ValidationInfo(message, myBranchesBorderPanel) : null;
}
}
@@ -286,7 +286,7 @@ public class PyActiveSdkConfigurable implements UnnamedConfigurable {
PySdkService.getInstance().solidifySdk(item);
}
else {
final Sdk sdk = myProjectSdksModel.findSdk(item);
final Sdk sdk = myProjectSdksModel.getProjectSdks().get(item);
if (item != null && sdk == null) {
myProjectSdksModel.addSdk(item);
myProjectSdksModel.apply(null, true);
@@ -183,8 +183,11 @@ public class PyOverrideImplementUtil {
private static PyFunctionBuilder buildOverriddenFunction(PyClass pyClass, PyFunction baseFunction, boolean implement) {
PyFunctionBuilder pyFunctionBuilder = new PyFunctionBuilder(baseFunction.getName());
final PyDecoratorList decorators = baseFunction.getDecoratorList();
if (decorators != null && decorators.findDecorator(PyNames.CLASSMETHOD) != null) {
pyFunctionBuilder.decorate(PyNames.CLASSMETHOD);
if (decorators != null) {
if (decorators.findDecorator(PyNames.CLASSMETHOD) != null)
pyFunctionBuilder.decorate(PyNames.CLASSMETHOD);
else if (decorators.findDecorator(PyNames.STATICMETHOD) != null)
pyFunctionBuilder.decorate(PyNames.STATICMETHOD);
}
PyAnnotation anno = baseFunction.getAnnotation();
if (anno != null) {
@@ -18,6 +18,7 @@ package com.jetbrains.python.debugger;
import com.intellij.util.xmlb.annotations.Attribute;
import com.intellij.xdebugger.breakpoints.XBreakpointProperties;
import com.jetbrains.python.debugger.pydev.ExceptionBreakpointCommandFactory;
import com.sun.istack.internal.NotNull;
/**
* @author traff
@@ -25,7 +25,9 @@ import com.jetbrains.python.PyBundle;
import com.jetbrains.python.PythonFileType;
import com.jetbrains.python.inspections.quickfix.AddEncodingQuickFix;
import com.jetbrains.python.psi.LanguageLevel;
import com.jetbrains.python.psi.PyReferenceExpression;
import com.jetbrains.python.psi.PyStringLiteralExpression;
import com.jetbrains.python.psi.PyTargetExpression;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -95,6 +97,16 @@ public class PyNonAsciiCharInspection extends PyInspection {
public void visitPyStringLiteralExpression(PyStringLiteralExpression node) {
checkString(node, node.getText());
}
@Override
public void visitPyReferenceExpression(PyReferenceExpression node) {
checkString(node, node.getText());
}
@Override
public void visitPyTargetExpression(PyTargetExpression node) {
checkString(node, node.getText());
}
}
public String myDefaultEncoding = "utf-8";
@@ -24,6 +24,7 @@ import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.NonPhysicalFileSystem;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
@@ -729,7 +730,8 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
public String extractDeprecationMessage() {
if (canHaveDeprecationMessage(getText())) {
return PyFunctionImpl.extractDeprecationMessage(getStatements());
} else {
}
else {
return null;
}
}
@@ -894,4 +896,13 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
}
};
}
@Override
public boolean isPhysical() {
VirtualFile virtualFile = getVirtualFile();
if (virtualFile != null && virtualFile.getFileSystem() instanceof NonPhysicalFileSystem) {
return false;
}
return super.isPhysical();
}
}
@@ -0,0 +1,4 @@
g = 2
i = 2
<warning descr="Non-ASCII character ɡ in file, but no encoding declared">ɡ</warning> = 1
a = g + i
+7
View File
@@ -0,0 +1,7 @@
class A:
@staticmethod
def foo(cls):
cls.k = 3
class B(A):
<caret>pass
@@ -0,0 +1,9 @@
class A:
@staticmethod
def foo(cls):
cls.k = 3
class B(A):
@staticmethod
def foo(cls):
<selection>A.foo(cls)</selection>
@@ -1,9 +1,11 @@
package com.jetbrains.env.python.debug;
import com.google.common.collect.Sets;
import com.intellij.execution.ExecutionResult;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.JarFileSystem;
@@ -37,6 +39,7 @@ public abstract class PyBaseDebuggerTask extends PyExecutionFixtureTestTask {
protected Semaphore myTerminateSemaphore;
protected boolean shouldPrintOutput = false;
protected boolean myProcessCanTerminate;
protected ExecutionResult myExecutionResult;
protected void waitForPause() throws InterruptedException, InvocationTargetException {
Assert.assertTrue("Debugger didn't stopped within timeout\nOutput:" + output(), waitFor(myPausedSemaphore));
@@ -246,9 +249,8 @@ public abstract class PyBaseDebuggerTask extends PyExecutionFixtureTestTask {
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
public void run() {
try {
if (mySession != null) {
finishSession();
}
finishSession();
PyBaseDebuggerTask.super.tearDown();
}
catch (Exception e) {
@@ -271,10 +273,22 @@ public abstract class PyBaseDebuggerTask extends PyExecutionFixtureTestTask {
waitFor(mySession.getDebugProcess().getProcessHandler()); //wait for process termination after session.stop() which is async
XDebuggerTestUtil.disposeDebugSession(mySession);
mySession = null;
myDebugProcess = null;
myPausedSemaphore = null;
}
if (myExecutionResult != null) {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
Disposer.dispose(myExecutionResult.getExecutionConsole());
}
});
myExecutionResult = null;
}
}
protected abstract void disposeDebugProcess() throws InterruptedException;
@@ -12,6 +12,7 @@ import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.xdebugger.*;
import com.jetbrains.python.debugger.PyDebugProcess;
@@ -111,15 +112,15 @@ public class PyDebuggerTask extends PyBaseDebuggerTask {
new WriteAction<ExecutionResult>() {
@Override
protected void run(@NotNull Result<ExecutionResult> result) throws Throwable {
final ExecutionResult res =
myExecutionResult =
pyState.execute(executor, PyDebugRunner.createCommandLinePatchers(myFixture.getProject(), pyState, profile, serverLocalPort));
mySession = XDebuggerManager.getInstance(getProject()).
startSession(runner, env, env.getContentToReuse(), new XDebugProcessStarter() {
startSession(env, new XDebugProcessStarter() {
@NotNull
public XDebugProcess start(@NotNull final XDebugSession session) {
myDebugProcess =
new PyDebugProcess(session, serverSocket, res.getExecutionConsole(), res.getProcessHandler(), isMultiprocessDebug());
new PyDebugProcess(session, serverSocket, myExecutionResult.getExecutionConsole(), myExecutionResult.getProcessHandler(), isMultiprocessDebug());
myDebugProcess.getProcessHandler().addProcessListener(new ProcessAdapter() {
@@ -142,7 +143,7 @@ public class PyDebuggerTask extends PyBaseDebuggerTask {
return myDebugProcess;
}
});
result.setResult(res);
result.setResult(myExecutionResult);
}
}.execute().getResultObject();
@@ -64,6 +64,10 @@ public class PyOverrideTest extends PyTestCase {
doTest();
}
public void testStaticMethod() {
doTest();
}
public void testNewStyle() {
doTest();
}
@@ -300,6 +300,10 @@ public class PythonInspectionsTest extends PyTestCase {
doHighlightingTest(PyNonAsciiCharInspection.class);
}
public void testPyNonAsciiCharReferenceInspection() {
doHighlightingTest(PyNonAsciiCharInspection.class);
}
public void testPySetFunctionToLiteralInspection() { //PY-3120
setLanguageLevel(LanguageLevel.PYTHON27);
doHighlightingTest(PySetFunctionToLiteralInspection.class);
+2 -2
View File
@@ -252,14 +252,14 @@
<projectConfigurable groupId="language" instance="com.intellij.psi.templateLanguages.TemplateDataLanguageConfigurable" id="Template Data Languages" key="template.data.language.configurable" bundle="messages.LangBundle" />
<!-- Scopes -->
<projectConfigurable groupId="project" instance="com.intellij.ide.util.scopeChooser.ScopeChooserConfigurable" id="project.scopes" key="scopes.display.name" bundle="messages.IdeBundle" />
<projectConfigurable groupId="appearance" instance="com.intellij.ide.util.scopeChooser.ScopeChooserConfigurable" id="project.scopes" key="scopes.display.name" bundle="messages.IdeBundle" />
<!-- Application Configurables -->
<!-- Path Variables -->
<!-- the implementation of this configurable is in platform-impl but it's not registered in platform because
it's only required in full IDEA -->
<applicationConfigurable groupId="project" instance="com.intellij.application.options.pathMacros.PathMacroConfigurable" id="preferences.pathVariables"
<applicationConfigurable groupId="build" instance="com.intellij.application.options.pathMacros.PathMacroConfigurable" id="preferences.pathVariables"
key="title.path.variables" bundle="messages.ApplicationBundle"/>
<applicationConfigurable parentId="editor" instance="com.intellij.execution.console.ConsoleFoldingConfigurable" id="Console Folding"
@@ -106048,6 +106048,7 @@ recurrent
recurrently
recurring
recurs
recurse
recursion
recursion's
recursions
@@ -119,7 +119,7 @@ public abstract class NetService implements Disposable {
}
@Nullable
protected abstract OSProcessHandler createProcessHandler(Project project, int port) throws ExecutionException;
protected abstract OSProcessHandler createProcessHandler(@NotNull Project project, int port) throws ExecutionException;
protected void connectToProcess(@NotNull AsyncResult<OSProcessHandler> asyncResult, int port, @NotNull OSProcessHandler processHandler, @NotNull Consumer<String> errorOutputConsumer) {
asyncResult.setDone(processHandler);
@@ -449,12 +449,16 @@ public class HtmlParsing {
advance();
while (true) {
final IElementType tt = token();
if (tt == XmlTokenType.XML_COMMENT_CHARACTERS || tt == XmlTokenType.XML_CHAR_ENTITY_REF || tt == XmlTokenType.XML_CONDITIONAL_COMMENT_START
if (tt == XmlTokenType.XML_COMMENT_CHARACTERS || tt == XmlTokenType.XML_CONDITIONAL_COMMENT_START
|| tt == XmlTokenType.XML_CONDITIONAL_COMMENT_START_END || tt == XmlTokenType.XML_CONDITIONAL_COMMENT_END_START
|| tt == XmlTokenType.XML_CONDITIONAL_COMMENT_END) {
advance();
continue;
}
if (tt == XmlTokenType.XML_ENTITY_REF_TOKEN || tt == XmlTokenType.XML_CHAR_ENTITY_REF) {
parseReference();
continue;
}
if (tt == XmlTokenType.XML_BAD_CHARACTER) {
final PsiBuilder.Marker error = mark();
advance();