Merge remote-tracking branch 'origin/master'

This commit is contained in:
Yann Cébron
2016-04-26 20:33:11 +02:00
17 changed files with 87 additions and 72 deletions
@@ -33,6 +33,7 @@ import com.intellij.psi.util.CachedValuesManager;
import com.intellij.psi.util.PsiFormatUtil;
import com.intellij.testFramework.LightVirtualFile;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.ConcurrentFactoryMap;
import com.intellij.util.containers.Stack;
import com.intellij.util.indexing.FileBasedIndex;
import org.jetbrains.annotations.NotNull;
@@ -218,27 +219,27 @@ public class ProjectBytecodeAnalysis {
}
public PsiAnnotation getNotNullAnnotation() {
return CachedValuesManager.getManager(myProject).getCachedValue(myProject, new CachedValueProvider<PsiAnnotation>() {
@Nullable
@Override
public Result<PsiAnnotation> compute() {
return Result.create(createAnnotationFromText("@" + AnnotationUtil.NOT_NULL), ModificationTracker.NEVER_CHANGED);
}
});
return CachedValuesManager.getManager(myProject).getCachedValue(myProject, () ->
CachedValueProvider.Result.create(createAnnotationFromText("@" + AnnotationUtil.NOT_NULL), ModificationTracker.NEVER_CHANGED));
}
public PsiAnnotation getNullableAnnotation() {
return CachedValuesManager.getManager(myProject).getCachedValue(myProject, new CachedValueProvider<PsiAnnotation>() {
@Nullable
@Override
public Result<PsiAnnotation> compute() {
return Result.create(createAnnotationFromText("@" + AnnotationUtil.NULLABLE), ModificationTracker.NEVER_CHANGED);
}
});
return CachedValuesManager.getManager(myProject).getCachedValue(myProject, () ->
CachedValueProvider.Result.create(createAnnotationFromText("@" + AnnotationUtil.NULLABLE), ModificationTracker.NEVER_CHANGED));
}
public PsiAnnotation createContractAnnotation(String contractValue) {
return createAnnotationFromText("@org.jetbrains.annotations.Contract(" + contractValue + ")");
Map<String, PsiAnnotation> cache = CachedValuesManager.getManager(myProject).getCachedValue(myProject, () -> {
Map<String, PsiAnnotation> map = new ConcurrentFactoryMap<String, PsiAnnotation>() {
@Nullable
@Override
protected PsiAnnotation create(String attrs) {
return createAnnotationFromText("@org.jetbrains.annotations.Contract(" + attrs + ")");
}
};
return CachedValueProvider.Result.create(map, ModificationTracker.NEVER_CHANGED);
});
return cache.get(contractValue);
}
@Nullable
@@ -16,7 +16,6 @@
package com.intellij.psi;
import com.intellij.ide.highlighter.JavaClassFileType;
import com.intellij.lang.Language;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
@@ -46,17 +45,11 @@ public class ClassFileViewProvider extends SingleRootFileViewProvider {
private static final Key<Boolean> IS_INNER_CLASS = Key.create("java.is.inner.class.key");
public ClassFileViewProvider(@NotNull PsiManager manager, @NotNull VirtualFile file) {
super(manager, file);
this(manager, file, true);
}
public ClassFileViewProvider(@NotNull PsiManager manager, @NotNull VirtualFile file, boolean eventSystemEnabled) {
super(manager, file, eventSystemEnabled, JavaClassFileType.INSTANCE);
}
@NotNull
@Override
public Language getBaseLanguage() {
return JavaLanguage.INSTANCE;
super(manager, file, eventSystemEnabled, JavaLanguage.INSTANCE, JavaClassFileType.INSTANCE);
}
@Override
@@ -293,12 +293,12 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
}
public List<PsiFile> getCachedPsiFiles() {
return ContainerUtil.createMaybeSingletonList(getCachedPsi(getBaseLanguage()));
return ContainerUtil.createMaybeSingletonList(getCachedPsi(myBaseLanguage));
}
@NotNull
public List<FileElement> getKnownTreeRoots() {
PsiFile psiFile = getCachedPsi(getBaseLanguage());
PsiFile psiFile = getCachedPsi(myBaseLanguage);
if (!(psiFile instanceof PsiFileImpl)) return Collections.emptyList();
FileElement element = ((PsiFileImpl)psiFile).getTreeElement();
return ContainerUtil.createMaybeSingletonList(element);
@@ -457,7 +457,7 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
@NotNull
@Override
public SingleRootFileViewProvider createCopy(@NotNull final VirtualFile copy) {
return new SingleRootFileViewProvider(getManager(), copy, false, getBaseLanguage());
return new SingleRootFileViewProvider(getManager(), copy, false, myBaseLanguage);
}
@Override
@@ -572,7 +572,7 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
}
public void markInvalidated() {
PsiFile psiFile = getCachedPsi(getBaseLanguage());
PsiFile psiFile = getCachedPsi(myBaseLanguage);
if (psiFile instanceof PsiFileEx) {
((PsiFileEx)psiFile).markInvalidated();
}
@@ -35,10 +35,7 @@ import com.intellij.openapi.module.ModuleTypeId;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.Alarm;
import com.intellij.util.Consumer;
import com.intellij.util.Function;
import com.intellij.util.SmartList;
import com.intellij.util.*;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import com.intellij.util.xmlb.annotations.AbstractCollection;
@@ -394,10 +391,8 @@ public class ExternalProjectsDataStorage implements SettingsSavingComponent, Per
projects.add(projectDataDataNode);
}
}
catch (ClassNotFoundException e) {
IOException ioException = new IOException();
ioException.initCause(e);
throw ioException;
catch (Exception e) {
throw new IOException(e);
}
finally {
os.close();
@@ -68,7 +68,7 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
private static final Object lock = new Object();
private final Map<RefEntity, CommonProblemDescriptor[]> myProblemElements = Collections.synchronizedMap(new THashMap<RefEntity, CommonProblemDescriptor[]>(
TObjectHashingStrategy.IDENTITY));
private final Map<String, Set<RefEntity>> myContents = Collections.synchronizedMap(new THashMap<String, Set<RefEntity>>(1)); // keys can be null
private final Map<String, Set<RefEntity>> myContents = Collections.synchronizedMap(new HashMap<String, Set<RefEntity>>(1)); // keys can be null
private final Set<RefModule> myModulesProblems = Collections.synchronizedSet(new THashSet<RefModule>(TObjectHashingStrategy.IDENTITY));
private final Map<CommonProblemDescriptor, RefEntity> myProblemToElements = Collections.synchronizedMap(new THashMap<CommonProblemDescriptor, RefEntity>(TObjectHashingStrategy.IDENTITY));
private DescriptorComposer myComposer;
@@ -337,7 +337,9 @@ public class InspectionTree extends Tree {
}
if (descriptorChildren != null) {
Collections.sort(descriptorChildren, DESCRIPTOR_COMPARATOR);
if (descriptorChildren.size() > 1) {
Collections.sort(descriptorChildren, DESCRIPTOR_COMPARATOR);
}
descriptors.addAll(descriptorChildren);
}
}
@@ -25,6 +25,7 @@ import com.intellij.codeInspection.ex.InspectionProfileImpl;
import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.codeInspection.reference.RefElement;
import com.intellij.codeInspection.reference.RefEntity;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.psi.PsiElement;
import com.intellij.util.containers.FactoryMap;
@@ -129,6 +130,13 @@ public class ProblemDescriptionNode extends SuppressableInspectionTreeNode {
return FileStatus.NOT_CHANGED;
}
@Override
protected void dropCache(Project project) {
if (!isQuickFixAppliedFromView()) {
super.dropCache(project);
}
}
@Override
public String calculatePresentableName() {
CommonProblemDescriptor descriptor = getDescriptor();
@@ -1695,14 +1695,8 @@ public abstract class DialogWrapper {
ActionUtil.registerForEveryKeyboardShortcut(getRootPane(), cancelKeyboardAction, CommonShortcuts.getCloseActiveWindow());
}
if (ApplicationInfo.contextHelpAvailable()) {
ActionListener helpAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
doHelpAction();
}
};
if (ApplicationInfo.contextHelpAvailable() && !isProgressDialog()) {
ActionListener helpAction = e -> doHelpAction();
ActionUtil.registerForEveryKeyboardShortcut(getRootPane(), helpAction, CommonShortcuts.getContextHelp());
rootPane.registerKeyboardAction(helpAction, KeyStroke.getKeyStroke(KeyEvent.VK_HELP, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
}
@@ -574,6 +574,10 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
myIsViewer = !enabled;
}
public boolean isViewer() {
return myIsViewer;
}
@Override
public Color getBackground() {
Color color = getBackgroundColor(isEnabled(), EditorColorsUtil.getGlobalOrDefaultColorScheme());
@@ -245,7 +245,7 @@ public class TreeTraverserTest extends TestCase {
// JBIterable ----------------------------------------------
public void testAppend() {
JBIterable<Integer> it = JBIterable.of(1, 2, 3).append(JBIterable.of(4, 5, 6)).append(7);
JBIterable<Integer> it = JBIterable.of(1, 2, 3).append(JBIterable.of(4, 5, 6)).append(JBIterable.empty()).append(7);
assertEquals(7, it.size());
assertEquals(Arrays.asList(1, 2, 3, 4, 5, 6, 7), it.toList());
assertTrue(it.contains(5));
@@ -20,7 +20,6 @@ import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Conditions;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Function;
import com.intellij.util.Functions;
import com.intellij.util.PairFunction;
@@ -193,9 +192,7 @@ public abstract class JBIterable<E> implements Iterable<E> {
*/
@Override
public String toString() {
int max = 50;
List<E> list = take(max + 1).toList();
return "(" + StringUtil.join(list.subList(0, Math.min(list.size(), max)), ", ") + (list.size() > max ? ", ..." : "") + ")";
return myIterable == this ? super.toString() : String.valueOf(myIterable);
}
/**
@@ -365,11 +362,10 @@ public abstract class JBIterable<E> implements Iterable<E> {
@Override
public T nextImpl() {
while ((cur == null || !cur.hasNext()) && iterator.hasNext()) {
cur = fun.fun(iterator.next()).iterator();
}
if (cur == null || !cur.hasNext()) return stop();
return cur.next();
if (cur != null && cur.hasNext()) return cur.next();
if (!iterator.hasNext()) return stop();
cur = fun.fun(iterator.next()).iterator();
return skip();
}
@Override
@@ -18,6 +18,7 @@ package com.intellij.xdebugger.impl.ui;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.impl.EditorFactoryImpl;
import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
@@ -31,7 +32,7 @@ public final class TextViewer extends EditorTextField {
private final boolean myEmbeddedIntoDialogWrapper;
public TextViewer(@NotNull String initialText, @NotNull Project project, boolean viewer) {
this(createDocument(initialText), project, true, viewer);
this(createDocument(initialText, viewer), project, true, viewer);
}
public TextViewer(@NotNull String initialText, @NotNull Project project) {
@@ -45,17 +46,25 @@ public final class TextViewer extends EditorTextField {
setFontInheritedFromLAF(false);
}
private static Document createDocument(@NotNull String initialText) {
final Document document = EditorFactory.getInstance().createDocument(StringUtil.convertLineSeparators(initialText));
//if (document instanceof DocumentImpl) {
// ((DocumentImpl)document).setAcceptSlashR(true);
//}
return document;
private static Document createDocument(@NotNull String initialText, boolean viewer) {
if (needSlashRSupport(initialText, viewer)){
return ((EditorFactoryImpl)EditorFactory.getInstance()).createDocument(initialText, true, false);
}
else {
return EditorFactory.getInstance().createDocument(StringUtil.convertLineSeparators(initialText));
}
}
@Override
public void setText(@Nullable String text) {
super.setText(text != null ? StringUtil.convertLineSeparators(text) : null);
if (text != null && !needSlashRSupport(text, isViewer())) {
text = StringUtil.convertLineSeparators(text);
}
super.setText(text);
}
private static boolean needSlashRSupport(String text, boolean viewer) {
return !viewer && text.contains("\r");
}
@Override
@@ -22,6 +22,7 @@ import com.intellij.psi.search.searches.OverridingMethodsSearch;
import com.intellij.psi.search.searches.SuperMethodsSearch;
import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.Query;
import com.siyeh.HardcodedMethodConstants;
@@ -328,6 +329,9 @@ public class MethodUtils {
if (method == null) {
return false;
}
if (!InheritanceUtil.isInheritorOrSelf(method.getContainingClass(), PsiUtil.resolveClassInClassTypeOnly(method.getReturnType()), true)) {
return false;
}
final PsiElement navigationElement = method.getNavigationElement();
if (!(navigationElement instanceof PsiMethod)) {
return false;
@@ -105,7 +105,7 @@ public abstract class GradleImportingTestCase extends ExternalSystemImportingTes
}
}.execute();
myProjectSettings = new GradleProjectSettings();
GradleSettings.getInstance(myProject).setGradleVmOptions("-Xmx64m -XX:MaxPermSize=64m");
GradleSettings.getInstance(myProject).setGradleVmOptions("-Xmx128m -XX:MaxPermSize=64m");
System.setProperty(ExternalSystemExecutionSettings.REMOTE_PROCESS_IDLE_TTL_IN_MS_KEY, String.valueOf(GRADLE_DAEMON_TTL_MS));
configureWrapper();
}
@@ -69,7 +69,7 @@ public abstract class AbstractModelBuilderTest {
public static final Object[][] SUPPORTED_GRADLE_VERSIONS = {
{"1.9"}, /*{"1.10"}, {"1.11"},*/ {"1.12"},
{"2.0"}, /*{"2.1"}, {"2.2"} , {"2.3"}, {"2.4"}, {"2.5"}, {"2.6"}, {"2.7"}, {"2.8"},*/ {"2.9"}, /*{"2.10"}, {"2.11"},*/ {"2.12"}
{"2.0"}, /*{"2.1"}, {"2.2"} , {"2.3"}, {"2.4"}, {"2.5"}, {"2.6"}, {"2.7"}, {"2.8"},*/ {"2.9"}, /*{"2.10"}, {"2.11"}, {"2.12"},*/ {"2.13"}
};
public static final String BASE_GRADLE_VERSION = String.valueOf(SUPPORTED_GRADLE_VERSIONS[SUPPORTED_GRADLE_VERSIONS.length - 1][0]);
@@ -155,7 +155,7 @@ public abstract class AbstractModelBuilderTest {
assertNotNull(initScript);
String jdkHome = IdeaTestUtil.requireRealJdkHome();
buildActionExecutor.setJavaHome(new File(jdkHome));
buildActionExecutor.setJvmArguments("-Xmx64m", "-XX:MaxPermSize=64m");
buildActionExecutor.setJvmArguments("-Xmx128m", "-XX:MaxPermSize=64m");
buildActionExecutor.withArguments("--info", "--recompile-scripts", GradleConstants.INIT_SCRIPT_CMD_OPTION, initScript.getAbsolutePath());
allModels = buildActionExecutor.run();
assertNotNull(allModels);
@@ -226,6 +226,7 @@ public class PythonSdkDetailsDialog extends DialogWrapper {
mySdkSettingsWereModified.run();
}
for (SdkModificator modificator : myModifiedModificators) {
/* This should always be true barring bug elsewhere, log error on else? */
if (modificator.isWritable()) {
modificator.commitChanges();
}
@@ -433,8 +434,13 @@ public class PythonSdkDetailsDialog extends DialogWrapper {
}
private void reloadSdk(@NotNull Sdk currentSdk) {
// XXX: Here we are reusing a modifier that we are going to commit later
PythonSdkUpdater.update(currentSdk, myModificators.get(currentSdk), myProject, null);
/* PythonSdkUpdater.update invalidates the modificator so we need to create a new
one for further changes
*/
if (PythonSdkUpdater.update(currentSdk, myModificators.get(currentSdk), myProject, null)){
myModifiedModificators.remove(myModificators.get(currentSdk));
myModificators.put(currentSdk, currentSdk.getSdkModificator());
}
}
private class ToggleVirtualEnvFilterButton extends ToggleActionButton implements DumbAware {
@@ -28,7 +28,9 @@ import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent;
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
import com.intellij.util.Alarm;
import com.intellij.util.messages.MessageBus;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.update.MergingUpdateQueue;
import com.intellij.util.ui.update.Update;
import com.jetbrains.python.PyNames;
@@ -44,7 +46,7 @@ import java.util.List;
*/
public class VFSTestFrameworkListener {
private static final Logger LOG = Logger.getInstance("#com.jetbrains.python.testing.VFSTestFrameworkListener");
private final MergingUpdateQueue myQueue = new MergingUpdateQueue("TestFrameworkChecker", 5000, true, null);
private final MergingUpdateQueue myQueue;
private final PyTestFrameworkService myService;
public VFSTestFrameworkListener() {
@@ -86,6 +88,7 @@ public class VFSTestFrameworkListener {
}
}
});
myQueue = new MergingUpdateQueue("TestFrameworkChecker", 5000, true, null, ApplicationManager.getApplication(), null, Alarm.ThreadToUse.POOLED_THREAD);
}
public void updateAllTestFrameworks(final Sdk sdk) {
@@ -100,8 +103,8 @@ public class VFSTestFrameworkListener {
@Override
public void run() {
final Boolean installed = isTestFrameworkInstalled(sdk, testPackageName);
if (installed != null)
testInstalled(installed, sdk.getHomePath(), testPackageName);
if (installed != null) ApplicationManager.getApplication().invokeLater( ( ()-> testInstalled(installed, sdk.getHomePath(), testPackageName)));
}
});
}