Merge remote-tracking branch 'origin/master'

This commit is contained in:
Maxim.Mossienko
2014-05-30 13:12:56 +02:00
55 changed files with 362 additions and 274 deletions
@@ -30,7 +30,6 @@ import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ArrayUtil;
import com.intellij.util.messages.MessageBus;
import com.intellij.util.messages.MessageBusConnection;
import org.jetbrains.annotations.NotNull;
@@ -246,48 +245,6 @@ public class CompilerManagerImpl extends CompilerManager {
}
}
// Compiler tests support
private static List<String> ourDeletedPaths;
private static List<String> ourRecompiledPaths;
private static List<String> ourCompiledPaths;
public static void testSetup() {
ourDeletedPaths = new ArrayList<String>();
ourRecompiledPaths = new ArrayList<String>();
ourCompiledPaths = new ArrayList<String>();
}
public static void addDeletedPath(String path) {
ourDeletedPaths.add(path);
}
public static void addRecompiledPath(String path) {
ourRecompiledPaths.add(path);
}
public static void addCompiledPath(String path) {
ourCompiledPaths.add(path);
}
public static String[] getPathsToDelete() {
return ArrayUtil.toStringArray(ourDeletedPaths);
}
public static String[] getPathsToRecompile() {
return ArrayUtil.toStringArray(ourRecompiledPaths);
}
public static String[] getPathsToCompile() {
return ArrayUtil.toStringArray(ourCompiledPaths);
}
public static void clearPathsToCompile() {
if (ourCompiledPaths != null) {
ourCompiledPaths.clear();
}
}
public boolean isExcludedFromCompilation(@NotNull VirtualFile file) {
return CompilerConfiguration.getInstance(myProject).isExcludedFromCompilation(file);
}
@@ -246,7 +246,6 @@ public abstract class BaseCompilerTestCase extends ModuleTestCase {
@Override
public void run() {
CompilerManagerImpl.testSetup();
final CompileStatusNotification callback = new CompileStatusNotification() {
@Override
public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
@@ -256,7 +255,6 @@ public abstract class BaseCompilerTestCase extends ModuleTestCase {
}
ExitStatus status = CompileDriver.getExternalBuildExitStatus(compileContext);
result.set(new CompilationLog(status == ExitStatus.UP_TO_DATE,
CompilerManagerImpl.getPathsToRecompile(), CompilerManagerImpl.getPathsToDelete(),
generatedFilePaths,
compileContext.getMessages(CompilerMessageCategory.ERROR),
compileContext.getMessages(CompilerMessageCategory.WARNING)));
@@ -413,20 +411,16 @@ public abstract class BaseCompilerTestCase extends ModuleTestCase {
}
protected class CompilationLog {
private final Set<String> myRecompiledPaths;
private final Set<String> myDeletedPaths;
private final Set<String> myGeneratedPaths;
private final boolean myExternalBuildUpToDate;
private final CompilerMessage[] myErrors;
private final CompilerMessage[] myWarnings;
public CompilationLog(boolean externalBuildUpToDate, String[] recompiledPaths, String[] deletedPaths, List<String> generatedFilePaths,
CompilerMessage[] errors, CompilerMessage[] warnings) {
public CompilationLog(boolean externalBuildUpToDate, List<String> generatedFilePaths, CompilerMessage[] errors,
CompilerMessage[] warnings) {
myExternalBuildUpToDate = externalBuildUpToDate;
myErrors = errors;
myWarnings = warnings;
myRecompiledPaths = getRelativePaths(recompiledPaths);
myDeletedPaths = getRelativePaths(deletedPaths);
myGeneratedPaths = new THashSet<String>(generatedFilePaths, FileUtil.PATH_HASHING_STRATEGY);
}
@@ -434,31 +428,10 @@ public abstract class BaseCompilerTestCase extends ModuleTestCase {
assertTrue(myExternalBuildUpToDate);
}
public void assertRecompiled(String... expected) {
checkRecompiled(expected);
checkDeleted();
}
public void assertGenerated(String... expected) {
assertSet("generated", myGeneratedPaths, expected);
}
public void assertDeleted(String... expected) {
checkRecompiled();
checkDeleted(expected);
}
public void assertRecompiledAndDeleted(String[] recompiled, String... deleted) {
checkRecompiled(recompiled);
checkDeleted(deleted);
}
private void checkRecompiled(String... expected) {
}
private void checkDeleted(String... expected) {
}
public CompilerMessage[] getErrors() {
return myErrors;
}
@@ -63,6 +63,9 @@ public class CompoundPositionManager extends PositionManagerEx {
catch (Exception e) {
LOG.error(e);
}
catch (AssertionError e) {
LOG.error(e);
}
}
return null;
}
@@ -79,6 +82,9 @@ public class CompoundPositionManager extends PositionManagerEx {
catch (Exception e) {
LOG.error(e);
}
catch (AssertionError e) {
LOG.error(e);
}
}
return Collections.emptyList();
}
@@ -95,6 +101,9 @@ public class CompoundPositionManager extends PositionManagerEx {
catch (Exception e) {
LOG.error(e);
}
catch (AssertionError e) {
LOG.error(e);
}
}
return Collections.emptyList();
}
@@ -110,6 +119,9 @@ public class CompoundPositionManager extends PositionManagerEx {
catch (Exception e) {
LOG.error(e);
}
catch (AssertionError e) {
LOG.error(e);
}
}
return null;
@@ -36,18 +36,23 @@ public class JavaBreakpointHandler extends XBreakpointHandler {
@Nullable
protected Breakpoint createJavaBreakpoint(@NotNull XBreakpoint xBreakpoint) {
return BreakpointManager.getJavaBreakpoint(xBreakpoint);
return null;
}
@Override
public void registerBreakpoint(@NotNull XBreakpoint breakpoint) {
final Breakpoint javaBreakpoint = createJavaBreakpoint(breakpoint);
Breakpoint javaBreakpoint = BreakpointManager.getJavaBreakpoint(breakpoint);
if (javaBreakpoint == null) {
javaBreakpoint = createJavaBreakpoint(breakpoint);
breakpoint.putUserData(Breakpoint.DATA_KEY, javaBreakpoint);
}
if (javaBreakpoint != null) {
BreakpointManager.addBreakpointInt(javaBreakpoint);
final Breakpoint bpt = javaBreakpoint;
BreakpointManager.addBreakpoint(bpt);
myProcess.getManagerThread().invoke(new DebuggerCommandImpl() {
@Override
protected void action() throws Exception {
javaBreakpoint.createRequest(myProcess);
bpt.createRequest(myProcess);
}
});
}
@@ -177,7 +177,16 @@ public class PositionManagerImpl implements PositionManager {
return null;
}
PsiClass psiClass = DebuggerUtils.findClass(refType.name(), project, myDebugProcess.getSearchScope());
final String originalQName = refType.name();
final GlobalSearchScope searchScope = myDebugProcess.getSearchScope();
PsiClass psiClass = DebuggerUtils.findClass(originalQName, project, searchScope); // try to lookup original name first
if (psiClass == null) {
int dollar = originalQName.indexOf('$');
if (dollar > 0) {
final String qName = originalQName.substring(0, dollar);
psiClass = DebuggerUtils.findClass(qName, project, searchScope);
}
}
if (psiClass != null) {
final PsiElement element = psiClass.getNavigationElement();
@@ -22,7 +22,6 @@ package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.DebuggerInvocationUtil;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.engine.BreakpointStepMethodFilter;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.requests.RequestManagerImpl;
@@ -112,10 +111,11 @@ public class BreakpointManager {
});
}
private boolean checkAndNotifyPossiblySlowBreakpoint(XBreakpoint breakpoint) {
private static boolean checkAndNotifyPossiblySlowBreakpoint(XBreakpoint breakpoint) {
if (breakpoint.isEnabled() &&
(breakpoint.getType() instanceof JavaMethodBreakpointType || breakpoint.getType() instanceof JavaWildcardMethodBreakpointType)) {
XDebugSessionImpl.NOTIFICATION_GROUP.createNotification("Method breakpoints may dramatically slow down debugging", MessageType.WARNING).notify(myProject);
XDebugSessionImpl.NOTIFICATION_GROUP.createNotification("Method breakpoints may dramatically slow down debugging", MessageType.WARNING)
.notify(((XBreakpointBase)breakpoint).getProject());
return true;
}
return false;
@@ -203,13 +203,12 @@ public class BreakpointManager {
return null;
}
XLineBreakpoint xLineBreakpoint = addXLineBreakpoint(JavaLineBreakpointType.class, document, lineIndex);
LineBreakpoint breakpoint = LineBreakpoint.create(myProject, xLineBreakpoint);
if (breakpoint == null) {
return null;
Breakpoint breakpoint = getJavaBreakpoint(xLineBreakpoint);
if (breakpoint instanceof LineBreakpoint) {
addBreakpoint(breakpoint);
return ((LineBreakpoint)breakpoint);
}
addBreakpoint(breakpoint);
return breakpoint;
return null;
}
@Nullable
@@ -232,11 +231,14 @@ public class BreakpointManager {
public FieldBreakpoint addFieldBreakpoint(Document document, int lineIndex, String fieldName) {
ApplicationManager.getApplication().assertIsDispatchThread();
XLineBreakpoint xBreakpoint = addXLineBreakpoint(JavaFieldBreakpointType.class, document, lineIndex);
FieldBreakpoint fieldBreakpoint = FieldBreakpoint.create(myProject, fieldName, xBreakpoint);
if (fieldBreakpoint != null) {
addBreakpoint(fieldBreakpoint);
Breakpoint javaBreakpoint = getJavaBreakpoint(xBreakpoint);
if (javaBreakpoint instanceof FieldBreakpoint) {
FieldBreakpoint fieldBreakpoint = (FieldBreakpoint)javaBreakpoint;
fieldBreakpoint.setFieldName(fieldName);
addBreakpoint(javaBreakpoint);
return fieldBreakpoint;
}
return fieldBreakpoint;
return null;
}
@NotNull
@@ -248,12 +250,18 @@ public class BreakpointManager {
public ExceptionBreakpoint compute() {
XBreakpoint<JavaExceptionBreakpointProperties> xBreakpoint = XDebuggerManager.getInstance(myProject).getBreakpointManager()
.addBreakpoint(type, new JavaExceptionBreakpointProperties(exceptionClassName, packageName));
ExceptionBreakpoint breakpoint = new ExceptionBreakpoint(myProject, exceptionClassName, packageName, xBreakpoint);
addBreakpoint(breakpoint);
if (LOG.isDebugEnabled()) {
LOG.debug("ExceptionBreakpoint Added");
Breakpoint javaBreakpoint = getJavaBreakpoint(xBreakpoint);
if (javaBreakpoint instanceof ExceptionBreakpoint) {
ExceptionBreakpoint exceptionBreakpoint = (ExceptionBreakpoint)javaBreakpoint;
exceptionBreakpoint.setQualifiedName(exceptionClassName);
exceptionBreakpoint.setPackageName(packageName);
addBreakpoint(exceptionBreakpoint);
if (LOG.isDebugEnabled()) {
LOG.debug("ExceptionBreakpoint Added");
}
return exceptionBreakpoint;
}
return breakpoint;
return null;
}
});
}
@@ -263,13 +271,12 @@ public class BreakpointManager {
ApplicationManager.getApplication().assertIsDispatchThread();
XLineBreakpoint xBreakpoint = addXLineBreakpoint(JavaMethodBreakpointType.class, document, lineIndex);
MethodBreakpoint breakpoint = MethodBreakpoint.create(myProject, xBreakpoint);
if (breakpoint == null) {
return null;
Breakpoint javaBreakpoint = getJavaBreakpoint(xBreakpoint);
if (javaBreakpoint instanceof MethodBreakpoint) {
addBreakpoint(javaBreakpoint);
return (MethodBreakpoint)javaBreakpoint;
}
addBreakpoint(breakpoint);
return breakpoint;
return null;
}
private <B extends XBreakpoint<?>> XLineBreakpoint addXLineBreakpoint(Class<? extends XBreakpointType<B,?>> typeCls, Document document, final int lineIndex) {
@@ -496,14 +503,8 @@ public class BreakpointManager {
return addXLineBreakpoint(typeCls, doc, line);
}
public static void addBreakpointInt(@NotNull Breakpoint breakpoint) {
BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(breakpoint.getProject()).getBreakpointManager();
breakpointManager.addBreakpoint(breakpoint);
}
//used in Fabrique
public void addBreakpoint(@NotNull Breakpoint breakpoint) {
breakpoint.myXBreakpoint.putUserData(Breakpoint.DATA_KEY, breakpoint);
public static void addBreakpoint(@NotNull Breakpoint breakpoint) {
assert breakpoint.myXBreakpoint.getUserData(Breakpoint.DATA_KEY) == breakpoint;
breakpoint.updateUI();
checkAndNotifyPossiblySlowBreakpoint(breakpoint.myXBreakpoint);
}
@@ -548,19 +549,17 @@ public class BreakpointManager {
}
@Nullable
public static Breakpoint getJavaBreakpoint(@Nullable XBreakpoint xBreakpoint) {
public static Breakpoint getJavaBreakpoint(@Nullable final XBreakpoint xBreakpoint) {
if (xBreakpoint == null) {
return null;
}
Breakpoint breakpoint = xBreakpoint.getUserData(Breakpoint.DATA_KEY);
if (breakpoint != null) {
return breakpoint;
if (breakpoint == null && xBreakpoint.getType() instanceof JavaBreakpointType) {
Project project = ((XBreakpointBase)xBreakpoint).getProject();
breakpoint = ((JavaBreakpointType)xBreakpoint.getType()).createJavaBreakpoint(project, xBreakpoint);
xBreakpoint.putUserData(Breakpoint.DATA_KEY, breakpoint);
}
Project project = ((XBreakpointBase)xBreakpoint).getProject();
if (xBreakpoint.getType() instanceof JavaBreakpointType) {
return ((JavaBreakpointType)xBreakpoint.getType()).createJavaBreakpoint(project, xBreakpoint);
}
return null;
return breakpoint;
}
//interaction with RequestManagerImpl
@@ -264,11 +264,11 @@ public class ExceptionBreakpoint extends Breakpoint<JavaExceptionBreakpointPrope
return getProperties().myQualifiedName;
}
private void setQualifiedName(String qualifiedName) {
void setQualifiedName(String qualifiedName) {
getProperties().myQualifiedName = qualifiedName;
}
private void setPackageName(String packageName) {
void setPackageName(String packageName) {
getProperties().myPackageName = packageName;
}
}
@@ -406,7 +406,7 @@ public class FieldBreakpoint extends BreakpointWithHighlighter<JavaFieldBreakpoi
return getProperties().WATCH_ACCESS;
}
private void setFieldName(String fieldName) {
void setFieldName(String fieldName) {
getProperties().myFieldName = fieldName;
}
}
@@ -30,9 +30,13 @@ 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.impl.source.resolve.DefaultParameterTypeInferencePolicy;
import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiTypesUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.ArrayUtilRt;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtilRt;
import com.intellij.util.containers.hash.LinkedHashMap;
@@ -106,6 +110,43 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
};
}
private static PsiType getInferredType(PsiAnonymousClass aClass) {
final PsiExpression expression = (PsiExpression)aClass.getParent();
final PsiType psiType = PsiTypesUtil.getExpectedTypeByParent(expression);
if (psiType != null) {
return psiType;
}
PsiExpression topExpr = expression;
while (topExpr.getParent() instanceof PsiParenthesizedExpression) {
topExpr = (PsiExpression)topExpr.getParent();
}
final PsiElement parent = topExpr.getParent();
if (parent instanceof PsiExpressionList) {
PsiExpressionList expressionList = (PsiExpressionList)parent;
final PsiElement callExpr = expressionList.getParent();
if (callExpr instanceof PsiCallExpression) {
final JavaResolveResult result = ((PsiCallExpression)callExpr).resolveMethodGenerics();
if (result instanceof MethodCandidateInfo) {
final PsiMethod method = ((MethodCandidateInfo)result).getElement();
PsiExpression[] expressions = expressionList.getExpressions();
int i = ArrayUtilRt.find(expressions, topExpr);
if (i < 0) return null;
expressions[i] = null;
final PsiParameter[] parameters = method.getParameterList().getParameters();
final PsiSubstitutor substitutor = PsiResolveHelper.SERVICE.getInstance(aClass.getProject())
.inferTypeArguments(method.getTypeParameters(), parameters, expressions,
((MethodCandidateInfo)result).getSiteSubstitutor(), callExpr.getParent(),
DefaultParameterTypeInferencePolicy.INSTANCE);
return substitutor.substitute(parameters[i].getType());
}
}
}
return null;
}
private static class ReplaceWithLambdaFix implements LocalQuickFix, HighPriorityAction {
@NotNull
@Override
@@ -328,10 +369,14 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
private final PsiMethod myMethod;
private final PsiAnonymousClass myAnonymClass;
private final boolean myRawType;
public ForbiddenRefsChecker(PsiMethod method,
PsiAnonymousClass aClass) {
myMethod = method;
myAnonymClass = aClass;
final PsiType inferredType = getInferredType(aClass);
myRawType = inferredType instanceof PsiClassType && ((PsiClassType)inferredType).isRaw();
}
@Override
@@ -390,6 +435,7 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
if (initializer == null ||
initializer.getTextOffset() > myAnonymClass.getTextOffset() && !((PsiField)resolved).hasModifierProperty(PsiModifier.STATIC)) {
myBodyContainsForbiddenRefs = true;
return;
}
}
} else {
@@ -407,16 +453,31 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
final Collection<PsiVariable> writtenVariables = ControlFlowUtil.getWrittenVariables(flow, 0, startOffset, false);
if (!writtenVariables.contains(resolved)) {
myBodyContainsForbiddenRefs = true;
return;
}
}
}
catch (AnalysisCanceledException e) {
myBodyContainsForbiddenRefs = true;
return;
}
}
}
}
}
if (myRawType) {
final PsiElement resolved = expression.resolve();
if (resolved instanceof PsiParameter && ((PsiParameter)resolved).getDeclarationScope() == myMethod) {
final int parameterIndex = myMethod.getParameterList().getParameterIndex((PsiParameter)resolved);
for (PsiMethod superMethod : myMethod.findDeepestSuperMethods()) {
if (PsiUtil.resolveClassInType(superMethod.getParameterList().getParameters()[parameterIndex].getType()) instanceof PsiTypeParameter) {
myBodyContainsForbiddenRefs = true;
return;
}
}
}
}
}
public boolean hasForbiddenRefs() {
@@ -207,7 +207,7 @@ public class StandardInstructionVisitor extends InstructionVisitor {
for (int i = 0; i < args.length; i++) {
final DfaValue arg = memState.pop();
int paramIndex = args.length - i - 1;
if (argValues != null && (paramIndex < args.length - 1 || !varargCall)) {
if (argValues != null && (paramIndex < argValues.length - 1 || !varargCall)) {
argValues[paramIndex] = arg;
}
@@ -245,7 +245,6 @@ public class StandardInstructionVisitor extends InstructionVisitor {
DfaConstValue.Factory constFactory = factory.getConstFactory();
List<DfaMemoryState> falseStates = ContainerUtil.newArrayList();
for (int i = 0; i < argValues.length; i++) {
List<DfaMemoryState> nextStates = ContainerUtil.newArrayList();
DfaValue argValue = argValues[i];
MethodContract.ValueConstraint constraint = contract.arguments[i];
DfaConstValue expectedValue = constraint == NULL_VALUE || constraint == NOT_NULL_VALUE ? constFactory.getNull() :
@@ -257,10 +256,14 @@ public class StandardInstructionVisitor extends InstructionVisitor {
boolean invertCondition = constraint == NOT_NULL_VALUE;
DfaValue condition = factory.getRelationFactory().createRelation(argValue, expectedValue, EQEQ, invertCondition);
if (condition == null) {
if (!(argValue instanceof DfaConstValue)) continue;
if (!(argValue instanceof DfaConstValue)) {
falseStates.addAll(states);
continue;
}
condition = constFactory.createFromValue(argValue == expectedValue, PsiType.BOOLEAN, null);
}
List<DfaMemoryState> nextStates = ContainerUtil.newArrayList();
for (DfaMemoryState state : states) {
boolean unknownVsNull = expectedValue == constFactory.getNull() &&
argValue instanceof DfaVariableValue &&
@@ -90,11 +90,11 @@ public abstract class MembersGetter {
public void processMembers(final Consumer<LookupElement> results, @Nullable final PsiClass where,
final boolean acceptMethods, final boolean searchInheritors) {
if (where == null || CommonClassNames.JAVA_LANG_STRING.equals(where.getQualifiedName())) return;
if (where == null || isPrimitiveClass(where)) return;
final boolean searchFactoryMethods = searchInheritors &&
!CommonClassNames.JAVA_LANG_OBJECT.equals(where.getQualifiedName()) &&
!CommonClassNames.JAVA_LANG_STRING.equals(where.getQualifiedName());
!isPrimitiveClass(where);
final Project project = myPlace.getProject();
final GlobalSearchScope scope = myPlace.getResolveScope();
@@ -127,6 +127,12 @@ public abstract class MembersGetter {
}
}
private static boolean isPrimitiveClass(PsiClass where) {
String qname = where.getQualifiedName();
if (qname == null || !qname.startsWith("java.lang.")) return false;
return CommonClassNames.JAVA_LANG_STRING.equals(qname) || InheritanceUtil.isInheritor(where, CommonClassNames.JAVA_LANG_NUMBER);
}
private void doProcessMembers(boolean acceptMethods,
Consumer<LookupElement> results,
boolean isExpectedTypeMember, Collection<? extends PsiElement> declarations) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 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.
@@ -117,7 +117,7 @@ public class PsiTypesUtil {
}
@Nullable
public static PsiClass getPsiClass(final PsiType psiType) {
public static PsiClass getPsiClass(@Nullable PsiType psiType) {
return psiType instanceof PsiClassType? ((PsiClassType)psiType).resolve() : null;
}
@@ -15,6 +15,8 @@
*/
package com.intellij.core;
import com.intellij.codeInsight.ContainerProvider;
import com.intellij.codeInsight.JavaContainerProvider;
import com.intellij.codeInsight.folding.JavaCodeFoldingSettings;
import com.intellij.codeInsight.folding.impl.JavaCodeFoldingSettingsBase;
import com.intellij.codeInsight.folding.impl.JavaFoldingBuilderBase;
@@ -75,6 +77,9 @@ public class JavaCoreApplicationEnvironment extends CoreApplicationEnvironment {
registerExtensionPoint(Extensions.getRootArea(), PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class);
registerExtensionPoint(Extensions.getRootArea(), JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class);
registerExtensionPoint(Extensions.getRootArea(), ContainerProvider.EP_NAME, ContainerProvider.class);
addExtension(ContainerProvider.EP_NAME, new JavaContainerProvider());
myApplication.registerService(PsiPackageImplementationHelper.class, new CorePsiPackageImplementationHelper());
myApplication.registerService(EmptySubstitutor.class, new EmptySubstitutorImpl());
@@ -0,0 +1,7 @@
public class Foo {
void foo(Object value) {
Integer i = val<caret>x
}
}
@@ -0,0 +1,24 @@
// "Replace with lambda" "false"
class DbTableBinder {
public Binder build() {
return new Bin<caret>der<DbTable>() {
public void bind(A q, DbTable dbTable) {
q.bind("name", dbTable.name);
}
};
}
}
class DbTable {
String name;
}
interface Binder <ArgType> {
void bind(A<?> sqlStatement, ArgType argType);
}
interface A<P> {
void bind(String s, String p);
}
@@ -0,0 +1,16 @@
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Nullable;
class Foo {
void foo() {
Object o1 = bar(goo());
if (o1 == null) {
System.out.println();
}
}
@Nullable Object goo() { return null;}
@Nullable @Contract("null->null") static Object bar(@Nullable Object foo) { return foo; }
}
@@ -32,6 +32,10 @@ class Contracts {
notBlank(message, "Message should not be blank", new Object(), new Object());
log(message);
}
public void vararg3(@Nullable String message) {
notBlank(message, "Message should not be blank", new Object(), new Object(), new Object(), new Object(), new Object());
log(message);
}
public void log(@NotNull String message) {
System.out.println(message);
@@ -625,6 +625,10 @@ interface TxANotAnno {}
checkPreferredItems 0, 'XException', 'XClass', 'XIntf'
}
public void testNoNumberValueOf() {
checkPreferredItems 0, 'value'
}
public void testGlobalStaticMemberStats() {
configureNoCompletion(getTestName(false) + ".java")
myFixture.complete(CompletionType.BASIC, 2)
@@ -207,6 +207,7 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
}
public void testContractAnnotation() { doTest(); }
public void testContractInapplicableComparison() { doTest(); }
public void testContractInLoopNotTooComplex() { doTest(); }
public void testContractWithNullable() { doTest(); }
public void testContractWithNotNull() { doTest(); }
@@ -15,7 +15,6 @@
*/
package com.intellij.testFramework;
import com.intellij.compiler.CompilerManagerImpl;
import com.intellij.compiler.CompilerTestUtil;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.Result;
@@ -62,7 +61,6 @@ public class CompilerTester {
myMainOutput = new TempDirTestFixtureImpl();
myMainOutput.setUp();
CompilerManagerImpl.testSetup();
new WriteCommandAction(getProject()) {
@Override
protected void run(Result result) throws Throwable {
@@ -145,7 +145,7 @@ public class MockVcsHelper extends AbstractVcsHelper {
}
@Override
public void showFileHistory(VcsHistoryProvider vcsHistoryProvider, FilePath path, AbstractVcs vcs, RepositoryLocation repositoryLocation) {
public void showFileHistory(VcsHistoryProvider vcsHistoryProvider, FilePath path, AbstractVcs vcs, String repositoryPath) {
throw new UnsupportedOperationException();
}
@@ -153,7 +153,7 @@ public class MockVcsHelper extends AbstractVcsHelper {
public void showFileHistory(VcsHistoryProvider vcsHistoryProvider,
AnnotationProvider annotationProvider,
FilePath path,
RepositoryLocation repositoryLocation,
String repositoryPath,
AbstractVcs vcs) {
throw new UnsupportedOperationException();
}
@@ -40,6 +40,7 @@ public class ExternalSystemDataKeys {
= DataKey.create("external.system.recent.tasks.list");
@NotNull public static final Key<Boolean> NEWLY_IMPORTED_PROJECT = new Key<Boolean>("external.system.newly.imported");
@NotNull public static final Key<Boolean> NEWLY_CREATED_PROJECT = new Key<Boolean>("external.system.newly.created");
private ExternalSystemDataKeys() {
}
@@ -52,9 +52,16 @@ public class ExternalSystemStartupActivity implements StartupActivity {
}
if (project.getUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT) != Boolean.TRUE) {
for (ExternalSystemManager manager : ExternalSystemManager.EP_NAME.getExtensions()) {
ExternalSystemUtil.refreshProjects(
new ImportSpecBuilder(project, manager.getSystemId()).whenAutoImportEnabled()
);
if (project.getUserData(ExternalSystemDataKeys.NEWLY_CREATED_PROJECT) == Boolean.TRUE) {
ExternalSystemUtil.refreshProjects(
new ImportSpecBuilder(project, manager.getSystemId())
);
}
else {
ExternalSystemUtil.refreshProjects(
new ImportSpecBuilder(project, manager.getSystemId()).whenAutoImportEnabled()
);
}
}
}
ExternalSystemAutoImporter.letTheMagicBegin(project);
@@ -27,6 +27,7 @@ import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
@@ -44,6 +45,8 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.List;
import java.util.Map;
@@ -207,6 +210,13 @@ public abstract class GotoActionBase extends AnAction {
popup.setFindUsagesTitle(findUsagesTitle);
final ChooseByNameFilter<T> filter = callback.createFilter(popup);
if (historyEnabled() && popup.getAdText() == null) {
popup.setAdText("Press " +
KeymapUtil.getKeystrokeText(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_MASK)) + " or " +
KeymapUtil.getKeystrokeText(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK)) +
" to navigate through the history");
}
popup.invoke(new ChooseByNamePopupComponent.Callback() {
@Override
public void onClose() {
@@ -251,7 +261,7 @@ public abstract class GotoActionBase extends AnAction {
abstract class HistoryAction extends DumbAwareAction {
@Override
public void update(AnActionEvent e) {
e.getPresentation().setEnabled(!ContainerUtil.isEmpty(ourHistory.get(myInAction)));
e.getPresentation().setEnabled(historyEnabled());
}
void setText(@NotNull List<String> strings) {
@@ -284,4 +294,8 @@ public abstract class GotoActionBase extends AnAction {
}
}.registerCustomShortcutSet(CustomShortcutSet.fromString("ctrl DOWN"), editor);
}
private static boolean historyEnabled() {
return !ContainerUtil.isEmpty(ourHistory.get(myInAction));
}
}
@@ -79,7 +79,7 @@ public class CustomizeKeyboardSchemeStepPanel extends AbstractCustomizeWizardSte
ButtonGroup group = new ButtonGroup();
group.add(macRadioButton);
group.add(defaultRadioButton);
defaultRadioButton.setSelected(true);
macRadioButton.setSelected(true);
}
@Override
@@ -83,9 +83,8 @@ class PluginGroups {
"org.intellij.grails",
"com.intellij.gwt",
"com.intellij.vaadin",
"JBoss",
"Seam:com.intellij.seam,com.intellij.seam.pages,com.intellij.seam.pageflow",
"JBPM",
"JBoss Seam:com.intellij.seam,com.intellij.seam.pages,com.intellij.seam.pageflow",
"JBoss jBPM:JBPM",
"Struts:StrutsAssistant,com.intellij.struts2",
"com.intellij.hibernate",
"Spring:com.intellij.spring.batch," +
@@ -215,7 +215,7 @@ public class MessageBusTest extends TestCase {
new MessageBusImpl(this, childBus);
}
PlatformTestUtil.assertTiming("Too long", 2500, new Runnable() {
PlatformTestUtil.assertTiming("Too long", 3000, new Runnable() {
@Override
public void run() {
T1Listener publisher = myBus.syncPublisher(TOPIC1);
@@ -144,10 +144,10 @@ public abstract class AbstractVcsHelper {
}
public abstract void showFileHistory(VcsHistoryProvider vcsHistoryProvider, FilePath path, final AbstractVcs vcs,
final RepositoryLocation repositoryLocation);
final String repositoryPath);
public abstract void showFileHistory(VcsHistoryProvider vcsHistoryProvider, AnnotationProvider annotationProvider, FilePath path,
final RepositoryLocation repositoryLocation, final AbstractVcs vcs);
final String repositoryPath, final AbstractVcs vcs);
/**
* Shows the "Rollback Changes" dialog with the specified list of changes.
@@ -21,7 +21,6 @@ import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.util.ThrowableComputable;
import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.RepositoryLocation;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.actions.VcsContextFactory;
import com.intellij.openapi.vcs.annotate.AnnotationProvider;
@@ -200,12 +199,6 @@ public class VcsAnnotationCachedProxy implements AnnotationProvider {
public void beforeRefresh() {
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return null;
}
@Override
public void forceRefresh() {
}
@@ -15,9 +15,7 @@
*/
package com.intellij.openapi.vcs.history;
import com.intellij.openapi.vcs.RepositoryLocation;
import com.intellij.openapi.vcs.VcsException;
import org.jetbrains.annotations.Nullable;
/**
* @author irengrig
@@ -55,12 +53,6 @@ public class VcsAppendableHistoryPartnerAdapter implements VcsAppendableHistoryS
public void beforeRefresh() {
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return null;
}
public void check() throws VcsException {
if (myException != null) throw myException;
}
@@ -15,9 +15,7 @@
*/
package com.intellij.openapi.vcs.history;
import com.intellij.openapi.vcs.RepositoryLocation;
import com.intellij.openapi.vcs.VcsException;
import org.jetbrains.annotations.Nullable;
public interface VcsAppendableHistorySessionPartner {
void reportCreatedEmptySession(VcsAbstractHistorySession session);
@@ -26,7 +24,4 @@ public interface VcsAppendableHistorySessionPartner {
void finished();
void forceRefresh();
void beforeRefresh();
@Nullable
RepositoryLocation getRepositoryLocation();
}
@@ -23,9 +23,7 @@ import com.intellij.openapi.roots.FileIndexFacade;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ChangeListManager;
import com.intellij.openapi.vcs.changes.LocalChangeList;
import com.intellij.openapi.vcs.changes.*;
import com.intellij.openapi.vcs.checkin.CheckinEnvironment;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
@@ -67,6 +65,7 @@ public class CommonCheckinFilesAction extends AbstractCommonCheckinAction {
@Override
protected LocalChangeList getInitiallySelectedChangeList(final VcsContext context, final Project project) {
final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
LocalChangeList defaultChangeList = changeListManager.getDefaultChangeList();
final FilePath[] roots = getRoots(context);
for(final FilePath root: roots) {
@@ -74,9 +73,13 @@ public class CommonCheckinFilesAction extends AbstractCommonCheckinAction {
if (file == null) continue;
final Ref<Change> change = new Ref<Change>();
if (!file.isDirectory()) {
change.set(changeListManager.getChange(file));
return changeListManager.getChangeList(file);
}
else {
if (hasChangesUnderDir(defaultChangeList, new FilePathImpl(file))) {
return defaultChangeList;
}
final FileIndexFacade index = PeriodicalTasksCloser.getInstance().safeGetService(project, FileIndexFacade.class);
final VirtualFileFilter filter = new VirtualFileFilter() {
public boolean accept(final VirtualFile file) {
@@ -104,7 +107,21 @@ public class CommonCheckinFilesAction extends AbstractCommonCheckinAction {
}
}
return changeListManager.getDefaultChangeList();
return defaultChangeList;
}
private static boolean hasChangesUnderDir(final ChangeList changeList, final FilePath dirPath) {
for (Change change : changeList.getChanges()) {
final ContentRevision afterRevision = change.getAfterRevision();
if (afterRevision != null && afterRevision.getFile().isUnder(dirPath, false)) {
return true;
}
final ContentRevision beforeRevision = change.getBeforeRevision();
if (beforeRevision != null && beforeRevision.getFile().isUnder(dirPath, false)) {
return true;
}
}
return false;
}
private String getCheckinActionName(final VcsContext dataContext) {
@@ -17,7 +17,6 @@ package com.intellij.openapi.vcs.history;
import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.RepositoryLocation;
import com.intellij.openapi.vcs.annotate.AnnotationProvider;
/**
@@ -36,12 +35,12 @@ public class FileHistoryRefresher implements FileHistoryRefresherI {
public FileHistoryRefresher(final VcsHistoryProvider vcsHistoryProvider,
final AnnotationProvider annotationProvider,
final FilePath path,
final RepositoryLocation repositoryLocation,
final String repositoryPath,
final AbstractVcs vcs) {
myVcsHistoryProvider = vcsHistoryProvider;
myPath = path;
myVcs = vcs;
mySessionPartner = new FileHistorySessionPartner(vcsHistoryProvider, annotationProvider, path, repositoryLocation, vcs, this);
mySessionPartner = new FileHistorySessionPartner(vcsHistoryProvider, annotationProvider, path, repositoryPath, vcs, this);
myCanUseCache = true;
}
@@ -17,7 +17,10 @@ package com.intellij.openapi.vcs.history;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.annotate.AnnotationProvider;
import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
@@ -30,7 +33,6 @@ import com.intellij.ui.content.ContentManager;
import com.intellij.util.BufferedListConsumer;
import com.intellij.util.Consumer;
import com.intellij.util.ContentsUtil;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@@ -43,7 +45,7 @@ public class FileHistorySessionPartner implements VcsAppendableHistorySessionPar
private final VcsHistoryProvider myVcsHistoryProvider;
private final AnnotationProvider myAnnotationProvider;
private final FilePath myPath;
private final RepositoryLocation myRepositoryLocation;
private final String myRepositoryPath;
private final AbstractVcs myVcs;
private final FileHistoryRefresherI myRefresherI;
private volatile VcsAbstractHistorySession mySession;
@@ -51,14 +53,14 @@ public class FileHistorySessionPartner implements VcsAppendableHistorySessionPar
public FileHistorySessionPartner(final VcsHistoryProvider vcsHistoryProvider, final AnnotationProvider annotationProvider,
final FilePath path,
final RepositoryLocation repositoryLocation,
final String repositoryPath,
final AbstractVcs vcs,
final FileHistoryRefresherI refresherI) {
myVcsHistoryProvider = vcsHistoryProvider;
myAnnotationProvider = annotationProvider;
myPath = path;
myLimitHistoryCheck = new LimitHistoryCheck(vcs.getProject(), path.getPath());
myRepositoryLocation = repositoryLocation;
myRepositoryPath = repositoryPath;
myVcs = vcs;
myRefresherI = refresherI;
myBuffer = new BufferedListConsumer<VcsFileRevision>(5, new Consumer<List<VcsFileRevision>>() {
@@ -74,12 +76,6 @@ public class FileHistorySessionPartner implements VcsAppendableHistorySessionPar
}, 1000);
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return myRepositoryLocation;
}
public void acceptRevision(VcsFileRevision revision) {
myLimitHistoryCheck.checkNumber();
myBuffer.consumeOne(revision);
@@ -221,12 +221,6 @@ public class VcsHistoryProviderBackgroundableProxy {
myPartner.beforeRefresh();
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return myPartner.getRepositoryLocation();
}
@Override
public void forceRefresh() {
myPartner.forceRefresh();
@@ -116,13 +116,13 @@ public class AbstractVcsHelperImpl extends AbstractVcsHelper {
}
public void showFileHistory(final VcsHistoryProvider vcsHistoryProvider, final FilePath path, final AbstractVcs vcs,
final RepositoryLocation repositoryLocation) {
showFileHistory(vcsHistoryProvider, null, path, repositoryLocation, vcs);
final String repositoryPath) {
showFileHistory(vcsHistoryProvider, null, path, repositoryPath, vcs);
}
public void showFileHistory(final VcsHistoryProvider vcsHistoryProvider, final AnnotationProvider annotationProvider, final FilePath path,
final RepositoryLocation repositoryLocation, final AbstractVcs vcs) {
final FileHistoryRefresherI refresherI = new FileHistoryRefresher(vcsHistoryProvider, annotationProvider, path, repositoryLocation, vcs);
final String repositoryPath, final AbstractVcs vcs) {
final FileHistoryRefresherI refresherI = new FileHistoryRefresher(vcsHistoryProvider, annotationProvider, path, repositoryPath, vcs);
refresherI.run(false, true);
}
@@ -166,6 +166,10 @@ public class XLightBreakpointPropertiesPanel<B extends XBreakpointBase<?,?,?>> i
myCustomRightPropertiesPanelWrapper.add(customRightConditionPanel.getComponent(), BorderLayout.CENTER);
myCustomPanels.add(customRightConditionPanel);
}
else {
// see IDEA-125745
myCustomRightPropertiesPanelWrapper.getParent().remove(myCustomRightPropertiesPanelWrapper);
}
XBreakpointCustomPropertiesPanel<B> customTopPropertiesPanel = breakpointType.createCustomTopPropertiesPanel(project);
if (customTopPropertiesPanel != null) {
@@ -1297,7 +1297,7 @@ boolean.expression.can.be.simplified.problem.descriptor=<code>#ref</code> can be
trivial.string.concatenation.problem.descriptor=Empty string used in concatenation
string.replace.quickfix=Replace concatenation with ''{0}''
instantiating.object.to.get.class.object.replace.quickfix=Replace with direct class object access
manual.array.copy.replace.quickfix=Replace with 'System.arrayCopy()'
manual.array.copy.replace.quickfix=Replace with 'System.arraycopy()'
manual.array.to.collection.copy.replace.quickfix=Replace with 'Collections.addAll(...,...)'
method.may.be.static.only.option=Only check 'private' or 'final' methods
method.may.be.static.empty.option=Ignore empty methods
@@ -0,0 +1,38 @@
/*
* 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.cvsSupport2;
import com.intellij.cvsSupport2.changeBrowser.CvsRepositoryLocation;
import com.intellij.openapi.vcs.FilePathImpl;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
/**
* @author Bas Leijdekkers
*/
public class CvsFilePath extends FilePathImpl {
private final CvsRepositoryLocation myRepositoryLocation;
public CvsFilePath(@NotNull VirtualFile virtualFile, CvsRepositoryLocation repositoryLocation) {
super(virtualFile);
myRepositoryLocation = repositoryLocation;
}
public CvsRepositoryLocation getRepositoryLocation() {
return myRepositoryLocation;
}
}
@@ -16,6 +16,7 @@
package com.intellij.cvsSupport2.cvsBrowser.ui;
import com.intellij.CvsBundle;
import com.intellij.cvsSupport2.CvsFilePath;
import com.intellij.cvsSupport2.CvsVcs2;
import com.intellij.cvsSupport2.actions.cvsContext.CvsContextAdapter;
import com.intellij.cvsSupport2.actions.cvsContext.CvsLightweightFile;
@@ -165,7 +166,7 @@ public class BrowserPanel extends JPanel implements DataProvider, CvsTabbedWindo
}
public void actionPerformed(AnActionEvent e) {
CvsElement[] currentSelection = myTree.getCurrentSelection();
final CvsElement[] currentSelection = myTree.getCurrentSelection();
if (currentSelection.length != 1) return;
final CvsElement cvsElement = currentSelection[0];
final VirtualFile virtualFile = cvsElement.getVirtualFile();
@@ -174,7 +175,7 @@ public class BrowserPanel extends JPanel implements DataProvider, CvsTabbedWindo
final VcsHistoryProvider historyProvider = vcs.getVcsHistoryProvider();
final String moduleName = cvsElement.getElementPath();
final CvsRepositoryLocation location = new CvsRepositoryLocation(null, myCvsRootConfiguration, moduleName);
AbstractVcsHelper.getInstance(myProject).showFileHistory(historyProvider, new FilePathImpl(virtualFile), vcs, location);
AbstractVcsHelper.getInstance(myProject).showFileHistory(historyProvider, new CvsFilePath(virtualFile, location), vcs, null);
}
}
@@ -16,6 +16,7 @@
package com.intellij.cvsSupport2.history;
import com.intellij.CvsBundle;
import com.intellij.cvsSupport2.CvsFilePath;
import com.intellij.cvsSupport2.CvsUtil;
import com.intellij.cvsSupport2.application.CvsEntriesManager;
import com.intellij.cvsSupport2.changeBrowser.CvsChangeList;
@@ -203,9 +204,9 @@ public class CvsHistoryProvider implements VcsHistoryProvider {
}
public void reportAppendableHistory(FilePath path, VcsAppendableHistorySessionPartner partner) throws VcsException {
final CvsRepositoryLocation location = (CvsRepositoryLocation)partner.getRepositoryLocation();
final VcsHistorySession session;
if (location != null) {
if (path instanceof CvsFilePath) {
final CvsRepositoryLocation location = ((CvsFilePath)path).getRepositoryLocation();
final List<VcsFileRevision> fileRevisionList = createRevisions(location.getEnvironment(), path.getIOFile());
if (fileRevisionList == null) return;
session = new MyHistorySession(fileRevisionList, path);
@@ -22,6 +22,7 @@ import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys;
import com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalModuleBuilder;
import com.intellij.openapi.externalSystem.service.project.wizard.ExternalModuleSettingsStep;
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings;
@@ -111,6 +112,7 @@ public class GradleModuleBuilder extends AbstractExternalModuleBuilder<GradlePro
String externalProjectPath = FileUtil.toCanonicalPath(project.getBasePath());
getExternalProjectSettings().setExternalProjectPath(externalProjectPath);
AbstractExternalSystemSettings settings = ExternalSystemApiUtil.getSettings(project, GradleConstants.SYSTEM_ID);
project.putUserData(ExternalSystemDataKeys.NEWLY_CREATED_PROJECT, Boolean.TRUE);
//noinspection unchecked
settings.linkProject(getExternalProjectSettings());
}
@@ -40,10 +40,9 @@ import java.util.List;
* @author ilyas
*/
public class GroovyFileType extends LanguageFileType {
public static final List<FileType> GROOVY_FILE_TYPES = new ArrayList<FileType>();
public static final GroovyFileType GROOVY_FILE_TYPE = new GroovyFileType();
@NonNls public static final String DEFAULT_EXTENSION = "groovy";
public static final List<FileType> GROOVY_FILE_TYPES = new ArrayList<FileType>();
private GroovyFileType() {
super(GroovyLanguage.INSTANCE);
@@ -55,8 +54,10 @@ public class GroovyFileType extends LanguageFileType {
return new GroovyEditorHighlighter(colors);
}
});
GROOVY_FILE_TYPES.add(this);
}
@NotNull
public static FileType[] getGroovyEnabledFileTypes() {
return GROOVY_FILE_TYPES.toArray(new FileType[GROOVY_FILE_TYPES.size()]);
}
@@ -318,12 +318,12 @@ public class GroovyDslFileIndex extends ScalarIndexExtension<String> {
return;
}
Set<Class> classes = ContainerUtil.map2Set(extensions, new Function<GroovyFrameworkConfigNotification, Class>() {
Set<Class> classes = new HashSet<Class>(ContainerUtil.map2Set(extensions, new Function<GroovyFrameworkConfigNotification, Class>() {
@Override
public Class fun(GroovyFrameworkConfigNotification notification) {
return notification.getClass();
}
});
}));
classes.add(GroovyFrameworkConfigNotification.class); // for default extension
// perhaps a separate extension for that?
@@ -704,7 +704,8 @@ public class PsiUtil {
return nextSibling;
}
public static PsiIdentifier getJavaNameIdentifier(GrNamedElement namedElement) {
@NotNull
public static PsiIdentifier getJavaNameIdentifier(@NotNull GrNamedElement namedElement) {
final PsiElement element = namedElement.getNameIdentifierGroovy();
JavaIdentifier identifier = element.getUserData(NAME_IDENTIFIER);
if (identifier == null) {
@@ -42,7 +42,7 @@ public class SwingBuilderNamedArgumentProvider extends GroovyNamedArgumentProvid
@Nullable String argumentName,
boolean forCompletion,
Map<String, NamedArgumentDescriptor> result) {
PsiType returnType = ((PsiMethod)resolve).getReturnType();
PsiType returnType = resolve == null ? null : ((PsiMethod)resolve).getReturnType();
PsiClass aClass = PsiTypesUtil.getPsiClass(returnType);
if (aClass == null) return;
@@ -50,6 +50,5 @@ public class GroovyFileTypeLoader extends FileTypeFactory{
@Override
public void createFileTypes(@NotNull FileTypeConsumer consumer) {
consumer.consume(GroovyFileType.GROOVY_FILE_TYPE, StringUtil.join(getAllGroovyExtensions(), ";"));
GroovyFileType.GROOVY_FILE_TYPES.add(GroovyFileType.GROOVY_FILE_TYPE);
}
}
@@ -15,8 +15,6 @@ package org.zmlx.hg4idea.execution;
import com.intellij.ide.passwordSafe.PasswordSafe;
import com.intellij.ide.passwordSafe.PasswordSafeException;
import com.intellij.ide.passwordSafe.impl.PasswordSafeImpl;
import com.intellij.ide.passwordSafe.impl.PasswordSafeProvider;
import com.intellij.ide.passwordSafe.impl.providers.masterKey.MasterKeyPasswordSafe;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
@@ -55,10 +53,13 @@ class HgCommandAuthenticator {
final String url = VirtualFileManager.extractPath(myRunnable.getURL());
final String key = keyForUrlAndLogin(url, myRunnable.getUserName());
final PasswordSafeProvider provider =
myRunnable.isRememberPassword() ? passwordSafe.getMasterKeyProvider() : passwordSafe.getMemoryProvider();
try {
provider.storePassword(myProject, HgCommandAuthenticator.class, key, myRunnable.getPassword());
if (myRunnable.isRememberPassword()) {
//save password to memory, despite of settings-> passwords
//todo should be reworked
passwordSafe.getMemoryProvider().storePassword(myProject, HgCommandAuthenticator.class, key, myRunnable.getPassword());
}
passwordSafe.storePassword(myProject, HgCommandAuthenticator.class, key, myRunnable.getPassword());
final HgVcs vcs = HgVcs.getInstance(myProject);
if (vcs != null) {
vcs.getGlobalSettings().addRememberedUrl(url, myRunnable.getUserName());
@@ -129,13 +130,7 @@ class HgCommandAuthenticator {
final PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance();
password = passwordSafe.getMemoryProvider().getPassword(myProject, HgCommandAuthenticator.class, key);
if (password == null) {
final MasterKeyPasswordSafe masterKeyProvider = passwordSafe.getMasterKeyProvider();
if (!masterKeyProvider.isEmpty()) {
// workaround for: don't ask for master password, if the requested password is not there.
// this should be fixed in PasswordSafe: don't ask master password to look for keys
// until then we assume that is PasswordSafe was used (there is anything there), then it makes sense to look there.
password = masterKeyProvider.getPassword(myProject, HgCommandAuthenticator.class, key);
}
password = passwordSafe.getPassword(myProject, HgCommandAuthenticator.class, key);
}
} catch (PasswordSafeException e) {
LOG.info("Couldn't get password for key [" + key + "]", e);
@@ -124,14 +124,14 @@ public class HgMockVcsHelper extends AbstractVcsHelper {
}
@Override
public void showFileHistory(VcsHistoryProvider vcsHistoryProvider, FilePath path, AbstractVcs vcs, RepositoryLocation repositoryLocation) {
public void showFileHistory(VcsHistoryProvider vcsHistoryProvider, FilePath path, AbstractVcs vcs, String repositoryPath) {
}
@Override
public void showFileHistory(VcsHistoryProvider vcsHistoryProvider,
AnnotationProvider annotationProvider,
FilePath path,
RepositoryLocation repositoryLocation,
String repositoryPath,
AbstractVcs vcs) {
}
@@ -15,7 +15,6 @@
*/
package org.jetbrains.idea.maven.compiler;
import com.intellij.compiler.CompilerManagerImpl;
import com.intellij.compiler.CompilerTestUtil;
import com.intellij.compiler.CompilerWorkspaceConfiguration;
import com.intellij.compiler.artifacts.ArtifactsTestUtil;
@@ -76,7 +75,6 @@ public abstract class MavenCompilingTestCase extends MavenImportingTestCase {
});
CompilerWorkspaceConfiguration.getInstance(myProject).CLEAR_OUTPUT_DIRECTORY = true;
CompilerManagerImpl.testSetup();
final Semaphore semaphore = new Semaphore();
semaphore.down();
@@ -348,10 +348,9 @@ public class RepositoryBrowserDialog extends DialogWrapper {
boolean isDirectory = node.getUserObject() instanceof SVNURL ||
(node.getSVNDirEntry() != null && node.getSVNDirEntry().getKind() == SVNNodeKind.DIR);
String url = node.getURL().toDecodedString();
final SvnRepositoryLocation repositoryLocation = new SvnRepositoryLocation(node.getURL().toString());
AbstractVcsHelper.getInstance(myProject)
.showFileHistory(myVCS.getVcsHistoryProvider(), VcsUtil.getFilePathOnNonLocal(url, isDirectory), myVCS, repositoryLocation);
.showFileHistory(myVCS.getVcsHistoryProvider(), VcsUtil.getFilePathOnNonLocal(url, isDirectory), myVCS, url);
node.reload(false);
}
}
@@ -25,7 +25,6 @@ import com.intellij.openapi.vcs.history.VcsFileRevision;
import com.intellij.openapi.vcs.history.VcsHistoryProvider;
import com.intellij.util.concurrency.Semaphore;
import junit.framework.Assert;
import org.jetbrains.annotations.Nullable;
import org.junit.Test;
/**
@@ -78,12 +77,6 @@ public class SvnHistoryTest extends Svn17TestCase {
public void beforeRefresh() {
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return null;
}
@Override
public void forceRefresh() {
}
@@ -134,12 +127,6 @@ public class SvnHistoryTest extends Svn17TestCase {
public void beforeRefresh() {
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return null;
}
@Override
public void forceRefresh() {
}
@@ -189,12 +176,6 @@ public class SvnHistoryTest extends Svn17TestCase {
public void beforeRefresh() {
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return null;
}
@Override
public void forceRefresh() {
}
@@ -248,12 +229,6 @@ public class SvnHistoryTest extends Svn17TestCase {
public void beforeRefresh() {
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return null;
}
@Override
public void forceRefresh() {
}
@@ -308,12 +283,6 @@ public class SvnHistoryTest extends Svn17TestCase {
public void beforeRefresh() {
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return null;
}
@Override
public void forceRefresh() {
}
@@ -348,12 +317,6 @@ public class SvnHistoryTest extends Svn17TestCase {
public void beforeRefresh() {
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return null;
}
@Override
public void forceRefresh() {
}
@@ -387,12 +350,6 @@ public class SvnHistoryTest extends Svn17TestCase {
public void beforeRefresh() {
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return null;
}
@Override
public void forceRefresh() {
}
@@ -67,6 +67,7 @@ import com.jetbrains.python.codeInsight.stdlib.PyNamedTupleType;
import com.jetbrains.python.magicLiteral.PyMagicLiteralTools;
import com.jetbrains.python.psi.impl.PyBuiltinCache;
import com.jetbrains.python.psi.impl.PyPsiUtils;
import com.jetbrains.python.psi.impl.PythonLanguageLevelPusher;
import com.jetbrains.python.psi.types.*;
import com.jetbrains.python.refactoring.classes.PyDependenciesComparator;
import com.jetbrains.python.refactoring.classes.extractSuperclass.PyExtractSuperclassHelper;
@@ -775,7 +776,8 @@ public class PyUtil {
// Most of the cases should be handled by this one, PyLanguageLevelPusher pushes folders only
final VirtualFile folder = virtualFile.getParent();
if (folder != null) {
final LanguageLevel level = folder.getUserData(LanguageLevel.KEY);
LanguageLevel level = folder.getUserData(LanguageLevel.KEY);
if (level == null) level = PythonLanguageLevelPusher.getFileLanguageLevel(project, virtualFile);
if (level != null) return level;
}
else {
@@ -20,7 +20,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.*;
@@ -85,14 +85,19 @@ public class PythonLanguageLevelPusher implements FilePropertyPusher<LanguageLev
}
public LanguageLevel getImmediateValue(@NotNull Project project, @Nullable VirtualFile file) {
return getFileLanguageLevel(project, file);
}
public static LanguageLevel getFileLanguageLevel(Project project, VirtualFile file) {
if (ApplicationManager.getApplication().isUnitTestMode() && LanguageLevel.FORCE_LANGUAGE_LEVEL != null) {
return LanguageLevel.FORCE_LANGUAGE_LEVEL;
}
if (file == null) return null;
final Module module = ModuleUtil.findModuleForFile(file, project);
final Module module = ModuleUtilCore.findModuleForFile(file, project);
if (module != null) {
return getImmediateValue(module);
final Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
return PythonSdkType.getLanguageLevelForSdk(sdk);
}
final Sdk sdk = findSdk(project, file);
if (sdk != null) {
@@ -208,16 +208,10 @@
<projectService serviceInterface="com.intellij.compiler.impl.javaCompiler.javac.JavacConfiguration"
serviceImplementation="com.intellij.compiler.impl.javaCompiler.javac.JavacConfiguration"/>
<projectService serviceInterface="com.intellij.compiler.impl.javaCompiler.api.CompilerAPIConfiguration"
serviceImplementation="com.intellij.compiler.impl.javaCompiler.api.CompilerAPIConfiguration"/>
<projectService serviceInterface="com.intellij.compiler.impl.javaCompiler.eclipse.EclipseCompilerConfiguration"
serviceImplementation="com.intellij.compiler.impl.javaCompiler.eclipse.EclipseCompilerConfiguration"/>
<projectService serviceInterface="com.intellij.compiler.impl.javaCompiler.eclipse.EclipseEmbeddedCompilerConfiguration"
serviceImplementation="com.intellij.compiler.impl.javaCompiler.eclipse.EclipseEmbeddedCompilerConfiguration"/>
<projectService serviceInterface="com.intellij.compiler.impl.rmiCompiler.RmicConfiguration"
serviceImplementation="com.intellij.compiler.impl.rmiCompiler.RmicConfiguration"/>
<projectService serviceInterface="com.intellij.compiler.impl.javaCompiler.jikes.JikesConfiguration"
serviceImplementation="com.intellij.compiler.impl.javaCompiler.jikes.JikesConfiguration"/>
<pathMacroFilter implementation="com.intellij.compiler.impl.javaCompiler.javac.JavacConfigurationMacroFilter"/>
<applicationService serviceInterface="com.intellij.openapi.wm.impl.FrameTitleBuilder"