mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -35,7 +35,6 @@
|
||||
|
||||
1.5 => plugins/Groovy/lib/groovy_rt.jar
|
||||
1.5 => lib/annotations.jar
|
||||
1.8 => lib/annotations-java8.jar
|
||||
1.8 => redist/annotations-java8.jar
|
||||
|
||||
1.6 => plugins/gradle/lib/gradle-jps-plugin.jar
|
||||
|
||||
@@ -137,10 +137,6 @@ def layoutFull(String home, String targetDirectory, String patchedDescriptorDir
|
||||
module("annotations-common")
|
||||
module("annotations")
|
||||
}
|
||||
jar("annotations-java8.jar") {
|
||||
module("annotations-common")
|
||||
module("annotations-java8")
|
||||
}
|
||||
jar("jdkAnnotations.jar") {
|
||||
fileset(dir: "${home}/java/jdkAnnotations")
|
||||
}
|
||||
@@ -218,6 +214,13 @@ def layoutFull(String home, String targetDirectory, String patchedDescriptorDir
|
||||
}
|
||||
}
|
||||
|
||||
dir("redist") {
|
||||
jar("annotations-java8.jar") {
|
||||
module("annotations-common")
|
||||
module("annotations-java8")
|
||||
}
|
||||
}
|
||||
|
||||
layoutCommunityPlugins(home)
|
||||
|
||||
dir("plugins") {
|
||||
|
||||
@@ -25,7 +25,6 @@ if ("GIT_TESTS".equalsIgnoreCase(System.getProperty("idea.test.group"))) {
|
||||
|
||||
def args = [
|
||||
"-Xmx450m",
|
||||
"-XX:MaxPermSize=430m",
|
||||
"-Dsun.io.useCanonCaches=false"
|
||||
]
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,12 +15,17 @@
|
||||
*/
|
||||
package com.intellij.debugger.actions;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiLambdaExpression;
|
||||
import com.intellij.psi.PsiSubstitutor;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
import com.intellij.util.Range;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 10/25/13
|
||||
@@ -43,6 +48,20 @@ public class LambdaSmartStepTarget extends SmartStepTarget{
|
||||
return myOrdinal;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return AllIcons.Nodes.Function;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentation() {
|
||||
String typeText = PsiFormatUtil.formatType(myLambda.getType(), 0, PsiSubstitutor.EMPTY);
|
||||
String label = getLabel();
|
||||
return label != null ? label + typeText : typeText;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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,10 +17,15 @@ package com.intellij.debugger.actions;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiSubstitutor;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
import com.intellij.psi.util.PsiFormatUtilBase;
|
||||
import com.intellij.util.Range;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 10/25/13
|
||||
@@ -38,6 +43,25 @@ public class MethodSmartStepTarget extends SmartStepTarget {
|
||||
return myMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return myMethod.getIcon(0);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentation() {
|
||||
String label = getLabel();
|
||||
String formatted = PsiFormatUtil.formatMethod(
|
||||
myMethod,
|
||||
PsiSubstitutor.EMPTY,
|
||||
PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS,
|
||||
PsiFormatUtilBase.SHOW_TYPE,
|
||||
999
|
||||
);
|
||||
return label != null? label + formatted : formatted;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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,13 +17,8 @@ package com.intellij.debugger.actions;
|
||||
|
||||
import com.intellij.codeInsight.unwrap.ScopeHighlighter;
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.ui.popup.*;
|
||||
import com.intellij.psi.PsiLambdaExpression;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiSubstitutor;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -62,38 +57,13 @@ class PsiMethodListPopupStep implements ListPopupStep<SmartStepTarget> {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Icon getIconFor(SmartStepTarget aValue) {
|
||||
if (aValue instanceof MethodSmartStepTarget) {
|
||||
return ((MethodSmartStepTarget)aValue).getMethod().getIcon(0);
|
||||
}
|
||||
if (aValue instanceof LambdaSmartStepTarget) {
|
||||
return AllIcons.Nodes.Function;
|
||||
}
|
||||
return null;
|
||||
public Icon getIconFor(SmartStepTarget avalue) {
|
||||
return avalue.getIcon();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getTextFor(SmartStepTarget value) {
|
||||
final String label = value.getLabel();
|
||||
final String formatted;
|
||||
if (value instanceof MethodSmartStepTarget) {
|
||||
final PsiMethod method = ((MethodSmartStepTarget)value).getMethod();
|
||||
formatted = PsiFormatUtil.formatMethod(
|
||||
method,
|
||||
PsiSubstitutor.EMPTY,
|
||||
PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS,
|
||||
PsiFormatUtil.SHOW_TYPE,
|
||||
999
|
||||
);
|
||||
}
|
||||
else if (value instanceof LambdaSmartStepTarget){
|
||||
final PsiLambdaExpression lambda = ((LambdaSmartStepTarget)value).getLambda();
|
||||
formatted = PsiFormatUtil.formatType(lambda.getType(), 0, PsiSubstitutor.EMPTY);
|
||||
}
|
||||
else {
|
||||
formatted = "";
|
||||
}
|
||||
return label != null? label + formatted : formatted;
|
||||
public String getTextFor(SmartStepTarget value) {
|
||||
return value.getPresentation();
|
||||
}
|
||||
|
||||
public ListSeparator getSeparatorAbove(SmartStepTarget value) {
|
||||
@@ -132,7 +102,7 @@ class PsiMethodListPopupStep implements ListPopupStep<SmartStepTarget> {
|
||||
return false;
|
||||
}
|
||||
|
||||
public MnemonicNavigationFilter getMnemonicNavigationFilter() {
|
||||
public MnemonicNavigationFilter<SmartStepTarget> getMnemonicNavigationFilter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -140,7 +110,7 @@ class PsiMethodListPopupStep implements ListPopupStep<SmartStepTarget> {
|
||||
return false;
|
||||
}
|
||||
|
||||
public SpeedSearchFilter getSpeedSearchFilter() {
|
||||
public SpeedSearchFilter<SmartStepTarget> getSpeedSearchFilter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,10 +15,14 @@
|
||||
*/
|
||||
package com.intellij.debugger.actions;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.Range;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 10/25/13
|
||||
@@ -58,4 +62,14 @@ public abstract class SmartStepTarget {
|
||||
public void setCallingExpressionLines(Range<Integer> expressionLines) {
|
||||
myExpressionLines = expressionLines;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Icon getIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getPresentation() {
|
||||
return StringUtil.notNullize(getLabel());
|
||||
}
|
||||
}
|
||||
|
||||
+7
-4
@@ -276,18 +276,22 @@ class RefCountHolder {
|
||||
TextRange dirtyScope,
|
||||
@NotNull ProgressIndicator indicator,
|
||||
@NotNull Runnable analyze) {
|
||||
ProgressIndicator result;
|
||||
if (myState.compareAndSet(EMPTY, indicator)) {
|
||||
if (!file.getTextRange().equals(dirtyScope)) {
|
||||
// empty holder needs filling before it can be used, so restart daemon to re-analyze the whole file
|
||||
myState.set(EMPTY);
|
||||
return false;
|
||||
}
|
||||
result = EMPTY;
|
||||
}
|
||||
else if (!myState.compareAndSet(READY, indicator)) {
|
||||
else if (myState.compareAndSet(READY, indicator)) {
|
||||
result = READY;
|
||||
}
|
||||
else {
|
||||
log("a: failed to change ", myState, "->", indicator);
|
||||
return false;
|
||||
}
|
||||
boolean success = false;
|
||||
try {
|
||||
log("a: changed ", myState, "->", indicator);
|
||||
if (dirtyScope != null) {
|
||||
@@ -300,11 +304,10 @@ class RefCountHolder {
|
||||
}
|
||||
|
||||
analyze.run();
|
||||
success = true;
|
||||
result = READY;
|
||||
return true;
|
||||
}
|
||||
finally {
|
||||
ProgressIndicator result = success ? READY : EMPTY;
|
||||
boolean set = myState.compareAndSet(indicator, result);
|
||||
assert set : myState.get();
|
||||
log("a: changed after analyze", indicator, "->", result);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.compiled.ClsClassImpl;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class JavaEditorFileSwapper extends EditorFileSwapper {
|
||||
@@ -76,12 +77,12 @@ public class JavaEditorFileSwapper extends EditorFileSwapper {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VirtualFile findSourceFile(Project project, VirtualFile file) {
|
||||
public static VirtualFile findSourceFile(@NotNull Project project, @NotNull VirtualFile file) {
|
||||
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
|
||||
if ((psiFile instanceof PsiCompiledFile && psiFile instanceof PsiClassOwner)) {
|
||||
PsiClass clsClass = ((PsiClassOwner)psiFile).getClasses()[0];
|
||||
if ((clsClass instanceof ClsClassImpl)) {
|
||||
PsiClass sourceClass = ((ClsClassImpl)clsClass).getSourceMirrorClass();
|
||||
if (psiFile instanceof PsiCompiledFile && psiFile instanceof PsiClassOwner) {
|
||||
PsiClass[] classes = ((PsiClassOwner)psiFile).getClasses();
|
||||
if (classes.length != 0 && classes[0] instanceof ClsClassImpl) {
|
||||
PsiClass sourceClass = ((ClsClassImpl)classes[0]).getSourceMirrorClass();
|
||||
if (sourceClass != null) {
|
||||
VirtualFile result = sourceClass.getContainingFile().getVirtualFile();
|
||||
assert result != null : sourceClass;
|
||||
|
||||
+1
-1
@@ -485,7 +485,7 @@ public class ReferenceExpressionCompletionContributor {
|
||||
if (expr instanceof PsiReferenceExpression) {
|
||||
return (PsiReferenceExpression)expr;
|
||||
}
|
||||
LOG.error("Unexpected type: " + expr.getType() + " from text " + text);
|
||||
LOG.error("Unexpected type: " + expr.getClass() + " from text " + text);
|
||||
return null;
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
|
||||
+11
-2
@@ -384,8 +384,17 @@ public abstract class OrderEntryFix implements IntentionAction, LocalQuickFix {
|
||||
|
||||
@Nullable
|
||||
public static String locateAnnotationsJar(@NotNull Module module) {
|
||||
String jarName = EffectiveLanguageLevelUtil.getEffectiveLanguageLevel(module).isAtLeast(LanguageLevel.JDK_1_8) ? "annotations-java8.jar" : "annotations.jar";
|
||||
final LocateLibraryDialog dialog = new LocateLibraryDialog(module, PathManager.getLibPath(), jarName, QuickFixBundle.message("add.library.annotations.description"));
|
||||
String jarName;
|
||||
String libPath;
|
||||
if (EffectiveLanguageLevelUtil.getEffectiveLanguageLevel(module).isAtLeast(LanguageLevel.JDK_1_8)) {
|
||||
jarName = "annotations-java8.jar";
|
||||
libPath = new File(PathManager.getHomePath(), "redist").getAbsolutePath();
|
||||
}
|
||||
else {
|
||||
jarName = "annotations.jar";
|
||||
libPath = PathManager.getLibPath();
|
||||
}
|
||||
final LocateLibraryDialog dialog = new LocateLibraryDialog(module, libPath, jarName, QuickFixBundle.message("add.library.annotations.description"));
|
||||
return dialog.showAndGet() ? dialog.getResultingLibraryPath() : null;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -149,7 +149,7 @@ public abstract class TextEditorHighlightingPass implements HighlightingPass {
|
||||
@Override
|
||||
@NonNls
|
||||
public String toString() {
|
||||
return getClass() + "; id=" + getId();
|
||||
return (getClass().isAnonymousClass() ? getClass().getSuperclass() : getClass()).getSimpleName() + "; id=" + getId();
|
||||
}
|
||||
|
||||
public boolean isRunIntentionPassAfter() {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/java5/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package com.intellij.psi.stubs;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.tree.IStubFileElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -45,7 +46,7 @@ public class PsiFileStubImpl<T extends PsiFile> extends StubBase<T> implements P
|
||||
public void setPsi(@NotNull final T psi) {
|
||||
myFile = psi;
|
||||
}
|
||||
|
||||
|
||||
public void clearPsi(@NotNull String reason) {
|
||||
myInvalidationReason = reason;
|
||||
myFile = null;
|
||||
@@ -73,6 +74,9 @@ public class PsiFileStubImpl<T extends PsiFile> extends StubBase<T> implements P
|
||||
}
|
||||
|
||||
public void setStubRoots(@NotNull PsiFileStub[] roots) {
|
||||
if (roots.length == 0) {
|
||||
Logger.getInstance(getClass()).error("Incorrect psi file stub roots count" + this + "," + getStubType());
|
||||
}
|
||||
myStubRoots = roots;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.psi.stubs;
|
||||
|
||||
import com.intellij.openapi.diagnostic.LogUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream;
|
||||
import com.intellij.util.containers.RecentStringInterner;
|
||||
import com.intellij.util.io.AbstractStringEnumerator;
|
||||
@@ -77,15 +78,22 @@ public class StubSerializationHelper {
|
||||
BufferExposingByteArrayOutputStream out = new BufferExposingByteArrayOutputStream();
|
||||
FileLocalStringEnumerator storage = new FileLocalStringEnumerator(true);
|
||||
StubOutputStream stubOutputStream = new StubOutputStream(out, storage);
|
||||
boolean doDefaultSerialization = true;
|
||||
|
||||
if (rootStub instanceof PsiFileStub) {
|
||||
final PsiFileStub[] roots = ((PsiFileStub)rootStub).getStubRoots();
|
||||
DataInputOutputUtil.writeINT(stubOutputStream, roots.length);
|
||||
for (PsiFileStub root : roots) {
|
||||
doSerialize(root, stubOutputStream);
|
||||
if (roots.length == 0) {
|
||||
Logger.getInstance(getClass()).error("Incorrect stub files count during serialization:" + rootStub + "," + rootStub.getStubType());
|
||||
} else {
|
||||
doDefaultSerialization = false;
|
||||
DataInputOutputUtil.writeINT(stubOutputStream, roots.length);
|
||||
for (PsiFileStub root : roots) {
|
||||
doSerialize(root, stubOutputStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if (doDefaultSerialization) {
|
||||
DataInputOutputUtil.writeINT(stubOutputStream, 1);
|
||||
doSerialize(rootStub, stubOutputStream);
|
||||
}
|
||||
@@ -137,6 +145,9 @@ public class StubSerializationHelper {
|
||||
return stubsArray[0];
|
||||
}
|
||||
else {
|
||||
if (stubFilesCount != 1) {
|
||||
Logger.getInstance(getClass()).error("Incorrect stub files count during deserialization:"+stubFilesCount);
|
||||
}
|
||||
return deserialize(inputStream, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,16 +35,16 @@ import java.lang.ref.SoftReference;
|
||||
* User: cdr
|
||||
*/
|
||||
public class SelfElementInfo implements SmartPointerElementInfo {
|
||||
protected final VirtualFile myVirtualFile;
|
||||
private final VirtualFile myVirtualFile;
|
||||
private Reference<RangeMarker> myMarkerRef; // create marker only in case of live document
|
||||
private volatile int mySyncStartOffset;
|
||||
private volatile int mySyncEndOffset;
|
||||
protected volatile boolean mySyncMarkerIsValid;
|
||||
volatile boolean mySyncMarkerIsValid;
|
||||
private final Class myType;
|
||||
protected final Project myProject;
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
private final Project myProject;
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
private volatile RangeMarker myRangeMarker; //maintains hard reference during modification
|
||||
protected final Language myLanguage;
|
||||
private final Language myLanguage;
|
||||
|
||||
SelfElementInfo(@NotNull Project project,
|
||||
@NotNull ProperTextRange range,
|
||||
@@ -157,7 +157,7 @@ public class SelfElementInfo implements SmartPointerElementInfo {
|
||||
return restoreFromFile(file);
|
||||
}
|
||||
|
||||
protected PsiElement restoreFromFile(@NotNull PsiFile file) {
|
||||
private PsiElement restoreFromFile(@NotNull PsiFile file) {
|
||||
final int syncStartOffset = getSyncStartOffset();
|
||||
final int syncEndOffset = getSyncEndOffset();
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,7 +30,7 @@ interface SmartPointerElementInfo {
|
||||
@Nullable
|
||||
Document getDocumentToSynchronize();
|
||||
|
||||
void fastenBelt(int offset, RangeMarker[] cachedRangeMarkers);
|
||||
void fastenBelt(int offset, @Nullable RangeMarker[] cachedRangeMarkers);
|
||||
|
||||
void unfastenBelt(int offset);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.SmartPsiElementPointer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface SmartPointerEx<E extends PsiElement> extends SmartPsiElementPointer<E> {
|
||||
interface SmartPointerEx<E extends PsiElement> extends SmartPsiElementPointer<E> {
|
||||
void fastenBelt(int offset, @Nullable RangeMarker[] cachedRangeMarkers);
|
||||
|
||||
void unfastenBelt(int offset);
|
||||
|
||||
+37
-37
@@ -162,26 +162,25 @@ public class SmartPointerManagerImpl extends SmartPointerManager {
|
||||
}
|
||||
processQueue();
|
||||
SmartPointerEx<E> pointer = getCachedPointer(element);
|
||||
if (pointer != null) {
|
||||
containingFile = containingFile == null ? element.getContainingFile() : containingFile;
|
||||
if (containingFile != null && areBeltsFastened(containingFile.getViewProvider().getVirtualFile())) {
|
||||
pointer.fastenBelt(0, null);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (pointer == null) {
|
||||
pointer = new SmartPsiElementPointerImpl<E>(myProject, element, containingFile);
|
||||
if (containingFile != null) {
|
||||
initPointer(pointer, containingFile.getViewProvider().getVirtualFile());
|
||||
initPointer((SmartPsiElementPointerImpl<E>)pointer, containingFile.getViewProvider().getVirtualFile());
|
||||
}
|
||||
element.putUserData(CACHED_SMART_POINTER_KEY, new SoftReference<SmartPointerEx>(pointer));
|
||||
}
|
||||
if (pointer instanceof SmartPsiElementPointerImpl) {
|
||||
else {
|
||||
containingFile = containingFile == null ? element.getContainingFile() : containingFile;
|
||||
synchronized (lock) {
|
||||
((SmartPsiElementPointerImpl)pointer).incrementAndGetReferenceCount(1);
|
||||
if (containingFile != null && areBeltsFastened(containingFile.getViewProvider().getVirtualFile())) {
|
||||
pointer.fastenBelt(0, null);
|
||||
}
|
||||
if (pointer instanceof SmartPsiElementPointerImpl) {
|
||||
((SmartPsiElementPointerImpl)pointer).incrementAndGetReferenceCount(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return pointer;
|
||||
|
||||
}
|
||||
|
||||
private static <E extends PsiElement> SmartPointerEx<E> getCachedPointer(@NotNull E element) {
|
||||
@@ -210,51 +209,52 @@ public class SmartPointerManagerImpl extends SmartPointerManager {
|
||||
return pointer;
|
||||
}
|
||||
|
||||
private <E extends PsiElement> void initPointer(@NotNull SmartPointerEx<E> pointer, @NotNull VirtualFile containingFile) {
|
||||
private <E extends PsiElement> void initPointer(@NotNull SmartPsiElementPointerImpl<E> pointer, @NotNull VirtualFile containingFile) {
|
||||
synchronized (lock) {
|
||||
Set<PointerReference> pointers = getPointers(containingFile);
|
||||
if (pointers == null) {
|
||||
pointers = ContainerUtil.newTroveSet(); // we synchronise access anyway
|
||||
containingFile.putUserData(POINTERS_KEY, pointers);
|
||||
}
|
||||
pointers.add(new PointerReference(pointer, containingFile, ourQueue, POINTERS_KEY));
|
||||
|
||||
if (areBeltsFastened(containingFile)) {
|
||||
pointer.fastenBelt(0, null);
|
||||
}
|
||||
pointer.incrementAndGetReferenceCount(1);
|
||||
|
||||
pointers.add(new PointerReference(pointer, containingFile, ourQueue, POINTERS_KEY));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePointer(@NotNull SmartPsiElementPointer pointer) {
|
||||
if (!(pointer instanceof SmartPsiElementPointerImpl)) {
|
||||
return false;
|
||||
}
|
||||
PsiFile containingFile = pointer.getContainingFile();
|
||||
if (containingFile == null) return false;
|
||||
synchronized (lock) {
|
||||
if (pointer instanceof SmartPsiElementPointerImpl) {
|
||||
int refCount = ((SmartPsiElementPointerImpl)pointer).incrementAndGetReferenceCount(-1);
|
||||
if (refCount == 0) {
|
||||
PsiElement element = ((SmartPointerEx)pointer).getCachedElement();
|
||||
if (element != null) {
|
||||
element.putUserData(CACHED_SMART_POINTER_KEY, null);
|
||||
}
|
||||
PsiFile containingFile = pointer.getContainingFile();
|
||||
if (containingFile == null) return false;
|
||||
int refCount = ((SmartPsiElementPointerImpl)pointer).incrementAndGetReferenceCount(-1);
|
||||
if (refCount == 0) {
|
||||
PsiElement element = ((SmartPointerEx)pointer).getCachedElement();
|
||||
if (element != null) {
|
||||
element.putUserData(CACHED_SMART_POINTER_KEY, null);
|
||||
}
|
||||
|
||||
VirtualFile vFile = containingFile.getViewProvider().getVirtualFile();
|
||||
Set<PointerReference> pointers = getPointers(vFile);
|
||||
if (pointers == null) return false;
|
||||
VirtualFile vFile = containingFile.getViewProvider().getVirtualFile();
|
||||
Set<PointerReference> pointers = getPointers(vFile);
|
||||
if (pointers == null) return false;
|
||||
|
||||
SmartPointerElementInfo info = ((SmartPsiElementPointerImpl)pointer).getElementInfo();
|
||||
info.cleanup();
|
||||
SmartPointerElementInfo info = ((SmartPsiElementPointerImpl)pointer).getElementInfo();
|
||||
info.cleanup();
|
||||
|
||||
for (Iterator<PointerReference> iterator = pointers.iterator(); iterator.hasNext(); ) {
|
||||
if (pointer == iterator.next().get()) {
|
||||
iterator.remove();
|
||||
if (pointers.isEmpty()) {
|
||||
vFile.putUserData(POINTERS_KEY, null);
|
||||
}
|
||||
return true;
|
||||
for (Iterator<PointerReference> iterator = pointers.iterator(); iterator.hasNext(); ) {
|
||||
if (pointer == iterator.next().get()) {
|
||||
iterator.remove();
|
||||
if (pointers.isEmpty()) {
|
||||
vFile.putUserData(POINTERS_KEY, null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -295,7 +295,7 @@ public class SmartPointerManagerImpl extends SmartPointerManager {
|
||||
file.putUserData(POINTERS_ARE_FASTENED_KEY, null);
|
||||
return fastened;
|
||||
}
|
||||
private boolean areBeltsFastened(VirtualFile file) {
|
||||
private boolean areBeltsFastened(@NotNull VirtualFile file) {
|
||||
return file.getUserData(POINTERS_ARE_FASTENED_KEY) == Boolean.TRUE;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -188,7 +188,7 @@ class SmartPsiElementPointerImpl<E extends PsiElement> implements SmartPointerEx
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public SmartPointerElementInfo getElementInfo() {
|
||||
SmartPointerElementInfo getElementInfo() {
|
||||
return myElementInfo;
|
||||
}
|
||||
|
||||
|
||||
+27
-24
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,38 +29,39 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author maxim
|
||||
*/
|
||||
public abstract class NamedObjectProviderBinding<Provider> implements ProviderBinding<Provider> {
|
||||
private final Map<String, List<ProviderInfo<Provider, ElementPattern>>> myNamesToProvidersMap = new THashMap<String, List<ProviderInfo<Provider,ElementPattern>>>(5);
|
||||
private final Map<String, List<ProviderInfo<Provider, ElementPattern>>> myNamesToProvidersMapInsensitive = new THashMap<String, List<ProviderInfo<Provider, ElementPattern>>>(5);
|
||||
public abstract class NamedObjectProviderBinding implements ProviderBinding {
|
||||
private final Map<String, List<ProviderInfo<ElementPattern>>> myNamesToProvidersMap = new THashMap<String, List<ProviderInfo<ElementPattern>>>(5);
|
||||
private final Map<String, List<ProviderInfo<ElementPattern>>> myNamesToProvidersMapInsensitive = new THashMap<String, List<ProviderInfo<ElementPattern>>>(5);
|
||||
|
||||
public void registerProvider(@NonNls @NotNull String[] names,
|
||||
@NotNull ElementPattern filter,
|
||||
boolean caseSensitive,
|
||||
@NotNull Provider provider,
|
||||
@NotNull PsiReferenceProvider provider,
|
||||
final double priority) {
|
||||
final Map<String, List<ProviderInfo<Provider, ElementPattern>>> map = caseSensitive ? myNamesToProvidersMap : myNamesToProvidersMapInsensitive;
|
||||
final Map<String, List<ProviderInfo<ElementPattern>>> map = caseSensitive ? myNamesToProvidersMap : myNamesToProvidersMapInsensitive;
|
||||
|
||||
for (final String attributeName : names) {
|
||||
String key = caseSensitive ? attributeName : attributeName.toLowerCase();
|
||||
List<ProviderInfo<Provider, ElementPattern>> psiReferenceProviders = map.get(key);
|
||||
List<ProviderInfo<ElementPattern>> psiReferenceProviders = map.get(key);
|
||||
|
||||
if (psiReferenceProviders == null) {
|
||||
map.put(key, psiReferenceProviders = new SmartList<ProviderInfo<Provider, ElementPattern>>());
|
||||
map.put(key, psiReferenceProviders = new SmartList<ProviderInfo<ElementPattern>>());
|
||||
}
|
||||
|
||||
psiReferenceProviders.add(new ProviderInfo<Provider,ElementPattern>(provider, filter, priority));
|
||||
psiReferenceProviders.add(new ProviderInfo<ElementPattern>(provider, filter, priority));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAcceptableReferenceProviders(@NotNull PsiElement position,
|
||||
@NotNull List<ProviderInfo<Provider, ProcessingContext>> list,
|
||||
@NotNull List<ProviderInfo<ProcessingContext>> list,
|
||||
@NotNull PsiReferenceService.Hints hints) {
|
||||
String name = getName(position);
|
||||
if (name != null) {
|
||||
@@ -70,16 +71,16 @@ public abstract class NamedObjectProviderBinding<Provider> implements ProviderBi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterProvider(@NotNull final Provider provider) {
|
||||
for (final List<ProviderInfo<Provider, ElementPattern>> list : myNamesToProvidersMap.values()) {
|
||||
for (final ProviderInfo<Provider, ElementPattern> trinity : new ArrayList<ProviderInfo<Provider,ElementPattern>>(list)) {
|
||||
public void unregisterProvider(@NotNull final PsiReferenceProvider provider) {
|
||||
for (final List<ProviderInfo<ElementPattern>> list : myNamesToProvidersMap.values()) {
|
||||
for (final ProviderInfo<ElementPattern> trinity : new ArrayList<ProviderInfo<ElementPattern>>(list)) {
|
||||
if (trinity.provider.equals(provider)) {
|
||||
list.remove(trinity);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final List<ProviderInfo<Provider, ElementPattern>> list : myNamesToProvidersMapInsensitive.values()) {
|
||||
for (final ProviderInfo<Provider, ElementPattern> trinity : new ArrayList<ProviderInfo<Provider,ElementPattern>>(list)) {
|
||||
for (final List<ProviderInfo<ElementPattern>> list : myNamesToProvidersMapInsensitive.values()) {
|
||||
for (final ProviderInfo<ElementPattern> trinity : new ArrayList<ProviderInfo<ElementPattern>>(list)) {
|
||||
if (trinity.provider.equals(provider)) {
|
||||
list.remove(trinity);
|
||||
}
|
||||
@@ -88,16 +89,18 @@ public abstract class NamedObjectProviderBinding<Provider> implements ProviderBi
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected abstract String getName(final PsiElement position);
|
||||
protected abstract String getName(@NotNull PsiElement position);
|
||||
|
||||
private void addMatchingProviders(final PsiElement position,
|
||||
@Nullable final List<ProviderInfo<Provider, ElementPattern>> providerList,
|
||||
@NotNull List<ProviderInfo<Provider, ProcessingContext>> ret,
|
||||
PsiReferenceService.Hints hints) {
|
||||
static void addMatchingProviders(@NotNull PsiElement position,
|
||||
@Nullable final List<ProviderInfo<ElementPattern>> providerList,
|
||||
@NotNull Collection<ProviderInfo<ProcessingContext>> output,
|
||||
@NotNull PsiReferenceService.Hints hints) {
|
||||
if (providerList == null) return;
|
||||
|
||||
for(ProviderInfo<Provider, ElementPattern> trinity:providerList) {
|
||||
if (hints != PsiReferenceService.Hints.NO_HINTS && !((PsiReferenceProvider)trinity.provider).acceptsHints(position, hints)) {
|
||||
//noinspection ForLoopReplaceableByForEach
|
||||
for (int i = 0; i < providerList.size(); i++) {
|
||||
ProviderInfo<ElementPattern> info = providerList.get(i);
|
||||
if (hints != PsiReferenceService.Hints.NO_HINTS && !info.provider.acceptsHints(position, hints)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -107,12 +110,12 @@ public abstract class NamedObjectProviderBinding<Provider> implements ProviderBi
|
||||
}
|
||||
boolean suitable = false;
|
||||
try {
|
||||
suitable = trinity.processingContext.accepts(position, context);
|
||||
suitable = info.processingContext.accepts(position, context);
|
||||
}
|
||||
catch (IndexNotReadyException ignored) {
|
||||
}
|
||||
if (suitable) {
|
||||
ret.add(new ProviderInfo<Provider,ProcessingContext>(trinity.provider, context, trinity.priority));
|
||||
output.add(new ProviderInfo<ProcessingContext>(info.provider, context, info.priority));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-6
@@ -17,6 +17,7 @@
|
||||
package com.intellij.psi.impl.source.resolve.reference;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReferenceProvider;
|
||||
import com.intellij.psi.PsiReferenceService;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -30,21 +31,21 @@ import java.util.List;
|
||||
* Time: 16:52:28
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public interface ProviderBinding<T> {
|
||||
class ProviderInfo<T, Context> {
|
||||
public final T provider;
|
||||
public interface ProviderBinding {
|
||||
class ProviderInfo<Context> {
|
||||
public final PsiReferenceProvider provider;
|
||||
public final Context processingContext;
|
||||
public final double priority;
|
||||
|
||||
public ProviderInfo(@NotNull T provider, @NotNull Context processingContext, double priority) {
|
||||
public ProviderInfo(@NotNull PsiReferenceProvider provider, @NotNull Context processingContext, double priority) {
|
||||
this.provider = provider;
|
||||
this.processingContext = processingContext;
|
||||
this.priority = priority;
|
||||
}
|
||||
}
|
||||
void addAcceptableReferenceProviders(@NotNull PsiElement position,
|
||||
@NotNull List<ProviderInfo<T, ProcessingContext>> list,
|
||||
@NotNull List<ProviderInfo<ProcessingContext>> list,
|
||||
@NotNull PsiReferenceService.Hints hints);
|
||||
|
||||
void unregisterProvider(@NotNull T provider);
|
||||
void unregisterProvider(@NotNull PsiReferenceProvider provider);
|
||||
}
|
||||
|
||||
+17
-18
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -40,18 +40,18 @@ import java.util.Map;
|
||||
*/
|
||||
public class PsiReferenceRegistrarImpl extends PsiReferenceRegistrar {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.resolve.reference.PsiReferenceRegistrarImpl");
|
||||
private final Map<Class<?>, SimpleProviderBinding<PsiReferenceProvider>> myBindingsMap = ContainerUtil.newTroveMap();
|
||||
private final Map<Class<?>, NamedObjectProviderBinding<PsiReferenceProvider>> myNamedBindingsMap = ContainerUtil.newTroveMap();
|
||||
private final Map<Class<?>, SimpleProviderBinding> myBindingsMap = ContainerUtil.newTroveMap();
|
||||
private final Map<Class<?>, NamedObjectProviderBinding> myNamedBindingsMap = ContainerUtil.newTroveMap();
|
||||
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
|
||||
private final ConcurrentFactoryMap<Class, ProviderBinding<PsiReferenceProvider>[]> myBindingCache;
|
||||
private final ConcurrentFactoryMap<Class, ProviderBinding[]> myBindingCache;
|
||||
private boolean myInitialized;
|
||||
|
||||
public PsiReferenceRegistrarImpl(final Language language) {
|
||||
myBindingCache = new ConcurrentFactoryMap<Class, ProviderBinding<PsiReferenceProvider>[]>() {
|
||||
myBindingCache = new ConcurrentFactoryMap<Class, ProviderBinding[]>() {
|
||||
@Nullable
|
||||
@Override
|
||||
protected ProviderBinding<PsiReferenceProvider>[] create(Class key) {
|
||||
List<ProviderBinding<PsiReferenceProvider>> result = ContainerUtil.newSmartList();
|
||||
protected ProviderBinding[] create(Class key) {
|
||||
List<ProviderBinding> result = ContainerUtil.newSmartList();
|
||||
for (Class<?> bindingClass : myBindingsMap.keySet()) {
|
||||
if (bindingClass.isAssignableFrom(key)) {
|
||||
result.add(myBindingsMap.get(bindingClass));
|
||||
@@ -107,9 +107,9 @@ public class PsiReferenceRegistrarImpl extends PsiReferenceRegistrar {
|
||||
break;
|
||||
}
|
||||
|
||||
SimpleProviderBinding<PsiReferenceProvider> providerBinding = myBindingsMap.get(scope);
|
||||
SimpleProviderBinding providerBinding = myBindingsMap.get(scope);
|
||||
if (providerBinding == null) {
|
||||
myBindingsMap.put(scope, providerBinding = new SimpleProviderBinding<PsiReferenceProvider>());
|
||||
myBindingsMap.put(scope, providerBinding = new SimpleProviderBinding());
|
||||
}
|
||||
providerBinding.registerProvider(provider, pattern, priority);
|
||||
|
||||
@@ -117,8 +117,7 @@ public class PsiReferenceRegistrarImpl extends PsiReferenceRegistrar {
|
||||
}
|
||||
|
||||
public void unregisterReferenceProvider(@NotNull Class scope, @NotNull PsiReferenceProvider provider) {
|
||||
ProviderBinding<PsiReferenceProvider> providerBinding = myBindingsMap.get(scope);
|
||||
providerBinding.unregisterProvider(provider);
|
||||
myBindingsMap.get(scope).unregisterProvider(provider);
|
||||
}
|
||||
|
||||
|
||||
@@ -129,12 +128,12 @@ public class PsiReferenceRegistrarImpl extends PsiReferenceRegistrar {
|
||||
@NotNull PsiReferenceProvider provider,
|
||||
final double priority,
|
||||
@NotNull ElementPattern pattern) {
|
||||
NamedObjectProviderBinding<PsiReferenceProvider> providerBinding = myNamedBindingsMap.get(scopeClass);
|
||||
NamedObjectProviderBinding providerBinding = myNamedBindingsMap.get(scopeClass);
|
||||
|
||||
if (providerBinding == null) {
|
||||
myNamedBindingsMap.put(scopeClass, providerBinding = new NamedObjectProviderBinding<PsiReferenceProvider>() {
|
||||
myNamedBindingsMap.put(scopeClass, providerBinding = new NamedObjectProviderBinding() {
|
||||
@Override
|
||||
protected String getName(final PsiElement position) {
|
||||
protected String getName(@NotNull final PsiElement position) {
|
||||
return nameCondition.getPropertyValue(position);
|
||||
}
|
||||
});
|
||||
@@ -151,14 +150,14 @@ public class PsiReferenceRegistrarImpl extends PsiReferenceRegistrar {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
List<ProviderBinding.ProviderInfo<PsiReferenceProvider,ProcessingContext>> getPairsByElement(@NotNull PsiElement element,
|
||||
List<ProviderBinding.ProviderInfo<ProcessingContext>> getPairsByElement(@NotNull PsiElement element,
|
||||
@NotNull PsiReferenceService.Hints hints) {
|
||||
|
||||
final ProviderBinding<PsiReferenceProvider>[] bindings = myBindingCache.get(element.getClass());
|
||||
final ProviderBinding[] bindings = myBindingCache.get(element.getClass());
|
||||
if (bindings.length == 0) return Collections.emptyList();
|
||||
|
||||
List<ProviderBinding.ProviderInfo<PsiReferenceProvider, ProcessingContext>> ret = ContainerUtil.newSmartList();
|
||||
for (ProviderBinding<PsiReferenceProvider> binding : bindings) {
|
||||
List<ProviderBinding.ProviderInfo<ProcessingContext>> ret = ContainerUtil.newSmartList();
|
||||
for (ProviderBinding binding : bindings) {
|
||||
binding.addAcceptableReferenceProviders(element, ret, hints);
|
||||
}
|
||||
return ret;
|
||||
|
||||
+6
-6
@@ -31,11 +31,11 @@ public class ReferenceProvidersRegistryImpl extends ReferenceProvidersRegistry {
|
||||
private static final LanguageExtension<PsiReferenceContributor> CONTRIBUTOR_EXTENSION = new LanguageExtension<PsiReferenceContributor>(PsiReferenceContributor.EP_NAME.getName());
|
||||
private static final LanguageExtension<PsiReferenceProviderBean> REFERENCE_PROVIDER_EXTENSION = new LanguageExtension<PsiReferenceProviderBean>(PsiReferenceProviderBean.EP_NAME.getName());
|
||||
|
||||
private static final Comparator<ProviderBinding.ProviderInfo<PsiReferenceProvider, ProcessingContext>> PRIORITY_COMPARATOR =
|
||||
new Comparator<ProviderBinding.ProviderInfo<PsiReferenceProvider, ProcessingContext>>() {
|
||||
private static final Comparator<ProviderBinding.ProviderInfo<ProcessingContext>> PRIORITY_COMPARATOR =
|
||||
new Comparator<ProviderBinding.ProviderInfo<ProcessingContext>>() {
|
||||
@Override
|
||||
public int compare(ProviderBinding.ProviderInfo<PsiReferenceProvider, ProcessingContext> o1,
|
||||
ProviderBinding.ProviderInfo<PsiReferenceProvider, ProcessingContext> o2) {
|
||||
public int compare(ProviderBinding.ProviderInfo<ProcessingContext> o1,
|
||||
ProviderBinding.ProviderInfo<ProcessingContext> o2) {
|
||||
return Comparing.compare(o2.priority, o1.priority);
|
||||
}
|
||||
};
|
||||
@@ -99,7 +99,7 @@ public class ReferenceProvidersRegistryImpl extends ReferenceProvidersRegistry {
|
||||
@Override
|
||||
protected PsiReference[] doGetReferencesFromProviders(@NotNull PsiElement context,
|
||||
@NotNull PsiReferenceService.Hints hints) {
|
||||
List<ProviderBinding.ProviderInfo<PsiReferenceProvider, ProcessingContext>> providers = getRegistrar(context.getLanguage()).getPairsByElement(context, hints);
|
||||
List<ProviderBinding.ProviderInfo<ProcessingContext>> providers = getRegistrar(context.getLanguage()).getPairsByElement(context, hints);
|
||||
|
||||
if (providers.isEmpty()) {
|
||||
return PsiReference.EMPTY_ARRAY;
|
||||
@@ -114,7 +114,7 @@ public class ReferenceProvidersRegistryImpl extends ReferenceProvidersRegistry {
|
||||
List<PsiReference> result = new ArrayList<PsiReference>();
|
||||
final double maxPriority = providers.get(0).priority;
|
||||
next:
|
||||
for (ProviderBinding.ProviderInfo<PsiReferenceProvider, ProcessingContext> trinity : providers) {
|
||||
for (ProviderBinding.ProviderInfo<ProcessingContext> trinity : providers) {
|
||||
final PsiReference[] refs;
|
||||
try {
|
||||
refs = trinity.provider.getReferencesByElement(context, trinity.processingContext);
|
||||
|
||||
+9
-28
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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,7 +16,6 @@
|
||||
|
||||
package com.intellij.psi.impl.source.resolve.reference;
|
||||
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.patterns.ElementPattern;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReferenceProvider;
|
||||
@@ -35,41 +34,23 @@ import java.util.List;
|
||||
* Time: 16:52:28
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class SimpleProviderBinding<Provider> implements ProviderBinding<Provider> {
|
||||
private final List<ProviderInfo<Provider, ElementPattern>> myProviderPairs = new SmartList<ProviderInfo<Provider, ElementPattern>>();
|
||||
class SimpleProviderBinding implements ProviderBinding {
|
||||
private final List<ProviderInfo<ElementPattern>> myProviderPairs = new SmartList<ProviderInfo<ElementPattern>>();
|
||||
|
||||
public void registerProvider(Provider provider, ElementPattern pattern, double priority) {
|
||||
myProviderPairs.add(new ProviderInfo<Provider, ElementPattern>(provider, pattern, priority));
|
||||
void registerProvider(@NotNull PsiReferenceProvider provider, @NotNull ElementPattern pattern, double priority) {
|
||||
myProviderPairs.add(new ProviderInfo<ElementPattern>(provider, pattern, priority));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAcceptableReferenceProviders(@NotNull PsiElement position,
|
||||
@NotNull List<ProviderInfo<Provider, ProcessingContext>> list,
|
||||
@NotNull List<ProviderInfo<ProcessingContext>> list,
|
||||
@NotNull PsiReferenceService.Hints hints) {
|
||||
for (ProviderInfo<Provider, ElementPattern> trinity : myProviderPairs) {
|
||||
if (hints != PsiReferenceService.Hints.NO_HINTS && !((PsiReferenceProvider)trinity.provider).acceptsHints(position, hints)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final ProcessingContext context = new ProcessingContext();
|
||||
if (hints != PsiReferenceService.Hints.NO_HINTS) {
|
||||
context.put(PsiReferenceService.HINTS, hints);
|
||||
}
|
||||
boolean suitable = false;
|
||||
try {
|
||||
suitable = trinity.processingContext.accepts(position, context);
|
||||
}
|
||||
catch (IndexNotReadyException ignored) {
|
||||
}
|
||||
if (suitable) {
|
||||
list.add(new ProviderInfo<Provider, ProcessingContext>(trinity.provider, context, trinity.priority));
|
||||
}
|
||||
}
|
||||
NamedObjectProviderBinding.addMatchingProviders(position, myProviderPairs, list, hints);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterProvider(@NotNull final Provider provider) {
|
||||
for (final ProviderInfo<Provider, ElementPattern> trinity : new ArrayList<ProviderInfo<Provider, ElementPattern>>(myProviderPairs)) {
|
||||
public void unregisterProvider(@NotNull final PsiReferenceProvider provider) {
|
||||
for (final ProviderInfo<ElementPattern> trinity : new ArrayList<ProviderInfo<ElementPattern>>(myProviderPairs)) {
|
||||
if (trinity.provider.equals(provider)) {
|
||||
myProviderPairs.remove(trinity);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -78,7 +78,10 @@ public class ObjectStubTree<T extends Stub> {
|
||||
protected static void enumerateStubs(@NotNull Stub root, @NotNull List<Stub> result, int idOffset) {
|
||||
((ObjectStubBase)root).id = idOffset + result.size();
|
||||
result.add(root);
|
||||
for (Stub child : root.getChildrenStubs()) {
|
||||
List<? extends Stub> childrenStubs = root.getChildrenStubs();
|
||||
//noinspection ForLoopReplaceableByForEach
|
||||
for (int i = 0; i < childrenStubs.size(); i++) {
|
||||
Stub child = childrenStubs.get(i);
|
||||
enumerateStubs(child, result, idOffset);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -45,7 +45,9 @@ public final class SingleTargetRequestResultProcessor extends RequestResultProce
|
||||
|
||||
final List<PsiReference> references = ourReferenceService.getReferences(element,
|
||||
new PsiReferenceService.Hints(myTarget, offsetInElement));
|
||||
for (PsiReference ref : references) {
|
||||
//noinspection ForLoopReplaceableByForEach
|
||||
for (int i = 0; i < references.size(); i++) {
|
||||
PsiReference ref = references.get(i);
|
||||
ProgressManager.checkCanceled();
|
||||
if (ReferenceRange.containsOffsetInElement(ref, offsetInElement) && ref.isReferenceTo(myTarget) && !consumer.process(ref)) {
|
||||
return false;
|
||||
|
||||
+22
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -38,11 +38,11 @@ import java.util.*;
|
||||
*/
|
||||
public class LibraryRuntimeClasspathScope extends GlobalSearchScope {
|
||||
private final ProjectFileIndex myIndex;
|
||||
private final LinkedHashSet<VirtualFile> myEntries = new LinkedHashSet<VirtualFile>();
|
||||
private final Set<VirtualFile> myEntries = new LinkedHashSet<VirtualFile>();
|
||||
|
||||
private int myCachedHashCode = 0;
|
||||
private int myCachedHashCode;
|
||||
|
||||
public LibraryRuntimeClasspathScope(final Project project, final List<Module> modules) {
|
||||
public LibraryRuntimeClasspathScope(@NotNull Project project, @NotNull Module[] modules) {
|
||||
super(project);
|
||||
myIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
final Set<Sdk> processedSdk = new THashSet<Sdk>();
|
||||
@@ -63,7 +63,7 @@ public class LibraryRuntimeClasspathScope extends GlobalSearchScope {
|
||||
}
|
||||
}
|
||||
|
||||
public LibraryRuntimeClasspathScope(Project project, LibraryOrderEntry entry) {
|
||||
public LibraryRuntimeClasspathScope(@NotNull Project project, @NotNull LibraryOrderEntry entry) {
|
||||
super(project);
|
||||
myIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
Collections.addAll(myEntries, entry.getRootFiles(OrderRootType.CLASSES));
|
||||
@@ -89,12 +89,13 @@ public class LibraryRuntimeClasspathScope extends GlobalSearchScope {
|
||||
@NotNull final Set<Module> processedModules,
|
||||
@NotNull final Set<Library> processedLibraries,
|
||||
@NotNull final Set<Sdk> processedSdk,
|
||||
Condition<OrderEntry> condition) {
|
||||
@NotNull Condition<OrderEntry> condition) {
|
||||
if (!processedModules.add(module)) return;
|
||||
|
||||
ModuleRootManager.getInstance(module).orderEntries().recursively().satisfying(condition).process(new RootPolicy<LinkedHashSet<VirtualFile>>() {
|
||||
public LinkedHashSet<VirtualFile> visitLibraryOrderEntry(final LibraryOrderEntry libraryOrderEntry,
|
||||
final LinkedHashSet<VirtualFile> value) {
|
||||
ModuleRootManager.getInstance(module).orderEntries().recursively().satisfying(condition).process(new RootPolicy<Set<VirtualFile>>() {
|
||||
@Override
|
||||
public Set<VirtualFile> visitLibraryOrderEntry(final LibraryOrderEntry libraryOrderEntry,
|
||||
final Set<VirtualFile> value) {
|
||||
final Library library = libraryOrderEntry.getLibrary();
|
||||
if (library != null && processedLibraries.add(library)) {
|
||||
ContainerUtil.addAll(value, libraryOrderEntry.getRootFiles(OrderRootType.CLASSES));
|
||||
@@ -102,15 +103,16 @@ public class LibraryRuntimeClasspathScope extends GlobalSearchScope {
|
||||
return value;
|
||||
}
|
||||
|
||||
public LinkedHashSet<VirtualFile> visitModuleSourceOrderEntry(final ModuleSourceOrderEntry moduleSourceOrderEntry,
|
||||
final LinkedHashSet<VirtualFile> value) {
|
||||
@Override
|
||||
public Set<VirtualFile> visitModuleSourceOrderEntry(final ModuleSourceOrderEntry moduleSourceOrderEntry,
|
||||
final Set<VirtualFile> value) {
|
||||
processedModules.add(moduleSourceOrderEntry.getOwnerModule());
|
||||
ContainerUtil.addAll(value, moduleSourceOrderEntry.getRootModel().getSourceRoots());
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkedHashSet<VirtualFile> visitModuleOrderEntry(ModuleOrderEntry moduleOrderEntry, LinkedHashSet<VirtualFile> value) {
|
||||
public Set<VirtualFile> visitModuleOrderEntry(ModuleOrderEntry moduleOrderEntry, Set<VirtualFile> value) {
|
||||
final Module depModule = moduleOrderEntry.getModule();
|
||||
if (depModule != null) {
|
||||
ContainerUtil.addAll(value, ModuleRootManager.getInstance(depModule).getSourceRoots());
|
||||
@@ -118,7 +120,8 @@ public class LibraryRuntimeClasspathScope extends GlobalSearchScope {
|
||||
return value;
|
||||
}
|
||||
|
||||
public LinkedHashSet<VirtualFile> visitJdkOrderEntry(final JdkOrderEntry jdkOrderEntry, final LinkedHashSet<VirtualFile> value) {
|
||||
@Override
|
||||
public Set<VirtualFile> visitJdkOrderEntry(final JdkOrderEntry jdkOrderEntry, final Set<VirtualFile> value) {
|
||||
final Sdk jdk = jdkOrderEntry.getJdk();
|
||||
if (jdk != null && processedSdk.add(jdk)) {
|
||||
ContainerUtil.addAll(value, jdkOrderEntry.getRootFiles(OrderRootType.CLASSES));
|
||||
@@ -128,12 +131,13 @@ public class LibraryRuntimeClasspathScope extends GlobalSearchScope {
|
||||
}, myEntries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(@NotNull VirtualFile file) {
|
||||
return myEntries.contains(getFileRoot(file));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private VirtualFile getFileRoot(VirtualFile file) {
|
||||
private VirtualFile getFileRoot(@NotNull VirtualFile file) {
|
||||
if (myIndex.isLibraryClassFile(file)) {
|
||||
return myIndex.getClassRootForFile(file);
|
||||
}
|
||||
@@ -146,6 +150,7 @@ public class LibraryRuntimeClasspathScope extends GlobalSearchScope {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(@NotNull VirtualFile file1, @NotNull VirtualFile file2) {
|
||||
final VirtualFile r1 = getFileRoot(file1);
|
||||
final VirtualFile r2 = getFileRoot(file2);
|
||||
@@ -157,14 +162,17 @@ public class LibraryRuntimeClasspathScope extends GlobalSearchScope {
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
@NotNull
|
||||
public List<VirtualFile> getRoots() {
|
||||
return new ArrayList<VirtualFile>(myEntries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSearchInModuleContent(@NotNull Module aModule) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSearchInLibraries() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.containers.ConcurrentFactoryMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -74,7 +73,7 @@ public class LibraryScopeCache {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
void clear() {
|
||||
myLibraryScopes.clear();
|
||||
mySdkScopes.clear();
|
||||
myLibraryResolveScopeCache.clear();
|
||||
@@ -82,27 +81,19 @@ public class LibraryScopeCache {
|
||||
|
||||
@NotNull
|
||||
public GlobalSearchScope getLibrariesOnlyScope() {
|
||||
return getScopeForLibraryUsedIn(Collections.<Module>emptyList());
|
||||
return getScopeForLibraryUsedIn(Module.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public GlobalSearchScope getScopeForLibraryUsedIn(@NotNull List<Module> modulesLibraryIsUsedIn) {
|
||||
Set<Module> set = new THashSet<Module>(modulesLibraryIsUsedIn);
|
||||
Module[] uniques = set.toArray(new Module[set.size()]);
|
||||
Arrays.sort(uniques, new Comparator<Module>() {
|
||||
@Override
|
||||
public int compare(Module o1, Module o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
});
|
||||
GlobalSearchScope scope = myLibraryScopes.get(uniques);
|
||||
private GlobalSearchScope getScopeForLibraryUsedIn(@NotNull Module[] modulesLibraryIsUsedIn) {
|
||||
GlobalSearchScope scope = myLibraryScopes.get(modulesLibraryIsUsedIn);
|
||||
if (scope != null) {
|
||||
return scope;
|
||||
}
|
||||
GlobalSearchScope newScope = uniques.length == 0
|
||||
GlobalSearchScope newScope = modulesLibraryIsUsedIn.length == 0
|
||||
? new LibrariesOnlyScope(GlobalSearchScope.allScope(myProject))
|
||||
: new LibraryRuntimeClasspathScope(myProject, modulesLibraryIsUsedIn);
|
||||
return ConcurrencyUtil.cacheOrGet(myLibraryScopes, uniques, newScope);
|
||||
return ConcurrencyUtil.cacheOrGet(myLibraryScopes, modulesLibraryIsUsedIn, newScope);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +125,17 @@ public class LibraryScopeCache {
|
||||
}
|
||||
}
|
||||
|
||||
GlobalSearchScope allCandidates = getScopeForLibraryUsedIn(modulesLibraryUsedIn);
|
||||
Comparator<Module> comparator = new Comparator<Module>() {
|
||||
@Override
|
||||
public int compare(@NotNull Module o1, @NotNull Module o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
};
|
||||
Collections.sort(modulesLibraryUsedIn, comparator);
|
||||
List<Module> uniquesList = ContainerUtil.removeDuplicatesFromSorted(modulesLibraryUsedIn, comparator);
|
||||
Module[] uniques = uniquesList.toArray(new Module[uniquesList.size()]);
|
||||
|
||||
GlobalSearchScope allCandidates = getScopeForLibraryUsedIn(uniques);
|
||||
if (lib != null) {
|
||||
final LibraryRuntimeClasspathScope preferred = new LibraryRuntimeClasspathScope(myProject, lib);
|
||||
// prefer current library
|
||||
|
||||
+15
-5
@@ -239,6 +239,9 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements Pers
|
||||
public List<HighlightInfo> runMainPasses(@NotNull PsiFile psiFile,
|
||||
@NotNull Document document,
|
||||
@NotNull final ProgressIndicator progress) {
|
||||
setUpdateByTimerEnabled(true); // by default we disable daemon while in modal dialog, but here we need to re-enable it because otherwise the paused daemon will conflict with our started passes
|
||||
restart(); // clear status maps to run passes from scratch so that refCountHolder won't conflict and try to restart itself on partially filled maps
|
||||
|
||||
final List<HighlightInfo> result = new ArrayList<HighlightInfo>();
|
||||
final VirtualFile virtualFile = psiFile.getVirtualFile();
|
||||
if (virtualFile != null && !virtualFile.getFileType().isBinary()) {
|
||||
@@ -255,10 +258,18 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements Pers
|
||||
}
|
||||
});
|
||||
|
||||
for (TextEditorHighlightingPass pass : passes) {
|
||||
pass.doCollectInformation(progress);
|
||||
result.addAll(pass.getInfos());
|
||||
LOG.debug("All passes for " + psiFile.getName()+ " started (" + passes+"). progress canceled: "+progress.isCanceled());
|
||||
try {
|
||||
for (TextEditorHighlightingPass pass : passes) {
|
||||
pass.doCollectInformation(progress);
|
||||
result.addAll(pass.getInfos());
|
||||
}
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
LOG.debug("Canceled: " + progress);
|
||||
throw e;
|
||||
}
|
||||
LOG.debug("All passes for " + psiFile.getName()+ " run. progress canceled: "+progress.isCanceled()+"; infos: "+result);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -548,7 +559,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements Pers
|
||||
}
|
||||
|
||||
private synchronized void cancelUpdateProgress(final boolean start, @NonNls String reason) {
|
||||
PassExecutorService.log(myUpdateProgress, null, "CancelX", reason, start);
|
||||
PassExecutorService.log(myUpdateProgress, null, "Cancel", reason, start);
|
||||
|
||||
if (myUpdateProgress != null) {
|
||||
myUpdateProgress.cancel();
|
||||
@@ -873,5 +884,4 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements Pers
|
||||
private List<Editor> getActiveEditors() {
|
||||
return myEditorTracker.getActiveEditors();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.codeHighlighting.Pass;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings;
|
||||
import com.intellij.codeInsight.hint.TooltipController;
|
||||
import com.intellij.ide.AppLifecycleListener;
|
||||
import com.intellij.ide.IdeTooltipManager;
|
||||
import com.intellij.ide.PowerSaveMode;
|
||||
import com.intellij.ide.todo.TodoConfiguration;
|
||||
@@ -158,9 +159,15 @@ public class DaemonListeners implements Disposable {
|
||||
|
||||
MessageBus messageBus = myProject.getMessageBus();
|
||||
myDaemonEventPublisher = messageBus.syncPublisher(DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC);
|
||||
final MessageBusConnection connection = messageBus.connect();
|
||||
|
||||
if (project.isDefault()) return;
|
||||
MessageBusConnection connection = messageBus.connect();
|
||||
|
||||
connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
|
||||
@Override
|
||||
public void appClosing() {
|
||||
stopDaemon(false, "App closing");
|
||||
}
|
||||
});
|
||||
EditorEventMulticaster eventMulticaster = editorFactory.getEventMulticaster();
|
||||
eventMulticaster.addDocumentListener(new DocumentAdapter() {
|
||||
// clearing highlighters before changing document because change can damage editor highlighters drastically, so we'll clear more than necessary
|
||||
@@ -338,7 +345,7 @@ public class DaemonListeners implements Disposable {
|
||||
public void beforeModalityStateChanged(boolean entering) {
|
||||
// before showing dialog we are in non-modal context yet, and before closing dialog we are still in modal context
|
||||
boolean inModalContext = LaterInvocator.isInModalContext();
|
||||
stopDaemon(inModalContext, "Modality change");
|
||||
stopDaemon(inModalContext, "Modality change. Was modal: "+inModalContext);
|
||||
myDaemonCodeAnalyzer.setUpdateByTimerEnabled(inModalContext);
|
||||
}
|
||||
};
|
||||
@@ -503,7 +510,7 @@ public class DaemonListeners implements Disposable {
|
||||
|
||||
private class MyTodoListener implements PropertyChangeListener {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
public void propertyChange(@NotNull PropertyChangeEvent evt) {
|
||||
if (TodoConfiguration.PROP_TODO_PATTERNS.equals(evt.getPropertyName())) {
|
||||
stopDaemonAndRestartAllFiles("Todo patterns changed");
|
||||
}
|
||||
|
||||
+23
-16
@@ -46,7 +46,6 @@ import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
@@ -60,20 +59,22 @@ import org.jetbrains.annotations.TestOnly;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author cdr
|
||||
*/
|
||||
public class PassExecutorService implements Disposable {
|
||||
class PassExecutorService implements Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.PassExecutorService");
|
||||
private static final boolean CHECK_CONSISTENCY = ApplicationManager.getApplication().isUnitTestMode();
|
||||
|
||||
private final Map<ScheduledPass, Job<Void>> mySubmittedPasses = new ConcurrentHashMap<ScheduledPass, Job<Void>>();
|
||||
private final Project myProject;
|
||||
protected volatile boolean isDisposed;
|
||||
private volatile boolean isDisposed;
|
||||
private final AtomicInteger nextPassId = new AtomicInteger(100);
|
||||
|
||||
public PassExecutorService(@NotNull Project project) {
|
||||
PassExecutorService(@NotNull Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ public class PassExecutorService implements Disposable {
|
||||
isDisposed = true;
|
||||
}
|
||||
|
||||
public void cancelAll(boolean waitForTermination) {
|
||||
void cancelAll(boolean waitForTermination) {
|
||||
for (Job<Void> submittedPass : mySubmittedPasses.values()) {
|
||||
submittedPass.cancel();
|
||||
}
|
||||
@@ -116,10 +117,12 @@ public class PassExecutorService implements Disposable {
|
||||
MultiMap<Document, FileEditor> documentToEditors = MultiMap.createSet();
|
||||
MultiMap<FileEditor, TextEditorHighlightingPass> documentBoundPasses = MultiMap.createSmart();
|
||||
MultiMap<FileEditor, EditorBoundHighlightingPass> editorBoundPasses = MultiMap.createSmart();
|
||||
Set<VirtualFile> vFiles = new HashSet<VirtualFile>();
|
||||
|
||||
for (Map.Entry<FileEditor, HighlightingPass[]> entry : passesMap.entrySet()) {
|
||||
FileEditor fileEditor = entry.getKey();
|
||||
HighlightingPass[] passes = entry.getValue();
|
||||
Document document = null;
|
||||
Document document;
|
||||
if (fileEditor instanceof TextEditor) {
|
||||
Editor editor = ((TextEditor)fileEditor).getEditor();
|
||||
LOG.assertTrue(!(editor instanceof EditorWindow));
|
||||
@@ -129,6 +132,9 @@ public class PassExecutorService implements Disposable {
|
||||
VirtualFile virtualFile = ((FileEditorManagerEx)FileEditorManager.getInstance(myProject)).getFile(fileEditor);
|
||||
document = virtualFile == null ? null : FileDocumentManager.getInstance().getDocument(virtualFile);
|
||||
}
|
||||
if (document != null) {
|
||||
vFiles.add(FileDocumentManager.getInstance().getFile(document));
|
||||
}
|
||||
|
||||
int prevId = 0;
|
||||
for (final HighlightingPass pass : passes) {
|
||||
@@ -185,7 +191,7 @@ public class PassExecutorService implements Disposable {
|
||||
assertConsistency(freePasses, toBeSubmitted, threadsToStartCountdown);
|
||||
}
|
||||
|
||||
log(updateProgress, null, "---------------------starting------------------------ " + threadsToStartCountdown.get(), freePasses);
|
||||
log(updateProgress, null, vFiles + " ----- starting " + threadsToStartCountdown.get(), freePasses);
|
||||
|
||||
for (ScheduledPass dependentPass : dependentPasses) {
|
||||
mySubmittedPasses.put(dependentPass, Job.NULL_JOB);
|
||||
@@ -227,7 +233,7 @@ public class PassExecutorService implements Disposable {
|
||||
id2Visits.put(succId, Pair.create(succ, newPred));
|
||||
assert newPred >= 0;
|
||||
if (newPred == 0) {
|
||||
checkConsistency((succ), id2Visits);
|
||||
checkConsistency(succ, id2Visits);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -534,7 +540,7 @@ public class PassExecutorService implements Disposable {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<TextEditorHighlightingPass> getAllSubmittedPasses() {
|
||||
List<TextEditorHighlightingPass> getAllSubmittedPasses() {
|
||||
List<TextEditorHighlightingPass> result = new ArrayList<TextEditorHighlightingPass>(mySubmittedPasses.size());
|
||||
for (ScheduledPass scheduledPass : mySubmittedPasses.keySet()) {
|
||||
if (!scheduledPass.myUpdateProgress.isCanceled()) {
|
||||
@@ -548,24 +554,25 @@ public class PassExecutorService implements Disposable {
|
||||
private static void sortById(@NotNull List<TextEditorHighlightingPass> result) {
|
||||
ContainerUtil.quickSort(result, new Comparator<TextEditorHighlightingPass>() {
|
||||
@Override
|
||||
public int compare(TextEditorHighlightingPass o1, TextEditorHighlightingPass o2) {
|
||||
public int compare(@NotNull TextEditorHighlightingPass o1, @NotNull TextEditorHighlightingPass o2) {
|
||||
return o1.getId() - o2.getId();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static final ConcurrentMap<Thread, Integer> threads = new ConcurrentHashMap<Thread, Integer>();
|
||||
private static int getThreadNum() {
|
||||
return ConcurrencyUtil.cacheOrGet(threads, Thread.currentThread(), threads.size());
|
||||
Matcher matcher = Pattern.compile("JobScheduler FJ pool (\\d*)/(\\d*)").matcher(Thread.currentThread().getName());
|
||||
String num = matcher.matches() ? matcher.group(1) : null;
|
||||
return StringUtil.parseInt(num, 0);
|
||||
}
|
||||
|
||||
public static void log(ProgressIndicator progressIndicator, TextEditorHighlightingPass pass, @NonNls @NotNull Object... info) {
|
||||
static void log(ProgressIndicator progressIndicator, TextEditorHighlightingPass pass, @NonNls @NotNull Object... info) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
CharSequence docText = pass == null ? "" : StringUtil.first(pass.getDocument().getCharsSequence(), 10, true);
|
||||
synchronized (PassExecutorService.class) {
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (Object o : info) {
|
||||
s.append(o.toString()).append(" ");
|
||||
s.append(o).append(" ");
|
||||
}
|
||||
String message = StringUtil.repeatSymbol(' ', getThreadNum() * 4)
|
||||
+ " " + pass + " "
|
||||
@@ -584,12 +591,12 @@ public class PassExecutorService implements Disposable {
|
||||
indicator.putUserDataIfAbsent(THROWABLE_KEY, e);
|
||||
}
|
||||
@TestOnly
|
||||
public static Throwable getSavedException(@NotNull DaemonProgressIndicator indicator) {
|
||||
static Throwable getSavedException(@NotNull DaemonProgressIndicator indicator) {
|
||||
return indicator.getUserData(THROWABLE_KEY);
|
||||
}
|
||||
|
||||
// return true if terminated
|
||||
public boolean waitFor(int millis) throws Throwable {
|
||||
boolean waitFor(int millis) throws Throwable {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
try {
|
||||
for (Job<Void> job : mySubmittedPasses.values()) {
|
||||
|
||||
@@ -38,7 +38,6 @@ import com.intellij.util.Function;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.containers.WeakHashMap;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jdom.Element;
|
||||
@@ -65,7 +64,7 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
|
||||
private final Map<String, RunnerAndConfigurationSettings> myConfigurations =
|
||||
new LinkedHashMap<String, RunnerAndConfigurationSettings>(); // template configurations are not included here
|
||||
private final Map<String, Boolean> mySharedConfigurations = new THashMap<String, Boolean>();
|
||||
private final Map<RunConfiguration, List<BeforeRunTask>> myConfigurationToBeforeTasksMap = new WeakHashMap<RunConfiguration, List<BeforeRunTask>>();
|
||||
private final Map<RunConfiguration, List<BeforeRunTask>> myConfigurationToBeforeTasksMap = ContainerUtil.createConcurrentWeakMap();
|
||||
|
||||
// When readExternal not all configuration may be loaded, so we need to remember the selected configuration
|
||||
// so that when it is eventually loaded, we can mark is as a selected.
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.FileAttribute;
|
||||
@@ -139,6 +140,17 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi
|
||||
final BufferExposingByteArrayOutputStream bytes = new BufferExposingByteArrayOutputStream();
|
||||
SerializationManagerEx.getInstanceEx().serialize(rootStub, bytes);
|
||||
|
||||
if (DebugAssertions.DEBUG) {
|
||||
try {
|
||||
Stub deserialized =
|
||||
SerializationManagerEx.getInstanceEx().deserialize(new ByteArrayInputStream(bytes.getInternalBuffer(), 0, bytes.size()));
|
||||
check(deserialized, rootStub);
|
||||
} catch(ProcessCanceledException pce) {
|
||||
throw pce;
|
||||
} catch (Throwable t) {
|
||||
LOG.error("Error indexing:" + file, t);
|
||||
}
|
||||
}
|
||||
final int key = Math.abs(FileBasedIndex.getFileId(file));
|
||||
result.put(key, new SerializedStubTree(bytes.getInternalBuffer(), bytes.size(), rootStub, file.getLength(), contentLength));
|
||||
}
|
||||
@@ -149,6 +161,16 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi
|
||||
};
|
||||
}
|
||||
|
||||
private static void check(Stub stub, Stub stub2) {
|
||||
assert stub.getStubType() == stub2.getStubType();
|
||||
List<? extends Stub> stubs = stub.getChildrenStubs();
|
||||
List<? extends Stub> stubs2 = stub2.getChildrenStubs();
|
||||
assert stubs.size() == stubs2.size();
|
||||
for(int i = 0, len = stubs.size(); i < len; ++i) {
|
||||
check(stubs.get(i), stubs2.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
private static void rememberIndexingStamp(final VirtualFile file, long contentLength) {
|
||||
try {
|
||||
DataOutputStream stream = INDEXED_STAMP.writeAttribute(file);
|
||||
|
||||
@@ -1471,7 +1471,7 @@ public class CaretImpl extends UserDataHolderBase implements Caret {
|
||||
|
||||
@Override
|
||||
public boolean isAtDirectionBoundary() {
|
||||
return myEditor.myUseNewRendering && myEditor.myView.isDirectionBoundary(myOffset);
|
||||
return myEditor.myUseNewRendering && myEditor.myView.isDirectionBoundary(myVisibleCaret);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -172,7 +172,7 @@ class EditorCoordinateMapper {
|
||||
maxVisualColumn = maxColumn;
|
||||
logicalLine = fragment.getEndLogicalLine();
|
||||
}
|
||||
return new LogicalPosition(logicalLine, column - maxVisualColumn + maxLogicalColumn, pos.leansRight);
|
||||
return new LogicalPosition(logicalLine, column - maxVisualColumn + maxLogicalColumn, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -268,9 +268,12 @@ public class EditorView implements Disposable {
|
||||
return layout.isRtlLocation(offset - myDocument.getLineStartOffset(line), leanForward);
|
||||
}
|
||||
|
||||
public boolean isDirectionBoundary(int offset) {
|
||||
public boolean isDirectionBoundary(@NotNull VisualPosition visualPosition) {
|
||||
assertIsDispatchThread();
|
||||
if (myDocument.getTextLength() == 0) return false;
|
||||
LogicalPosition logicalPosition = visualToLogicalPosition(visualPosition);
|
||||
int offset = logicalPositionToOffset(logicalPosition);
|
||||
if (!visualPosition.equals(offsetToVisualPosition(offset, logicalPosition.leansForward))) return false;
|
||||
int line = myDocument.getLineNumber(offset);
|
||||
LineLayout layout = getLineLayout(line);
|
||||
return layout.isDirectionBoundary(offset - myDocument.getLineStartOffset(line));
|
||||
|
||||
@@ -101,7 +101,7 @@ class TabFragment implements LineFragment {
|
||||
public float visualColumnToX(float startX, int column) {
|
||||
if (column <= 0) return startX;
|
||||
if (column >= getVisualColumnCount(startX)) return getNextTabStop(startX);
|
||||
return myView.getPlainSpaceWidth() * column;
|
||||
return startX + myView.getPlainSpaceWidth() * column;
|
||||
}
|
||||
|
||||
private static int trimOffset(int offset) {
|
||||
|
||||
@@ -59,11 +59,9 @@ class ProgressDialog implements Disposable {
|
||||
|
||||
myTextLabel.setText(text != null && !text.isEmpty() ? text : " ");
|
||||
|
||||
if (myProgressBar.isShowing()) {
|
||||
final int perc = (int)(fraction * 100);
|
||||
myProgressBar.setIndeterminate(perc == 0 || myProgressWindow.isIndeterminate());
|
||||
myProgressBar.setValue(perc);
|
||||
}
|
||||
final int perc = (int)(fraction * 100);
|
||||
myProgressBar.setIndeterminate(perc == 0 || myProgressWindow.isIndeterminate());
|
||||
myProgressBar.setValue(perc);
|
||||
|
||||
myText2Label.setText(getTitle2Text(text2, myText2Label.getWidth()));
|
||||
|
||||
|
||||
+5
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -63,15 +63,9 @@ import java.lang.ref.Reference;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
@State(
|
||||
name = "Encoding",
|
||||
storages = {
|
||||
@Storage(file = StoragePathMacros.APP_CONFIG + "/encoding.xml")
|
||||
}
|
||||
)
|
||||
@State(name = "Encoding", storages = @Storage(file = StoragePathMacros.APP_CONFIG + "/encoding.xml"))
|
||||
public class EncodingManagerImpl extends EncodingManager implements PersistentStateComponent<EncodingManagerImpl.State>, Disposable {
|
||||
private static final Equality<Reference<Document>> REFERENCE_EQUALITY = new Equality<Reference<Document>>() {
|
||||
@Override
|
||||
@@ -154,7 +148,7 @@ public class EncodingManagerImpl extends EncodingManager implements PersistentSt
|
||||
}
|
||||
|
||||
@Nullable("returns null if charset set cannot be determined from content")
|
||||
public Charset computeCharsetFromContent(@NotNull final VirtualFile virtualFile) {
|
||||
Charset computeCharsetFromContent(@NotNull final VirtualFile virtualFile) {
|
||||
final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
|
||||
if (document == null) {
|
||||
return null;
|
||||
@@ -183,7 +177,7 @@ public class EncodingManagerImpl extends EncodingManager implements PersistentSt
|
||||
clearDocumentQueue();
|
||||
}
|
||||
|
||||
public void queueUpdateEncodingFromContent(@NotNull Document document) {
|
||||
void queueUpdateEncodingFromContent(@NotNull Document document) {
|
||||
myChangedDocuments.offerIfAbsent(new WeakReference<Document>(document), REFERENCE_EQUALITY);
|
||||
}
|
||||
|
||||
@@ -206,7 +200,7 @@ public class EncodingManagerImpl extends EncodingManager implements PersistentSt
|
||||
@Override
|
||||
@NotNull
|
||||
public Collection<Charset> getFavorites() {
|
||||
Set<Charset> result = new THashSet<Charset>();
|
||||
Collection<Charset> result = new THashSet<Charset>();
|
||||
Project[] projects = ProjectManager.getInstance().getOpenProjects();
|
||||
for (Project project : projects) {
|
||||
result.addAll(EncodingProjectManager.getInstance(project).getFavorites());
|
||||
|
||||
@@ -17,7 +17,6 @@ package com.intellij.openapi.vfs.newvfs;
|
||||
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -191,15 +190,13 @@ public class VfsImplUtil {
|
||||
return getHandler(vfs, localPath, producer);
|
||||
}
|
||||
|
||||
//made public for Kotlin
|
||||
@NotNull
|
||||
public static <T extends ArchiveHandler> T getHandler(@NotNull ArchiveFileSystem vfs,
|
||||
@NotNull String localPath,
|
||||
@NotNull Function<String, T> producer) {
|
||||
@NotNull String localPath,
|
||||
@NotNull Function<String, T> producer) {
|
||||
checkSubscription();
|
||||
|
||||
ArchiveHandler handler;
|
||||
boolean refresh = false;
|
||||
|
||||
synchronized (ourLock) {
|
||||
Pair<ArchiveFileSystem, ArchiveHandler> record = ourHandlers.get(localPath);
|
||||
@@ -219,21 +216,10 @@ public class VfsImplUtil {
|
||||
handlers.add(finalRootPath);
|
||||
}
|
||||
});
|
||||
refresh = true;
|
||||
}
|
||||
handler = record.second;
|
||||
}
|
||||
|
||||
if (refresh) {
|
||||
final File file = handler.getFile();
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
|
||||
}
|
||||
}, ModalityState.NON_MODAL);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked") T t = (T)handler;
|
||||
return t;
|
||||
}
|
||||
|
||||
+1
-19
@@ -58,9 +58,6 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di
|
||||
private final TextPanel myProcessName = new TextPanel();
|
||||
private boolean myDisposed;
|
||||
|
||||
private long myLastTimeProgressWasAtZero;
|
||||
private boolean myLastTimeProgressWasZero;
|
||||
|
||||
public InlineProgressIndicator(boolean compact, @NotNull TaskInfo processInfo) {
|
||||
myCompact = compact;
|
||||
myInfo = processInfo;
|
||||
@@ -159,13 +156,7 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di
|
||||
}
|
||||
|
||||
public void updateProgressNow() {
|
||||
if (myLastTimeProgressWasAtZero == 0 && getFraction() == 0) {
|
||||
myLastTimeProgressWasAtZero = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
final long delta = System.currentTimeMillis() - myLastTimeProgressWasAtZero;
|
||||
|
||||
boolean indeterminate = isIndeterminate() || getFraction() == 0 && delta > 2000 && !myCompact;
|
||||
boolean indeterminate = isIndeterminate() || getFraction() == 0;
|
||||
if (indeterminate) {
|
||||
myProgress.setIndeterminate(true);
|
||||
}
|
||||
@@ -187,15 +178,6 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di
|
||||
|
||||
myCancelButton.setPainting(isCancelable());
|
||||
|
||||
if (getFraction() == 0) {
|
||||
if (!myLastTimeProgressWasZero) {
|
||||
myLastTimeProgressWasAtZero = System.currentTimeMillis();
|
||||
myLastTimeProgressWasZero = true;
|
||||
}
|
||||
} else {
|
||||
myLastTimeProgressWasZero = false;
|
||||
}
|
||||
|
||||
final boolean isStopping = wasStarted() && (isCanceled() || !isRunning()) && !isFinished();
|
||||
if (isStopping) {
|
||||
if (myCompact) {
|
||||
|
||||
@@ -159,7 +159,7 @@ i18nize.dialog.error.jdk.message=Class 'java.util.ResourceBundle' cannot be foun
|
||||
i18nize.dialog.error.jdk.title=Class Not Found
|
||||
i18nize.dialog.property.file.chooser.title=Choose Properties File
|
||||
i18nize.dialog.template.link.label=Edit I18n template
|
||||
i18nize.dialog.error.property.already.defined.message=Property ''{0}'' already exists in the file ''{1}''
|
||||
i18nize.dialog.error.property.already.defined.message=Property ''{0}'' already exists in the file ''{1}''. Override its value?
|
||||
i18nize.dialog.error.property.already.defined.title=Property Already Exists
|
||||
intention.split.declaration.family=Split Declaration
|
||||
intention.join.declaration.family=Join Declaration and Assignment
|
||||
|
||||
+46
-4
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.editor.impl;
|
||||
|
||||
import com.intellij.openapi.editor.Caret;
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.editor.VisualPosition;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
@@ -69,7 +70,7 @@ public class EditorRtlTest extends AbstractEditorTest {
|
||||
checkVPConversions(vR(3), lB(3), xy(30));
|
||||
checkVPConversions(vL(4), lF(2), xy(40));
|
||||
checkVPConversions(vR(4), lF(4), xy(40));
|
||||
checkVPConversions(vL(5), lB(5), xy(50));
|
||||
checkVPConversions(vL(5), lF(5), xy(50));
|
||||
checkVPConversions(vR(5), lF(5), xy(50));
|
||||
checkVPConversions(v(1, 0, false), l(1, 0, false), xy(0, 10));
|
||||
checkVPConversions(v(1, 0, true), l(1, 0, true), xy(0, 10));
|
||||
@@ -167,7 +168,7 @@ public class EditorRtlTest extends AbstractEditorTest {
|
||||
checkVPConversions(vR(6), lB(5), xy(60));
|
||||
checkVPConversions(vL(7), lF(4), xy(70));
|
||||
checkVPConversions(vR(7), lF(6), xy(70));
|
||||
checkVPConversions(vL(8), lB(7), xy(80));
|
||||
checkVPConversions(vL(8), lF(7), xy(80));
|
||||
checkVPConversions(vR(8), lF(7), xy(80));
|
||||
|
||||
checkXYConversion(xy(1), vR(0));
|
||||
@@ -257,6 +258,40 @@ public class EditorRtlTest extends AbstractEditorTest {
|
||||
up();
|
||||
assertCaretPosition(vR(2));
|
||||
}
|
||||
|
||||
public void testMovingIntoVirtualSpace() throws Exception {
|
||||
init("r");
|
||||
myEditor.getSettings().setVirtualSpace(true);
|
||||
assertVisualCaretLocation(0, false);
|
||||
right();
|
||||
assertVisualCaretLocation(0, true);
|
||||
right();
|
||||
assertVisualCaretLocation(1, true);
|
||||
right();
|
||||
assertVisualCaretLocation(1, false);
|
||||
right();
|
||||
assertVisualCaretLocation(2, false);
|
||||
right();
|
||||
assertVisualCaretLocation(3, false);
|
||||
}
|
||||
|
||||
public void testMovingThroughFoldedRegion() throws Exception {
|
||||
init("rrr");
|
||||
addCollapsedFoldRegion(1, 2, "..");
|
||||
assertVisualCaretLocation(0, false);
|
||||
right();
|
||||
assertVisualCaretLocation(0, true);
|
||||
right();
|
||||
assertVisualCaretLocation(1, true);
|
||||
right();
|
||||
assertVisualCaretLocation(1, true);
|
||||
right();
|
||||
assertVisualCaretLocation(2, true);
|
||||
right();
|
||||
assertVisualCaretLocation(3, true);
|
||||
right();
|
||||
assertVisualCaretLocation(4, true);
|
||||
}
|
||||
|
||||
private void init(String text) throws IOException {
|
||||
initText(text.replace(RTL_CHAR_REPRESENTATION, RTL_CHAR));
|
||||
@@ -278,11 +313,11 @@ public class EditorRtlTest extends AbstractEditorTest {
|
||||
Point xyTowardsLargerOffsets) {
|
||||
assertLogicalPositionsEqual("Wrong offset->logicalPosition calculation", logicalPosition, myEditor.offsetToLogicalPosition(offset));
|
||||
assertVisualPositionsEqual("Wrong beforeOffset->visualPosition calculation",
|
||||
visualPositionTowardsSmallerOffsets, ((EditorImpl)myEditor).offsetToVisualPosition(offset, false));
|
||||
visualPositionTowardsSmallerOffsets, myEditor.offsetToVisualPosition(offset, false));
|
||||
assertEquals("Wrong beforeOffset->visualLine calculation",
|
||||
visualPositionTowardsSmallerOffsets.line, ((EditorImpl)myEditor).offsetToVisualLine(offset));
|
||||
assertVisualPositionsEqual("Wrong afterOffset->visualPosition calculation",
|
||||
visualPositionTowardsLargerOffsets, ((EditorImpl)myEditor).offsetToVisualPosition(offset, true));
|
||||
visualPositionTowardsLargerOffsets, myEditor.offsetToVisualPosition(offset, true));
|
||||
assertEquals("Wrong afterOffset->visualLine calculation",
|
||||
visualPositionTowardsLargerOffsets.line, ((EditorImpl)myEditor).offsetToVisualLine(offset));
|
||||
assertEquals("Wrong beforeOffset->xy calculation", xyTowardsSmallerOffsets, ((EditorImpl)myEditor).offsetToXY(offset, false));
|
||||
@@ -326,6 +361,13 @@ public class EditorRtlTest extends AbstractEditorTest {
|
||||
private static void assertCaretPosition(VisualPosition visualPosition) {
|
||||
assertVisualPositionsEqual("Wrong caret position", visualPosition, myEditor.getCaretModel().getVisualPosition());
|
||||
}
|
||||
|
||||
private static void assertVisualCaretLocation(int visualColumn, boolean reversedDirection) {
|
||||
assertEquals(1, myEditor.getCaretModel().getCaretCount());
|
||||
Caret caret = myEditor.getCaretModel().getPrimaryCaret();
|
||||
assertEquals(visualColumn, caret.getVisualPosition().column);
|
||||
assertEquals(reversedDirection, caret.isAtRtlLocation());
|
||||
}
|
||||
|
||||
// logical position leaning backward
|
||||
private static LogicalPosition lB(int column) {
|
||||
|
||||
@@ -51,6 +51,7 @@ import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
import org.intellij.lang.annotations.RegExp;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -656,6 +657,7 @@ public abstract class UsefulTestCase extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Contract("null, _ -> fail")
|
||||
public static <T> T assertInstanceOf(Object o, Class<T> aClass) {
|
||||
Assert.assertNotNull("Expected instance of: " + aClass.getName() + " actual: " + null, o);
|
||||
Assert.assertTrue("Expected instance of: " + aClass.getName() + " actual: " + o.getClass().getName(), aClass.isInstance(o));
|
||||
|
||||
@@ -143,6 +143,7 @@ public abstract class AbstractTestProxy extends CompositePrintable {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public interface AssertEqualsDiffChain {
|
||||
DiffHyperlink getPrevious();
|
||||
DiffHyperlink getCurrent();
|
||||
|
||||
+11
-91
@@ -27,18 +27,11 @@ import com.intellij.execution.testframework.Printable;
|
||||
import com.intellij.execution.testframework.Printer;
|
||||
import com.intellij.execution.testframework.actions.ViewAssertEqualsDiffAction;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.diff.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
|
||||
public class DiffHyperlink implements Printable {
|
||||
@@ -66,94 +59,21 @@ public class DiffHyperlink implements Printable {
|
||||
myPrintOneLine = printOneLine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use {@link ViewAssertEqualsDiffAction#openDiff(DataContext, DiffHyperlink)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void openDiff(Project project) {
|
||||
openMultiDiff(project, null);
|
||||
ViewAssertEqualsDiffAction.openDiff(DataManager.getInstance().getDataContext(), this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use {@link ViewAssertEqualsDiffAction#openDiff(DataContext, DiffHyperlink)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void openMultiDiff(final Project project,
|
||||
final AbstractTestProxy.AssertEqualsDiffChain chain) {
|
||||
final SimpleDiffRequest diffData = createRequest(project, chain, myFilePath, myExpected, myActual);
|
||||
DiffManager.getInstance().getIdeaDiffTool().show(diffData);
|
||||
}
|
||||
|
||||
private SimpleDiffRequest createRequest(final Project project,
|
||||
final AbstractTestProxy.AssertEqualsDiffChain chain,
|
||||
String filePath, String expected, String actual) {
|
||||
String expectedTitle = ExecutionBundle.message("diff.content.expected.title");
|
||||
final DiffContent expectedContent;
|
||||
final VirtualFile vFile;
|
||||
if (filePath != null && (vFile = LocalFileSystem.getInstance().findFileByPath(filePath)) != null) {
|
||||
expectedContent = DiffContent.fromFile(project, vFile);
|
||||
expectedTitle += " (" + vFile.getPresentableUrl() + ")";
|
||||
} else {
|
||||
expectedContent = new SimpleContent(expected);
|
||||
}
|
||||
final SimpleDiffRequest diffData = new SimpleDiffRequest(project, getTitle());
|
||||
if (chain != null) {
|
||||
diffData.setToolbarAddons(new DiffRequest.ToolbarAddons() {
|
||||
@Override
|
||||
public void customize(DiffToolbar toolbar) {
|
||||
toolbar.addAction(new NextPrevAction("Compare Previous Failure", AllIcons.Actions.Prevfile, chain) {
|
||||
{
|
||||
registerCustomShortcutSet(ActionManager.getInstance().getAction("PreviousTab").getShortcutSet(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DiffHyperlink getNextId() {
|
||||
return chain.getPrevious();
|
||||
}
|
||||
});
|
||||
toolbar.addAction(new NextPrevAction("Compare Next Failure", AllIcons.Actions.Nextfile, chain) {
|
||||
{
|
||||
registerCustomShortcutSet(ActionManager.getInstance().getAction("NextTab").getShortcutSet(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DiffHyperlink getNextId() {
|
||||
return chain.getNext();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
diffData.setContents(expectedContent, new SimpleContent(actual));
|
||||
diffData.setContentTitles(expectedTitle, ExecutionBundle.message("diff.content.actual.title"));
|
||||
diffData.addHint(DiffTool.HINT_SHOW_FRAME);
|
||||
diffData.addHint(DiffTool.HINT_DO_NOT_IGNORE_WHITESPACES);
|
||||
diffData.setGroupKey("#com.intellij.execution.junit2.states.ComparisonFailureState$DiffDialog");
|
||||
return diffData;
|
||||
}
|
||||
|
||||
abstract class NextPrevAction extends AnAction {
|
||||
|
||||
private final AbstractTestProxy.AssertEqualsDiffChain myChain;
|
||||
|
||||
public NextPrevAction(@Nullable String text, @Nullable Icon icon,
|
||||
final AbstractTestProxy.AssertEqualsDiffChain chain) {
|
||||
super(text, text, icon);
|
||||
myChain = chain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
final DiffViewer viewer = e.getData(PlatformDataKeys.DIFF_VIEWER);
|
||||
LOG.assertTrue(viewer != null);
|
||||
final Project project = e.getData(CommonDataKeys.PROJECT);
|
||||
final DiffHyperlink nextProvider = getNextId();
|
||||
myChain.setCurrent(nextProvider);
|
||||
final SimpleDiffRequest nextRequest = createRequest(project, myChain,
|
||||
nextProvider.getFilePath(), nextProvider.getLeft(), nextProvider.getRight());
|
||||
viewer.setDiffRequest(nextRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
final DiffViewer viewer = e.getData(PlatformDataKeys.DIFF_VIEWER);
|
||||
final Project project = e.getData(CommonDataKeys.PROJECT);
|
||||
e.getPresentation().setEnabled(project != null && viewer != null);
|
||||
}
|
||||
|
||||
protected abstract DiffHyperlink getNextId();
|
||||
ViewAssertEqualsDiffAction.openDiff(DataManager.getInstance().getDataContext(), this);
|
||||
}
|
||||
|
||||
protected String getTitle() {
|
||||
|
||||
@@ -1101,10 +1101,11 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
public static <T> Iterable<T> iterate(@NotNull final Collection<? extends T> collection, @NotNull final Condition<? super T> condition) {
|
||||
if (collection.isEmpty()) return emptyIterable();
|
||||
return new Iterable<T>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return new Iterator<T>() {
|
||||
private Iterator<? extends T> impl = collection.iterator();
|
||||
private final Iterator<? extends T> impl = collection.iterator();
|
||||
private T next = findNext();
|
||||
|
||||
@Override
|
||||
@@ -1143,10 +1144,11 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
@Contract(pure=true)
|
||||
public static <T> Iterable<T> iterateBackward(@NotNull final List<? extends T> list) {
|
||||
return new Iterable<T>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return new Iterator<T>() {
|
||||
private ListIterator<? extends T> it = list.listIterator(list.size());
|
||||
private final ListIterator<? extends T> it = list.listIterator(list.size());
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
@@ -1269,7 +1271,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #append(java.util.List, java.lang.Object[])} or {@link #prepend(java.util.List, java.lang.Object[])} instead
|
||||
* @deprecated Use {@link #append(List, Object[])} or {@link #prepend(List, Object[])} instead
|
||||
* @param appendTail specify whether additional values should be appended in front or after the list
|
||||
* @return read-only list consisting of the elements from specified list with some additional values
|
||||
*/
|
||||
@@ -1338,6 +1340,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
@Contract(pure=true)
|
||||
public static <T> Iterable<T> concat(@NotNull final Iterable<? extends T>... iterables) {
|
||||
return new Iterable<T>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
Iterator[] iterators = new Iterator[iterables.length];
|
||||
@@ -1367,12 +1370,13 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
@Contract(pure=true)
|
||||
public static <T> Iterable<T> concat(@NotNull final T[]... iterables) {
|
||||
return new Iterable<T>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
Iterator[] iterators = new Iterator[iterables.length];
|
||||
for (int i = 0, iterablesLength = iterables.length; i < iterablesLength; i++) {
|
||||
for (int i = 0; i < iterables.length; i++) {
|
||||
T[] iterable = iterables[i];
|
||||
iterators[i] = Arrays.asList(iterable).iterator();
|
||||
iterators[i] = iterate(iterable);
|
||||
}
|
||||
@SuppressWarnings("unchecked") Iterator<T> i = concatIterators(iterators);
|
||||
return i;
|
||||
@@ -2134,6 +2138,37 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
return flatten(Arrays.asList(collections));
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the list, remove all duplicates and return the list with unique elements.
|
||||
* @param list must be sorted (according to the comparator), all elements must be not-null
|
||||
*/
|
||||
@NotNull
|
||||
public static <T> List<T> removeDuplicatesFromSorted(@NotNull List<T> list, @NotNull Comparator<? super T> comparator) {
|
||||
T prev = null;
|
||||
List<T> result = null;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
T t = list.get(i);
|
||||
if (t == null) {
|
||||
throw new IllegalArgumentException("get(" + i + ") = null");
|
||||
}
|
||||
int cmp = prev == null ? -1 : comparator.compare(prev, t);
|
||||
if (cmp < 0) {
|
||||
if (result != null) result.add(t);
|
||||
}
|
||||
else if (cmp == 0) {
|
||||
if (result == null) {
|
||||
result = new ArrayList<T>(list.size());
|
||||
result.addAll(list.subList(0, i));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("List must be sorted but get(" + (i - 1) + ")=" + list.get(i - 1) + " > get(" + i + ")=" + t);
|
||||
}
|
||||
prev = t;
|
||||
}
|
||||
return result == null ? list : result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return read-only list consisting of the elements from all of the collections
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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,10 +16,11 @@
|
||||
package com.intellij.openapi.vcs;
|
||||
|
||||
import com.intellij.codeInsight.CodeSmellInfo;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,10 +37,11 @@ public abstract class CodeSmellDetector {
|
||||
*
|
||||
* @param files the files to analyze.
|
||||
* @return the list of problems found during the analysis.
|
||||
* @throws com.intellij.openapi.progress.ProcessCanceledException if the analysis was cancelled by the user.
|
||||
* @throws ProcessCanceledException if the analysis was cancelled by the user.
|
||||
* @since 5.1
|
||||
*/
|
||||
public abstract List<CodeSmellInfo> findCodeSmells(List<VirtualFile> files) throws ProcessCanceledException;
|
||||
@NotNull
|
||||
public abstract List<CodeSmellInfo> findCodeSmells(@NotNull List<VirtualFile> files) throws ProcessCanceledException;
|
||||
|
||||
/**
|
||||
* Shows the specified list of problems found during pre-checkin code analysis in a Messages pane.
|
||||
@@ -47,6 +49,6 @@ public abstract class CodeSmellDetector {
|
||||
* @param smells the problems to show.
|
||||
* @since 5.1
|
||||
*/
|
||||
public abstract void showCodeSmellErrors(final List<CodeSmellInfo> smells);
|
||||
public abstract void showCodeSmellErrors(@NotNull List<CodeSmellInfo> smells);
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -60,7 +60,7 @@ public class CodeSmellDetectorImpl extends CodeSmellDetector {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showCodeSmellErrors(final List<CodeSmellInfo> smellList) {
|
||||
public void showCodeSmellErrors(@NotNull final List<CodeSmellInfo> smellList) {
|
||||
Collections.sort(smellList, new Comparator<CodeSmellInfo>() {
|
||||
@Override
|
||||
public int compare(final CodeSmellInfo o1, final CodeSmellInfo o2) {
|
||||
@@ -104,9 +104,10 @@ public class CodeSmellDetectorImpl extends CodeSmellDetector {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<CodeSmellInfo> findCodeSmells(final List<VirtualFile> filesToCheck) throws ProcessCanceledException {
|
||||
public List<CodeSmellInfo> findCodeSmells(@NotNull final List<VirtualFile> filesToCheck) throws ProcessCanceledException {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
final List<CodeSmellInfo> result = new ArrayList<CodeSmellInfo>();
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
if (ApplicationManager.getApplication().isWriteAccessAllowed()) throw new RuntimeException("Must not run under write action");
|
||||
@@ -137,7 +138,8 @@ public class CodeSmellDetectorImpl extends CodeSmellDetector {
|
||||
}
|
||||
});
|
||||
if (!exception.isNull()) {
|
||||
Rethrow.reThrowRuntime(exception.get());
|
||||
Exception t = exception.get();
|
||||
Rethrow.reThrowRuntime(t);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -145,11 +147,11 @@ public class CodeSmellDetectorImpl extends CodeSmellDetector {
|
||||
|
||||
@NotNull
|
||||
private List<CodeSmellInfo> findCodeSmells(@NotNull final VirtualFile file, @NotNull final ProgressIndicator progress) {
|
||||
final List<CodeSmellInfo> result = new ArrayList<CodeSmellInfo>();
|
||||
final List<CodeSmellInfo> result = Collections.synchronizedList(new ArrayList<CodeSmellInfo>());
|
||||
|
||||
final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject);
|
||||
final DaemonProgressIndicator daemonIndicator = new DaemonProgressIndicator();
|
||||
((ProgressIndicatorEx)progress).addStateDelegate(new AbstractProgressIndicatorExBase(){
|
||||
final ProgressIndicator daemonIndicator = new DaemonProgressIndicator();
|
||||
((ProgressIndicatorEx)progress).addStateDelegate(new AbstractProgressIndicatorExBase() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
super.cancel();
|
||||
@@ -163,13 +165,12 @@ public class CodeSmellDetectorImpl extends CodeSmellDetector {
|
||||
@Override
|
||||
public void run() {
|
||||
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
|
||||
if (psiFile != null) {
|
||||
final Document document = FileDocumentManager.getInstance().getDocument(file);
|
||||
if (document != null) {
|
||||
List<HighlightInfo> infos = codeAnalyzer.runMainPasses(psiFile, document, daemonIndicator);
|
||||
collectErrorsAndWarnings(infos, result, document);
|
||||
}
|
||||
final Document document = FileDocumentManager.getInstance().getDocument(file);
|
||||
if (psiFile == null || document == null) {
|
||||
return;
|
||||
}
|
||||
List<HighlightInfo> infos = codeAnalyzer.runMainPasses(psiFile, document, daemonIndicator);
|
||||
convertErrorsAndWarnings(infos, result, document);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -178,10 +179,9 @@ public class CodeSmellDetectorImpl extends CodeSmellDetector {
|
||||
return result;
|
||||
}
|
||||
|
||||
private void collectErrorsAndWarnings(final Collection<HighlightInfo> highlights,
|
||||
final List<CodeSmellInfo> result,
|
||||
final Document document) {
|
||||
if (highlights == null) return;
|
||||
private void convertErrorsAndWarnings(@NotNull Collection<HighlightInfo> highlights,
|
||||
@NotNull List<CodeSmellInfo> result,
|
||||
@NotNull Document document) {
|
||||
for (HighlightInfo highlightInfo : highlights) {
|
||||
final HighlightSeverity severity = highlightInfo.getSeverity();
|
||||
if (SeverityRegistrar.getSeverityRegistrar(myProject).compare(severity, HighlightSeverity.WARNING) >= 0) {
|
||||
@@ -191,7 +191,7 @@ public class CodeSmellDetectorImpl extends CodeSmellDetector {
|
||||
}
|
||||
}
|
||||
|
||||
private static String getDescription(final HighlightInfo highlightInfo) {
|
||||
private static String getDescription(@NotNull HighlightInfo highlightInfo) {
|
||||
final String description = highlightInfo.getDescription();
|
||||
final HighlightInfoType type = highlightInfo.type;
|
||||
if (type instanceof HighlightInfoType.HighlightInfoTypeSeverityByKey) {
|
||||
|
||||
@@ -42,7 +42,7 @@ public abstract class ResourceBundleManager {
|
||||
public abstract PsiClass getResourceBundle();
|
||||
|
||||
public List<String> suggestPropertiesFiles(){
|
||||
return I18nUtil.defaultGetPropertyFiles(myProject);
|
||||
return I18nUtil.defaultSuggestPropertiesFiles(myProject);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+6
-1
@@ -30,6 +30,12 @@ import org.junit.Assume;
|
||||
import java.util.List;
|
||||
|
||||
public class JavaFXCollapseSubtagToAttributeTest extends DaemonAnalyzerTestCase {
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
Assume.assumeFalse(SystemInfo.isMac);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUpModule() {
|
||||
super.setUpModule();
|
||||
@@ -37,7 +43,6 @@ public class JavaFXCollapseSubtagToAttributeTest extends DaemonAnalyzerTestCase
|
||||
}
|
||||
|
||||
public void testAdditionalSubtags() throws Exception {
|
||||
Assume.assumeFalse(SystemInfo.isMac);
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
|
||||
+24
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,10 +30,13 @@ import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.psi.search.DelegatingGlobalSearchScope;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.CommonProcessors;
|
||||
import com.intellij.util.PathsList;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
import org.jetbrains.idea.maven.importing.ArtifactsDownloadingTestCase;
|
||||
@@ -780,15 +783,27 @@ public class MavenClasspathsAndSearchScopesTest extends MavenImportingTestCase {
|
||||
importProjects(m1, m2);
|
||||
assertModules("m1", "m2");
|
||||
|
||||
List<Module> modules = Arrays.asList(getModule("m1"), getModule("m2"));
|
||||
GlobalSearchScope scope = LibraryScopeCache.getInstance(myProject).getScopeForLibraryUsedIn(modules);
|
||||
String libraryPath = getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar";
|
||||
assertSearchScope(scope,
|
||||
Module m1m = ModuleManager.getInstance(myProject).findModuleByName("m1");
|
||||
List<OrderEntry> modules1 = new ArrayList<OrderEntry>();
|
||||
ModuleRootManager.getInstance(m1m).orderEntries().withoutSdk().withoutModuleSourceEntries().forEach(new CommonProcessors.CollectProcessor<OrderEntry>(modules1));
|
||||
GlobalSearchScope scope1 = LibraryScopeCache.getInstance(myProject).getLibraryScope(modules1);
|
||||
assertSearchScope(scope1,
|
||||
getProjectPath() + "/m1/src/main/java",
|
||||
getProjectPath() + "/m1/src/test/java",
|
||||
getProjectPath() + "/m2/src/main/java",
|
||||
getProjectPath() + "/m2/src/test/java"
|
||||
);
|
||||
|
||||
String libraryPath = getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar";
|
||||
Module m2m = ModuleManager.getInstance(myProject).findModuleByName("m2");
|
||||
List<OrderEntry> modules2 = new ArrayList<OrderEntry>();
|
||||
ModuleRootManager.getInstance(m2m).orderEntries().withoutSdk().withoutModuleSourceEntries().forEach(new CommonProcessors.CollectProcessor<OrderEntry>(modules2));
|
||||
GlobalSearchScope scope2 = LibraryScopeCache.getInstance(myProject).getLibraryScope(modules2);
|
||||
assertSearchScope(scope2,
|
||||
getProjectPath() + "/m2/src/main/java",
|
||||
getProjectPath() + "/m2/src/test/java",
|
||||
libraryPath);
|
||||
libraryPath
|
||||
);
|
||||
}
|
||||
|
||||
public void testDoNotIncludeConflictingTransitiveDependenciesInTheClasspath() throws Exception {
|
||||
@@ -1132,6 +1147,9 @@ public class MavenClasspathsAndSearchScopesTest extends MavenImportingTestCase {
|
||||
|
||||
private void assertSearchScope(GlobalSearchScope searchScope, String... expectedPaths) {
|
||||
Collection<VirtualFile> roots;
|
||||
if (searchScope instanceof DelegatingGlobalSearchScope) {
|
||||
searchScope = ReflectionUtil.getField(DelegatingGlobalSearchScope.class, searchScope, GlobalSearchScope.class, "myBaseScope");
|
||||
}
|
||||
if (searchScope instanceof ModuleWithDependenciesScope) {
|
||||
roots = ((ModuleWithDependenciesScope)searchScope).getRoots();
|
||||
}
|
||||
|
||||
+5
-1
@@ -20,6 +20,7 @@ import com.intellij.lang.properties.IProperty;
|
||||
import com.intellij.lang.properties.PropertiesFileProcessor;
|
||||
import com.intellij.lang.properties.PropertiesReferenceManager;
|
||||
import com.intellij.lang.properties.psi.PropertiesFile;
|
||||
import com.intellij.lang.properties.xml.XmlPropertiesFile;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
@@ -74,7 +75,7 @@ public class I18nUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> defaultGetPropertyFiles(Project project) {
|
||||
public static List<String> defaultSuggestPropertiesFiles(Project project) {
|
||||
final List<String> paths = new ArrayList<String>();
|
||||
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
|
||||
@@ -82,6 +83,9 @@ public class I18nUtil {
|
||||
|
||||
@Override
|
||||
public boolean process(String baseName, PropertiesFile propertiesFile) {
|
||||
if (propertiesFile instanceof XmlPropertiesFile) {
|
||||
return true;
|
||||
}
|
||||
VirtualFile virtualFile = propertiesFile.getVirtualFile();
|
||||
if (projectFileIndex.isInContent(virtualFile)) {
|
||||
String path = FileUtil.toSystemDependentName(virtualFile.getPath());
|
||||
|
||||
+11
-7
@@ -64,7 +64,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class I18nizeQuickFixDialog extends DialogWrapper implements I18nizeQuickFixModel {
|
||||
protected static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.i18n.I18nizeQuickFixDialog");
|
||||
|
||||
|
||||
private static final Pattern PATTERN = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
|
||||
|
||||
private JTextField myValue;
|
||||
@@ -269,7 +269,7 @@ public class I18nizeQuickFixDialog extends DialogWrapper implements I18nizeQuick
|
||||
}
|
||||
|
||||
protected String defaultSuggestPropertyKey(String value) {
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
private void propertiesFileChanged() {
|
||||
@@ -359,7 +359,7 @@ public class I18nizeQuickFixDialog extends DialogWrapper implements I18nizeQuick
|
||||
}
|
||||
|
||||
protected List<String> defaultSuggestPropertiesFiles() {
|
||||
return I18nUtil.defaultGetPropertyFiles(myProject);
|
||||
return I18nUtil.defaultSuggestPropertiesFiles(myProject);
|
||||
}
|
||||
|
||||
protected PropertiesFile getPropertiesFile() {
|
||||
@@ -438,10 +438,14 @@ public class I18nizeQuickFixDialog extends DialogWrapper implements I18nizeQuick
|
||||
IProperty existingProperty = propertiesFile.findPropertyByKey(getKey());
|
||||
final String propValue = myValue.getText();
|
||||
if (existingProperty != null && !Comparing.strEqual(existingProperty.getValue(), propValue)) {
|
||||
Messages.showErrorDialog(myProject, CodeInsightBundle.message("i18nize.dialog.error.property.already.defined.message", getKey(),
|
||||
propertiesFile.getName()),
|
||||
CodeInsightBundle.message("i18nize.dialog.error.property.already.defined.title"));
|
||||
return;
|
||||
final String messageText = CodeInsightBundle.message("i18nize.dialog.error.property.already.defined.message", getKey(), propertiesFile.getName());
|
||||
final int code = Messages.showOkCancelDialog(myProject,
|
||||
messageText,
|
||||
CodeInsightBundle.message("i18nize.dialog.error.property.already.defined.title"),
|
||||
null);
|
||||
if (code == Messages.CANCEL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,10 @@ import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.generation.OverrideImplementExploreUtil;
|
||||
import com.intellij.codeInsight.generation.OverrideImplementUtil;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -40,7 +43,6 @@ import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.uiDesigner.FormEditingUtil;
|
||||
import com.intellij.uiDesigner.UIDesignerBundle;
|
||||
@@ -211,7 +213,7 @@ public class CreateListenerAction extends AbstractGuiEditorAction {
|
||||
|
||||
PsiStatement stmt = factory.createStatementFromText(builder.toString(), constructor);
|
||||
stmt = (PsiStatement)body.addAfter(stmt, body.getLastBodyElement());
|
||||
JavaCodeStyleManager.getInstance(body.getProject()).shortenClassReferences(stmt);
|
||||
stmt = (PsiStatement)JavaCodeStyleManager.getInstance(body.getProject()).shortenClassReferences(stmt);
|
||||
|
||||
if (boundFields.length > 1) {
|
||||
PsiElement anchor = stmt;
|
||||
@@ -224,23 +226,32 @@ public class CreateListenerAction extends AbstractGuiEditorAction {
|
||||
}
|
||||
}
|
||||
|
||||
final Ref<PsiClass> newClassRef = new Ref<PsiClass>();
|
||||
stmt.accept(new JavaRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitClass(PsiClass aClass) {
|
||||
newClassRef.set(aClass);
|
||||
}
|
||||
});
|
||||
final PsiClass newClass = newClassRef.get();
|
||||
final SmartPsiElementPointer ptr = SmartPointerManager.getInstance(myClass.getProject()).createSmartPsiElementPointer(newClass);
|
||||
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(newClass);
|
||||
final SmartPsiElementPointer ptr = SmartPointerManager.getInstance(myClass.getProject()).createSmartPsiElementPointer(stmt);
|
||||
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(myClass);
|
||||
final FileEditor[] fileEditors =
|
||||
virtualFile != null ? FileEditorManager.getInstance(newClass.getProject()).openFile(virtualFile, true, true) : null;
|
||||
virtualFile != null ? FileEditorManager.getInstance(myClass.getProject()).openFile(virtualFile, true, true) : null;
|
||||
IdeFocusManager.findInstance().doWhenFocusSettlesDown(new Runnable() {
|
||||
public void run() {
|
||||
final PsiClass newClass = (PsiClass)ptr.getElement();
|
||||
final PsiElement anonymousClassStatement = ptr.getElement();
|
||||
if (anonymousClassStatement == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Ref<PsiClass> newClassRef = new Ref<PsiClass>();
|
||||
anonymousClassStatement.accept(new JavaRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitClass(PsiClass aClass) {
|
||||
newClassRef.set(aClass);
|
||||
}
|
||||
});
|
||||
final PsiClass newClass = newClassRef.get();
|
||||
|
||||
final Editor editor = getEditor();
|
||||
if (editor != null && newClass != null) {
|
||||
PsiElement brace = newClass.getLBrace();
|
||||
if (brace != null) {
|
||||
editor.getCaretModel().moveToOffset(brace.getTextOffset());
|
||||
}
|
||||
CommandProcessor.getInstance().executeCommand(myClass.getProject(), new Runnable() {
|
||||
public void run() {
|
||||
if (!OverrideImplementExploreUtil.getMethodSignaturesToImplement(newClass).isEmpty()) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import os
|
||||
import time
|
||||
import abc
|
||||
import tcmessages
|
||||
from utils import VersionAgnosticUtils
|
||||
from _jb_utils import VersionAgnosticUtils
|
||||
|
||||
__author__ = 'Ilya.Kazakevich'
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import re
|
||||
import _bdd_utils
|
||||
from distutils import version
|
||||
from behave import __version__ as behave_version
|
||||
from utils import VersionAgnosticUtils
|
||||
from _jb_utils import VersionAgnosticUtils
|
||||
_MAX_STEPS_SEARCH_FEATURES = 5000 # Do not look for features in folder that has more that this number of children
|
||||
_FEATURES_FOLDER = 'features' # "features" folder name.
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ from django.core.exceptions import ImproperlyConfigured
|
||||
from django.core.management import ManagementUtility, get_commands, BaseCommand
|
||||
|
||||
from django_manage_commands_provider._parser import _optparse, _argparse
|
||||
from utils import VersionAgnosticUtils
|
||||
from _jb_utils import VersionAgnosticUtils
|
||||
|
||||
|
||||
__author__ = 'Ilya.Kazakevich'
|
||||
|
||||
@@ -24,7 +24,7 @@ TODO: Since Django 1.8 we can fetch much more info from argparse like positional
|
||||
"""
|
||||
from xml.dom import minidom
|
||||
from xml.dom.minidom import Element
|
||||
from utils import VersionAgnosticUtils
|
||||
from _jb_utils import VersionAgnosticUtils
|
||||
|
||||
__author__ = 'Ilya.Kazakevich'
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
This helper fetchers manage commands from Django installation.
|
||||
It supports custom commands as well.
|
||||
Entry point is "provider.py": it exports data in XML format that is described in "_xml.py".
|
||||
Entry point is "_jb_manage_tasks_provider.py: one level up, it exports data in XML format that is described in "_xml.py".
|
||||
This helper should be used in pair with com.jetbrains.django.manage.RealCommandsProvider
|
||||
Reference in New Issue
Block a user