Merge remote-tracking branch 'origin/master'

This commit is contained in:
Roman Shevchenko
2016-10-28 18:02:41 +02:00
20 changed files with 123 additions and 109 deletions

View File

@@ -28,20 +28,17 @@ import com.intellij.psi.util.CachedValuesManager;
import com.intellij.psi.util.PsiModificationTracker;
import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.SmartHashSet;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import static com.intellij.psi.search.GlobalSearchScope.EMPTY_SCOPE;
class DirtyModulesHolder extends UserDataHolderBase {
private final CompilerReferenceServiceImpl myService;
private final FileDocumentManager myFileDocManager;
private final PsiDocumentManager myPsiDocManager;
private final Set<Module> myChangedModules = ContainerUtil.newHashSet();
private final Set<Module> myVFSChangedModules = ContainerUtil.newHashSet();
private final Set<Module> myChangedModulesDuringCompilation = ContainerUtil.newHashSet();
private final Object myLock = new Object();
@@ -65,30 +62,30 @@ class DirtyModulesHolder extends UserDataHolderBase {
synchronized (myLock) {
myCompilationPhase = false;
ContainerUtil.removeAll(myChangedModules, affectedModules);
Collections.addAll(myChangedModules, markAsDirty);
myChangedModules.addAll(myChangedModulesDuringCompilation);
ContainerUtil.removeAll(myVFSChangedModules, affectedModules);
Collections.addAll(myVFSChangedModules, markAsDirty);
myVFSChangedModules.addAll(myChangedModulesDuringCompilation);
myChangedModulesDuringCompilation.clear();
}
}
GlobalSearchScope getDirtyScope() {
return CachedValuesManager.getManager(myService.getProject()).getCachedValue(this, () ->
CachedValueProvider.Result.create(calculateDirtyModules(), PsiModificationTracker.MODIFICATION_COUNT, VirtualFileManager.getInstance(), myService));
}
private GlobalSearchScope calculateDirtyModules() {
synchronized (myLock) {
final Set<Module> unCommittedModules = new SmartHashSet<>(0);
final Set<Module> dirtyModules = new THashSet<>(myVFSChangedModules);
for (Document document : myFileDocManager.getUnsavedDocuments()) {
final Module m = getModuleForSourceContentFile(myFileDocManager.getFile(document));
if (m != null && !myChangedModules.contains(m)) unCommittedModules.add(m);
if (m != null) dirtyModules.add(m);
}
for (Document document : ReadAction.compute(() -> myPsiDocManager.getUncommittedDocuments())) {
final Module m = getModuleForSourceContentFile(ObjectUtils.notNull(myPsiDocManager.getPsiFile(document)).getVirtualFile());
if (m != null && !myChangedModules.contains(m)) unCommittedModules.add(m);
if (m != null) dirtyModules.add(m);
}
GlobalSearchScope dirtyCommittedScope = CachedValuesManager.getManager(myService.getProject()).getCachedValue(this, () ->
CachedValueProvider.Result.create(addModulesWithDependentToScope(myChangedModules, EMPTY_SCOPE), PsiModificationTracker.MODIFICATION_COUNT, myService));
if (unCommittedModules.isEmpty()) {
return dirtyCommittedScope;
}
return addModulesWithDependentToScope(unCommittedModules, dirtyCommittedScope);
return dirtyModules.stream().map(Module::getModuleWithDependentsScope).reduce(GlobalSearchScope.EMPTY_SCOPE, (s1, s2) -> s1.union(s2));
}
}
@@ -146,7 +143,7 @@ class DirtyModulesHolder extends UserDataHolderBase {
if (myCompilationPhase) {
myChangedModulesDuringCompilation.add(module);
} else {
myChangedModules.add(module);
myVFSChangedModules.add(module);
}
}
}
@@ -160,8 +157,4 @@ class DirtyModulesHolder extends UserDataHolderBase {
}
return null;
}
private static GlobalSearchScope addModulesWithDependentToScope(Collection<Module> modules, GlobalSearchScope baseScope) {
return modules.stream().map(Module::getModuleWithDependentsScope).reduce(baseScope, (s1, s2) -> s1.union(s2));
}
}

