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:
@@ -116,8 +116,8 @@ public class JavaExecutionStack extends XExecutionStack {
|
||||
@Override
|
||||
protected void action() throws Exception {
|
||||
boolean showLibraryStackframes = DebuggerSettings.getInstance().SHOW_LIBRARY_STACKFRAMES;
|
||||
List<JavaStackFrame> frames = new ArrayList<JavaStackFrame>();
|
||||
if (!myThreadProxy.isCollected() && myDebugProcess.getSuspendManager().isSuspended(myThreadProxy)) {
|
||||
List<JavaStackFrame> frames = new ArrayList<JavaStackFrame>();
|
||||
int status = myThreadProxy.status();
|
||||
if (!(status == ThreadReference.THREAD_STATUS_UNKNOWN) &&
|
||||
!(status == ThreadReference.THREAD_STATUS_NOT_STARTED) &&
|
||||
@@ -146,8 +146,11 @@ public class JavaExecutionStack extends XExecutionStack {
|
||||
return;
|
||||
}
|
||||
}
|
||||
container.addStackFrames(frames, true);
|
||||
}
|
||||
else {
|
||||
container.errorOccurred(DebuggerBundle.message("frame.panel.frames.not.available"));
|
||||
}
|
||||
container.addStackFrames(frames, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+6
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,7 +43,7 @@ import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
@@ -79,13 +79,14 @@ public class AttachSourcesNotificationProvider extends EditorNotifications.Provi
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Key<EditorNotificationPanel> getKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EditorNotificationPanel createNotificationPanel(final VirtualFile file, FileEditor fileEditor) {
|
||||
public EditorNotificationPanel createNotificationPanel(@NotNull final VirtualFile file, @NotNull FileEditor fileEditor) {
|
||||
if (file.getFileType() != JavaClassFileType.INSTANCE) return null;
|
||||
final List<LibraryOrderEntry> libraries = findOrderEntriesContainingFile(file);
|
||||
if (libraries == null) return null;
|
||||
@@ -240,7 +241,7 @@ public class AttachSourcesNotificationProvider extends EditorNotifications.Provi
|
||||
if (modelsToCommit.isEmpty()) return new ActionCallback.Rejected();
|
||||
new WriteAction() {
|
||||
@Override
|
||||
protected void run(final Result result) {
|
||||
protected void run(@NotNull final Result result) {
|
||||
for (Library.ModifiableModel model : modelsToCommit) {
|
||||
model.commit();
|
||||
}
|
||||
@@ -253,7 +254,7 @@ public class AttachSourcesNotificationProvider extends EditorNotifications.Provi
|
||||
@Nullable
|
||||
private VirtualFile findRoot(Library library) {
|
||||
for (VirtualFile classesRoot : library.getFiles(OrderRootType.CLASSES)) {
|
||||
if (VfsUtil.isAncestor(classesRoot, myClassFile, true)) {
|
||||
if (VfsUtilCore.isAncestor(classesRoot, myClassFile, true)) {
|
||||
return classesRoot;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -53,13 +53,14 @@ public class SetupSDKNotificationProvider extends EditorNotifications.Provider<E
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Key<EditorNotificationPanel> getKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EditorNotificationPanel createNotificationPanel(VirtualFile file, FileEditor fileEditor) {
|
||||
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
|
||||
if (file.getFileType() == JavaClassFileType.INSTANCE) return null;
|
||||
|
||||
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
|
||||
|
||||
+6
-7
@@ -13,11 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 26-Dec-2007
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.configuration.libraryEditor;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
@@ -30,11 +25,15 @@ import com.intellij.openapi.roots.ui.OrderRootTypeUIFactory;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author anna
|
||||
* @since 26-Dec-2007
|
||||
*/
|
||||
public class ClassesOrderRootTypeUIFactory implements OrderRootTypeUIFactory {
|
||||
|
||||
@Override
|
||||
public SdkPathEditor createPathEditor(Sdk sdk) {
|
||||
return new SdkPathEditor(ProjectBundle.message("sdk.configure.classpath.tab"), OrderRootType.CLASSES, new FileChooserDescriptor(true, true, true, false, true, true));
|
||||
FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, true, false, true, true);
|
||||
return new SdkPathEditor(ProjectBundle.message("sdk.configure.classpath.tab"), OrderRootType.CLASSES, descriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,12 +22,11 @@ import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.HierarchicalMethodSignatureImpl;
|
||||
import com.intellij.psi.impl.source.PsiClassImpl;
|
||||
import com.intellij.psi.search.searches.DeepestSuperMethodsSearch;
|
||||
import com.intellij.psi.search.searches.SuperMethodsSearch;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.*;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
@@ -143,7 +142,15 @@ public class PsiSuperMethodImplUtil {
|
||||
}
|
||||
});
|
||||
|
||||
for (PsiMethod method : aClass.getMethods()) {
|
||||
PsiMethod[] methods = aClass.getMethods();
|
||||
if (aClass instanceof PsiClassImpl) {
|
||||
final PsiMethod valuesMethod = ((PsiClassImpl)aClass).getValuesMethod();
|
||||
if (valuesMethod != null) {
|
||||
methods = ArrayUtil.append(methods, valuesMethod);
|
||||
}
|
||||
}
|
||||
|
||||
for (PsiMethod method : methods) {
|
||||
if (!method.isValid()) {
|
||||
throw new PsiInvalidElementAccessException(method, "class.valid=" + aClass.isValid() + "; name=" + method.getName());
|
||||
}
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class EnumValues {
|
||||
|
||||
{
|
||||
Supplier<I<ABC>> supplier = () -> new C<>(ABC::values);
|
||||
}
|
||||
|
||||
private static interface I<T> {
|
||||
T get();
|
||||
}
|
||||
|
||||
private static class C<E> implements I<E> {
|
||||
C(Supplier<E[]> supplier) {}
|
||||
|
||||
@Override
|
||||
public E get() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static enum ABC {
|
||||
A, B, C
|
||||
}
|
||||
}
|
||||
+4
@@ -265,6 +265,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testEnumValuesMethod() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
@@ -86,10 +86,8 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase {
|
||||
|
||||
private static void doTest(String clsPath, String txtPath) {
|
||||
VirtualFileSystem fs = clsPath.contains("!/") ? JarFileSystem.getInstance() : LocalFileSystem.getInstance();
|
||||
VirtualFile vFile = fs.findFileByPath(clsPath);
|
||||
assertNotNull(clsPath, vFile);
|
||||
PsiFile clsFile = getPsiManager().findFile(vFile);
|
||||
assertNotNull(vFile.getPath(), clsFile);
|
||||
VirtualFile file = fs.findFileByPath(clsPath);
|
||||
assertNotNull(clsPath, file);
|
||||
|
||||
String expected;
|
||||
try {
|
||||
@@ -100,6 +98,6 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase {
|
||||
return;
|
||||
}
|
||||
|
||||
assertEquals(expected, ((ClsFileImpl)clsFile).getMirror().getText());
|
||||
assertEquals(expected, ClsFileImpl.decompile(file).toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -690,7 +690,6 @@ public class ClsRepositoryUseTest extends PsiTestCase {
|
||||
final PsiType returnType = methodsWithReturnType.getReturnType();
|
||||
assert returnType != null : methodsWithReturnType;
|
||||
assertEquals("pack.Parametrized<? extends T>", returnType.getCanonicalText());
|
||||
assertEquals("public pack.Parametrized<? extends T> method() { /* compiled code */ }", methodsWithReturnType.getText());
|
||||
}
|
||||
|
||||
private static void checkEnumConstant(String name, PsiField field, PsiClassType type) {
|
||||
@@ -740,19 +739,20 @@ public class ClsRepositoryUseTest extends PsiTestCase {
|
||||
assertEquals(PsiWildcardType.createUnbounded(myPsiManager), substitution);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public void testModifiers() throws Exception {
|
||||
final PsiClass psiClass = myJavaFacade.findClass("pack.Modifiers", RESOLVE_SCOPE);
|
||||
PsiClass psiClass = myJavaFacade.findClass("pack.Modifiers", RESOLVE_SCOPE);
|
||||
assertNotNull(psiClass);
|
||||
assertEquals("public class Modifiers {\n" +
|
||||
" private transient int f1;\n" +
|
||||
" private volatile int f2;\n" +
|
||||
"\n" +
|
||||
" public Modifiers() { /* compiled code */ }\n" +
|
||||
"\n" +
|
||||
" private void m1(int... i) { /* compiled code */ }\n" +
|
||||
"\n" +
|
||||
" private synchronized void m2() { /* compiled code */ }\n" +
|
||||
"}",
|
||||
psiClass.getText().trim());
|
||||
|
||||
PsiField f1 = psiClass.findFieldByName("f1", false);
|
||||
assertEquals("private transient", f1.getModifierList().getText());
|
||||
PsiField f2 = psiClass.findFieldByName("f2", false);
|
||||
assertEquals("private volatile", f2.getModifierList().getText());
|
||||
PsiMethod init = psiClass.findMethodsByName("Modifiers", false)[0];
|
||||
assertEquals("public", init.getModifierList().getText());
|
||||
PsiMethod m1 = psiClass.findMethodsByName("m1", false)[0];
|
||||
assertEquals("private", m1.getModifierList().getText());
|
||||
PsiMethod m2 = psiClass.findMethodsByName("m2", false)[0];
|
||||
assertEquals("private synchronized", m2.getModifierList().getText());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.JavaPsiFacade
|
||||
import com.intellij.psi.PsiClass
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.psi.PsiMethod
|
||||
import com.intellij.psi.impl.source.PsiFileImpl
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.search.searches.ClassInheritorsSearch
|
||||
import com.intellij.psi.search.searches.OverridingMethodsSearch
|
||||
import com.intellij.psi.stubs.StubTreeLoader
|
||||
import com.intellij.testFramework.PsiTestUtil
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase
|
||||
/**
|
||||
@@ -150,14 +150,12 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase {
|
||||
|
||||
Collection<VirtualFile> pkgDirs = pkg.directories.collect { it.virtualFile }
|
||||
Collection<VirtualFile> pkgChildren = pkgDirs.collect { it.children as List }.flatten()
|
||||
PsiFile javaSrc = psiManager.findFile(pkgChildren.find { it.name == 'LibraryClass.java' })
|
||||
assert !javaSrc.contentsLoaded
|
||||
assert !javaSrc.stub
|
||||
VirtualFile javaSrc = pkgChildren.find { it.name == 'LibraryClass.java' }
|
||||
checkFileIsNotLoadedAndHasNoIndexedStub(javaSrc)
|
||||
|
||||
assert pkg.containsClassNamed('LibraryClass')
|
||||
assert !javaSrc.contentsLoaded
|
||||
assert !javaSrc.stub
|
||||
assert !javaSrc.node.parsed
|
||||
checkFileIsNotLoadedAndHasNoIndexedStub(javaSrc)
|
||||
assert !((PsiFileImpl)psiManager.findFile(javaSrc)).treeElement
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -174,7 +172,7 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase {
|
||||
def localFile = myFixture.copyFileToProject(testDataPathForTest + File.separator + "Foo.java", 'Foo.java')
|
||||
assert localFile != null
|
||||
|
||||
checkFileIsNotLoadedAndHasNoStub(localFile)
|
||||
checkFileIsNotLoadedAndHasNoIndexedStub(localFile)
|
||||
assert facade.findClasses('Foo', scope).size() == 0
|
||||
PsiTestUtil.addLibrary(myModule, 'cas', lib.path, [] as String[], ["/classesAndSources.jar!/"] as String[])
|
||||
|
||||
@@ -187,14 +185,16 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase {
|
||||
|
||||
assert facade.findClasses('LibraryClass', scope).size() == 0
|
||||
|
||||
checkFileIsNotLoadedAndHasNoStub(vfile)
|
||||
checkFileIsNotLoadedAndHasNoIndexedStub(vfile)
|
||||
}
|
||||
|
||||
private void checkFileIsNotLoadedAndHasNoStub(VirtualFile vfile) {
|
||||
def file = PsiManager.getInstance(project).findFile(vfile);
|
||||
private void checkFileIsNotLoadedAndHasNoIndexedStub(VirtualFile vfile) {
|
||||
PsiFileImpl file = psiManager.findFile(vfile);
|
||||
assert file != null
|
||||
|
||||
assert !file.contentsLoaded
|
||||
assert !file.stub
|
||||
assert !StubTreeLoader.instance.readFromVFile(project, vfile)
|
||||
assert !StubTreeLoader.instance.canHaveStub(vfile)
|
||||
assert file.stub // from text
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.WalkingState;
|
||||
import com.intellij.util.concurrency.AtomicFieldUpdater;
|
||||
import gnu.trove.TLongHashSet;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -32,7 +33,6 @@ import java.lang.ref.WeakReference;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
@@ -295,14 +295,14 @@ public abstract class IntervalTreeImpl<T extends MutableInterval> extends RedBla
|
||||
}
|
||||
|
||||
/**
|
||||
* packing/unpacking cachedDeltaUpToRoot field parts
|
||||
* Bits layout:
|
||||
* XXXXXXXXNMMMMMMMM where
|
||||
* XXXXXXXX - 31bit int containing cached delta up to root
|
||||
* N - 1bit flag. if set then all deltas up to root are null
|
||||
* MMMMMMMM - 32bit int containing this node modification count
|
||||
* packing/unpacking cachedDeltaUpToRoot field parts
|
||||
* Bits layout:
|
||||
* XXXXXXXXNMMMMMMMM where
|
||||
* XXXXXXXX - 31bit int containing cached delta up to root
|
||||
* N - 1bit flag. if set then all deltas up to root are null
|
||||
* MMMMMMMM - 32bit int containing this node modification count
|
||||
*/
|
||||
private static final AtomicLongFieldUpdater<IntervalNode> cachedDeltaUpdater = AtomicLongFieldUpdater.newUpdater(IntervalNode.class, "cachedDeltaUpToRoot");
|
||||
private static final AtomicFieldUpdater<IntervalNode, Long> cachedDeltaUpdater = AtomicFieldUpdater.forLongFieldIn(IntervalNode.class);
|
||||
|
||||
private void setCachedValues(int deltaUpToRoot, boolean allDeltaUpToRootAreNull, int modCount) {
|
||||
cachedDeltaUpToRoot = packValues(deltaUpToRoot, allDeltaUpToRootAreNull, modCount);
|
||||
@@ -316,7 +316,7 @@ public abstract class IntervalTreeImpl<T extends MutableInterval> extends RedBla
|
||||
if (myIntervalTree.modCount != treeModCount) return false;
|
||||
long newValue = packValues(deltaUpToRoot, allDeltasUpAreNull, treeModCount);
|
||||
long oldValue = cachedDeltaUpToRoot;
|
||||
return cachedDeltaUpdater.compareAndSet(this, oldValue, newValue);
|
||||
return cachedDeltaUpdater.compareAndSetLong(this, oldValue, newValue);
|
||||
}
|
||||
|
||||
private static boolean allDeltasUpAreNull(long packedOffsets) {
|
||||
|
||||
@@ -13,11 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 26-Dec-2007
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -31,16 +26,20 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author anna
|
||||
* @since 26-Dec-2007
|
||||
*/
|
||||
public interface OrderRootTypeUIFactory {
|
||||
ExtensionPointName<KeyedFactoryEPBean> EP_NAME = ExtensionPointName.create("com.intellij.OrderRootTypeUI");
|
||||
KeyedExtensionFactory<OrderRootTypeUIFactory, OrderRootType> FACTORY = new KeyedExtensionFactory<OrderRootTypeUIFactory, OrderRootType>(OrderRootTypeUIFactory.class, EP_NAME,
|
||||
ApplicationManager
|
||||
.getApplication().getPicoContainer()) {
|
||||
@Override
|
||||
public String getKey(@NotNull final OrderRootType key) {
|
||||
return key.name();
|
||||
}
|
||||
};
|
||||
|
||||
KeyedExtensionFactory<OrderRootTypeUIFactory, OrderRootType> FACTORY =
|
||||
new KeyedExtensionFactory<OrderRootTypeUIFactory, OrderRootType>(OrderRootTypeUIFactory.class, EP_NAME, ApplicationManager.getApplication().getPicoContainer()) {
|
||||
@Override
|
||||
public String getKey(@NotNull final OrderRootType key) {
|
||||
return key.name();
|
||||
}
|
||||
};
|
||||
|
||||
SdkPathEditor createPathEditor(Sdk sdk);
|
||||
|
||||
|
||||
+12
-1
@@ -1,5 +1,6 @@
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.AutoPopupController;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -11,7 +12,14 @@ import com.intellij.psi.PsiDocumentManager;
|
||||
* @author zolotov
|
||||
*/
|
||||
public class AddSpaceInsertHandler implements InsertHandler<LookupElement> {
|
||||
public final static InsertHandler<LookupElement> INSTANCE = new AddSpaceInsertHandler();
|
||||
public final static InsertHandler<LookupElement> INSTANCE = new AddSpaceInsertHandler(false);
|
||||
public final static InsertHandler<LookupElement> INSTANCE_WITH_AUTO_POPUP = new AddSpaceInsertHandler(true);
|
||||
|
||||
private final boolean myTriggerAutoPopup;
|
||||
|
||||
public AddSpaceInsertHandler(boolean triggerAutoPopup) {
|
||||
myTriggerAutoPopup = triggerAutoPopup;
|
||||
}
|
||||
|
||||
public void handleInsert(InsertionContext context, LookupElement item) {
|
||||
Editor editor = context.getEditor();
|
||||
@@ -25,6 +33,9 @@ public class AddSpaceInsertHandler implements InsertHandler<LookupElement> {
|
||||
else {
|
||||
editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + 1);
|
||||
}
|
||||
if (myTriggerAutoPopup) {
|
||||
AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable
|
||||
private final Editor myEditor;
|
||||
private final JBList myList = new JBList(new CollectionListModel<LookupElement>()) {
|
||||
@Override
|
||||
protected void processKeyEvent(final KeyEvent e) {
|
||||
protected void processKeyEvent(@NotNull final KeyEvent e) {
|
||||
final char keyChar = e.getKeyChar();
|
||||
if (keyChar == KeyEvent.VK_ENTER || keyChar == KeyEvent.VK_TAB) {
|
||||
IdeFocusManager.getInstance(myProject).requestFocus(myEditor.getContentComponent(), true).doWhenDone(new Runnable() {
|
||||
@@ -590,7 +590,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable
|
||||
|
||||
final String prefix = itemPattern(item);
|
||||
final int length = prefix.length();
|
||||
if (length == 0 || !StringUtil.startsWithIgnoreCase(lookupString, prefix)) return lookupString;
|
||||
if (length == 0 || !itemMatcher(item).prefixMatches(prefix)) return lookupString;
|
||||
boolean isAllLower = true;
|
||||
boolean isAllUpper = true;
|
||||
boolean sameCase = true;
|
||||
@@ -771,7 +771,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable
|
||||
private LookupElement oldItem = null;
|
||||
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e){
|
||||
public void valueChanged(@NotNull ListSelectionEvent e){
|
||||
final LookupElement item = getCurrentItem();
|
||||
if (oldItem != item && !myList.isEmpty()) { // do not update on temporary model wipe
|
||||
fireCurrentItemChanged(item);
|
||||
|
||||
+4
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.EditorNotificationPanel;
|
||||
import com.intellij.ui.EditorNotifications;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -33,6 +34,7 @@ public class GeneratedFileEditingNotificationProvider extends EditorNotification
|
||||
myChangeTracker = changeTracker;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Key<EditorNotificationPanel> getKey() {
|
||||
return KEY;
|
||||
@@ -40,7 +42,7 @@ public class GeneratedFileEditingNotificationProvider extends EditorNotification
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public EditorNotificationPanel createNotificationPanel(VirtualFile file, FileEditor fileEditor) {
|
||||
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
|
||||
if (!myChangeTracker.isEditedGeneratedFile(file)) return null;
|
||||
|
||||
EditorNotificationPanel panel = new EditorNotificationPanel();
|
||||
|
||||
@@ -48,6 +48,8 @@ public class FragmentContent extends DiffContent {
|
||||
|
||||
public FragmentContent(@NotNull DiffContent original, @NotNull TextRange range, Project project, FileType fileType) {
|
||||
RangeMarker rangeMarker = original.getDocument().createRangeMarker(range.getStartOffset(), range.getEndOffset(), true);
|
||||
rangeMarker.setGreedyToLeft(true);
|
||||
rangeMarker.setGreedyToRight(true);
|
||||
mySynchonizer = new MyDocumentsSynchronizer(project, rangeMarker);
|
||||
myOriginal = original;
|
||||
myType = fileType;
|
||||
|
||||
+48
-35
@@ -23,9 +23,10 @@ import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
@@ -34,7 +35,7 @@ import java.util.TreeMap;
|
||||
* Time: 12:52 PM
|
||||
*/
|
||||
public class FragmentedEditorHighlighter implements EditorHighlighter {
|
||||
private final TreeMap<Integer, Element> myPieces;
|
||||
private final List<Element> myPieces;
|
||||
private final Document myDocument;
|
||||
private final int myAdditionalOffset;
|
||||
private final boolean myMergeByTextAttributes;
|
||||
@@ -49,52 +50,70 @@ public class FragmentedEditorHighlighter implements EditorHighlighter {
|
||||
boolean mergeByTextAttributes) {
|
||||
myMergeByTextAttributes = mergeByTextAttributes;
|
||||
myDocument = sourceIterator.getDocument();
|
||||
myPieces = new TreeMap<Integer, Element>();
|
||||
myPieces = new ArrayList<Element>();
|
||||
myAdditionalOffset = additionalOffset;
|
||||
translate(sourceIterator, ranges);
|
||||
}
|
||||
|
||||
private void translate(HighlighterIterator iterator, List<TextRange> ranges) {
|
||||
if (iterator.atEnd()) return;
|
||||
int offset = 0;
|
||||
for (TextRange range : ranges) {
|
||||
while (range.getStartOffset() > iterator.getStart()) {
|
||||
int index = 0;
|
||||
|
||||
while (!iterator.atEnd() && index < ranges.size()) {
|
||||
TextRange range = ranges.get(index);
|
||||
|
||||
if (range.getStartOffset() >= iterator.getEnd()) {
|
||||
iterator.advance();
|
||||
if (iterator.atEnd()) return;
|
||||
continue;
|
||||
}
|
||||
while (range.getEndOffset() >= iterator.getEnd()) {
|
||||
int relativeStart = iterator.getStart() - range.getStartOffset();
|
||||
|
||||
if (range.getEndOffset() >= iterator.getStart()) {
|
||||
int relativeStart = Math.max(iterator.getStart() - range.getStartOffset(), 0);
|
||||
int relativeEnd = Math.min(iterator.getEnd() - range.getStartOffset(), range.getLength());
|
||||
boolean merged = false;
|
||||
if (myMergeByTextAttributes && !myPieces.isEmpty()) {
|
||||
Map.Entry<Integer, Element> entry = myPieces.lastEntry();
|
||||
final Integer key = entry.getKey();
|
||||
final Element element = entry.getValue();
|
||||
Element element = myPieces.get(myPieces.size() - 1);
|
||||
if (element.getEnd() >= offset + relativeStart &&
|
||||
element.getAttributes().equals(iterator.getTextAttributes()) &&
|
||||
element.getElementType().equals(iterator.getTokenType())) {
|
||||
merged = true;
|
||||
myPieces.put(key, new Element(key,
|
||||
offset + (iterator.getEnd() - range.getStartOffset()), iterator.getTokenType(),
|
||||
iterator.getTextAttributes()));
|
||||
myPieces.add(new Element(element.getStart(),
|
||||
offset + relativeEnd,
|
||||
iterator.getTokenType(),
|
||||
iterator.getTextAttributes()));
|
||||
}
|
||||
}
|
||||
if (!merged) {
|
||||
myPieces.put(offset + relativeStart, new Element(offset + relativeStart,
|
||||
offset + (iterator.getEnd() - range.getStartOffset()), iterator.getTokenType(),
|
||||
iterator.getTextAttributes()));
|
||||
myPieces.add(new Element(offset + relativeStart,
|
||||
offset + relativeEnd,
|
||||
iterator.getTokenType(),
|
||||
iterator.getTextAttributes()));
|
||||
}
|
||||
iterator.advance();
|
||||
if (iterator.atEnd()) return;
|
||||
}
|
||||
offset += range.getLength() + 1 + myAdditionalOffset; // myAdditionalOffset because of extra line - for shoene separators
|
||||
|
||||
if (range.getEndOffset() < iterator.getEnd()) {
|
||||
offset += range.getLength() + 1 + myAdditionalOffset; // myAdditionalOffset because of extra line - for shoene separators
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
|
||||
iterator.advance();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HighlighterIterator createIterator(int startOffset) {
|
||||
Map.Entry<Integer, Element> entry = myPieces.ceilingEntry(startOffset);
|
||||
return new ProxyIterator(myDocument, entry == null ? -1 : entry.getKey());
|
||||
int offset = Collections.binarySearch(myPieces, new Element(startOffset, 0, null, null), new Comparator<Element>() {
|
||||
@Override
|
||||
public int compare(Element o1, Element o2) {
|
||||
return o1.getStart() - o2.getStart();
|
||||
}
|
||||
});
|
||||
// offset: (-insertion point - 1), where insertionPoint is the index of the first element greater than the key
|
||||
// and we need offset of the first element that is less or equal (floorElement)
|
||||
if (offset < 0) offset = Math.max(-offset - 2, 0);
|
||||
return new ProxyIterator(myDocument, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,27 +167,21 @@ public class FragmentedEditorHighlighter implements EditorHighlighter {
|
||||
|
||||
@Override
|
||||
public void advance() {
|
||||
if (myIdx == myPieces.lastKey() || myIdx == -1) {
|
||||
myIdx = -1;
|
||||
return;
|
||||
if (myIdx < myPieces.size()) {
|
||||
myIdx++;
|
||||
}
|
||||
Map.Entry<Integer, Element> entry = myPieces.tailMap(myIdx, false).firstEntry();
|
||||
myIdx = entry.getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void retreat() {
|
||||
if (myIdx == myPieces.firstKey() || myIdx == -1) {
|
||||
myIdx = -1;
|
||||
return;
|
||||
if (myIdx > -1) {
|
||||
myIdx--;
|
||||
}
|
||||
Map.Entry<Integer, Element> entry = myPieces.headMap(myIdx, false).lastEntry();
|
||||
myIdx = entry.getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean atEnd() {
|
||||
return myIdx < 0;
|
||||
return myIdx < 0 || myIdx >= myPieces.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -31,10 +32,11 @@ import javax.swing.*;
|
||||
public abstract class EditorNotifications extends AbstractProjectComponent {
|
||||
|
||||
public abstract static class Provider<T extends JComponent> {
|
||||
@NotNull
|
||||
public abstract Key<T> getKey();
|
||||
|
||||
@Nullable
|
||||
public abstract T createNotificationPanel(VirtualFile file, FileEditor fileEditor);
|
||||
public abstract T createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor);
|
||||
}
|
||||
|
||||
public static EditorNotifications getInstance(Project project) {
|
||||
@@ -45,7 +47,7 @@ public abstract class EditorNotifications extends AbstractProjectComponent {
|
||||
super(project);
|
||||
}
|
||||
|
||||
public abstract void updateNotifications(final VirtualFile file);
|
||||
public abstract void updateNotifications(@NotNull VirtualFile file);
|
||||
|
||||
public abstract void updateAllNotifications();
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ public class FileChangedNotificationProvider extends EditorNotifications.Provide
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Key<EditorNotificationPanel> getKey() {
|
||||
return KEY;
|
||||
|
||||
@@ -20,70 +20,38 @@ import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.ide.CopyPasteManager;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class CopyPathsAction extends AnAction implements DumbAware {
|
||||
|
||||
public CopyPathsAction() {
|
||||
setEnabledInModalContext(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final Collection<VirtualFile> files = getFiles(e);
|
||||
if (files.isEmpty()) {
|
||||
return;
|
||||
VirtualFile[] files = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(e.getDataContext());
|
||||
if (files != null && files.length > 0) {
|
||||
CopyPasteManager.getInstance().setContents(new StringSelection(getPaths(files)));
|
||||
}
|
||||
CopyPasteManager.getInstance().setContents(new StringSelection(getPaths(files)));
|
||||
}
|
||||
|
||||
private static String getPaths(Collection<VirtualFile> files) {
|
||||
final StringBuilder buf = new StringBuilder(files.size() * 64);
|
||||
boolean first = true;
|
||||
private static String getPaths(VirtualFile[] files) {
|
||||
StringBuilder buf = new StringBuilder(files.length * 64);
|
||||
for (VirtualFile file : files) {
|
||||
if (first) {
|
||||
first = false;
|
||||
}
|
||||
else {
|
||||
buf.append("\n");
|
||||
}
|
||||
if (buf.length() > 0) buf.append('\n');
|
||||
buf.append(file.getPresentableUrl());
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent event) {
|
||||
final Collection<VirtualFile> files = getFiles(event);
|
||||
final Presentation presentation = event.getPresentation();
|
||||
final boolean enabled = !files.isEmpty();
|
||||
presentation.setEnabled(enabled);
|
||||
if (ActionPlaces.isPopupPlace(event.getPlace())) {
|
||||
presentation.setVisible(enabled);
|
||||
}
|
||||
else {
|
||||
presentation.setVisible(true);
|
||||
}
|
||||
presentation.setText((files.size() == 1)
|
||||
? IdeBundle.message("action.copy.path")
|
||||
: IdeBundle.message("action.copy.paths"));
|
||||
VirtualFile[] files = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(event.getDataContext());
|
||||
int num = files != null ? files.length : 0;
|
||||
Presentation presentation = event.getPresentation();
|
||||
presentation.setEnabled(num > 0);
|
||||
presentation.setVisible(num > 0 || !ActionPlaces.isPopupPlace(event.getPlace()));
|
||||
presentation.setText(IdeBundle.message(num == 1 ? "action.copy.path" : "action.copy.paths"));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Collection<VirtualFile> getFiles(AnActionEvent e) {
|
||||
final VirtualFile[] files = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(e.getDataContext());
|
||||
if (files == null || files.length == 0) return Collections.emptyList();
|
||||
final ArrayList<VirtualFile> result = new ArrayList<VirtualFile>(files.length);
|
||||
for (VirtualFile file : files) {
|
||||
if (!(file instanceof LightVirtualFile)) {
|
||||
result.add(file);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ public class DeleteLineAction extends TextComponentEditorAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeWriteAction(Editor editor, DataContext dataContext) {
|
||||
public void executeWriteAction(Editor editor, Caret caret, DataContext dataContext) {
|
||||
CommandProcessor.getInstance().setCurrentCommandGroupId(EditorActionUtil.DELETE_COMMAND_GROUP);
|
||||
CopyPasteManager.getInstance().stopKillRings();
|
||||
SelectionModel selectionModel = editor.getSelectionModel();
|
||||
@@ -76,7 +76,7 @@ public class DeleteLineAction extends TextComponentEditorAction {
|
||||
selectionModel.selectLineAtCaret();
|
||||
boolean removeLastSymbol = selectionModel.getSelectionEnd() == document.getTextLength() && document.getLineCount() > 1;
|
||||
EditorModificationUtil.deleteSelectedText(editor);
|
||||
if (removeLastSymbol) {
|
||||
if (removeLastSymbol && document.getTextLength() > 0) {
|
||||
document.deleteString(document.getTextLength() - 1, document.getTextLength());
|
||||
position = new VisualPosition(position.line - 1, position.column);
|
||||
}
|
||||
|
||||
@@ -2075,7 +2075,9 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
|
||||
private void paintComposedTextDecoration(@NotNull Graphics2D g) {
|
||||
if (myInputMethodRequestsHandler != null && myInputMethodRequestsHandler.composedText != null) {
|
||||
if (myInputMethodRequestsHandler != null
|
||||
&& myInputMethodRequestsHandler.composedText != null
|
||||
&& myInputMethodRequestsHandler.composedTextRange != null) {
|
||||
VisualPosition visStart =
|
||||
offsetToVisualPosition(Math.min(myInputMethodRequestsHandler.composedTextRange.getStartOffset(), myDocument.getTextLength()));
|
||||
int y = visibleLineToY(visStart.line) + getAscent() + 1;
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,6 +52,7 @@ public class PluginAdvertiserEditorNotificationProvider extends EditorNotificati
|
||||
myNotifications = notifications;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Key<EditorNotificationPanel> getKey() {
|
||||
return KEY;
|
||||
@@ -59,7 +60,7 @@ public class PluginAdvertiserEditorNotificationProvider extends EditorNotificati
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public EditorNotificationPanel createNotificationPanel(VirtualFile file, FileEditor fileEditor) {
|
||||
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
|
||||
if (file.getFileType() != PlainTextFileType.INSTANCE) return null;
|
||||
|
||||
final String extension = file.getExtension();
|
||||
|
||||
@@ -90,6 +90,8 @@ public class EditorNotificationsImpl extends EditorNotifications {
|
||||
myCurrentUpdates.put(file, indicator);
|
||||
|
||||
final ReadTask task = createTask(indicator, file);
|
||||
if (task == null) return;
|
||||
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
task.computeInReadAction(indicator);
|
||||
}
|
||||
@@ -106,11 +108,25 @@ public class EditorNotificationsImpl extends EditorNotifications {
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ReadTask createTask(final ProgressIndicator indicator, final VirtualFile file) {
|
||||
final FileEditor[] editors = FileEditorManager.getInstance(myProject).getAllEditors(file);
|
||||
if (editors.length == 0) return null;
|
||||
|
||||
return new ReadTask() {
|
||||
|
||||
private boolean isOutdated() {
|
||||
return myProject.isDisposed() || !file.isValid() || indicator != myCurrentUpdates.get(file);
|
||||
if (myProject.isDisposed() || !file.isValid() || indicator != myCurrentUpdates.get(file)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (FileEditor editor : editors) {
|
||||
if (!editor.isValid()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,7 +134,7 @@ public class EditorNotificationsImpl extends EditorNotifications {
|
||||
if (isOutdated()) return;
|
||||
|
||||
final List<Runnable> updates = ContainerUtil.newArrayList();
|
||||
for (final FileEditor editor : FileEditorManager.getInstance(myProject).getAllEditors(file)) {
|
||||
for (final FileEditor editor : editors) {
|
||||
for (final Provider<?> provider : Extensions.getExtensions(EXTENSION_POINT_NAME, myProject)) {
|
||||
final JComponent component = provider.createNotificationPanel(file, editor);
|
||||
updates.add(new Runnable() {
|
||||
|
||||
+33
@@ -20,6 +20,8 @@ import com.intellij.openapi.editor.impl.AbstractEditorTest;
|
||||
import com.intellij.testFramework.EditorTestUtil;
|
||||
import com.intellij.testFramework.TestFileType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class EditorActionTest extends AbstractEditorTest {
|
||||
public void testDownWithSelectionWhenCaretsAreAllowedInsideTabs() throws Exception {
|
||||
init("<caret>text",
|
||||
@@ -69,4 +71,35 @@ public class EditorActionTest extends AbstractEditorTest {
|
||||
executeAction("EditorTab");
|
||||
checkResultByText("some <caret>text");
|
||||
}
|
||||
|
||||
public void testLineDeleteWithSelectionEndAtLineStart() throws IOException {
|
||||
String text =
|
||||
"line 1\n" +
|
||||
"<selection>line 2\n" +
|
||||
"</selection>line 3";
|
||||
init(text, TestFileType.TEXT);
|
||||
deleteLine();
|
||||
checkResultByText(
|
||||
"line 1\n" +
|
||||
"line 3"
|
||||
);
|
||||
}
|
||||
|
||||
public void testDeleteLastLine() throws IOException {
|
||||
String text =
|
||||
"1\n" +
|
||||
"2<caret>\n" +
|
||||
"3";
|
||||
init(text, TestFileType.TEXT);
|
||||
|
||||
deleteLine();
|
||||
deleteLine();
|
||||
checkResultByText("1");
|
||||
}
|
||||
|
||||
public void testDeleteLastNonEmptyLine() throws IOException {
|
||||
init("<caret>1\n", TestFileType.TEXT);
|
||||
deleteLine();
|
||||
checkResultByText("");
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ public interface ScriptManager {
|
||||
*
|
||||
* @param newSource new text of script
|
||||
*/
|
||||
@NotNull
|
||||
AsyncResult<?> setSourceOnRemote(@NotNull Script script, @NotNull String newSource, boolean preview);
|
||||
|
||||
void forEachScript(@NotNull Processor<Script> scriptProcessor);
|
||||
|
||||
@@ -27,8 +27,6 @@ import sun.misc.Unsafe;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
|
||||
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
|
||||
|
||||
/**
|
||||
* Utility class similar to {@link java.util.concurrent.atomic.AtomicReferenceFieldUpdater} except:
|
||||
@@ -69,15 +67,13 @@ public class AtomicFieldUpdater<T,V> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> AtomicLongFieldUpdater<T> forLongFieldIn(@NotNull Class<T> ownerClass) {
|
||||
Field field = getTheOnlyVolatileFieldOfClass(ownerClass, long.class);
|
||||
return AtomicLongFieldUpdater.newUpdater(ownerClass, field.getName());
|
||||
public static <T> AtomicFieldUpdater<T, Long> forLongFieldIn(@NotNull Class<T> ownerClass) {
|
||||
return new AtomicFieldUpdater<T, Long>(ownerClass, long.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> AtomicIntegerFieldUpdater<T> forIntFieldIn(@NotNull Class<T> ownerClass) {
|
||||
Field field = getTheOnlyVolatileFieldOfClass(ownerClass, int.class);
|
||||
return AtomicIntegerFieldUpdater.newUpdater(ownerClass, field.getName());
|
||||
public static <T> AtomicFieldUpdater<T, Integer> forIntFieldIn(@NotNull Class<T> ownerClass) {
|
||||
return new AtomicFieldUpdater<T, Integer>(ownerClass, int.class);
|
||||
}
|
||||
|
||||
private AtomicFieldUpdater(@NotNull Class<T> ownerClass, @NotNull Class<V> fieldType) {
|
||||
@@ -120,6 +116,10 @@ public class AtomicFieldUpdater<T,V> {
|
||||
return unsafe.compareAndSwapLong(owner, offset, expected, newValue);
|
||||
}
|
||||
|
||||
public boolean compareAndSetInt(@NotNull T owner, int expected, int newValue) {
|
||||
return unsafe.compareAndSwapInt(owner, offset, expected, newValue);
|
||||
}
|
||||
|
||||
public void set(@NotNull T owner, V newValue) {
|
||||
unsafe.putObjectVolatile(owner, offset, newValue);
|
||||
}
|
||||
|
||||
+6
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.EditorNotifications;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
@@ -34,11 +35,14 @@ public class ChangelistConflictNotificationProvider extends EditorNotifications.
|
||||
myConflictTracker = changeListManager.getConflictTracker();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Key<ChangelistConflictNotificationPanel> getKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
public ChangelistConflictNotificationPanel createNotificationPanel(VirtualFile file, FileEditor fileEditor) {
|
||||
@Override
|
||||
public ChangelistConflictNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
|
||||
return myConflictTracker.hasConflict(file) ? ChangelistConflictNotificationPanel.create(myConflictTracker, file) : null;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -85,13 +85,14 @@ public class UseDistributionWithSourcesNotificationProvider extends EditorNotifi
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Key<EditorNotificationPanel> getKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EditorNotificationPanel createNotificationPanel(VirtualFile file, FileEditor fileEditor) {
|
||||
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
|
||||
try {
|
||||
if (GradleConstants.DEFAULT_SCRIPT_NAME.equals(file.getName()) ||
|
||||
GradleConstants.SETTINGS_FILE_NAME.equals(file.getName())) {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
<root url="jar://$MODULE_DIR$/../lib/gradle-messaging-1.12.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/../lib/gradle-wrapper-1.12.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/../lib/gradle-base-services-1.12.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/../lib/gradle-base-services-groovy-1.12.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/../lib/gradle-native-1.12.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License")
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.plugins.gradle.tooling.builder
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.file.FileVisitDetails
|
||||
import org.gradle.api.file.FileVisitor
|
||||
import org.gradle.api.java.archives.Manifest
|
||||
import org.gradle.api.plugins.WarPlugin
|
||||
import org.gradle.api.tasks.bundling.War
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import org.jetbrains.annotations.Nullable
|
||||
import org.jetbrains.plugins.gradle.model.web.WebConfiguration
|
||||
import org.jetbrains.plugins.gradle.tooling.ErrorMessageBuilder
|
||||
import org.jetbrains.plugins.gradle.tooling.ModelBuilderService
|
||||
import org.jetbrains.plugins.gradle.tooling.internal.web.WarModelImpl
|
||||
import org.jetbrains.plugins.gradle.tooling.internal.web.WebConfigurationImpl
|
||||
import org.jetbrains.plugins.gradle.tooling.internal.web.WebResourceImpl
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 6/25/2014
|
||||
*/
|
||||
class WarModelBuilderImpl implements ModelBuilderService {
|
||||
|
||||
private static final String WEB_APP_DIR_PROPERTY = "webAppDir"
|
||||
private static final String WEB_APP_DIR_NAME_PROPERTY = "webAppDirName"
|
||||
|
||||
@Override
|
||||
public boolean canBuild(String modelName) {
|
||||
return WebConfiguration.name.equals(modelName)
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object buildAll(String modelName, Project project) {
|
||||
final WarPlugin warPlugin = project.plugins.findPlugin(WarPlugin)
|
||||
if (warPlugin == null) return null
|
||||
|
||||
final String webAppDirName = !project.hasProperty(WEB_APP_DIR_NAME_PROPERTY) ?
|
||||
"src/main/webapp" : String.valueOf(project.property(WEB_APP_DIR_NAME_PROPERTY))
|
||||
|
||||
final File webAppDir = !project.hasProperty(WEB_APP_DIR_PROPERTY) ? new File(project.projectDir, webAppDirName) :
|
||||
(File)project.property(WEB_APP_DIR_PROPERTY)
|
||||
|
||||
def warModels = []
|
||||
|
||||
project.tasks.each { Task task ->
|
||||
if (task instanceof War) {
|
||||
final WarModelImpl warModel =
|
||||
new WarModelImpl((task as War).archiveName, webAppDirName, webAppDir)
|
||||
|
||||
final List<WebConfiguration.WebResource> webResources = []
|
||||
final War warTask = task as War
|
||||
warModel.webXml = warTask.webXml
|
||||
|
||||
warTask.rootSpec.walk({ def resolver ->
|
||||
// def resolver ->
|
||||
// in Gradle v1.x - org.gradle.api.internal.file.copy.CopySpecInternal
|
||||
// in Gradle v2.x - org.gradle.api.internal.file.copy.CopySpecResolver
|
||||
|
||||
if (resolver.metaClass.respondsTo(resolver, 'setIncludeEmptyDirs', boolean)) {
|
||||
resolver.setIncludeEmptyDirs(true)
|
||||
}
|
||||
if (!resolver.metaClass.respondsTo(resolver, 'getDestPath') ||
|
||||
!resolver.metaClass.respondsTo(resolver, 'getSource')) {
|
||||
throw new RuntimeException("${GradleVersion.current()} is not supported by web artifact importer")
|
||||
}
|
||||
|
||||
final String relativePath = resolver.destPath.pathString
|
||||
resolver.source.visit(new FileVisitor() {
|
||||
@Override
|
||||
public void visitDir(FileVisitDetails dirDetails) {
|
||||
try {
|
||||
addPath(webResources, relativePath, dirDetails.path, dirDetails.file)
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitFile(FileVisitDetails fileDetails) {
|
||||
try {
|
||||
if (warTask.webXml == null ||
|
||||
!fileDetails.file.canonicalPath.equals(warTask.webXml.canonicalPath)) {
|
||||
addPath(webResources, relativePath, fileDetails.path, fileDetails.file)
|
||||
}
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
warModel.webResources = webResources
|
||||
warModel.classpath = warTask.classpath.files
|
||||
|
||||
Manifest manifest = warTask.manifest
|
||||
if (manifest != null) {
|
||||
def writer = new StringWriter()
|
||||
manifest.writeTo(writer)
|
||||
warModel.manifestContent = writer.toString()
|
||||
}
|
||||
warModels.add(warModel)
|
||||
}
|
||||
}
|
||||
|
||||
new WebConfigurationImpl(warModels)
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ErrorMessageBuilder getErrorMessageBuilder(@NotNull Project project, @NotNull Exception e) {
|
||||
ErrorMessageBuilder.create(
|
||||
project, e, "Web project import errors"
|
||||
).withDescription("Web Facets/Artifacts will not be configured")
|
||||
}
|
||||
|
||||
private static addPath(List<WebConfiguration.WebResource> webResources, String warRelativePath, String fileRelativePath, File file) {
|
||||
warRelativePath = warRelativePath == null ? "" : warRelativePath
|
||||
|
||||
WebConfiguration.WebResource webResource = new WebResourceImpl(warRelativePath, fileRelativePath, file)
|
||||
webResources.add(webResource)
|
||||
}
|
||||
}
|
||||
-140
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.plugins.gradle.tooling.builder;
|
||||
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.Task;
|
||||
import org.gradle.api.file.FileVisitDetails;
|
||||
import org.gradle.api.file.FileVisitor;
|
||||
import org.gradle.api.internal.file.copy.CopySpecInternal;
|
||||
import org.gradle.api.java.archives.Manifest;
|
||||
import org.gradle.api.plugins.WarPlugin;
|
||||
import org.gradle.api.tasks.bundling.War;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.model.web.WebConfiguration;
|
||||
import org.jetbrains.plugins.gradle.tooling.ErrorMessageBuilder;
|
||||
import org.jetbrains.plugins.gradle.tooling.ModelBuilderService;
|
||||
import org.jetbrains.plugins.gradle.tooling.internal.web.WarModelImpl;
|
||||
import org.jetbrains.plugins.gradle.tooling.internal.web.WebConfigurationImpl;
|
||||
import org.jetbrains.plugins.gradle.tooling.internal.web.WebResourceImpl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 11/5/13
|
||||
*/
|
||||
public class WarModelBuilderImpl implements ModelBuilderService {
|
||||
|
||||
private static final String WEB_APP_DIR_PROPERTY = "webAppDir";
|
||||
private static final String WEB_APP_DIR_NAME_PROPERTY = "webAppDirName";
|
||||
|
||||
@Override
|
||||
public boolean canBuild(String modelName) {
|
||||
return WebConfiguration.class.getName().equals(modelName);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object buildAll(String modelName, Project project) {
|
||||
final WarPlugin warPlugin = project.getPlugins().findPlugin(WarPlugin.class);
|
||||
if (warPlugin == null) return null;
|
||||
|
||||
final String webAppDirName = !project.hasProperty(WEB_APP_DIR_NAME_PROPERTY) ?
|
||||
"src/main/webapp" : String.valueOf(project.property(WEB_APP_DIR_NAME_PROPERTY));
|
||||
|
||||
final File webAppDir = !project.hasProperty(WEB_APP_DIR_PROPERTY)
|
||||
? new File(project.getProjectDir(), webAppDirName)
|
||||
: (File)project.property(WEB_APP_DIR_PROPERTY);
|
||||
|
||||
|
||||
List<WebConfiguration.WarModel> warModels = new ArrayList<WebConfiguration.WarModel>();
|
||||
|
||||
|
||||
for (Task task : project.getTasks()) {
|
||||
if (task instanceof War) {
|
||||
final WarModelImpl warModel =
|
||||
new WarModelImpl(((War)task).getArchiveName(), webAppDirName, webAppDir);
|
||||
final List<WebConfiguration.WebResource> webResources = new ArrayList<WebConfiguration.WebResource>();
|
||||
|
||||
final War warTask = (War)task;
|
||||
warModel.setWebXml(warTask.getWebXml());
|
||||
|
||||
warTask.getRootSpec().walk(new Action<CopySpecInternal>() {
|
||||
@Override
|
||||
public void execute(CopySpecInternal internal) {
|
||||
final String relativePath = internal.getDestPath().getPathString();
|
||||
internal.getSource().visit(new FileVisitor() {
|
||||
@Override
|
||||
public void visitDir(FileVisitDetails dirDetails) {
|
||||
try {
|
||||
addPath(webResources, relativePath, dirDetails.getPath(), dirDetails.getFile());
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitFile(FileVisitDetails fileDetails) {
|
||||
try {
|
||||
if (warTask.getWebXml() == null ||
|
||||
!fileDetails.getFile().getCanonicalPath().equals(warTask.getWebXml().getCanonicalPath())) {
|
||||
addPath(webResources, relativePath, fileDetails.getPath(), fileDetails.getFile());
|
||||
}
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
warModel.setWebResources(webResources);
|
||||
warModel.setClasspath(warTask.getClasspath().getFiles());
|
||||
|
||||
Manifest manifest = warTask.getManifest();
|
||||
if (manifest != null) {
|
||||
StringWriter writer = new StringWriter();
|
||||
manifest.writeTo(writer);
|
||||
warModel.setManifestContent(writer.toString());
|
||||
}
|
||||
warModels.add(warModel);
|
||||
}
|
||||
}
|
||||
|
||||
return new WebConfigurationImpl(warModels);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ErrorMessageBuilder getErrorMessageBuilder(@NotNull Project project, @NotNull Exception e) {
|
||||
return ErrorMessageBuilder.create(
|
||||
project, e, "Web project import errors"
|
||||
).withDescription("Web Facets/Artifacts will not be configured");
|
||||
}
|
||||
|
||||
private static void addPath(List<WebConfiguration.WebResource> webResources, String warRelativePath, String fileRelativePath, File file) {
|
||||
warRelativePath = warRelativePath == null ? "" : warRelativePath;
|
||||
|
||||
WebConfiguration.WebResource webResource = new WebResourceImpl(warRelativePath, fileRelativePath, file);
|
||||
webResources.add(webResource);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -20,7 +20,7 @@ allprojects {
|
||||
|
||||
idea {
|
||||
module {
|
||||
scopes.PROVIDED.plus += configurations.provided
|
||||
scopes.PROVIDED.plus += [configurations.provided]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -65,6 +65,7 @@ public abstract class AbstractModelBuilderTest {
|
||||
public static final String GRADLE_v1_10 = "1.10";
|
||||
public static final String GRADLE_v1_11 = "1.11";
|
||||
public static final String GRADLE_v1_12 = "1.12";
|
||||
public static final String GRADLE_v2_0 = "2.0-rc-2";
|
||||
|
||||
public static final Pattern TEST_METHOD_NAME_PATTERN = Pattern.compile("(.*)\\[(\\d*)\\]");
|
||||
|
||||
@@ -84,10 +85,11 @@ public abstract class AbstractModelBuilderTest {
|
||||
@Parameterized.Parameters
|
||||
public static Collection<Object[]> data() {
|
||||
Object[][] data = {
|
||||
{AbstractModelBuilderTest.GRADLE_v1_9},
|
||||
{AbstractModelBuilderTest.GRADLE_v1_10},
|
||||
{AbstractModelBuilderTest.GRADLE_v1_11},
|
||||
{AbstractModelBuilderTest.GRADLE_v1_12}
|
||||
{GRADLE_v1_9},
|
||||
{GRADLE_v1_10},
|
||||
{GRADLE_v1_11},
|
||||
{GRADLE_v1_12},
|
||||
{GRADLE_v2_0}
|
||||
};
|
||||
return Arrays.asList(data);
|
||||
}
|
||||
|
||||
+4
-2
@@ -21,6 +21,7 @@ import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -67,13 +68,14 @@ public class ConfigureGroovyLibraryNotificationProvider extends EditorNotificati
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Key<EditorNotificationPanel> getKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EditorNotificationPanel createNotificationPanel(VirtualFile file, FileEditor fileEditor) {
|
||||
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
|
||||
try {
|
||||
if (!supportedFileTypes.contains(file.getFileType())) return null;
|
||||
// do not show the panel for Gradle build scripts
|
||||
@@ -81,7 +83,7 @@ public class ConfigureGroovyLibraryNotificationProvider extends EditorNotificati
|
||||
if (StringUtil.endsWith(file.getName(), ".gradle")) return null;
|
||||
if (CompilerManager.getInstance(myProject).isExcludedFromCompilation(file)) return null;
|
||||
|
||||
final Module module = ModuleUtil.findModuleForFile(file, myProject);
|
||||
final Module module = ModuleUtilCore.findModuleForFile(file, myProject);
|
||||
if (module == null) return null;
|
||||
|
||||
if (isMavenModule(module)) return null;
|
||||
|
||||
-2
@@ -171,7 +171,6 @@ public class RenameGrFieldProcessor extends RenameJavaVariableProcessor {
|
||||
return GrTraitUtil.getTraitFieldPrefix(prototype.getContainingClass()) + newPrototypeName;
|
||||
}
|
||||
|
||||
LOG.error(element);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -202,7 +201,6 @@ public class RenameGrFieldProcessor extends RenameJavaVariableProcessor {
|
||||
return getNewElement(prototype);
|
||||
}
|
||||
|
||||
LOG.error(element);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -55,6 +55,7 @@ public class IdeaDecompilerTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testExtendsList() { doTestDecompiler(); }
|
||||
public void testParameters() { doTestDecompiler(); }
|
||||
public void testConstants() { doTestDecompiler(); }
|
||||
public void testAnonymous() { doTestDecompiler(); }
|
||||
|
||||
private void doTestDecompiler() {
|
||||
String name = PluginPathManager.getPluginHomePath("java-decompiler") + "/testData/" + getName().substring(4);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,13 @@
|
||||
public class Anonymous {
|
||||
private int count = 0;
|
||||
|
||||
public Object produce() {
|
||||
final int id = count++;
|
||||
return new Object() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "anonymous_" + id;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
|
||||
public class Anonymous {
|
||||
|
||||
private int count = 0;
|
||||
|
||||
|
||||
public Anonymous() {
|
||||
}
|
||||
|
||||
public Object produce() {
|
||||
++this.count;
|
||||
final int var1 = this.count;
|
||||
return new Object() {
|
||||
public String toString() {
|
||||
return "anonymous_" + var1;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,17 +19,12 @@ package com.intellij.execution;
|
||||
import com.intellij.execution.junit.JUnitUtil;
|
||||
import com.intellij.execution.junit.TestClassFilter;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.PsiElementProcessor;
|
||||
import com.intellij.psi.search.PsiElementProcessorAdapter;
|
||||
import com.intellij.psi.search.PsiShortNamesCache;
|
||||
import com.intellij.psi.search.*;
|
||||
import com.intellij.psi.search.searches.AnnotatedMembersSearch;
|
||||
import com.intellij.psi.search.searches.ClassInheritorsSearch;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
@@ -47,7 +42,7 @@ public class ConfigurationUtil {
|
||||
final Project project = manager.getProject();
|
||||
GlobalSearchScope projectScopeWithoutLibraries = GlobalSearchScope.projectScope(project);
|
||||
final GlobalSearchScope scope = projectScopeWithoutLibraries.intersectWith(testClassFilter.getScope());
|
||||
ClassInheritorsSearch.search(testClassFilter.getBase(), scope, true).forEach(new PsiElementProcessorAdapter<PsiClass>(new PsiElementProcessor<PsiClass>() {
|
||||
ClassInheritorsSearch.search(testClassFilter.getBase(), scope, true, true, false).forEach(new PsiElementProcessorAdapter<PsiClass>(new PsiElementProcessor<PsiClass>() {
|
||||
public boolean execute(@NotNull final PsiClass aClass) {
|
||||
if (testClassFilter.isAccepted(aClass)) found.add(aClass);
|
||||
return true;
|
||||
@@ -113,7 +108,7 @@ public class ConfigurationUtil {
|
||||
found.add(containingClass);
|
||||
isJUnit4.set(Boolean.TRUE);
|
||||
}
|
||||
ClassInheritorsSearch.search(containingClass, scope, true)
|
||||
ClassInheritorsSearch.search(containingClass, scope, true, true, false)
|
||||
.forEach(new PsiElementProcessorAdapter<PsiClass>(new PsiElementProcessor<PsiClass>() {
|
||||
public boolean execute(@NotNull final PsiClass aClass) {
|
||||
if (testClassFilter.isAccepted(aClass)) {
|
||||
|
||||
@@ -20,8 +20,6 @@ import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static com.intellij.tasks.actions.TaskSearchSupport.getRepositoriesTasks;
|
||||
|
||||
/**
|
||||
* @author Mikhail Golubev
|
||||
*/
|
||||
@@ -88,7 +86,15 @@ class TaskItemProvider implements ChooseByNameItemProvider, Disposable {
|
||||
try {
|
||||
List<Task> tasks = future.get();
|
||||
myFutureReference.compareAndSet(future, null);
|
||||
tasks.removeAll(cachedAndLocalTasks);
|
||||
|
||||
// Exclude *all* cached and local issues, not only those returned by TaskSearchSupport.getLocalAndCachedTasks().
|
||||
// Previously used approach might lead to the following strange behavior. Local task excluded by getLocalAndCachedTasks()
|
||||
// as "locally closed" (i.e. having no associated change list) was indeed *included* in popup because it
|
||||
// was contained in server response (as not remotely closed). Moreover on next request with pagination when the
|
||||
// same issues was not returned again by server it was *excluded* from popup (thus subsequent update reduced total
|
||||
// number of items shown).
|
||||
tasks.removeAll(TaskManager.getManager(myProject).getLocalTasks());
|
||||
tasks.removeAll(TaskManager.getManager(myProject).getCachedIssues());
|
||||
return processTasks(tasks, consumer, cancelled);
|
||||
}
|
||||
catch (InterruptedException interrupted) {
|
||||
@@ -138,7 +144,8 @@ class TaskItemProvider implements ChooseByNameItemProvider, Disposable {
|
||||
limit = GotoTaskAction.PAGE_SIZE;
|
||||
myCurrentOffset += GotoTaskAction.PAGE_SIZE;
|
||||
}
|
||||
List<Task> tasks = getRepositoriesTasks(TaskManager.getManager(myProject), pattern, offset, limit, true, everywhere, cancelled);
|
||||
List<Task> tasks = TaskSearchSupport.getRepositoriesTasks(TaskManager.getManager(myProject),
|
||||
pattern, offset, limit, true, everywhere, cancelled);
|
||||
myOldEverywhere = everywhere;
|
||||
myOldPattern = pattern;
|
||||
return tasks;
|
||||
|
||||
@@ -108,7 +108,11 @@ public class RedmineRepository extends NewBaseRepositoryImpl {
|
||||
// /users/current.json. Unfortunately this endpoint may be unavailable on some old servers (see IDEA-122845)
|
||||
// and in this case we have to come back to requesting issues in this case to test anything at all.
|
||||
HttpClient client = getHttpClient();
|
||||
HttpResponse response = client.execute(new HttpGet(getRestApiUrl("users", "current.json")));
|
||||
URIBuilder uriBuilder = new URIBuilder(getRestApiUrl("users", "current.json"));
|
||||
if (isUseApiKeyAuthentication()) {
|
||||
uriBuilder.addParameter("key", getAPIKey());
|
||||
}
|
||||
HttpResponse response = client.execute(new HttpGet(uriBuilder.build()));
|
||||
//TaskUtil.prettyFormatResponseToLog(LOG, response);
|
||||
int code = response.getStatusLine().getStatusCode();
|
||||
if (code == HttpStatus.SC_NOT_FOUND) {
|
||||
@@ -189,7 +193,7 @@ public class RedmineRepository extends NewBaseRepositoryImpl {
|
||||
}
|
||||
|
||||
private boolean isUseApiKeyAuthentication() {
|
||||
return !StringUtil.isEmptyOrSpaces(myAPIKey) && !isUseHttpAuthentication();
|
||||
return !isUseHttpAuthentication() && StringUtil.isNotEmpty(myAPIKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -203,11 +207,11 @@ public class RedmineRepository extends NewBaseRepositoryImpl {
|
||||
|
||||
@Override
|
||||
public boolean isConfigured() {
|
||||
if (!super.isConfigured() || StringUtil.isEmpty(myUsername)) return false;
|
||||
if (!super.isConfigured()) return false;
|
||||
if (isUseHttpAuthentication()) {
|
||||
return StringUtil.isNotEmpty(myPassword);
|
||||
return StringUtil.isNotEmpty(myPassword) && StringUtil.isNotEmpty(myUsername);
|
||||
}
|
||||
return !StringUtil.isEmptyOrSpaces(myAPIKey);
|
||||
return StringUtil.isNotEmpty(myAPIKey);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+18
-1
@@ -35,6 +35,8 @@ public class RedmineRepositoryEditor extends BaseRepositoryEditor<RedmineReposit
|
||||
installListener(myProjectCombo);
|
||||
installListener(myAPIKey);
|
||||
|
||||
toggleCredentialsVisibility();
|
||||
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -47,6 +49,8 @@ public class RedmineRepositoryEditor extends BaseRepositoryEditor<RedmineReposit
|
||||
protected void afterTestConnection(boolean connectionSuccessful) {
|
||||
if (connectionSuccessful) {
|
||||
new FetchProjectsTask().queue();
|
||||
} else {
|
||||
myProjectCombo.removeAllItems();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +67,19 @@ public class RedmineRepositoryEditor extends BaseRepositoryEditor<RedmineReposit
|
||||
myRepository.setCurrentProject((RedmineProject)myProjectCombo.getSelectedItem());
|
||||
myRepository.setAPIKey(myAPIKey.getText().trim());
|
||||
myTestButton.setEnabled(myRepository.isConfigured());
|
||||
toggleCredentialsVisibility();
|
||||
}
|
||||
|
||||
private void toggleCredentialsVisibility() {
|
||||
myPasswordLabel.setVisible(myRepository.isUseHttpAuthentication());
|
||||
myPasswordText.setVisible(myRepository.isUseHttpAuthentication());
|
||||
|
||||
myUsernameLabel.setVisible(myRepository.isUseHttpAuthentication());
|
||||
myUserNameText.setVisible(myRepository.isUseHttpAuthentication());
|
||||
|
||||
myAPIKeyLabel.setVisible(!myRepository.isUseHttpAuthentication());
|
||||
myAPIKey.setVisible(!myRepository.isUseHttpAuthentication());
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -72,7 +89,7 @@ public class RedmineRepositoryEditor extends BaseRepositoryEditor<RedmineReposit
|
||||
myProjectCombo = new ComboBox(300);
|
||||
myProjectCombo.setRenderer(new TaskUiUtil.SimpleComboBoxRenderer("Set URL and password/token first"));
|
||||
myAPIKeyLabel = new JBLabel("API Token:", SwingConstants.RIGHT);
|
||||
myAPIKey = new JTextField();
|
||||
myAPIKey = new JPasswordField();
|
||||
return FormBuilder.createFormBuilder()
|
||||
.addLabeledComponent(myAPIKeyLabel, myAPIKey)
|
||||
.addLabeledComponent(myProjectLabel, myProjectCombo)
|
||||
|
||||
+5
-2
@@ -44,6 +44,7 @@ import icons.PythonIcons;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
@@ -353,10 +354,12 @@ abstract public class AbstractProjectSettingsStep extends AbstractActionWithPane
|
||||
}
|
||||
|
||||
private static class Button extends ActionButtonWithText {
|
||||
private final Border myBorder;
|
||||
|
||||
public Button(AnAction action, Presentation presentation) {
|
||||
super(action, presentation, "NewProject", new Dimension(70, 50));
|
||||
setBorder(UIUtil.getButtonBorder());
|
||||
myBorder = UIUtil.isUnderDarcula() ? UIUtil.getButtonBorder() : BorderFactory.createLineBorder(UIUtil.getBorderColor());
|
||||
setBorder(myBorder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -385,7 +388,7 @@ abstract public class AbstractProjectSettingsStep extends AbstractActionWithPane
|
||||
setBorder(null);
|
||||
}
|
||||
else if (e.getID() == MouseEvent.MOUSE_EXITED) {
|
||||
setBorder(UIUtil.getButtonBorder());
|
||||
setBorder(myBorder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public class PySdkListCellRenderer extends ListCellRendererWrapper<Object> {
|
||||
}
|
||||
}
|
||||
else if (new File(name).exists()) {
|
||||
name = ".../" + new File(name).getParentFile().getParentFile().getName();
|
||||
name = "..." + File.separator + new File(name).getParentFile().getParentFile().getName();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user