mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git@git.labs.intellij.net:idea/community
This commit is contained in:
@@ -67,7 +67,7 @@ def wire_build_date(String buildNumber) {
|
||||
target('default': 'The default target') {
|
||||
depends(compile)
|
||||
layoutAll(
|
||||
buildNumber: "IC-98.SNAPSHOT",
|
||||
buildNumber: "IC-100.SNAPSHOT",
|
||||
version: "IdeaX",
|
||||
system_selector: "IntelliJIdeaCE10",
|
||||
jdk_req: "1.6*",
|
||||
|
||||
@@ -17,8 +17,10 @@ package com.intellij.execution.junit2.segments;
|
||||
|
||||
import com.intellij.execution.junit.SegmentedInputStreamReader;
|
||||
import com.intellij.execution.junit2.SegmentedInputStream;
|
||||
import com.intellij.execution.testframework.Printable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.rt.execution.junit.segments.PacketProcessor;
|
||||
|
||||
import java.io.InputStream;
|
||||
@@ -31,6 +33,8 @@ import java.nio.charset.Charset;
|
||||
public class Extractor {
|
||||
private DeferredActionsQueue myFulfilledWorkGate = null;
|
||||
private final SegmentedInputStream myStream;
|
||||
private OutputPacketProcessor myEventsDispatcher;
|
||||
private static final Logger LOG = Logger.getInstance("#" + Extractor.class.getName());
|
||||
|
||||
public Extractor(final InputStream stream, final Charset charset) {
|
||||
myStream = new SegmentedInputStream(stream, charset);
|
||||
@@ -54,7 +58,7 @@ public class Extractor {
|
||||
queue.setDispactchListener(listener);
|
||||
}
|
||||
};
|
||||
myStream.setEventsDispatcher(new PacketProcessor() {
|
||||
myEventsDispatcher = new OutputPacketProcessor() {
|
||||
public void processPacket(final String packet) {
|
||||
myFulfilledWorkGate.addLast(new Runnable() {
|
||||
public void run() {
|
||||
@@ -62,7 +66,22 @@ public class Extractor {
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void processOutput(final Printable printable) {
|
||||
LOG.assertTrue(packetProcessor instanceof OutputPacketProcessor);
|
||||
myFulfilledWorkGate.addLast(new Runnable() {
|
||||
public void run() {
|
||||
((OutputPacketProcessor)packetProcessor).processOutput(printable);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
myStream.setEventsDispatcher(myEventsDispatcher);
|
||||
}
|
||||
|
||||
public OutputPacketProcessor getEventsDispatcher() {
|
||||
return myEventsDispatcher;
|
||||
}
|
||||
|
||||
public Reader createReader() {
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.junit2.segments;
|
||||
|
||||
import com.intellij.execution.testframework.Printable;
|
||||
import com.intellij.rt.execution.junit.segments.PacketProcessor;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: 12/6/10
|
||||
*/
|
||||
public interface OutputPacketProcessor extends PacketProcessor{
|
||||
void processOutput(Printable printable);
|
||||
}
|
||||
@@ -27,6 +27,7 @@
|
||||
<orderEntry type="module" module-name="icons" />
|
||||
<orderEntry type="library" name="jcip" level="project" />
|
||||
<orderEntry type="library" name="Groovy" level="project" />
|
||||
<orderEntry type="library" name="Guava" level="project" />
|
||||
</component>
|
||||
<component name="copyright">
|
||||
<Base>
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.java.stubs.PsiMethodStub;
|
||||
import com.intellij.psi.impl.source.tree.ChildRole;
|
||||
import com.intellij.util.PatchedSoftReference;
|
||||
@@ -33,7 +34,7 @@ public class PsiAnnotationMethodImpl extends PsiMethodImpl implements PsiAnnotat
|
||||
private PatchedSoftReference<PsiAnnotationMemberValue> myCachedDefaultValue = null;
|
||||
|
||||
public PsiAnnotationMethodImpl(final PsiMethodStub stub) {
|
||||
super(stub);
|
||||
super(stub, JavaStubElementTypes.ANNOTATION_METHOD);
|
||||
}
|
||||
|
||||
public PsiAnnotationMethodImpl(final ASTNode node) {
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiClassImplUtil;
|
||||
import com.intellij.psi.impl.PsiSuperMethodImplUtil;
|
||||
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.java.stubs.PsiClassStub;
|
||||
import com.intellij.psi.impl.source.parsing.Parsing;
|
||||
import com.intellij.psi.impl.source.tree.ChildRole;
|
||||
@@ -35,7 +36,7 @@ public class PsiAnonymousClassImpl extends PsiClassImpl implements PsiAnonymousC
|
||||
private PatchedSoftReference<PsiClassType> myCachedBaseType = null;
|
||||
|
||||
public PsiAnonymousClassImpl(final PsiClassStub stub) {
|
||||
super(stub);
|
||||
super(stub, JavaStubElementTypes.ANONYMOUS_CLASS);
|
||||
}
|
||||
|
||||
public PsiAnonymousClassImpl(final ASTNode node) {
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.intellij.psi.impl.InheritanceImplUtil;
|
||||
import com.intellij.psi.impl.PsiClassImplUtil;
|
||||
import com.intellij.psi.impl.PsiImplUtil;
|
||||
import com.intellij.psi.impl.PsiSuperMethodImplUtil;
|
||||
import com.intellij.psi.impl.java.stubs.JavaClassElementType;
|
||||
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.java.stubs.PsiClassStub;
|
||||
import com.intellij.psi.impl.light.LightMethod;
|
||||
@@ -73,7 +72,7 @@ public class PsiClassImpl extends JavaStubPsiElement<PsiClassStub<?>> implements
|
||||
@NonNls private static final String VALUE_OF_METHOD = "valueOf";
|
||||
|
||||
public PsiClassImpl(final PsiClassStub stub) {
|
||||
this(stub, typeForClass(stub.isAnonymous(), stub.isEnumConstantInitializer()));
|
||||
this(stub, JavaStubElementTypes.CLASS);
|
||||
}
|
||||
|
||||
protected PsiClassImpl(final PsiClassStub stub, final IStubElementType type) {
|
||||
@@ -84,12 +83,6 @@ public class PsiClassImpl extends JavaStubPsiElement<PsiClassStub<?>> implements
|
||||
super(node);
|
||||
}
|
||||
|
||||
public static JavaClassElementType typeForClass(final boolean anonymous, final boolean enumConst) {
|
||||
return enumConst
|
||||
? JavaStubElementTypes.ENUM_CONSTANT_INITIALIZER
|
||||
: anonymous ? JavaStubElementTypes.ANONYMOUS_CLASS : JavaStubElementTypes.CLASS;
|
||||
}
|
||||
|
||||
public void subtreeChanged() {
|
||||
dropCaches();
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.psi.impl.source;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.java.stubs.PsiClassStub;
|
||||
import com.intellij.psi.impl.light.LightClassReference;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -27,14 +28,13 @@ public class PsiEnumConstantInitializerImpl extends PsiClassImpl implements PsiE
|
||||
private PsiClassType myCachedBaseType = null;
|
||||
|
||||
public PsiEnumConstantInitializerImpl(final PsiClassStub stub) {
|
||||
super(stub);
|
||||
super(stub, JavaStubElementTypes.ENUM_CONSTANT_INITIALIZER);
|
||||
}
|
||||
|
||||
public PsiEnumConstantInitializerImpl(final ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
|
||||
protected Object clone() {
|
||||
PsiEnumConstantInitializerImpl clone = (PsiEnumConstantInitializerImpl)super.clone();
|
||||
clone.myCachedBaseType = null;
|
||||
@@ -56,7 +56,6 @@ public class PsiEnumConstantInitializerImpl extends PsiClassImpl implements PsiE
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public PsiJavaCodeReferenceElement getBaseClassReference() {
|
||||
PsiClass containingClass = getBaseClass();
|
||||
|
||||
@@ -19,9 +19,9 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiImportStatementBase;
|
||||
import com.intellij.psi.PsiJavaCodeReferenceElement;
|
||||
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.java.stubs.PsiImportStatementStub;
|
||||
import com.intellij.psi.impl.source.tree.ChildRole;
|
||||
import com.intellij.psi.stubs.IStubElementType;
|
||||
|
||||
/**
|
||||
* @author dsl
|
||||
@@ -29,8 +29,8 @@ import com.intellij.psi.impl.source.tree.ChildRole;
|
||||
public abstract class PsiImportStatementBaseImpl extends JavaStubPsiElement<PsiImportStatementStub> implements PsiImportStatementBase{
|
||||
public static final PsiImportStatementBaseImpl[] EMPTY_ARRAY = new PsiImportStatementBaseImpl[0];
|
||||
|
||||
protected PsiImportStatementBaseImpl(final PsiImportStatementStub stub) {
|
||||
super(stub, stub.isStatic() ? JavaStubElementTypes.IMPORT_STATIC_STATEMENT : JavaStubElementTypes.IMPORT_STATEMENT);
|
||||
protected PsiImportStatementBaseImpl(final PsiImportStatementStub stub, final IStubElementType type) {
|
||||
super(stub, type);
|
||||
}
|
||||
|
||||
protected PsiImportStatementBaseImpl(final ASTNode node) {
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.psi.impl.source;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.java.stubs.PsiImportStatementStub;
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -30,7 +31,7 @@ public class PsiImportStatementImpl extends PsiImportStatementBaseImpl implement
|
||||
};
|
||||
|
||||
public PsiImportStatementImpl(final PsiImportStatementStub stub) {
|
||||
super(stub);
|
||||
super(stub, JavaStubElementTypes.IMPORT_STATEMENT);
|
||||
}
|
||||
|
||||
public PsiImportStatementImpl(final ASTNode node) {
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.psi.impl.source;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.java.stubs.PsiImportStatementStub;
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -31,7 +32,7 @@ public class PsiImportStaticStatementImpl extends PsiImportStatementBaseImpl imp
|
||||
};
|
||||
|
||||
public PsiImportStaticStatementImpl(final PsiImportStatementStub stub) {
|
||||
super(stub);
|
||||
super(stub, JavaStubElementTypes.IMPORT_STATIC_STATEMENT);
|
||||
}
|
||||
|
||||
public PsiImportStaticStatementImpl(final ASTNode node) {
|
||||
|
||||
@@ -28,7 +28,7 @@ public class PsiChangeTrackerTest extends IdeaTestCase {
|
||||
final VirtualFile testRoot = getTestRoot();
|
||||
final VirtualFile child = testRoot.findChild("PsiChangesTest.java");
|
||||
assert child != null : "Can't find PsiChangesTest.java";
|
||||
final PsiFile original = this.getPsiManager().findFile(child);
|
||||
final PsiFile original = getPsiManager().findFile(child);
|
||||
assert original != null : "Can't create PsiFile from VirtualFile " + child.getName();
|
||||
myOriginalFile = original;
|
||||
|
||||
|
||||
+9
-4
@@ -17,14 +17,13 @@
|
||||
package com.intellij.execution.configurations;
|
||||
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.JDOMExternalizable;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.*;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -85,7 +84,13 @@ public class RunConfigurationModule implements JDOMExternalizable {
|
||||
|
||||
@Nullable
|
||||
public Module findModule(final String moduleName) {
|
||||
return getModuleManager().findModuleByName(moduleName);
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<Module>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Module compute() {
|
||||
return getModuleManager().findModuleByName(moduleName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setModule(final Module module) {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface KillableProcess {
|
||||
boolean canKillProcess();
|
||||
|
||||
void killProcess();
|
||||
}
|
||||
@@ -17,20 +17,33 @@
|
||||
package com.intellij.execution.actions;
|
||||
|
||||
import com.intellij.execution.ExecutionManager;
|
||||
import com.intellij.execution.KillableProcess;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.execution.ui.RunContentManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class StopAction extends DumbAwareAction implements AnAction.TransparentUpdate {
|
||||
public static final Icon KILL_PROCESS_ICON = IconLoader.getIcon("/debugger/killProcess.png");
|
||||
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
final ProcessHandler processHandler = getProcessHandler(e);
|
||||
if(processHandler == null) return;
|
||||
|
||||
if (processHandler instanceof KillableProcess && processHandler.isProcessTerminating()) {
|
||||
((KillableProcess)processHandler).killProcess();
|
||||
return;
|
||||
}
|
||||
|
||||
if(processHandler.detachIsDefault()) {
|
||||
processHandler.detachProcess();
|
||||
} else {
|
||||
@@ -40,8 +53,24 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
|
||||
|
||||
public void update(final AnActionEvent e) {
|
||||
final ProcessHandler processHandler = getProcessHandler(e);
|
||||
boolean enable = processHandler != null && !processHandler.isProcessTerminating() && !processHandler.isProcessTerminated();
|
||||
e.getPresentation().setEnabled(enable);
|
||||
final Presentation presentation = e.getPresentation();
|
||||
|
||||
boolean enable = false;
|
||||
Icon icon = getTemplatePresentation().getIcon();
|
||||
String description = getTemplatePresentation().getDescription();
|
||||
if (processHandler != null && !processHandler.isProcessTerminated()) {
|
||||
if (!processHandler.isProcessTerminating()) {
|
||||
enable = true;
|
||||
}
|
||||
else if (processHandler instanceof KillableProcess && ((KillableProcess)processHandler).canKillProcess()) {
|
||||
enable = true;
|
||||
icon = KILL_PROCESS_ICON;
|
||||
description = "Kill process";
|
||||
}
|
||||
}
|
||||
presentation.setEnabled(enable);
|
||||
presentation.setIcon(icon);
|
||||
presentation.setDescription(description);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -1784,7 +1784,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
return;
|
||||
}
|
||||
|
||||
final int deferredOffset = myContentSize - consoleView.myDeferredUserInput.length();
|
||||
final int deferredOffset = myContentSize - consoleView.myDeferredOutput.length() - consoleView.myDeferredUserInput.length();
|
||||
if (offset > info.endOffset) {
|
||||
startOffset = info.endOffset;
|
||||
}
|
||||
@@ -1835,7 +1835,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
}
|
||||
if (consoleView.myDeferredUserInput.length() == 0) return;
|
||||
|
||||
final int deferredOffset = myContentSize - consoleView.myDeferredUserInput.length();
|
||||
final int deferredOffset = myContentSize - consoleView.myDeferredOutput.length() - consoleView.myDeferredUserInput.length();
|
||||
|
||||
startOffset = getStartOffset(start, info, deferredOffset);
|
||||
endOffset = getEndOffset(end, info);
|
||||
@@ -1883,7 +1883,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
if (info.contentType != ConsoleViewContentType.USER_INPUT) return;
|
||||
if (consoleView.myDeferredUserInput.length() == 0) return;
|
||||
|
||||
final int deferredOffset = myContentSize - consoleView.myDeferredUserInput.length();
|
||||
final int deferredOffset = myContentSize - consoleView.myDeferredOutput.length() - consoleView.myDeferredUserInput.length();
|
||||
startOffset = getStartOffset(offset, info, deferredOffset);
|
||||
endOffset = getEndOffset(offset + length, info);
|
||||
if (startOffset == -1 ||
|
||||
|
||||
@@ -170,15 +170,11 @@ public class CompositeElement extends TreeElement {
|
||||
|
||||
@NotNull
|
||||
public String getText() {
|
||||
char[] buffer = new char[getTextLength()];
|
||||
AstBufferUtil.toBuffer(this, buffer, 0);
|
||||
return new String(buffer);
|
||||
return new String(textToCharArray());
|
||||
}
|
||||
|
||||
public CharSequence getChars() {
|
||||
char[] buffer = new char[getTextLength()];
|
||||
AstBufferUtil.toBuffer(this, buffer, 0);
|
||||
return new CharArrayCharSequence(buffer);
|
||||
return new CharArrayCharSequence(textToCharArray());
|
||||
}
|
||||
|
||||
public int getNotCachedLength() {
|
||||
@@ -220,7 +216,7 @@ public class CompositeElement extends TreeElement {
|
||||
return curOffset;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public final PsiElement findChildByRoleAsPsiElement(int role) {
|
||||
ASTNode element = findChildByRole(role);
|
||||
if (element == null) return null;
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.intellij.util.io.DataInputOutputUtil;
|
||||
import gnu.trove.TIntArrayList;
|
||||
import gnu.trove.TObjectIntHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
@@ -52,6 +53,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
@State(
|
||||
@@ -64,6 +66,7 @@ import java.util.concurrent.locks.Lock;
|
||||
}
|
||||
)
|
||||
public class StubIndexImpl extends StubIndex implements ApplicationComponent, PersistentStateComponent<StubIndexState> {
|
||||
private static final AtomicReference<Boolean> ourForcedClean = new AtomicReference<Boolean>(null);
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.stubs.StubIndexImpl");
|
||||
private final Map<StubIndexKey<?,?>, MyIndex<?>> myIndices = new HashMap<StubIndexKey<?,?>, MyIndex<?>>();
|
||||
private final TObjectIntHashMap<ID<?, ?>> myIndexIdToVersionMap = new TObjectIntHashMap<ID<?, ?>>();
|
||||
@@ -71,19 +74,29 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
|
||||
private StubIndexState myPreviouslyRegistered;
|
||||
|
||||
public StubIndexImpl(FileBasedIndex fileBasedIndex /* need this to ensure initialization order*/ ) throws IOException {
|
||||
final boolean forceClean = Boolean.TRUE == ourForcedClean.getAndSet(Boolean.FALSE);
|
||||
|
||||
final StubIndexExtension<?, ?>[] extensions = Extensions.getExtensions(StubIndexExtension.EP_NAME);
|
||||
boolean needRebuild = false;
|
||||
for (StubIndexExtension extension : extensions) {
|
||||
//noinspection unchecked
|
||||
needRebuild |= registerIndexer(extension);
|
||||
needRebuild |= registerIndexer(extension, forceClean);
|
||||
}
|
||||
if (needRebuild) {
|
||||
requestRebuild();
|
||||
}
|
||||
dropUnregisteredIndices();
|
||||
}
|
||||
|
||||
private <K> boolean registerIndexer(final StubIndexExtension<K, ?> extension) throws IOException {
|
||||
|
||||
@Nullable
|
||||
public static StubIndexImpl getInstanceOrInvalidate() {
|
||||
if (ourForcedClean.compareAndSet(null, Boolean.TRUE)) {
|
||||
return null;
|
||||
}
|
||||
return (StubIndexImpl)getInstance();
|
||||
}
|
||||
|
||||
private <K> boolean registerIndexer(final StubIndexExtension<K, ?> extension, final boolean forceClean) throws IOException {
|
||||
final StubIndexKey<K, ?> indexKey = extension.getKey();
|
||||
final int version = extension.getVersion();
|
||||
myIndexIdToVersionMap.put(indexKey, version);
|
||||
@@ -91,10 +104,10 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
|
||||
final boolean versionFileExisted = versionFile.exists();
|
||||
final File indexRootDir = IndexInfrastructure.getIndexRootDir(indexKey);
|
||||
boolean needRebuild = false;
|
||||
if (IndexInfrastructure.versionDiffers(versionFile, version)) {
|
||||
if (forceClean || IndexInfrastructure.versionDiffers(versionFile, version)) {
|
||||
final String[] children = indexRootDir.list();
|
||||
// rebuild only if there exists what to rebuild
|
||||
needRebuild = versionFileExisted || children != null && children.length > 0;
|
||||
needRebuild = !forceClean && (versionFileExisted || children != null && children.length > 0);
|
||||
if (needRebuild) {
|
||||
LOG.info("Version has changed for stub index " + extension.getKey() + ". The index will be rebuilt.");
|
||||
}
|
||||
|
||||
@@ -370,19 +370,25 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi
|
||||
}
|
||||
|
||||
public void clear() throws StorageException {
|
||||
final StubIndexImpl stubIndex = getStubIndex();
|
||||
final StubIndexImpl stubIndex = StubIndexImpl.getInstanceOrInvalidate();
|
||||
try {
|
||||
for (StubIndexKey key : stubIndex.getAllStubIndexKeys()) {
|
||||
stubIndex.getWriteLock(key).lock();
|
||||
if (stubIndex != null) {
|
||||
for (StubIndexKey key : stubIndex.getAllStubIndexKeys()) {
|
||||
stubIndex.getWriteLock(key).lock();
|
||||
}
|
||||
}
|
||||
getWriteLock().lock();
|
||||
stubIndex.clearAllIndices();
|
||||
if (stubIndex != null) {
|
||||
stubIndex.clearAllIndices();
|
||||
}
|
||||
super.clear();
|
||||
}
|
||||
finally {
|
||||
getWriteLock().unlock();
|
||||
for (StubIndexKey key : stubIndex.getAllStubIndexKeys()) {
|
||||
stubIndex.getWriteLock(key).unlock();
|
||||
if (stubIndex != null) {
|
||||
for (StubIndexKey key : stubIndex.getAllStubIndexKeys()) {
|
||||
stubIndex.getWriteLock(key).unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public final class FileContent extends UserDataHolderBase {
|
||||
public FileContent(@NotNull final VirtualFile file, @NotNull final byte[] content) {
|
||||
this(file);
|
||||
myContent = content;
|
||||
myCharset = LoadTextUtil.detectCharset(file, content);
|
||||
myCharset = LoadTextUtil.detectCharsetAndSetBOM(file, content);
|
||||
}
|
||||
|
||||
public FileContent(@NotNull final VirtualFile file) {
|
||||
|
||||
+6
-1
@@ -27,6 +27,7 @@ import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class LocalHistoryAction extends AnAction implements DumbAware {
|
||||
@Override
|
||||
@@ -39,7 +40,10 @@ public abstract class LocalHistoryAction extends AnAction implements DumbAware {
|
||||
}
|
||||
p.setVisible(true);
|
||||
p.setText(getText(e), true);
|
||||
p.setEnabled(isEnabled(getVcs(), getGateway(), getFile(e), e));
|
||||
|
||||
LocalHistoryFacade vcs = getVcs();
|
||||
IdeaGateway gateway = getGateway();
|
||||
p.setEnabled(vcs != null && gateway != null && isEnabled(vcs, gateway, getFile(e), e));
|
||||
}
|
||||
|
||||
protected String getText(AnActionEvent e) {
|
||||
@@ -58,6 +62,7 @@ public abstract class LocalHistoryAction extends AnAction implements DumbAware {
|
||||
return LocalHistoryImpl.getInstanceImpl().getGateway();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected VirtualFile getFile(AnActionEvent e) {
|
||||
VirtualFile[] ff = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY);
|
||||
if (ff == null || ff.length == 0) return null;
|
||||
|
||||
@@ -760,11 +760,11 @@ public class PluginManager {
|
||||
ourBuildNumber = BuildNumber.fromString(new String(FileUtil.loadFileText(buildTxtFile)).trim());
|
||||
}
|
||||
else {
|
||||
ourBuildNumber = BuildNumber.fromString("98.SNAPSHOT");
|
||||
ourBuildNumber = BuildNumber.fromString("100.SNAPSHOT");
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
ourBuildNumber = BuildNumber.fromString("98.SNAPSHOT");
|
||||
ourBuildNumber = BuildNumber.fromString("100.SNAPSHOT");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.openapi.wm.ex.WindowManagerEx;
|
||||
import com.intellij.util.KeyedLazyInstanceEP;
|
||||
import com.intellij.util.StringSetSpinAllocator;
|
||||
import com.intellij.util.containers.WeakHashMap;
|
||||
import com.intellij.util.containers.WeakValueHashMap;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -299,7 +299,7 @@ public class DataManagerImpl extends DataManager implements ApplicationComponent
|
||||
// the weak reference. For example, Swing often remembers menu items
|
||||
// that have DataContext as a field.
|
||||
private final WeakReference<Component> myRef;
|
||||
private WeakHashMap<Key, Object> mySavedData;
|
||||
private WeakValueHashMap<Key, Object> mySavedData;
|
||||
|
||||
public MyDataContext(final Component component) {
|
||||
myEventCount = -1;
|
||||
@@ -375,9 +375,9 @@ public class DataManagerImpl extends DataManager implements ApplicationComponent
|
||||
getOrCreateMap().put(key, value);
|
||||
}
|
||||
|
||||
private WeakHashMap<Key, Object> getOrCreateMap() {
|
||||
private WeakValueHashMap<Key, Object> getOrCreateMap() {
|
||||
if (mySavedData == null) {
|
||||
mySavedData = new WeakHashMap<Key, Object>();
|
||||
mySavedData = new WeakValueHashMap<Key, Object>();
|
||||
}
|
||||
return mySavedData;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public final class LoadTextUtil {
|
||||
return Pair.create(result, detectedLineSeparator);
|
||||
}
|
||||
|
||||
public static Charset detectCharset(final VirtualFile virtualFile, final byte[] content) {
|
||||
private static Charset detectCharset(final VirtualFile virtualFile, final byte[] content) {
|
||||
Charset charset = dodetectCharset(virtualFile, content);
|
||||
charset = charset == null ? EncodingManager.getInstance().getDefaultCharset() : charset;
|
||||
if (virtualFile.getFileType() == StdFileTypes.PROPERTIES && EncodingManager.getInstance().isNative2AsciiForPropertiesFiles(virtualFile)) {
|
||||
@@ -104,6 +104,12 @@ public final class LoadTextUtil {
|
||||
return charset;
|
||||
}
|
||||
|
||||
public static Charset detectCharsetAndSetBOM(final VirtualFile virtualFile, final byte[] content) {
|
||||
Charset charset = detectCharset(virtualFile, content);
|
||||
detectAndSetBOM(virtualFile, content);
|
||||
return charset;
|
||||
}
|
||||
|
||||
private static Charset dodetectCharset(final VirtualFile virtualFile, final byte[] content) {
|
||||
EncodingManager settings = EncodingManager.getInstance();
|
||||
boolean shouldGuess = settings != null && settings.isUseUTFGuessing(virtualFile);
|
||||
@@ -133,7 +139,8 @@ public final class LoadTextUtil {
|
||||
return CharsetToolkit.forName(charsetName);
|
||||
}
|
||||
|
||||
private static int skipBOM(final VirtualFile virtualFile, byte[] content) {
|
||||
// returns offset of the BOM end
|
||||
private static int detectAndSetBOM(final VirtualFile virtualFile, byte[] content) {
|
||||
final byte[] bom = getBOM(content, Patches.SUN_BUG_ID_4508058 ? virtualFile.getCharset() : null);
|
||||
if (bom.length != 0) {
|
||||
virtualFile.setBOM(bom);
|
||||
@@ -268,7 +275,7 @@ public final class LoadTextUtil {
|
||||
@NotNull
|
||||
public static CharSequence getTextByBinaryPresentation(@NotNull byte[] bytes, @NotNull VirtualFile virtualFile, final boolean rememberDetectedSeparators) {
|
||||
final Charset charset = detectCharset(virtualFile, bytes);
|
||||
final int offset = skipBOM(virtualFile, bytes);
|
||||
final int offset = detectAndSetBOM(virtualFile, bytes);
|
||||
|
||||
final Pair<CharSequence, String> result = convertBytes(bytes, charset, offset);
|
||||
if (rememberDetectedSeparators) {
|
||||
|
||||
+2
-2
@@ -271,6 +271,7 @@ public abstract class VirtualFileSystemEntry extends NewVirtualFile {
|
||||
if (isDirectory()) {
|
||||
Charset configured = EncodingManager.getInstance().getEncoding(this, true);
|
||||
charset = configured == null ? Charset.defaultCharset() : configured;
|
||||
setCharset(charset);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
@@ -282,7 +283,7 @@ public abstract class VirtualFileSystemEntry extends NewVirtualFile {
|
||||
// file has already been deleted from disk
|
||||
return super.getCharset();
|
||||
}
|
||||
charset = LoadTextUtil.detectCharset(this, content);
|
||||
charset = LoadTextUtil.detectCharsetAndSetBOM(this, content);
|
||||
}
|
||||
catch (FileTooBigException e) {
|
||||
return super.getCharset();
|
||||
@@ -291,7 +292,6 @@ public abstract class VirtualFileSystemEntry extends NewVirtualFile {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
setCharset(charset);
|
||||
}
|
||||
return charset;
|
||||
}
|
||||
|
||||
+2
-2
@@ -118,11 +118,11 @@ public class TestsOutputConsolePrinter implements Printer, Disposable {
|
||||
}
|
||||
|
||||
public boolean isCurrent(CompositePrintable printable) {
|
||||
return myCurrentTest == printable || (isRoot() && myUnboundOutputRoot != null);
|
||||
return myCurrentTest == printable || isRoot();
|
||||
}
|
||||
|
||||
private boolean isRoot() {
|
||||
return myCurrentTest.getParent() == myUnboundOutputRoot;
|
||||
return myCurrentTest != null && myCurrentTest.getParent() == myUnboundOutputRoot;
|
||||
}
|
||||
|
||||
public void printHyperlink(final String text, final HyperlinkInfo info) {
|
||||
|
||||
@@ -26,7 +26,7 @@ public class BuildNumber implements Comparable<BuildNumber> {
|
||||
private final int myBaselineVersion;
|
||||
private final int myBuildNumber;
|
||||
private static final String BUILD_NUMBER = "__BUILD_NUMBER__";
|
||||
private static final int TOP_BASELINE_VERSION = 98;
|
||||
private static final int TOP_BASELINE_VERSION = 100;
|
||||
|
||||
public BuildNumber(String productCode, int baselineVersion, int buildNumber) {
|
||||
myProductCode = productCode;
|
||||
|
||||
@@ -534,6 +534,7 @@ public class FileUtil {
|
||||
return true;
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.info(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ public class SkipDefaultValuesSerializationFilters implements SerializationFilte
|
||||
private final Map<Class, Object> myDefaultBeans = new HashMap<Class, Object>();
|
||||
|
||||
public boolean accepts(final Accessor accessor, final Object bean) {
|
||||
if (bean == null) {
|
||||
return true;
|
||||
}
|
||||
Object defaultBean = getDefaultBean(bean);
|
||||
|
||||
final Object defValue = accessor.read(defaultBean);
|
||||
|
||||
+3
@@ -152,6 +152,9 @@ public class AnnotationUtilEx {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (parent instanceof PsiConditionalExpression && ((PsiConditionalExpression)parent).getCondition() == element) {
|
||||
return false;
|
||||
}
|
||||
else if (parent instanceof PsiReturnStatement) {
|
||||
final PsiMethod m = PsiTreeUtil.getParentOfType(parent, PsiMethod.class);
|
||||
if (m != null) {
|
||||
|
||||
+7
-8
@@ -65,7 +65,6 @@ public class ContextComputationProcessor {
|
||||
}
|
||||
|
||||
public void collectOperands(final PsiElement expression, final List<Object> result, final Ref<Boolean> unparsable) {
|
||||
final PsiElement firstChild;
|
||||
if (expression instanceof PsiParenthesizedExpression) {
|
||||
collectOperands(((PsiParenthesizedExpression)expression).getExpression(), result, unparsable);
|
||||
}
|
||||
@@ -93,17 +92,17 @@ public class ContextComputationProcessor {
|
||||
else if (PsiUtilEx.isStringOrCharacterLiteral(expression)) {
|
||||
result.add(expression);
|
||||
}
|
||||
else {
|
||||
else if (expression instanceof PsiExpression) {
|
||||
final SmartList<PsiExpression> uncomputables = new SmartList<PsiExpression>();
|
||||
final Object o = expression instanceof PsiExpression? myEvaluationHelper.computeExpression((PsiExpression)expression, uncomputables) : null;
|
||||
final Object o = myEvaluationHelper.computeExpression((PsiExpression)expression, uncomputables);
|
||||
addStringFragment(String.valueOf(o), result);
|
||||
if (uncomputables.size() > 0) {
|
||||
unparsable.set(Boolean.TRUE);
|
||||
}
|
||||
if (o == null) {
|
||||
result.add(expression);
|
||||
} else {
|
||||
addStringFragment(String.valueOf(o), result);
|
||||
}
|
||||
}
|
||||
else {
|
||||
unparsable.set(Boolean.TRUE);
|
||||
result.add(expression);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.lang.ant.dom;
|
||||
import com.intellij.codeInspection.ProblemHighlightType;
|
||||
import com.intellij.lang.ant.AntBundle;
|
||||
import com.intellij.lang.ant.validation.AntInspection;
|
||||
import com.intellij.psi.PsiPolyVariantReference;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.xml.XmlElement;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -98,7 +99,7 @@ public class AntResolveInspection extends AntInspection {
|
||||
if (processed != null && processed.contains(ref)) {
|
||||
continue;
|
||||
}
|
||||
if (ref.resolve() == null) {
|
||||
if (!isResolvable(ref)) {
|
||||
holder.createProblem(domElement, ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, antDomRef.getUnresolvedMessagePattern(), ref.getRangeInElement() /*todo add quickfixes*/);
|
||||
if (ref instanceof AntDomFileReference) {
|
||||
if (processed == null) {
|
||||
@@ -115,5 +116,13 @@ public class AntResolveInspection extends AntInspection {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static boolean isResolvable(PsiReference ref) {
|
||||
if (ref.resolve() != null) {
|
||||
return true;
|
||||
}
|
||||
if (ref instanceof PsiPolyVariantReference) {
|
||||
return ((PsiPolyVariantReference)ref).multiResolve(false).length > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ package org.jetbrains.plugins.github;
|
||||
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.CheckoutProvider;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -54,13 +56,17 @@ public class GithubCheckoutProvider implements CheckoutProvider {
|
||||
@Override
|
||||
public List<RepositoryInfo> compute() {
|
||||
ProgressManager.getInstance().getProgressIndicator().setText("Extracting info about available repositories");
|
||||
return GithubUtil.getAvailableRepos(settings.getLogin(), settings.getPassword());
|
||||
return GithubUtil.getAvailableRepos(settings.getLogin(), settings.getPassword(), false);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (GithubUtil.CancelledException e) {
|
||||
return;
|
||||
}
|
||||
if (availableRepos.isEmpty()){
|
||||
Messages.showErrorDialog(project, "You don't have any repository available on GitHub.", "Cannot clone");
|
||||
return;
|
||||
}
|
||||
Collections.sort(availableRepos, new Comparator<RepositoryInfo>() {
|
||||
@Override
|
||||
public int compare(final RepositoryInfo r1, final RepositoryInfo r2) {
|
||||
@@ -68,11 +74,20 @@ public class GithubCheckoutProvider implements CheckoutProvider {
|
||||
}
|
||||
});
|
||||
final GithubCloneProjectDialog checkoutDialog = new GithubCloneProjectDialog(project, availableRepos);
|
||||
// Change default directory to ~/work if exists
|
||||
final File work = new File(System.getProperty("user.home"), "work");
|
||||
if (work.exists() && work.isDirectory()){
|
||||
checkoutDialog.setSelectedPath(work.getPath());
|
||||
// Configure folder to select project to
|
||||
String clonePath = settings.getClonePath();
|
||||
final String homePath = System.getProperty("user.home");
|
||||
if (StringUtil.isEmpty(clonePath)) {
|
||||
clonePath = homePath;
|
||||
}
|
||||
else {
|
||||
final File file = new File(clonePath);
|
||||
if (!file.exists() || !file.isDirectory()){
|
||||
clonePath = homePath;
|
||||
}
|
||||
}
|
||||
settings.setClonePath(clonePath);
|
||||
checkoutDialog.setSelectedPath(clonePath);
|
||||
checkoutDialog.show();
|
||||
if (!checkoutDialog.isOK()) {
|
||||
return;
|
||||
|
||||
@@ -25,21 +25,24 @@ public class GithubSettings implements PersistentStateComponent<Element> {
|
||||
private static final String GITHUB_SETTINGS_TAG = "GithubSettings";
|
||||
private static final String LOGIN = "Login";
|
||||
private static final String PASSWORD = "Password";
|
||||
private static final String CLONE_PATH = "ClonePath";
|
||||
|
||||
private String myLogin;
|
||||
private String myPassword;
|
||||
private String myClonePath;
|
||||
|
||||
public static GithubSettings getInstance(){
|
||||
return ServiceManager.getService(GithubSettings.class);
|
||||
}
|
||||
|
||||
public Element getState() {
|
||||
if (StringUtil.isEmptyOrSpaces(myLogin) && StringUtil.isEmptyOrSpaces(myPassword)) {
|
||||
if (StringUtil.isEmptyOrSpaces(myLogin) && StringUtil.isEmptyOrSpaces(myPassword) && StringUtil.isEmpty(myClonePath)) {
|
||||
return null;
|
||||
}
|
||||
final Element element = new Element(GITHUB_SETTINGS_TAG);
|
||||
element.setAttribute(LOGIN, myLogin);
|
||||
element.setAttribute(PASSWORD, getEncodedPassword());
|
||||
element.setAttribute(CLONE_PATH, myClonePath);
|
||||
return element;
|
||||
}
|
||||
|
||||
@@ -60,6 +63,7 @@ public class GithubSettings implements PersistentStateComponent<Element> {
|
||||
try {
|
||||
setLogin(element.getAttributeValue(LOGIN));
|
||||
setEncodedPassword(element.getAttributeValue(PASSWORD));
|
||||
setClonePath(element.getAttributeValue(CLONE_PATH));
|
||||
}
|
||||
catch (Exception e) {
|
||||
// ignore
|
||||
@@ -81,4 +85,12 @@ public class GithubSettings implements PersistentStateComponent<Element> {
|
||||
public void setPassword(final String password) {
|
||||
myPassword = password;
|
||||
}
|
||||
|
||||
public String getClonePath() {
|
||||
return myClonePath;
|
||||
}
|
||||
|
||||
public void setClonePath(String clonePath) {
|
||||
myClonePath = clonePath;
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,6 @@ import git4idea.checkin.GitPushUtils;
|
||||
import git4idea.commands.*;
|
||||
import git4idea.i18n.GitBundle;
|
||||
import git4idea.ui.GitUIUtil;
|
||||
import org.jetbrains.plugins.github.ui.GithubLoginDialog;
|
||||
import org.jetbrains.plugins.github.ui.GithubShareDialog;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -83,21 +82,29 @@ public class GithubShareAction extends DumbAwareAction {
|
||||
}
|
||||
|
||||
BasicAction.saveAll();
|
||||
final GithubSettings settings = GithubSettings.getInstance();
|
||||
if (!GithubUtil.testConnection(settings.getLogin(), settings.getPassword())){
|
||||
final GithubLoginDialog dialog = new GithubLoginDialog(project);
|
||||
dialog.show();
|
||||
if (!dialog.isOK()) {
|
||||
return;
|
||||
}
|
||||
final List<RepositoryInfo> availableRepos = GithubUtil.getAvailableRepos(project, true);
|
||||
if (availableRepos == null){
|
||||
return;
|
||||
}
|
||||
|
||||
final HashSet<String> names = new HashSet<String>();
|
||||
for (RepositoryInfo info : GithubUtil.getAvailableRepos(settings.getLogin(), settings.getPassword())) {
|
||||
for (RepositoryInfo info : availableRepos) {
|
||||
names.add(info.getName());
|
||||
}
|
||||
|
||||
final boolean privateRepoAllowed = GithubUtil.isPrivateRepoAllowed(settings.getLogin(), settings.getPassword());
|
||||
final GithubSettings settings = GithubSettings.getInstance();
|
||||
final boolean privateRepoAllowed;
|
||||
try {
|
||||
privateRepoAllowed = GithubUtil.accessToGithubWithModalProgress(project, new Computable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
ProgressManager.getInstance().getProgressIndicator().setText("Trying to login to GitHub");
|
||||
return GithubUtil.isPrivateRepoAllowed(settings.getLogin(), settings.getPassword());
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (GithubUtil.CancelledException ex) {
|
||||
return;
|
||||
}
|
||||
final GithubShareDialog shareDialog = new GithubShareDialog(project, names, privateRepoAllowed);
|
||||
shareDialog.show();
|
||||
if (!shareDialog.isOK()) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.jetbrains.plugins.github;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
@@ -16,6 +17,8 @@ import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.github.ui.GithubLoginDialog;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
@@ -28,6 +31,7 @@ import java.util.List;
|
||||
public class GithubUtil {
|
||||
public static final String GITHUB_HOST = "https://github.com";
|
||||
private static final String API_URL = "/api/v2/xml";
|
||||
private static final Logger LOG = Logger.getInstance(GithubUtil.class.getName());
|
||||
|
||||
public static <T> T accessToGithubWithModalProgress(final Project project, final Computable<T> computable) throws CancelledException {
|
||||
final Ref<T> result = new Ref<T>();
|
||||
@@ -81,11 +85,16 @@ public class GithubUtil {
|
||||
return GITHUB_HOST + API_URL;
|
||||
}
|
||||
|
||||
public static List<RepositoryInfo> getAvailableRepos(final String login, final String password) {
|
||||
public static List<RepositoryInfo> getAvailableRepos(final String login, final String password, final boolean ownOnly) {
|
||||
try {
|
||||
final HttpMethod method = doREST(login, password, "/repos/watched/" + login, false);
|
||||
final String request = (ownOnly ? "/repos/show/" : "/repos/watched/") + login;
|
||||
final HttpMethod method = doREST(login, password, request, false);
|
||||
final InputStream stream = method.getResponseBodyAsStream();
|
||||
final Element element = new SAXBuilder(false).build(stream).getRootElement();
|
||||
if ("error".equals(element.getName())){
|
||||
LOG.warn("Got error element by request: " + request);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final List repositories = element.getChildren();
|
||||
final List<RepositoryInfo> result = new ArrayList<RepositoryInfo>();
|
||||
for (int i = 0; i < repositories.size(); i++) {
|
||||
@@ -102,9 +111,14 @@ public class GithubUtil {
|
||||
|
||||
public static boolean isPrivateRepoAllowed(final String login, final String password) {
|
||||
try {
|
||||
final HttpMethod method = doREST(login, password, "/user/show/" + login, false);
|
||||
final String request = "/user/show/" + login;
|
||||
final HttpMethod method = doREST(login, password, request, false);
|
||||
final InputStream stream = method.getResponseBodyAsStream();
|
||||
final Element element = new SAXBuilder(false).build(stream).getRootElement();
|
||||
if ("error".equals(element.getName())){
|
||||
LOG.warn("Got error element by request: " + request);
|
||||
return false;
|
||||
}
|
||||
final Element plan = element.getChild("plan");
|
||||
assert plan != null : "Authentification failed";
|
||||
final String privateRepos = plan.getChildText("private_repos");
|
||||
@@ -117,4 +131,48 @@ public class GithubUtil {
|
||||
}
|
||||
|
||||
public static class CancelledException extends RuntimeException {}
|
||||
|
||||
/**
|
||||
* Shows GitHub login settings if credentials are wrong or empty and return the list of all the watched repos by user
|
||||
* @param project
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
public static List<RepositoryInfo> getAvailableRepos(final Project project, final boolean ownOnly) {
|
||||
final GithubSettings settings = GithubSettings.getInstance();
|
||||
final boolean validCredentials;
|
||||
try {
|
||||
validCredentials = accessToGithubWithModalProgress(project, new Computable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
ProgressManager.getInstance().getProgressIndicator().setText("Trying to login to GitHub");
|
||||
return testConnection(settings.getLogin(), settings.getPassword());
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (CancelledException e) {
|
||||
return null;
|
||||
}
|
||||
if (!validCredentials){
|
||||
final GithubLoginDialog dialog = new GithubLoginDialog(project);
|
||||
dialog.show();
|
||||
if (!dialog.isOK()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// Otherwise our credentials are valid and they are successfully stored in settings
|
||||
try {
|
||||
return accessToGithubWithModalProgress(project, new Computable<List<RepositoryInfo>>() {
|
||||
@Override
|
||||
public List<RepositoryInfo> compute() {
|
||||
ProgressManager.getInstance().getProgressIndicator().setText("Extracting info about available repositories");
|
||||
return getAvailableRepos(settings.getLogin(), settings.getPassword(), ownOnly);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (CancelledException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.github.ui.GithubCloneProjectPane">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="402" height="92"/>
|
||||
<xy x="20" y="20" width="402" height="112"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -55,6 +55,11 @@
|
||||
<caretAspectRatio class="java.lang.Float" value="0.04"/>
|
||||
</clientProperties>
|
||||
</component>
|
||||
<vspacer id="f273c">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.github.ui.GithubSharePanel">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="376" height="98"/>
|
||||
@@ -61,6 +61,11 @@
|
||||
<text value="Private"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="18a1f">
|
||||
<constraints>
|
||||
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.execution.junit2.TestProxy;
|
||||
import com.intellij.execution.junit2.segments.DeferredActionsQueue;
|
||||
import com.intellij.execution.junit2.segments.DeferredActionsQueueImpl;
|
||||
import com.intellij.execution.junit2.segments.DispatchListener;
|
||||
import com.intellij.execution.junit2.segments.Extractor;
|
||||
import com.intellij.execution.junit2.ui.JUnitTreeConsoleView;
|
||||
import com.intellij.execution.junit2.ui.TestsPacketsReceiver;
|
||||
import com.intellij.execution.junit2.ui.actions.RerunFailedTestsAction;
|
||||
@@ -263,7 +264,7 @@ public abstract class TestObject implements JavaCommandLine {
|
||||
consoleView.attachToProcess(handler);
|
||||
unboundOutputRoot.setPrinter(consoleView.getPrinter());
|
||||
Disposer.register(consoleView, unboundOutputRoot);
|
||||
final TestsPacketsReceiver packetsReceiver = new TestsPacketsReceiver(consoleView) {
|
||||
final TestsPacketsReceiver packetsReceiver = new TestsPacketsReceiver(consoleView, unboundOutputRoot) {
|
||||
@Override
|
||||
public void notifyStart(TestProxy root) {
|
||||
super.notifyStart(root);
|
||||
@@ -309,20 +310,23 @@ public abstract class TestObject implements JavaCommandLine {
|
||||
public void onTextAvailable(final ProcessEvent event, final Key outputType) {
|
||||
final String text = event.getText();
|
||||
final ConsoleViewContentType consoleViewType = ConsoleViewContentType.getConsoleViewType(outputType);
|
||||
final Set<TestProxy> currentTests = packetsReceiver.getCurrentTests();
|
||||
final Printable printable = new Printable() {
|
||||
public void printOn(final Printer printer) {
|
||||
printer.print(text, consoleViewType);
|
||||
}
|
||||
};
|
||||
|
||||
if (!currentTests.isEmpty()) {
|
||||
for (TestProxy currentTest : currentTests) {
|
||||
currentTest.addLast(printable);
|
||||
}
|
||||
if (consoleViewType == ConsoleViewContentType.SYSTEM_OUTPUT) {
|
||||
unboundOutputRoot.addLast(printable);
|
||||
}
|
||||
else {
|
||||
unboundOutputRoot.addLast(printable);
|
||||
final Extractor extractor;
|
||||
if (consoleViewType == ConsoleViewContentType.ERROR_OUTPUT) {
|
||||
extractor = handler.getErr();
|
||||
}
|
||||
else {
|
||||
extractor = handler.getOut();
|
||||
}
|
||||
extractor.getEventsDispatcher().processOutput(printable);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -25,31 +25,36 @@ import com.intellij.execution.junit2.info.ClassBasedInfo;
|
||||
import com.intellij.execution.junit2.info.DisplayTestInfoExtractor;
|
||||
import com.intellij.execution.junit2.segments.InputObjectRegistry;
|
||||
import com.intellij.execution.junit2.segments.ObjectReader;
|
||||
import com.intellij.execution.junit2.segments.OutputPacketProcessor;
|
||||
import com.intellij.execution.junit2.states.*;
|
||||
import com.intellij.execution.junit2.ui.model.CompletionEvent;
|
||||
import com.intellij.execution.junit2.ui.model.JUnitListenersNotifier;
|
||||
import com.intellij.execution.junit2.ui.model.JUnitRunningModel;
|
||||
import com.intellij.execution.junit2.ui.properties.JUnitConsoleProperties;
|
||||
import com.intellij.execution.testframework.AbstractTestProxy;
|
||||
import com.intellij.execution.testframework.Printable;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.rt.execution.junit.segments.PacketProcessor;
|
||||
import com.intellij.rt.execution.junit.segments.PoolOfDelimiters;
|
||||
import com.intellij.rt.execution.junit.states.PoolOfTestStates;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class TestsPacketsReceiver implements PacketProcessor, Disposable {
|
||||
public class TestsPacketsReceiver implements OutputPacketProcessor, Disposable {
|
||||
|
||||
public static final Map<Integer, StateChanger> STATE_CLASSES = new HashMap<Integer, StateChanger>();
|
||||
private Map<String, TestProxy> myKnownDynamicParents;
|
||||
private TestProxy myUnboundOutput;
|
||||
|
||||
static {
|
||||
mapClass(PoolOfTestStates.RUNNING_INDEX, new RunningStateSetter());
|
||||
@@ -74,18 +79,13 @@ public class TestsPacketsReceiver implements PacketProcessor, Disposable {
|
||||
private final JUnitConsoleProperties myConsoleProperties;
|
||||
|
||||
|
||||
public TestsPacketsReceiver(final JUnitTreeConsoleView consoleView) {
|
||||
public TestsPacketsReceiver(final JUnitTreeConsoleView consoleView, TestProxy unboundOutput) {
|
||||
myUnboundOutput = unboundOutput;
|
||||
myObjectRegistry = new InputObjectRegistry();
|
||||
myConsoleProperties = (JUnitConsoleProperties)consoleView.getProperties();
|
||||
Disposer.register(consoleView, this);
|
||||
}
|
||||
|
||||
public Set<TestProxy> getCurrentTests() {
|
||||
synchronized (myCurrentTests) {
|
||||
return new HashSet<TestProxy>(myCurrentTests);
|
||||
}
|
||||
}
|
||||
|
||||
public void processPacket(final String packet) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
|
||||
@@ -110,6 +110,18 @@ public class TestsPacketsReceiver implements PacketProcessor, Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOutput(Printable printable) {
|
||||
synchronized (myCurrentTests) {
|
||||
if (myCurrentTests.isEmpty()) {
|
||||
myUnboundOutput.addLast(printable);
|
||||
} else {
|
||||
for (TestProxy currentTest : myCurrentTests) {
|
||||
currentTest.addLast(printable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyStart(TestProxy root) {
|
||||
myModel = new JUnitRunningModel(root, myConsoleProperties);
|
||||
|
||||
+2
@@ -261,6 +261,8 @@ public class MavenServicesConfigurable extends BaseConfigurable implements Searc
|
||||
}
|
||||
|
||||
public void disposeUIResources() {
|
||||
if (myRepaintTimer == null) return; // has not yet been initialized and reset
|
||||
|
||||
myRepaintTimer.removeActionListener(myTimerListener);
|
||||
myRepaintTimer.stop();
|
||||
Disposer.dispose(myUpdatingIcon);
|
||||
|
||||
+18
-12
@@ -46,6 +46,7 @@ import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.ui.update.Update;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.idea.maven.model.MavenConstants;
|
||||
import org.jetbrains.idea.maven.utils.MavenMergingUpdateQueue;
|
||||
@@ -168,25 +169,30 @@ public class MavenProjectsManagerWatcher {
|
||||
|
||||
File parentFile = settingsFile.getParentFile();
|
||||
if (parentFile != null) {
|
||||
myWatchedRoots.add(LocalFileSystem.getInstance().addRootToWatch(getNormalizedPath(parentFile), false));
|
||||
String path = getNormalizedPath(parentFile);
|
||||
if (path != null) {
|
||||
myWatchedRoots.add(LocalFileSystem.getInstance().addRootToWatch(path, false));
|
||||
}
|
||||
}
|
||||
|
||||
String url = VfsUtil.pathToUrl(getNormalizedPath(settingsFile));
|
||||
mySettingsFilesPointers
|
||||
.add(VirtualFilePointerManager.getInstance().create(url, myChangedDocumentsQueue, new VirtualFilePointerListener() {
|
||||
public void beforeValidityChanged(VirtualFilePointer[] pointers) {
|
||||
}
|
||||
String path = getNormalizedPath(settingsFile);
|
||||
if (path != null) {
|
||||
String url = VfsUtil.pathToUrl(path);
|
||||
mySettingsFilesPointers.add(
|
||||
VirtualFilePointerManager.getInstance().create(url, myChangedDocumentsQueue, new VirtualFilePointerListener() {
|
||||
public void beforeValidityChanged(VirtualFilePointer[] pointers) {
|
||||
}
|
||||
|
||||
public void validityChanged(VirtualFilePointer[] pointers) {
|
||||
}
|
||||
}));
|
||||
public void validityChanged(VirtualFilePointer[] pointers) {
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getNormalizedPath(@NotNull File settingsFile) {
|
||||
String canonized = PathUtil.getCanonicalPath(settingsFile.getAbsolutePath());
|
||||
// todo hook for IDEADEV-40110
|
||||
assert canonized != null : "cannot normalize path for: " + settingsFile;
|
||||
return FileUtil.toSystemIndependentName(canonized);
|
||||
return canonized == null ? null : FileUtil.toSystemIndependentName(canonized);
|
||||
}
|
||||
|
||||
public synchronized void stop() {
|
||||
|
||||
+12
-9
@@ -54,11 +54,12 @@ public class MavenProjectBuilder extends ProjectImportBuilder<MavenProject> {
|
||||
private List<String> mySelectedProfiles = new ArrayList<String>();
|
||||
|
||||
private MavenProjectsTree myMavenProjectTree;
|
||||
private List<MavenProject> mySelectedProjects;
|
||||
|
||||
private boolean myOpenModulesConfigurator;
|
||||
}
|
||||
|
||||
private Parameters myParamaters;
|
||||
private Parameters myParameters;
|
||||
|
||||
public String getName() {
|
||||
return ProjectBundle.message("maven.name");
|
||||
@@ -69,7 +70,7 @@ public class MavenProjectBuilder extends ProjectImportBuilder<MavenProject> {
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
myParamaters = null;
|
||||
myParameters = null;
|
||||
super.cleanup();
|
||||
}
|
||||
|
||||
@@ -79,10 +80,10 @@ public class MavenProjectBuilder extends ProjectImportBuilder<MavenProject> {
|
||||
}
|
||||
|
||||
private Parameters getParameters() {
|
||||
if (myParamaters == null) {
|
||||
myParamaters = new Parameters();
|
||||
if (myParameters == null) {
|
||||
myParameters = new Parameters();
|
||||
}
|
||||
return myParamaters;
|
||||
return myParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,8 +102,7 @@ public class MavenProjectBuilder extends ProjectImportBuilder<MavenProject> {
|
||||
settings.importingSettings = getImportingSettings();
|
||||
|
||||
MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
|
||||
List<VirtualFile> files = getParameters().myMavenProjectTree.getRootProjectsFiles();
|
||||
manager.addManagedFilesWithProfiles(files, getSelectedProfiles());
|
||||
manager.addManagedFilesWithProfiles(MavenUtil.collectFiles(getParameters().mySelectedProjects), getSelectedProfiles());
|
||||
manager.waitForReadingCompletion();
|
||||
|
||||
boolean isFromUI = model != null;
|
||||
@@ -196,7 +196,9 @@ public class MavenProjectBuilder extends ProjectImportBuilder<MavenProject> {
|
||||
MavenProjectsTree tree = new MavenProjectsTree();
|
||||
tree.addManagedFilesWithProfiles(getParameters().myFiles, getParameters().mySelectedProfiles);
|
||||
tree.updateAll(false, getGeneralSettings(), process);
|
||||
|
||||
getParameters().myMavenProjectTree = tree;
|
||||
getParameters().mySelectedProjects = tree.getRootProjects();
|
||||
}
|
||||
|
||||
public List<MavenProject> getList() {
|
||||
@@ -204,10 +206,11 @@ public class MavenProjectBuilder extends ProjectImportBuilder<MavenProject> {
|
||||
}
|
||||
|
||||
public void setList(List<MavenProject> projects) {
|
||||
getParameters().mySelectedProjects = projects;
|
||||
}
|
||||
|
||||
public boolean isMarked(final MavenProject element) {
|
||||
return true;
|
||||
public boolean isMarked(MavenProject element) {
|
||||
return getParameters().mySelectedProjects.contains(element);
|
||||
}
|
||||
|
||||
public boolean isOpenProjectSettingsAfter() {
|
||||
|
||||
Reference in New Issue
Block a user