View File

@@ -66,40 +66,34 @@ public class BasicStepMethodFilter implements NamedMethodFilter {
}
public boolean locationMatches(final DebugProcessImpl process, final Location location) throws EvaluateException {
final Method method = location.method();
boolean lambdaMatched = false;
Method method = location.method();
String name = method.name();
if (!myTargetMethodName.equals(name)) {
if (LambdaMethodFilter.isLambdaName(name)) {
SourcePosition position = process.getPositionManager().getSourcePosition(location);
lambdaMatched = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
PsiElement psiMethod = DebuggerUtilsEx.getContainingMethod(position);
if (psiMethod instanceof PsiLambdaExpression) {
PsiType type = ((PsiLambdaExpression)psiMethod).getFunctionalInterfaceType();
PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(type);
if (type != null && interfaceMethod != null && myTargetMethodName.equals(interfaceMethod.getName())) {
try {
return type.getCanonicalText().equals(myDeclaringClassName.getName(process).replace('$', '.'));
}
catch (EvaluateException e) {
LOG.info(e);
}
return ApplicationManager.getApplication().runReadAction((Computable<Boolean>)() -> {
PsiElement psiMethod = DebuggerUtilsEx.getContainingMethod(position);
if (psiMethod instanceof PsiLambdaExpression) {
PsiType type = ((PsiLambdaExpression)psiMethod).getFunctionalInterfaceType();
PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(type);
if (type != null && interfaceMethod != null && myTargetMethodName.equals(interfaceMethod.getName())) {
try {
return type.getCanonicalText().equals(myDeclaringClassName.getName(process).replace('$', '.'));
}
catch (EvaluateException e) {
LOG.info(e);
}
}
return false;
}
return false;
});
}
if (!lambdaMatched) return false;
return false;
}
if (myTargetMethodSignature != null) {
if (!signatureMatches(method, myTargetMethodSignature.getName(process))) {
return false;
}
if (myTargetMethodSignature != null && !signatureMatches(method, myTargetMethodSignature.getName(process))) {
return false;
}
return lambdaMatched || DebuggerUtilsEx.isAssignableFrom(myDeclaringClassName.getName(process), location.declaringType());
return DebuggerUtilsEx.isAssignableFrom(myDeclaringClassName.getName(process), location.declaringType());
}
private static boolean signatureMatches(Method method, final String expectedSignature) throws EvaluateException {

View File

@@ -334,6 +334,8 @@ class SchemeManagerImpl<T : Scheme, MUTABLE_SCHEME : T>(val fileSpec: String,
removeExternalizableSchemes()
loadSchemes()
(processor as? LazySchemeProcessor)?.reloaded()
}
private fun removeExternalizableSchemes() {

View File

@@ -271,9 +271,9 @@ public class LayeredIcon extends JBUI.AuxScalableJBIcon {
@Override
public Icon scale(float scale) {
if (scale == 1f) return this;
if (scale == getScale()) return this;
setScale(scaleVal(scale, Scale.ARBITRARY));
setScale(scale);
if (myScaledIcons != null) Arrays.fill(myScaledIcons, null);
return this;
}

View File

@@ -57,9 +57,9 @@ public class RowIcon extends JBUI.AuxScalableJBIcon {
@Override
public Icon scale(float scale) {
if (scale == 1f) return this;
if (scale == getScale()) return this;
setScale(scaleVal(scale, Scale.ARBITRARY));
setScale(scale);
rescale();
return this;
}

View File

@@ -26,19 +26,20 @@ import org.jetbrains.annotations.NotNull;
public class ExtensionPointName<T> {
private final String myName;
public ExtensionPointName(@NonNls final String name) {
public ExtensionPointName(@NotNull @NonNls final String name) {
myName = name;
}
public static <T> ExtensionPointName<T> create(@NonNls final String name) {
@NotNull
public static <T> ExtensionPointName<T> create(@NotNull @NonNls final String name) {
return new ExtensionPointName<T>(name);
}
@NotNull
public String getName() {
return myName;
}
@Override
public String toString() {
return myName;
@@ -49,6 +50,7 @@ public class ExtensionPointName<T> {
return Extensions.getExtensions(this);
}
@NotNull
public T[] getExtensions(AreaInstance areaInstance) {
return Extensions.getExtensions(this, areaInstance);
}

View File

@@ -58,11 +58,11 @@ public class SizedIcon extends JBUI.ScalableJBIcon {
@Override
public Icon scale(float scale) {
if (scale == 1f) return this;
if (scale == getScale()) return this;
if (myDelegate instanceof ScalableIcon) {
setScale(scaleVal(scale, Scale.ARBITRARY));
myScaledDelegate = ((ScalableIcon)myDelegate).scale(getScale());
setScale(scale);
myScaledDelegate = ((ScalableIcon)myDelegate).scale(scale);
}
return this;
}

View File

@@ -135,6 +135,12 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Pers
return scheme.isEqualToBundled(bundledScheme);
}
@Override
public void reloaded() {
initEditableDefaultSchemesCopies();
initEditableBundledSchemesCopies();
}
}
mySchemeManager = schemeManagerFactory.create(FILE_SPEC, new EditorColorSchemeProcessor());

View File

@@ -419,7 +419,7 @@ public final class IdeKeyEventDispatcher implements Disposable {
if (SystemInfo.isMac) {
boolean keyTyped = e.getID() == KeyEvent.KEY_TYPED;
boolean hasMnemonicsInWindow = e.getID() == KeyEvent.KEY_PRESSED && hasMnemonicInWindow(focusOwner, e.getKeyCode()) ||
boolean hasMnemonicsInWindow = (e.getID() == KeyEvent.KEY_PRESSED) || (e.getID() == KeyEvent.KEY_RELEASED) && hasMnemonicInWindow(focusOwner, e.getKeyCode()) ||
keyTyped && hasMnemonicInWindow(focusOwner, e.getKeyChar());
boolean imEnabled = IdeEventQueue.getInstance().isInputMethodEnabled();

View File

@@ -29,7 +29,7 @@ import java.io.IOException
abstract class HttpRequestHandler {
companion object {
// Your handler will be instantiated on first user request
val EP_NAME = ExtensionPointName.create<HttpRequestHandler>("com.intellij.httpRequestHandler")!!
val EP_NAME = ExtensionPointName.create<HttpRequestHandler>("com.intellij.httpRequestHandler")
@JvmStatic
fun checkPrefix(uri: String, prefix: String): Boolean {

View File

@@ -63,7 +63,7 @@ class EditorColorSchemeTest {
assertThat(removeSchemeMetaInfo(schemeFile.readText())).isEqualTo("""
<scheme name="Foo" version="142" parent_scheme="Default">
<option name="EDITOR_FONT_SIZE" value="12" />
<option name="EDITOR_FONT_NAME" value="Menlo" />
<option name="EDITOR_FONT_NAME" value="${scheme.editorFontName}" />
</scheme>""".trimIndent())
assertThat(schemeFile.parent).hasChildren("Foo.icls")
}

View File

@@ -69,6 +69,9 @@ abstract class LazySchemeProcessor<SCHEME : Scheme, MUTABLE_SCHEME : SCHEME>(pri
open fun isSchemeDefault(scheme: MUTABLE_SCHEME, digest: ByteArray) = false
open fun isSchemeEqualToBundled(scheme: MUTABLE_SCHEME) = false
open fun reloaded() {
}
}
class DigestOutputStream(val digest: MessageDigest) : OutputStream() {

View File

@@ -580,12 +580,12 @@ public final class IconLoader {
@Override
public Icon scale(float scale) {
if (scale == 1f) return this;
if (scale == getScale()) return this;
getOrComputeIcon();
if (myIcon instanceof ScalableIcon) {
setScale(scaleVal(scale, Scale.ARBITRARY));
myIcon = ((ScalableIcon)myIcon).scale(getScale());
setScale(scale);
myIcon = ((ScalableIcon)myIcon).scale(scale);
}
return this;
}

View File

@@ -58,7 +58,7 @@ public class Junit5AssertionsConverterFixTest extends IGQuickFixesTestCase {
" public static void assertEquals(String message, Object expected, Object actual) {}" +
" public static void assertEquals(Object expected, Object actual) {}" +
" public static void fail(String message) {}" +
" public static <T> void assertThat(T actual, Matcher<? super T> matcher) {}" +
" public static <T> void assertThat(String reason, T actual, org.hamcrest.Matcher<? super T> matcher) {}" +
"}");
myFixture.addClass("package org.junit.jupiter.api;\n" +

View File

@@ -16,13 +16,12 @@
package org.jetbrains.plugins.groovy.transformations.indexedProperty
import com.intellij.psi.CommonClassNames.JAVA_UTIL_LIST
import com.intellij.psi.JavaPsiFacade
import com.intellij.psi.PsiArrayType
import com.intellij.psi.PsiClassType
import com.intellij.psi.PsiType
import com.intellij.psi.util.CachedValueProvider.Result
import com.intellij.psi.util.CachedValuesManager
import com.intellij.psi.util.InheritanceUtil
import com.intellij.psi.util.PsiUtil
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder
@@ -38,15 +37,7 @@ private fun doGetIndexedComponentType(field: GrField): PsiType? {
val fieldType = field.type
return when (fieldType) {
is PsiArrayType -> fieldType.componentType
is PsiClassType -> {
val facade = JavaPsiFacade.getInstance(field.project)
val listClass = facade.findClass(JAVA_UTIL_LIST, field.resolveScope) ?: return null
val typeParameter = listClass.typeParameters.singleOrNull() ?: return null
val resolveResult = fieldType.resolveGenerics()
if (!InheritanceUtil.isInheritorOrSelf(resolveResult.element, listClass, true)) return null
val typeParameterType = facade.elementFactory.createType(typeParameter)
resolveResult.substitutor.substitute(typeParameterType)
}
is PsiClassType -> PsiUtil.substituteTypeParameter(fieldType, JAVA_UTIL_LIST, 0, true)
else -> null
}
}

View File

@@ -87,6 +87,7 @@ class A {
@IndexedProperty List<String> stringList
@IndexedProperty Double[] doubleArray
@IndexedProperty long[] primitiveArray
@IndexedProperty <error descr="Property is not indexable. Type must be array or list but found Collection<Number>">Collection<Number></error> numberCollection
@IndexedProperty <error descr="Property is not indexable. Type must be array or list but found Object">untyped</error>
@IndexedProperty <error descr="Property is not indexable. Type must be array or list but found Integer">Integer</error> nonIndexable
private <error descr="@IndexedProperty is applicable to properties only">@IndexedProperty</error> explicitVisibility

View File

@@ -114,17 +114,22 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent
private MavenWorkspaceSettings myWorkspaceSettings;
private MavenMergingUpdateQueue mySaveQueue;
private static final int SAVE_DELAY = 1000;
public static MavenProjectsManager getInstance(Project p) {
return p.getComponent(MavenProjectsManager.class);
}
public MavenProjectsManager(Project project) {
super(project);
myEmbeddersManager = new MavenEmbeddersManager(myProject);
myEmbeddersManager = new MavenEmbeddersManager(project);
myModificationTracker = new MavenModificationTracker(this);
myInitializationAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, project);
mySaveQueue = new MavenMergingUpdateQueue("Maven save queue", SAVE_DELAY, !isUnitTestMode(), null);
}
@Override
public MavenProjectsManagerState getState() {
if (isInitialized()) {
applyTreeToState();
@@ -132,6 +137,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent
return myState;
}
@Override
public void loadState(MavenProjectsManagerState state) {
myState = state;
if (isInitialized()) {
@@ -140,6 +146,12 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent
}
}
@Override
public void disposeComponent() {
super.disposeComponent();
Disposer.dispose(mySaveQueue);
}
public ModificationTracker getModificationTracker() {
return myModificationTracker;
}
@@ -324,14 +336,20 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent
myProjectsTree.setIgnoredFilesPatterns(myState.ignoredPathMasks);
}
@Override
public void save() {
if (myProjectsTree != null) {
try {
myProjectsTree.save(getProjectsTreeFile());
}
catch (IOException e) {
MavenLog.LOG.info(e);
}
mySaveQueue.queue(new Update(MavenProjectsManager.this) {
@Override
public void run() {
try {
myProjectsTree.save(getProjectsTreeFile());
}
catch (IOException e) {
MavenLog.LOG.info(e);
}
}
});
}
}
@@ -507,6 +525,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent
myFoldersResolvingProcessor.stop();
myArtifactsDownloadingProcessor.stop();
myPostProcessor.stop();
mySaveQueue.flush();
if (isUnitTestMode()) {
FileUtil.delete(getProjectsTreesDir());

View File

@@ -182,30 +182,32 @@ public class PythonConsoleView extends LanguageConsoleImpl implements Observable
@Override
public void executeCode(final @NotNull String code, @Nullable final Editor editor) {
myInitialized.doWhenDone(() ->
ProgressManager.getInstance().run(new Task.Backgroundable(null, "Executing Code in Console...", false) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
long time = System.currentTimeMillis();
while (!myExecuteActionHandler.isEnabled() || !myExecuteActionHandler.canExecuteNow()) {
if (indicator.isCanceled()) {
break;
}
if (System.currentTimeMillis() - time > 1000) {
if (editor != null) {
UIUtil.invokeLaterIfNeeded(
() -> HintManager.getInstance()
.showErrorHint(editor, myExecuteActionHandler.getCantExecuteMessage()));
}
return;
}
TimeoutUtil.sleep(300);
}
if (!indicator.isCanceled()) {
executeInConsole(code);
}
}
}));
myInitialized.doWhenDone(
() ->
ProgressManager.getInstance().run(new Task.Backgroundable(null, "Executing Code in Console...", false) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
long time = System.currentTimeMillis();
while (!myExecuteActionHandler.isEnabled() || !myExecuteActionHandler.canExecuteNow()) {
if (indicator.isCanceled()) {
break;
}
if (System.currentTimeMillis() - time > 1000) {
if (editor != null) {
UIUtil.invokeLaterIfNeeded(
() -> HintManager.getInstance()
.showErrorHint(editor, myExecuteActionHandler.getCantExecuteMessage()));
}
return;
}
TimeoutUtil.sleep(300);
}
if (!indicator.isCanceled()) {
executeInConsole(code);
}
}
})
);
}

View File

@@ -39,7 +39,7 @@ public class PythonConsoleTest extends PyEnvTestCase {
@Override
public void testing() throws Exception {
exec("if True:\n" +
" x=1\n" +
" x=1\n" +
"y=x+100\n" +
"for i in range(1):\n" +
" print(y)\n");
@@ -86,10 +86,8 @@ public class PythonConsoleTest extends PyEnvTestCase {
public void testing() throws Exception {
exec("x = 96");
exec("x +=1");
exec("if True:");
exec(" print(x)");
exec("");
exec("");
exec("if True:\n" +
" print(x)\n");
waitForOutput("97");
}
});

View File

@@ -324,6 +324,9 @@ public class PyConsoleTask extends PyExecutionFixtureTestTask {
myConsoleView.executeInConsole(command);
}
});
Assert.assertTrue(String.format("Command execution wasn't finished: `%s` \n" +
"Output: %s", command, output()), waitFor(myCommandSemaphore));
myCommandSemaphore.release();
}
protected boolean hasValue(String varName, String value) throws PyDebuggerException {