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:
@@ -77,6 +77,7 @@ import com.intellij.packaging.artifacts.ArtifactManager;
|
||||
import com.intellij.packaging.impl.artifacts.ArtifactImpl;
|
||||
import com.intellij.packaging.impl.artifacts.ArtifactUtil;
|
||||
import com.intellij.packaging.impl.compiler.ArtifactCompileScope;
|
||||
import com.intellij.packaging.impl.compiler.ArtifactCompilerUtil;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
@@ -2474,6 +2475,7 @@ public class CompileDriver {
|
||||
}
|
||||
}
|
||||
}
|
||||
affectedOutputPaths.addAll(ArtifactCompilerUtil.getArtifactOutputsContainingSourceFiles(myProject));
|
||||
|
||||
if (!affectedOutputPaths.isEmpty()) {
|
||||
final StringBuilder paths = new StringBuilder();
|
||||
|
||||
@@ -18,14 +18,32 @@ package com.intellij.packaging.impl.compiler;
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.compiler.CompilerMessageCategory;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactManager;
|
||||
import com.intellij.packaging.elements.ComplexPackagingElement;
|
||||
import com.intellij.packaging.elements.PackagingElement;
|
||||
import com.intellij.packaging.elements.PackagingElementResolvingContext;
|
||||
import com.intellij.packaging.impl.artifacts.ArtifactUtil;
|
||||
import com.intellij.packaging.impl.artifacts.PackagingElementPath;
|
||||
import com.intellij.packaging.impl.artifacts.PackagingElementProcessor;
|
||||
import com.intellij.packaging.impl.elements.ArtifactPackagingElement;
|
||||
import com.intellij.packaging.impl.elements.FileOrDirectoryCopyPackagingElement;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
@@ -65,4 +83,40 @@ public class ArtifactCompilerUtil {
|
||||
String fullPath = jarEntry.getPath();
|
||||
return new File(FileUtil.toSystemDependentName(fullPath.substring(fullPath.indexOf(JarFileSystem.JAR_SEPARATOR))));
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static Set<VirtualFile> getArtifactOutputsContainingSourceFiles(final @NotNull Project project) {
|
||||
final List<VirtualFile> allOutputs = new ArrayList<VirtualFile>();
|
||||
for (Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) {
|
||||
ContainerUtil.addIfNotNull(artifact.getOutputFile(), allOutputs);
|
||||
}
|
||||
|
||||
final Set<VirtualFile> affectedOutputPaths = new HashSet<VirtualFile>();
|
||||
final PackagingElementResolvingContext context = ArtifactManager.getInstance(project).getResolvingContext();
|
||||
for (Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) {
|
||||
ArtifactUtil.processPackagingElements(artifact, null, new PackagingElementProcessor<PackagingElement<?>>() {
|
||||
@Override
|
||||
public boolean shouldProcessSubstitution(ComplexPackagingElement<?> element) {
|
||||
return !(element instanceof ArtifactPackagingElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(@NotNull PackagingElement<?> element, @NotNull PackagingElementPath path) {
|
||||
if (element instanceof FileOrDirectoryCopyPackagingElement<?>) {
|
||||
final VirtualFile file = ((FileOrDirectoryCopyPackagingElement)element).findFile();
|
||||
if (file != null) {
|
||||
for (VirtualFile output : allOutputs) {
|
||||
if (VfsUtilCore.isAncestor(output, file, false)) {
|
||||
affectedOutputPaths.add(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}, context, true);
|
||||
}
|
||||
return affectedOutputPaths;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -730,16 +730,9 @@ public class JavaCompletionUtil {
|
||||
|
||||
if (psiClass.isValid() && !psiClass.getManager().areElementsEquivalent(psiClass, resolveReference(ref))) {
|
||||
final boolean staticImport = ref instanceof PsiImportStaticReferenceElement;
|
||||
CodeEditUtil.setAllowSuspendNodesReformatting(true);
|
||||
PsiElement newElement;
|
||||
try {
|
||||
newElement = staticImport
|
||||
? ((PsiImportStaticReferenceElement)ref).bindToTargetClass(psiClass)
|
||||
: ref.bindToElement(psiClass);
|
||||
}
|
||||
finally {
|
||||
CodeEditUtil.setAllowSuspendNodesReformatting(false);
|
||||
}
|
||||
PsiElement newElement = staticImport
|
||||
? ((PsiImportStaticReferenceElement)ref).bindToTargetClass(psiClass)
|
||||
: ref.bindToElement(psiClass);
|
||||
|
||||
newElement = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(newElement);
|
||||
if (newElement != null) {
|
||||
|
||||
+2
-2
@@ -48,12 +48,12 @@ public class JavaAnnotationElementType extends JavaStubElementType<PsiAnnotation
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiAnnotation createPsi(final PsiAnnotationStub stub) {
|
||||
public PsiAnnotation createPsi(@NotNull final PsiAnnotationStub stub) {
|
||||
return getPsiFactory(stub).createAnnotation(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiAnnotation createPsi(final ASTNode node) {
|
||||
public PsiAnnotation createPsi(@NotNull final ASTNode node) {
|
||||
return new PsiAnnotationImpl(node);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,12 +52,12 @@ public abstract class JavaClassElementType extends JavaStubElementType<PsiClassS
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiClass createPsi(final PsiClassStub stub) {
|
||||
public PsiClass createPsi(@NotNull final PsiClassStub stub) {
|
||||
return getPsiFactory(stub).createClass(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiClass createPsi(final ASTNode node) {
|
||||
public PsiClass createPsi(@NotNull final ASTNode node) {
|
||||
if (node instanceof EnumConstantInitializerElement) {
|
||||
return new PsiEnumConstantInitializerImpl(node);
|
||||
}
|
||||
|
||||
+2
-2
@@ -45,12 +45,12 @@ public class JavaClassInitializerElementType extends JavaStubElementType<PsiClas
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiClassInitializer createPsi(final PsiClassInitializerStub stub) {
|
||||
public PsiClassInitializer createPsi(@NotNull final PsiClassInitializerStub stub) {
|
||||
return getPsiFactory(stub).createClassInitializer(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiClassInitializer createPsi(final ASTNode node) {
|
||||
public PsiClassInitializer createPsi(@NotNull final ASTNode node) {
|
||||
return new PsiClassInitializerImpl(node);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -48,12 +48,12 @@ public abstract class JavaClassReferenceListElementType extends JavaStubElementT
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiReferenceList createPsi(final PsiClassReferenceListStub stub) {
|
||||
public PsiReferenceList createPsi(@NotNull final PsiClassReferenceListStub stub) {
|
||||
return getPsiFactory(stub).createClassReferenceList(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiReferenceList createPsi(final ASTNode node) {
|
||||
public PsiReferenceList createPsi(@NotNull final ASTNode node) {
|
||||
if (node.getElementType() == JavaStubElementTypes.EXTENDS_BOUND_LIST) {
|
||||
return new PsiTypeParameterExtendsBoundsListImpl(node);
|
||||
}
|
||||
|
||||
+2
-2
@@ -53,12 +53,12 @@ public abstract class JavaFieldStubElementType extends JavaStubElementType<PsiFi
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiField createPsi(final PsiFieldStub stub) {
|
||||
public PsiField createPsi(@NotNull final PsiFieldStub stub) {
|
||||
return getPsiFactory(stub).createField(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiField createPsi(final ASTNode node) {
|
||||
public PsiField createPsi(@NotNull final ASTNode node) {
|
||||
if (node instanceof EnumConstantElement) {
|
||||
return new PsiEnumConstantImpl(node);
|
||||
}
|
||||
|
||||
+2
-2
@@ -45,12 +45,12 @@ public class JavaImportListElementType extends JavaStubElementType<PsiImportList
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiImportList createPsi(final PsiImportListStub stub) {
|
||||
public PsiImportList createPsi(@NotNull final PsiImportListStub stub) {
|
||||
return getPsiFactory(stub).createImportList(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiImportList createPsi(final ASTNode node) {
|
||||
public PsiImportList createPsi(@NotNull final ASTNode node) {
|
||||
return new PsiImportListImpl(node);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -46,12 +46,12 @@ public abstract class JavaImportStatementElementType extends JavaStubElementType
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiImportStatementBase createPsi(final PsiImportStatementStub stub) {
|
||||
public PsiImportStatementBase createPsi(@NotNull final PsiImportStatementStub stub) {
|
||||
return getPsiFactory(stub).createImportStatement(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiImportStatementBase createPsi(final ASTNode node) {
|
||||
public PsiImportStatementBase createPsi(@NotNull final ASTNode node) {
|
||||
if (node instanceof ImportStaticStatementElement) {
|
||||
return new PsiImportStaticStatementImpl(node);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.intellij.psi.stubs.StubOutputStream;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -51,12 +52,12 @@ public abstract class JavaMethodElementType extends JavaStubElementType<PsiMetho
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiMethod createPsi(final PsiMethodStub stub) {
|
||||
public PsiMethod createPsi(@NotNull final PsiMethodStub stub) {
|
||||
return getPsiFactory(stub).createMethod(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiMethod createPsi(final ASTNode node) {
|
||||
public PsiMethod createPsi(@NotNull final ASTNode node) {
|
||||
if (node instanceof AnnotationMethodElement) {
|
||||
return new PsiAnnotationMethodImpl(node);
|
||||
}
|
||||
|
||||
+2
-2
@@ -48,12 +48,12 @@ public class JavaModifierListElementType extends JavaStubElementType<PsiModifier
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiModifierList createPsi(final PsiModifierListStub stub) {
|
||||
public PsiModifierList createPsi(@NotNull final PsiModifierListStub stub) {
|
||||
return getPsiFactory(stub).createModifierList(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiModifierList createPsi(final ASTNode node) {
|
||||
public PsiModifierList createPsi(@NotNull final ASTNode node) {
|
||||
return new PsiModifierListImpl(node);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -50,12 +50,12 @@ public class JavaParameterElementType extends JavaStubElementType<PsiParameterSt
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiParameter createPsi(final PsiParameterStub stub) {
|
||||
public PsiParameter createPsi(@NotNull PsiParameterStub stub) {
|
||||
return getPsiFactory(stub).createParameter(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiParameter createPsi(final ASTNode node) {
|
||||
public PsiParameter createPsi(@NotNull final ASTNode node) {
|
||||
return new PsiParameterImpl(node);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -45,12 +45,12 @@ public class JavaParameterListElementType extends JavaStubElementType<PsiParamet
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiParameterList createPsi(final PsiParameterListStub stub) {
|
||||
public PsiParameterList createPsi(@NotNull final PsiParameterListStub stub) {
|
||||
return getPsiFactory(stub).createParameterList(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiParameterList createPsi(final ASTNode node) {
|
||||
public PsiParameterList createPsi(@NotNull final ASTNode node) {
|
||||
return new PsiParameterListImpl(node);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,10 +64,10 @@ public abstract class JavaStubElementType<StubT extends StubElement, PsiT extend
|
||||
}
|
||||
|
||||
@SuppressWarnings("MethodOverloadsMethodOfSuperclass")
|
||||
public abstract PsiT createPsi(ASTNode node);
|
||||
public abstract PsiT createPsi(@NotNull ASTNode node);
|
||||
|
||||
@Override
|
||||
public final StubT createStub(final PsiT psi, final StubElement parentStub) {
|
||||
public final StubT createStub(@NotNull final PsiT psi, final StubElement parentStub) {
|
||||
final String message = "Should not be called. Element=" + psi + "; file=" + (psi.isValid() ? psi.getContainingFile() : "-");
|
||||
throw new UnsupportedOperationException(message);
|
||||
}
|
||||
|
||||
+2
-2
@@ -49,12 +49,12 @@ public class JavaTypeParameterElementType extends JavaStubElementType<PsiTypePar
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiTypeParameter createPsi(final PsiTypeParameterStub stub) {
|
||||
public PsiTypeParameter createPsi(@NotNull final PsiTypeParameterStub stub) {
|
||||
return getPsiFactory(stub).createTypeParameter(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiTypeParameter createPsi(final ASTNode node) {
|
||||
public PsiTypeParameter createPsi(@NotNull final ASTNode node) {
|
||||
return new PsiTypeParameterImpl(node);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -45,12 +45,12 @@ public class JavaTypeParameterListElementType extends JavaStubElementType<PsiTyp
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiTypeParameterList createPsi(final PsiTypeParameterListStub stub) {
|
||||
public PsiTypeParameterList createPsi(@NotNull final PsiTypeParameterListStub stub) {
|
||||
return getPsiFactory(stub).createTypeParameterList(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiTypeParameterList createPsi(final ASTNode node) {
|
||||
public PsiTypeParameterList createPsi(@NotNull final ASTNode node) {
|
||||
return new PsiTypeParameterListImpl(node);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
public abstract class JavaStubPsiElement<T extends StubElement> extends StubBasedPsiElementBase<T> implements StubBasedPsiElement<T> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.JavaStubPsiElement");
|
||||
|
||||
public JavaStubPsiElement(final T stub, IStubElementType nodeType) {
|
||||
public JavaStubPsiElement(@NotNull T stub, @NotNull IStubElementType nodeType) {
|
||||
super(stub, nodeType);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,11 +44,11 @@ public class PsiParameterImpl extends JavaStubPsiElement<PsiParameterStub> imple
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiParameterImpl");
|
||||
private volatile PatchedSoftReference<PsiType> myCachedType = null;
|
||||
|
||||
public PsiParameterImpl(final PsiParameterStub stub) {
|
||||
public PsiParameterImpl(@NotNull PsiParameterStub stub) {
|
||||
super(stub, JavaStubElementTypes.PARAMETER);
|
||||
}
|
||||
|
||||
public PsiParameterImpl(final ASTNode node) {
|
||||
public PsiParameterImpl(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,11 +31,11 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class PsiParameterListImpl extends JavaStubPsiElement<PsiParameterListStub> implements PsiParameterList {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiParameterListImpl");
|
||||
|
||||
public PsiParameterListImpl(final PsiParameterListStub stub) {
|
||||
public PsiParameterListImpl(@NotNull PsiParameterListStub stub) {
|
||||
super(stub, JavaStubElementTypes.PARAMETER_LIST);
|
||||
}
|
||||
|
||||
public PsiParameterListImpl(final ASTNode node) {
|
||||
public PsiParameterListImpl(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.intellij.psi.impl.source.tree.java;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.impl.source.Constants;
|
||||
import com.intellij.psi.impl.source.tree.ChildRole;
|
||||
import com.intellij.psi.impl.source.tree.CompositeElement;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
@@ -29,7 +28,7 @@ public class ParameterElement extends CompositeElement{
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.java.ParameterElement");
|
||||
|
||||
public ParameterElement() {
|
||||
super(Constants.PARAMETER);
|
||||
super(JavaElementType.PARAMETER);
|
||||
}
|
||||
|
||||
protected ParameterElement(IElementType type) {
|
||||
|
||||
+1
-1
@@ -621,7 +621,7 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
|
||||
public void testSpacesAroundEq() throws Throwable { doTest('='); }
|
||||
|
||||
public void testClassBeforeCast() throws Throwable { doTest '\n' }
|
||||
public void _testClassBeforeCast() throws Throwable { doTest '\n' }
|
||||
|
||||
public void testNoAllClassesOnQualifiedReference() throws Throwable {
|
||||
configureByFile(getTestName(false) + ".java");
|
||||
|
||||
@@ -32,9 +32,9 @@ public abstract class IStubElementType<StubT extends StubElement, PsiT extends P
|
||||
super(debugName, language);
|
||||
}
|
||||
|
||||
public abstract PsiT createPsi(StubT stub);
|
||||
public abstract PsiT createPsi(@NotNull StubT stub);
|
||||
|
||||
public abstract StubT createStub(PsiT psi, final StubElement parentStub);
|
||||
public abstract StubT createStub(@NotNull PsiT psi, final StubElement parentStub);
|
||||
|
||||
public boolean shouldCreateStub(ASTNode node) {
|
||||
return true;
|
||||
|
||||
@@ -441,7 +441,7 @@ public class CodeEditUtil {
|
||||
* <ol>
|
||||
* <li>This method is called with <code>'false'</code> argument;</li>
|
||||
* <li>Document is processed at dedicated <code>'try'</code> block;</li>
|
||||
* <li>This method is called with <code>'false'</code> argument from <code>'finally'</code> section;</li>
|
||||
* <li>This method is called with <code>'true'</code> argument from <code>'finally'</code> section;</li>
|
||||
* </ol>
|
||||
</pre>
|
||||
*/
|
||||
|
||||
@@ -17,7 +17,7 @@ public abstract class EmptyStubElementType<T extends PsiElement> extends IStubEl
|
||||
}
|
||||
|
||||
@Override
|
||||
public final EmptyStub createStub(T psi, StubElement parentStub) {
|
||||
public final EmptyStub createStub(@NotNull T psi, StubElement parentStub) {
|
||||
return createStub(parentStub);
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -118,6 +118,7 @@ public class SurroundWithHandler implements CodeInsightActionHandler {
|
||||
final PsiElement[] elements = descriptor.getElementsToSurround(file, startOffset, endOffset);
|
||||
if (elements.length > 0) {
|
||||
for (PsiElement element : elements) {
|
||||
assert element != null : "descriptor " + descriptor + " returned null element";
|
||||
assert element.isValid() : descriptor;
|
||||
}
|
||||
for (Surrounder s: descriptor.getSurrounders()) {
|
||||
|
||||
@@ -36,6 +36,7 @@ public class EndHandler extends EditorActionHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
lookup.markSelectionTouched();
|
||||
ListScrollingUtil.moveEnd(lookup.getList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ public class HomeHandler extends EditorActionHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
lookup.markSelectionTouched();
|
||||
ListScrollingUtil.moveHome(lookup.getList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
|
||||
private static final int FLUSH_DELAY = 200; //TODO : make it an option
|
||||
|
||||
private static final Key<ConsoleViewImpl> CONSOLE_VIEW_IN_EDITOR_VIEW = Key.create("CONSOLE_VIEW_IN_EDITOR_VIEW");
|
||||
public static final Key<ConsoleViewImpl> CONSOLE_VIEW_IN_EDITOR_VIEW = Key.create("CONSOLE_VIEW_IN_EDITOR_VIEW");
|
||||
|
||||
static {
|
||||
final EditorActionManager actionManager = EditorActionManager.getInstance();
|
||||
|
||||
@@ -79,7 +79,7 @@ public abstract class IndentationParser implements PsiParser {
|
||||
currentIndent = 0;
|
||||
}
|
||||
}
|
||||
builder.advanceLexer();
|
||||
advanceLexer(builder);
|
||||
}
|
||||
|
||||
// Close all left opened markers
|
||||
@@ -90,10 +90,20 @@ public abstract class IndentationParser implements PsiParser {
|
||||
stack.pop().second.done(myBlockElementType);
|
||||
}
|
||||
|
||||
return buildTree(fileMarker, builder, root);
|
||||
}
|
||||
|
||||
protected ASTNode buildTree(final PsiBuilder.Marker fileMarker,
|
||||
final PsiBuilder builder,
|
||||
final IElementType root) {
|
||||
fileMarker.done(root);
|
||||
return builder.getTreeBuilt();
|
||||
}
|
||||
|
||||
protected void advanceLexer(PsiBuilder builder) {
|
||||
builder.advanceLexer();
|
||||
}
|
||||
|
||||
private void passEOLsAndIndents(final PsiBuilder builder) {
|
||||
IElementType tokenType = builder.getTokenType();
|
||||
while (tokenType == myEolTokenType || tokenType == myIndentTokenType){
|
||||
|
||||
@@ -20,10 +20,13 @@
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.impl.ProjectLifecycleListener;
|
||||
import com.intellij.psi.util.PsiModificationTracker;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.HashMap;
|
||||
@@ -42,6 +45,12 @@ public class IconDeferrerImpl extends IconDeferrer {
|
||||
clear();
|
||||
}
|
||||
});
|
||||
connection.subscribe(ProjectLifecycleListener.TOPIC, new ProjectLifecycleListener.Adapter() {
|
||||
@Override
|
||||
public void afterProjectClosed(@NotNull Project project) {
|
||||
clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
|
||||
+40
-14
@@ -15,10 +15,14 @@
|
||||
*/
|
||||
package com.intellij.util.ui;
|
||||
|
||||
import com.intellij.codeInsight.lookup.LookupEx;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CustomShortcutSet;
|
||||
import com.intellij.openapi.editor.impl.EditorComponentImpl;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -36,22 +40,12 @@ public class UpDownHandler {
|
||||
register(input, affectedComponent, true);
|
||||
}
|
||||
|
||||
public static void register(JComponent input, final JComponent affectedComponent, boolean registerOnBothComponents) {
|
||||
public static void register(final JComponent input, final JComponent affectedComponent, boolean registerOnBothComponents) {
|
||||
final SelectionMover mover = new SelectionMover(affectedComponent);
|
||||
final AnAction up = new AnAction("Up") {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
mover.move(-1);
|
||||
}
|
||||
};
|
||||
final AnAction up = new UpDownAction(mover, input, true);
|
||||
up.registerCustomShortcutSet(UP_KEY, input);
|
||||
|
||||
final AnAction down = new AnAction("Down") {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
mover.move(1);
|
||||
}
|
||||
};
|
||||
|
||||
final AnAction down = new UpDownAction(mover, input, false);
|
||||
down.registerCustomShortcutSet(DOWN_KEY, input);
|
||||
if (registerOnBothComponents) {
|
||||
up.registerCustomShortcutSet(UP_KEY, affectedComponent);
|
||||
@@ -103,4 +97,36 @@ public class UpDownHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class UpDownAction extends AnAction {
|
||||
private final int myDirection;
|
||||
private final SelectionMover myMover;
|
||||
private final JComponent myInput;
|
||||
|
||||
UpDownAction(SelectionMover mover, JComponent input, boolean isUp) {
|
||||
super(isUp ? "Up" : "Down");
|
||||
myMover = mover;
|
||||
myInput = input;
|
||||
myDirection = isUp ? -1 : 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
myMover.move(myDirection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
final LookupEx lookup;
|
||||
if (myInput instanceof EditorTextField) {
|
||||
lookup = LookupManager.getActiveLookup(((EditorTextField)myInput).getEditor());
|
||||
} else if (myInput instanceof EditorComponentImpl) {
|
||||
lookup = LookupManager.getActiveLookup(((EditorComponentImpl)myInput).getEditor());
|
||||
} else {
|
||||
lookup = null;
|
||||
}
|
||||
|
||||
e.getPresentation().setEnabled(lookup == null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,12 @@ public class JBEditorTabs extends JBTabsImpl {
|
||||
super.paintLastGhost(g2d);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isTabDraggingEnabled() {
|
||||
return super.isTabDraggingEnabled() && isSingleRow();
|
||||
}
|
||||
|
||||
public boolean isGhostsAlwaysVisible() {
|
||||
return super.isGhostsAlwaysVisible() && !isEditorTabs();
|
||||
}
|
||||
@@ -71,7 +76,7 @@ public class JBEditorTabs extends JBTabsImpl {
|
||||
int _height = effectiveBounds.height - insets.top - insets.bottom;
|
||||
|
||||
|
||||
if ((!isSingleRow() && label.getBounds().y > 0 /* for multiline */) || (isSingleRow() && isHorizontalTabs())) {
|
||||
if ((!isSingleRow() /* for multiline */) || (isSingleRow() && isHorizontalTabs())) {
|
||||
if (isSingleRow() && getPosition() == JBTabsPosition.bottom) {
|
||||
_y += TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT;
|
||||
} else {
|
||||
|
||||
@@ -25,12 +25,15 @@ import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.mac.foundation.Foundation;
|
||||
import com.intellij.ui.mac.foundation.ID;
|
||||
import com.intellij.ui.mac.foundation.MacUtil;
|
||||
import com.sun.jna.Callback;
|
||||
import com.sun.jna.IntegerType;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import sun.awt.datatransfer.DataTransferer;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.io.IOException;
|
||||
@@ -180,8 +183,31 @@ public class ClipboardSynchronizer implements ApplicationComponent {
|
||||
|
||||
private static class MacClipboardHandler extends ClipboardHandler {
|
||||
|
||||
private static final String CLIPBOARD_CONTENTS = "CLIPBOARD_CONTENTS";
|
||||
private Pair<String,Transferable> myFullTransferable;
|
||||
|
||||
private static Callback myClipboardQueryCallback = new Callback() {
|
||||
public void callback(ID self, String selector, ID params) {
|
||||
JRootPane pane = getRootPane();
|
||||
if (pane != null) {
|
||||
Transferable transferable = getClipboardContentNatively();
|
||||
if (transferable != null) {
|
||||
pane.putClientProperty(CLIPBOARD_CONTENTS, transferable);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static {
|
||||
if (SystemInfo.isMac) {
|
||||
final ID delegateClass = Foundation.allocateObjcClassPair(Foundation.getClass("NSObject"), "ClipboardSynchronizer_");
|
||||
if (!Foundation.addMethod(delegateClass, Foundation.createSelector("run:"), myClipboardQueryCallback, "v*")) {
|
||||
throw new RuntimeException("Unable to add method to objective-c delegate class!");
|
||||
}
|
||||
Foundation.registerObjcClassPair(delegateClass);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Transferable doGetContents() throws IllegalStateException {
|
||||
if (Registry.is("ide.mac.useNativeClipboard")) {
|
||||
@@ -247,43 +273,45 @@ public class ClipboardSynchronizer implements ApplicationComponent {
|
||||
super.setContent(content, owner);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static JRootPane getRootPane() {
|
||||
Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
|
||||
if (window == null) return null;
|
||||
return SwingUtilities.getRootPane(window);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Transferable getContentsSafe() {
|
||||
if (Registry.is("ide.mac.useNativeClipboard.async")) {
|
||||
JRootPane pane = getRootPane();
|
||||
if (pane != null) {
|
||||
ID synchronizer_ = Foundation.getClass("ClipboardSynchronizer_");
|
||||
final ID synchronizer = Foundation.invoke(Foundation.invoke(synchronizer_, "alloc"), "init");
|
||||
Foundation
|
||||
.invoke(synchronizer, "performSelectorOnMainThread:withObject:waitUntilDone:", Foundation.createSelector("run:"), null, false);
|
||||
|
||||
MacUtil.startModal(pane);
|
||||
|
||||
Foundation.cfRelease(synchronizer);
|
||||
|
||||
Object contents = pane.getClientProperty(CLIPBOARD_CONTENTS);
|
||||
pane.putClientProperty(CLIPBOARD_CONTENTS, null);
|
||||
if (contents != null) {
|
||||
return (Transferable) contents;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
final Ref<Transferable> result = new Ref<Transferable>();
|
||||
Foundation.executeOnMainThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String plainText = "public.utf8-plain-text";
|
||||
String jvmObject = "application/x-java-jvm";
|
||||
|
||||
ID pasteboard = Foundation.invoke("NSPasteboard", "generalPasteboard");
|
||||
ID types = Foundation.invoke(pasteboard, "types");
|
||||
IntegerType count = Foundation.invoke(types, "count");
|
||||
|
||||
ID plainTextType = null;
|
||||
|
||||
for (int i = 0; i < count.intValue(); i++) {
|
||||
ID each = Foundation.invoke(types, "objectAtIndex:", i);
|
||||
String eachType = Foundation.toStringViaUTF8(each);
|
||||
if (plainText.equals(eachType)) {
|
||||
plainTextType = each;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// will put string value even if we doesn't found java object. this is needed because java caches clipboard value internally and
|
||||
// will reset it ONLY IF we'll put jvm-object into clipboard (see our setContent optimizations which avoids putting jvm-objects
|
||||
// into clipboard)
|
||||
|
||||
if (plainTextType != null) {
|
||||
ID text = Foundation.invoke(pasteboard, "stringForType:", plainTextType);
|
||||
String value = Foundation.toStringViaUTF8(text);
|
||||
if (value == null) {
|
||||
LOG.info(String.format("[Clipboard] Strange string value (null?) for type: %s", plainTextType));
|
||||
}
|
||||
else {
|
||||
result.set(new StringSelection(value));
|
||||
}
|
||||
Transferable transferable = getClipboardContentNatively();
|
||||
if (transferable != null) {
|
||||
result.set(transferable);
|
||||
}
|
||||
}
|
||||
}, true, true);
|
||||
@@ -291,6 +319,45 @@ public class ClipboardSynchronizer implements ApplicationComponent {
|
||||
return result.get();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Transferable getClipboardContentNatively() {
|
||||
String plainText = "public.utf8-plain-text";
|
||||
String jvmObject = "application/x-java-jvm";
|
||||
|
||||
ID pasteboard = Foundation.invoke("NSPasteboard", "generalPasteboard");
|
||||
ID types = Foundation.invoke(pasteboard, "types");
|
||||
IntegerType count = Foundation.invoke(types, "count");
|
||||
|
||||
ID plainTextType = null;
|
||||
|
||||
for (int i = 0; i < count.intValue(); i++) {
|
||||
ID each = Foundation.invoke(types, "objectAtIndex:", i);
|
||||
String eachType = Foundation.toStringViaUTF8(each);
|
||||
if (plainText.equals(eachType)) {
|
||||
plainTextType = each;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// will put string value even if we doesn't found java object. this is needed because java caches clipboard value internally and
|
||||
// will reset it ONLY IF we'll put jvm-object into clipboard (see our setContent optimizations which avoids putting jvm-objects
|
||||
// into clipboard)
|
||||
|
||||
Transferable result = null;
|
||||
if (plainTextType != null) {
|
||||
ID text = Foundation.invoke(pasteboard, "stringForType:", plainTextType);
|
||||
String value = Foundation.toStringViaUTF8(text);
|
||||
if (value == null) {
|
||||
LOG.info(String.format("[Clipboard] Strange string value (null?) for type: %s", plainTextType));
|
||||
}
|
||||
else {
|
||||
result = new StringSelection(value);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static class LinuxClipboardHandler extends ClipboardHandler {
|
||||
private static final FlavorTable FLAVOR_MAP = (FlavorTable)SystemFlavorMap.getDefaultFlavorMap();
|
||||
|
||||
@@ -809,7 +809,8 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
myPanel.addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
myMarkupModel.repaint(0, myDocument.getTextLength());
|
||||
myMarkupModel.recalcEditorDimensions();
|
||||
myMarkupModel.repaint(-1, -1);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1570,7 +1571,8 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
myEditorComponent.setSize(dim);
|
||||
myEditorComponent.fireResized();
|
||||
|
||||
myMarkupModel.repaint(0, myDocument.getTextLength());
|
||||
myMarkupModel.recalcEditorDimensions();
|
||||
myMarkupModel.repaint(-1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -112,7 +112,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
return myMinMarkHeight;
|
||||
}
|
||||
|
||||
private void recalcEditorDimensions() {
|
||||
void recalcEditorDimensions() {
|
||||
EditorImpl.MyScrollBar scrollBar = myEditor.getVerticalScrollBar();
|
||||
int scrollBarHeight = scrollBar.getSize().height;
|
||||
|
||||
@@ -751,10 +751,10 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
LOG.assertTrue(success);
|
||||
}
|
||||
|
||||
public void markDirtied(@NotNull ProperTextRange pos) {
|
||||
int start = Math.max(0, pos.getStartOffset() - myEditor.getLineHeight());
|
||||
int end = myEditorScrollbarTop + myEditorTargetHeight == 0 ? pos.getEndOffset() + myEditor.getLineHeight()
|
||||
: Math.min(myEditorScrollbarTop + myEditorTargetHeight, pos.getEndOffset() + myEditor.getLineHeight());
|
||||
public void markDirtied(@NotNull ProperTextRange yPositions) {
|
||||
int start = Math.max(0, yPositions.getStartOffset() - myEditor.getLineHeight());
|
||||
int end = myEditorScrollbarTop + myEditorTargetHeight == 0 ? yPositions.getEndOffset() + myEditor.getLineHeight()
|
||||
: Math.min(myEditorScrollbarTop + myEditorTargetHeight, yPositions.getEndOffset() + myEditor.getLineHeight());
|
||||
ProperTextRange adj = new ProperTextRange(start, Math.max(end, start));
|
||||
|
||||
if (myDirtyYPositions == null) {
|
||||
|
||||
+86
-64
@@ -20,6 +20,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileSystemUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -175,6 +176,8 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
|
||||
private WatchRequest[] normalizeRootsForRefresh() {
|
||||
if (myCachedNormalizedRequests != null) return myCachedNormalizedRequests;
|
||||
List<WatchRequestImpl> result = new ArrayList<WatchRequestImpl>();
|
||||
|
||||
// No need to call for a read action here since we're only called with it on hands already.
|
||||
WRITE_LOCK.lock();
|
||||
try {
|
||||
NextRoot:
|
||||
@@ -338,37 +341,43 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
|
||||
}
|
||||
|
||||
@Override
|
||||
public WatchRequest addRootToWatch(@NotNull String rootPath, boolean toWatchRecursively) {
|
||||
public WatchRequest addRootToWatch(@NotNull final String rootPath, final boolean toWatchRecursively) {
|
||||
if (rootPath.length() == 0 || !FileWatcher.getInstance().isOperational()) return null;
|
||||
|
||||
WRITE_LOCK.lock();
|
||||
try {
|
||||
final WatchRequestImpl result = new WatchRequestImpl(rootPath, toWatchRecursively);
|
||||
boolean alreadyWatched = isAlreadyWatched(result);
|
||||
if (!alreadyWatched) {
|
||||
final VirtualFile existingFile = findFileByPathIfCached(rootPath);
|
||||
if (existingFile != null) {
|
||||
final ModalityState modalityState = ModalityState.defaultModalityState();
|
||||
RefreshQueue.getInstance().refresh(true, toWatchRecursively, null, modalityState, existingFile);
|
||||
if (existingFile.isDirectory() && !toWatchRecursively && existingFile instanceof NewVirtualFile) {
|
||||
for (VirtualFile child : ((NewVirtualFile)existingFile).getCachedChildren()) {
|
||||
RefreshQueue.getInstance().refresh(true, false, null, modalityState, child);
|
||||
Application app = ApplicationManager.getApplication();
|
||||
return app.runReadAction(new Computable<WatchRequest>() {
|
||||
@Override
|
||||
public WatchRequest compute() {
|
||||
WRITE_LOCK.lock();
|
||||
try {
|
||||
final WatchRequestImpl result = new WatchRequestImpl(rootPath, toWatchRecursively);
|
||||
boolean alreadyWatched = isAlreadyWatched(result);
|
||||
if (!alreadyWatched) {
|
||||
final VirtualFile existingFile = findFileByPathIfCached(rootPath);
|
||||
if (existingFile != null) {
|
||||
final ModalityState modalityState = ModalityState.defaultModalityState();
|
||||
RefreshQueue.getInstance().refresh(true, toWatchRecursively, null, modalityState, existingFile);
|
||||
if (existingFile.isDirectory() && !toWatchRecursively && existingFile instanceof NewVirtualFile) {
|
||||
for (VirtualFile child : ((NewVirtualFile)existingFile).getCachedChildren()) {
|
||||
RefreshQueue.getInstance().refresh(true, false, null, modalityState, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
myRootsToWatch.add(result);
|
||||
if (alreadyWatched) {
|
||||
result.myDominated = true;
|
||||
return result;
|
||||
}
|
||||
myCachedNormalizedRequests = null;
|
||||
setUpFileWatcher();
|
||||
return result;
|
||||
}
|
||||
finally {
|
||||
WRITE_LOCK.unlock();
|
||||
}
|
||||
}
|
||||
myRootsToWatch.add(result);
|
||||
if (alreadyWatched) {
|
||||
result.myDominated = true;
|
||||
return result;
|
||||
}
|
||||
myCachedNormalizedRequests = null;
|
||||
setUpFileWatcher();
|
||||
return result;
|
||||
}
|
||||
finally {
|
||||
WRITE_LOCK.unlock();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isAlreadyWatched(final WatchRequest request) {
|
||||
@@ -383,33 +392,38 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
|
||||
public Set<WatchRequest> addRootsToWatch(@NotNull final Collection<String> rootPaths, final boolean toWatchRecursively) {
|
||||
if (!FileWatcher.getInstance().isOperational()) return Collections.emptySet();
|
||||
|
||||
Set<WatchRequest> result = new HashSet<WatchRequest>();
|
||||
Set<VirtualFile> filesToSynchronize = new HashSet<VirtualFile>();
|
||||
final Set<WatchRequest> result = new HashSet<WatchRequest>();
|
||||
final Set<VirtualFile> filesToSynchronize = new HashSet<VirtualFile>();
|
||||
|
||||
WRITE_LOCK.lock();
|
||||
try {
|
||||
for (String rootPath : rootPaths) {
|
||||
LOG.assertTrue(rootPath != null);
|
||||
if (rootPath.length() > 0) {
|
||||
final WatchRequestImpl request = new WatchRequestImpl(rootPath, toWatchRecursively);
|
||||
final VirtualFile existingFile = findFileByPathIfCached(rootPath);
|
||||
if (existingFile != null) {
|
||||
if (!isAlreadyWatched(request)) {
|
||||
filesToSynchronize.add(existingFile);
|
||||
Application application = ApplicationManager.getApplication();
|
||||
application.runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
WRITE_LOCK.lock();
|
||||
try {
|
||||
for (String rootPath : rootPaths) {
|
||||
LOG.assertTrue(rootPath != null);
|
||||
if (rootPath.length() > 0) {
|
||||
final WatchRequestImpl request = new WatchRequestImpl(rootPath, toWatchRecursively);
|
||||
final VirtualFile existingFile = findFileByPathIfCached(rootPath);
|
||||
if (existingFile != null) {
|
||||
if (!isAlreadyWatched(request)) {
|
||||
filesToSynchronize.add(existingFile);
|
||||
}
|
||||
}
|
||||
result.add(request);
|
||||
myRootsToWatch.add(request); //add in any case, safe to add inplace without copying myRootsToWatch before the loop
|
||||
}
|
||||
}
|
||||
result.add(request);
|
||||
myRootsToWatch.add(request); //add in any case, safe to add inplace without copying myRootsToWatch before the loop
|
||||
myCachedNormalizedRequests = null;
|
||||
setUpFileWatcher();
|
||||
}
|
||||
finally {
|
||||
WRITE_LOCK.unlock();
|
||||
}
|
||||
}
|
||||
myCachedNormalizedRequests = null;
|
||||
setUpFileWatcher();
|
||||
}
|
||||
finally {
|
||||
WRITE_LOCK.unlock();
|
||||
}
|
||||
});
|
||||
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode() && !filesToSynchronize.isEmpty()) {
|
||||
if (!application.isUnitTestMode() && !filesToSynchronize.isEmpty()) {
|
||||
for (VirtualFile file : filesToSynchronize) {
|
||||
if (file instanceof NewVirtualFile && file.getFileSystem() instanceof LocalFileSystem) {
|
||||
((NewVirtualFile)file).markDirtyRecursively();
|
||||
@@ -423,30 +437,38 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
|
||||
|
||||
@Override
|
||||
public void removeWatchedRoot(@NotNull final WatchRequest watchRequest) {
|
||||
WRITE_LOCK.lock();
|
||||
try {
|
||||
if (myRootsToWatch.remove((WatchRequestImpl)watchRequest) && !((WatchRequestImpl)watchRequest).myDominated) {
|
||||
myCachedNormalizedRequests = null;
|
||||
setUpFileWatcher();
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
WRITE_LOCK.lock();
|
||||
try {
|
||||
if (myRootsToWatch.remove((WatchRequestImpl)watchRequest) && !((WatchRequestImpl)watchRequest).myDominated) {
|
||||
myCachedNormalizedRequests = null;
|
||||
setUpFileWatcher();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
WRITE_LOCK.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
WRITE_LOCK.unlock();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeWatchedRoots(@NotNull final Collection<WatchRequest> rootsToWatch) {
|
||||
WRITE_LOCK.lock();
|
||||
try {
|
||||
if (myRootsToWatch.removeAll(rootsToWatch)) {
|
||||
myCachedNormalizedRequests = null;
|
||||
setUpFileWatcher();
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
WRITE_LOCK.lock();
|
||||
try {
|
||||
if (myRootsToWatch.removeAll(rootsToWatch)) {
|
||||
myCachedNormalizedRequests = null;
|
||||
setUpFileWatcher();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
WRITE_LOCK.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
WRITE_LOCK.unlock();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1183,7 +1183,9 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
button.dispose();
|
||||
myId2StripeButton.remove(id);
|
||||
//
|
||||
myId2FocusWatcher.remove(id);
|
||||
ToolWindowFocusWatcher watcher = (ToolWindowFocusWatcher)myId2FocusWatcher.remove(id);
|
||||
watcher.deinstall();
|
||||
|
||||
// Destroy decorator
|
||||
final InternalDecorator decorator = getInternalDecorator(id);
|
||||
decorator.dispose();
|
||||
@@ -1946,11 +1948,17 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
*/
|
||||
private final class ToolWindowFocusWatcher extends FocusWatcher {
|
||||
private final String myId;
|
||||
private final ToolWindowImpl myToolWindow;
|
||||
|
||||
|
||||
private ToolWindowFocusWatcher(final ToolWindowImpl toolWindow) {
|
||||
myId = toolWindow.getId();
|
||||
install(toolWindow.getComponent());
|
||||
myToolWindow = toolWindow;
|
||||
}
|
||||
|
||||
public void deinstall() {
|
||||
deinstall(myToolWindow.getComponent());
|
||||
}
|
||||
|
||||
protected boolean isFocusedComponentChangeValid(final Component comp, final AWTEvent cause) {
|
||||
|
||||
@@ -152,7 +152,10 @@ dir.diff.default.src.folder=
|
||||
dir.diff.default.trg.folder=
|
||||
show.live.templates.in.completion=false
|
||||
documentation.component.editor.font=false
|
||||
|
||||
ide.mac.useNativeClipboard=true
|
||||
ide.mac.useNativeClipboard.async=false
|
||||
|
||||
show.all.classes.on.first.completion=false
|
||||
limited.relevance.sorting.in.completion=false
|
||||
limited.relevance.sorting.in.completion.description=Whether only 5 most relevant items are shown at the top of the completion list, or it's sorted by relevance completely
|
||||
@@ -166,4 +169,4 @@ show.anonymous.in.structure.view=false
|
||||
show.anonymous.in.structure.view.description=Enables Java anonymous classes in Structure View
|
||||
|
||||
enable.groovy.hotswap=true
|
||||
enable.groovy.hotswap.description=Whether IDEA should add a special java agent to the debugged process which allows to hot-swap Groovy changes in some cases
|
||||
enable.groovy.hotswap.description=Whether IDEA should add a special java agent to the debugged process which allows to hot-swap Groovy changes in some cases
|
||||
|
||||
+2
-1
@@ -32,6 +32,7 @@ import com.intellij.openapi.util.DefaultJDOMExternalizer;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.JDOMExternalizable;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.changes.*;
|
||||
import com.intellij.openapi.vcs.changes.shelf.ShelveChangesManager;
|
||||
@@ -70,7 +71,7 @@ public class CreatePatchCommitExecutor implements CommitExecutorWithHelp, Projec
|
||||
|
||||
@Nls
|
||||
public String getActionText() {
|
||||
return VcsBundle.message("create.patch.commit.action.text");
|
||||
return VcsBundle.message("create.patch.commit.action.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ public class DiffShelvedChangesAction extends AnAction implements DumbAware {
|
||||
VcsBalloonProblemNotifier.showOverChangesView(project, "Show Diff: Cannot find base for: " + StringUtil.join(missing, ",\n"), MessageType.WARNING);
|
||||
}
|
||||
|
||||
ShowDiffAction.showDiffImpl(project, diffRequestPresentables, toSelectIdx, new ShowDiffUIContext(false));
|
||||
ShowDiffAction.showDiffImpl(project, diffRequestPresentables, toSelectIdx, new ShowDiffUIContext(true));
|
||||
}
|
||||
|
||||
private static class PatchesPreloader {
|
||||
|
||||
@@ -77,6 +77,7 @@ public class LineStatusTracker {
|
||||
private boolean myAnathemaThrown;
|
||||
private FileEditorManager myFileEditorManager;
|
||||
private final VirtualFile myVirtualFile;
|
||||
private volatile boolean myReleased;
|
||||
|
||||
private LineStatusTracker(final Document document, final Document upToDateDocument, final Project project, final VirtualFile virtualFile) {
|
||||
myVirtualFile = virtualFile;
|
||||
@@ -89,10 +90,12 @@ public class LineStatusTracker {
|
||||
myRanges = new ArrayList<Range>();
|
||||
myAnathemaThrown = false;
|
||||
myFileEditorManager = FileEditorManager.getInstance(myProject);
|
||||
myReleased = false;
|
||||
}
|
||||
|
||||
public void initialize(@NotNull final String upToDateContent, @NotNull RevisionPack baseRevisionNumber) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
if (myReleased) return;
|
||||
|
||||
synchronized (myLock) {
|
||||
try {
|
||||
@@ -166,6 +169,7 @@ public class LineStatusTracker {
|
||||
|
||||
@SuppressWarnings({"AutoBoxing"})
|
||||
private RangeHighlighter createHighlighter(final Range range) {
|
||||
assert ! myReleased;
|
||||
int first =
|
||||
range.getOffset1() >= myDocument.getLineCount() ? myDocument.getTextLength() : myDocument.getLineStartOffset(range.getOffset1());
|
||||
|
||||
@@ -204,6 +208,7 @@ public class LineStatusTracker {
|
||||
removeHighlightersFromMarkupModel();
|
||||
myRanges.clear();
|
||||
}
|
||||
myReleased = true;
|
||||
}
|
||||
|
||||
public Document getDocument() {
|
||||
@@ -228,6 +233,7 @@ public class LineStatusTracker {
|
||||
}
|
||||
|
||||
public void startBulkUpdate() {
|
||||
if (myReleased) return;
|
||||
synchronized (myLock) {
|
||||
myBulkUpdate = true;
|
||||
removeAnathema();
|
||||
@@ -247,6 +253,7 @@ public class LineStatusTracker {
|
||||
}
|
||||
|
||||
public void finishBulkUpdate() {
|
||||
if (myReleased) return;
|
||||
synchronized (myLock) {
|
||||
myBulkUpdate = false;
|
||||
reinstallRanges();
|
||||
@@ -286,6 +293,7 @@ public class LineStatusTracker {
|
||||
private final VcsDirtyScopeManager myVcsDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject);
|
||||
|
||||
public void beforeDocumentChange(DocumentEvent e) {
|
||||
if (myReleased) return;
|
||||
myApplication.assertWriteAccessAllowed();
|
||||
|
||||
synchronized (myLock) {
|
||||
@@ -338,6 +346,11 @@ public class LineStatusTracker {
|
||||
}
|
||||
|
||||
public void documentChanged(final DocumentEvent e) {
|
||||
if (myReleased) {
|
||||
return;
|
||||
}
|
||||
// TODO: remove assertion when cached document listeners will work ok
|
||||
//assert ! myReleased;
|
||||
myApplication.assertWriteAccessAllowed();
|
||||
|
||||
synchronized (myLock) {
|
||||
|
||||
@@ -212,14 +212,9 @@ public class LineStatusTrackerManager implements ProjectComponent, LineStatusTra
|
||||
if (tracker == null && (! shouldBeInstalled)) return;
|
||||
|
||||
if (tracker != null) {
|
||||
if (! shouldBeInstalled) {
|
||||
releaseTracker(document);
|
||||
return;
|
||||
} else {
|
||||
tracker.resetForBaseRevisionLoad();
|
||||
startAlarm(document, virtualFile);
|
||||
}
|
||||
} else if (shouldBeInstalled) {
|
||||
releaseTracker(document);
|
||||
}
|
||||
if (shouldBeInstalled) {
|
||||
installTracker(virtualFile, document);
|
||||
}
|
||||
}
|
||||
|
||||
+22
-22
@@ -68,32 +68,32 @@ public interface GroovyElementTypes extends GroovyTokenTypes, GroovyDocElementTy
|
||||
*/
|
||||
GrStubElementType<GrTypeDefinitionStub, GrClassDefinition> CLASS_DEFINITION =
|
||||
new GrTypeDefinitionElementType<GrClassDefinition>("class definition") {
|
||||
public GrClassDefinition createPsi(GrTypeDefinitionStub stub) {
|
||||
public GrClassDefinition createPsi(@NotNull GrTypeDefinitionStub stub) {
|
||||
return new GrClassDefinitionImpl(stub);
|
||||
}
|
||||
};
|
||||
GrStubElementType<GrTypeDefinitionStub, GrInterfaceDefinition> INTERFACE_DEFINITION =
|
||||
new GrTypeDefinitionElementType<GrInterfaceDefinition>("interface definition") {
|
||||
public GrInterfaceDefinition createPsi(GrTypeDefinitionStub stub) {
|
||||
public GrInterfaceDefinition createPsi(@NotNull GrTypeDefinitionStub stub) {
|
||||
return new GrInterfaceDefinitionImpl(stub);
|
||||
}
|
||||
};
|
||||
GrStubElementType<GrTypeDefinitionStub, GrEnumTypeDefinition> ENUM_DEFINITION =
|
||||
new GrTypeDefinitionElementType<GrEnumTypeDefinition>("enumeration definition") {
|
||||
public GrEnumTypeDefinition createPsi(GrTypeDefinitionStub stub) {
|
||||
public GrEnumTypeDefinition createPsi(@NotNull GrTypeDefinitionStub stub) {
|
||||
return new GrEnumTypeDefinitionImpl(stub);
|
||||
}
|
||||
};
|
||||
GrStubElementType<GrTypeDefinitionStub, GrAnnotationTypeDefinition> ANNOTATION_DEFINITION =
|
||||
new GrTypeDefinitionElementType<GrAnnotationTypeDefinition>("annotation definition") {
|
||||
public GrAnnotationTypeDefinition createPsi(GrTypeDefinitionStub stub) {
|
||||
public GrAnnotationTypeDefinition createPsi(@NotNull GrTypeDefinitionStub stub) {
|
||||
return new GrAnnotationTypeDefinitionImpl(stub);
|
||||
}
|
||||
};
|
||||
GrStubElementType<GrTypeDefinitionStub, GrAnonymousClassDefinition> ANONYMOUS_CLASS_DEFINITION =
|
||||
new GrTypeDefinitionElementType<GrAnonymousClassDefinition>("Anonymous class") {
|
||||
@Override
|
||||
public GrAnonymousClassDefinition createPsi(GrTypeDefinitionStub stub) {
|
||||
public GrAnonymousClassDefinition createPsi(@NotNull GrTypeDefinitionStub stub) {
|
||||
return new GrAnonymousClassDefinitionImpl(stub);
|
||||
}
|
||||
};
|
||||
@@ -101,7 +101,7 @@ public interface GroovyElementTypes extends GroovyTokenTypes, GroovyDocElementTy
|
||||
GrStubElementType<GrTypeDefinitionStub, GrEnumConstantInitializer> ENUM_CONSTANT_INITIALIZER =
|
||||
new GrTypeDefinitionElementType<GrEnumConstantInitializer>("Enum constant initializer") {
|
||||
@Override
|
||||
public GrEnumConstantInitializer createPsi(GrTypeDefinitionStub stub) {
|
||||
public GrEnumConstantInitializer createPsi(@NotNull GrTypeDefinitionStub stub) {
|
||||
return new GrEnumConstantInitializerImpl(stub);
|
||||
}
|
||||
};
|
||||
@@ -112,13 +112,13 @@ public interface GroovyElementTypes extends GroovyTokenTypes, GroovyDocElementTy
|
||||
GrStubElementType<GrFieldStub, GrField> FIELD = new GrFieldElementType();
|
||||
GrMethodElementType METHOD_DEFINITION = new GrMethodElementType("method definition") {
|
||||
|
||||
public GrMethod createPsi(GrMethodStub stub) {
|
||||
public GrMethod createPsi(@NotNull GrMethodStub stub) {
|
||||
return new GrMethodImpl(stub);
|
||||
}
|
||||
};
|
||||
GrStubElementType<GrMethodStub, GrMethod> ANNOTATION_METHOD = new GrMethodElementType("annotation method") {
|
||||
@Override
|
||||
public GrMethod createPsi(GrMethodStub stub) {
|
||||
public GrMethod createPsi(@NotNull GrMethodStub stub) {
|
||||
return new GrAnnotationMethodImpl(stub);
|
||||
}
|
||||
|
||||
@@ -133,12 +133,12 @@ public interface GroovyElementTypes extends GroovyTokenTypes, GroovyDocElementTy
|
||||
};
|
||||
|
||||
GrReferenceListElementType<GrImplementsClause> IMPLEMENTS_CLAUSE = new GrReferenceListElementType<GrImplementsClause>("implements clause") {
|
||||
public GrImplementsClause createPsi(GrReferenceListStub stub) {
|
||||
public GrImplementsClause createPsi(@NotNull GrReferenceListStub stub) {
|
||||
return new GrImplementsClauseImpl(stub);
|
||||
}
|
||||
};
|
||||
GrReferenceListElementType<GrExtendsClause> EXTENDS_CLAUSE = new GrReferenceListElementType<GrExtendsClause>("super class clause") {
|
||||
public GrExtendsClause createPsi(GrReferenceListStub stub) {
|
||||
public GrExtendsClause createPsi(@NotNull GrReferenceListStub stub) {
|
||||
return new GrExtendsClauseImpl(stub);
|
||||
}
|
||||
};
|
||||
@@ -263,19 +263,19 @@ public interface GroovyElementTypes extends GroovyTokenTypes, GroovyDocElementTy
|
||||
GroovyElementType TYPE_ARGUMENT = new GroovyElementType("type argument");
|
||||
EmptyStubElementType<GrTypeParameterList> TYPE_PARAMETER_LIST = new EmptyStubElementType<GrTypeParameterList>("type parameter list", GroovyFileType.GROOVY_LANGUAGE) {
|
||||
@Override
|
||||
public GrTypeParameterList createPsi(EmptyStub stub) {
|
||||
public GrTypeParameterList createPsi(@NotNull EmptyStub stub) {
|
||||
return new GrTypeParameterListImpl(stub);
|
||||
}
|
||||
};
|
||||
|
||||
GrStubElementType<GrTypeParameterStub, GrTypeParameter> TYPE_PARAMETER = new GrStubElementType<GrTypeParameterStub, GrTypeParameter>("type parameter") {
|
||||
@Override
|
||||
public GrTypeParameter createPsi(GrTypeParameterStub stub) {
|
||||
public GrTypeParameter createPsi(@NotNull GrTypeParameterStub stub) {
|
||||
return new GrTypeParameterImpl(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrTypeParameterStub createStub(GrTypeParameter psi, StubElement parentStub) {
|
||||
public GrTypeParameterStub createStub(@NotNull GrTypeParameter psi, StubElement parentStub) {
|
||||
return new GrTypeParameterStub(parentStub, StringRef.fromString(psi.getName()));
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ public interface GroovyElementTypes extends GroovyTokenTypes, GroovyDocElementTy
|
||||
|
||||
GrMethodElementType CONSTRUCTOR_DEFINITION = new GrMethodElementType("constructor definition") {
|
||||
@Override
|
||||
public GrMethod createPsi(GrMethodStub stub) {
|
||||
public GrMethod createPsi(@NotNull GrMethodStub stub) {
|
||||
return new GrConstructorImpl(stub);
|
||||
}
|
||||
};
|
||||
@@ -313,12 +313,12 @@ public interface GroovyElementTypes extends GroovyTokenTypes, GroovyDocElementTy
|
||||
GrStubElementType<GrAnnotationStub, GrAnnotation> ANNOTATION = new GrStubElementType<GrAnnotationStub, GrAnnotation>("annotation") {
|
||||
|
||||
@Override
|
||||
public GrAnnotation createPsi(GrAnnotationStub stub) {
|
||||
public GrAnnotation createPsi(@NotNull GrAnnotationStub stub) {
|
||||
return new GrAnnotationImpl(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrAnnotationStub createStub(GrAnnotation psi, StubElement parentStub) {
|
||||
public GrAnnotationStub createStub(@NotNull GrAnnotation psi, StubElement parentStub) {
|
||||
return new GrAnnotationStub(parentStub, psi);
|
||||
}
|
||||
|
||||
@@ -335,19 +335,19 @@ public interface GroovyElementTypes extends GroovyTokenTypes, GroovyDocElementTy
|
||||
//parameters
|
||||
EmptyStubElementType<GrParameterList> PARAMETERS_LIST = new EmptyStubElementType<GrParameterList>("parameters list", GroovyFileType.GROOVY_LANGUAGE) {
|
||||
@Override
|
||||
public GrParameterList createPsi(EmptyStub stub) {
|
||||
public GrParameterList createPsi(@NotNull EmptyStub stub) {
|
||||
return new GrParameterListImpl(stub);
|
||||
}
|
||||
};
|
||||
|
||||
GrStubElementType<GrParameterStub, GrParameter> PARAMETER = new GrStubElementType<GrParameterStub, GrParameter>("parameter") {
|
||||
@Override
|
||||
public GrParameter createPsi(GrParameterStub stub) {
|
||||
public GrParameter createPsi(@NotNull GrParameterStub stub) {
|
||||
return new GrParameterImpl(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrParameterStub createStub(GrParameter psi, StubElement parentStub) {
|
||||
public GrParameterStub createStub(@NotNull GrParameter psi, StubElement parentStub) {
|
||||
return new GrParameterStub(parentStub, StringRef.fromString(psi.getName()), GrStubUtils.getAnnotationNames(psi), GrStubUtils.getTypeText(psi));
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ public interface GroovyElementTypes extends GroovyTokenTypes, GroovyDocElementTy
|
||||
|
||||
EmptyStubElementType<GrTypeDefinitionBody> CLASS_BODY = new EmptyStubElementType<GrTypeDefinitionBody>("class block", GroovyFileType.GROOVY_LANGUAGE) {
|
||||
@Override
|
||||
public GrTypeDefinitionBody createPsi(EmptyStub stub) {
|
||||
public GrTypeDefinitionBody createPsi(@NotNull EmptyStub stub) {
|
||||
return new GrTypeDefinitionBodyBase.GrClassBody(stub);
|
||||
}
|
||||
};
|
||||
@@ -402,14 +402,14 @@ public interface GroovyElementTypes extends GroovyTokenTypes, GroovyDocElementTy
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrVariableDeclaration createPsi(EmptyStub stub) {
|
||||
public GrVariableDeclaration createPsi(@NotNull EmptyStub stub) {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
}
|
||||
};
|
||||
EmptyStubElementType<GrVariableDeclaration> VARIABLE_DEFINITION =
|
||||
new EmptyStubElementType<GrVariableDeclaration>("variable definitions", GroovyFileType.GROOVY_LANGUAGE) {
|
||||
@Override
|
||||
public GrVariableDeclaration createPsi(EmptyStub stub) {
|
||||
public GrVariableDeclaration createPsi(@NotNull EmptyStub stub) {
|
||||
return new GrVariableDeclarationBase.GrVariables(stub);
|
||||
}
|
||||
};
|
||||
|
||||
+3
-2
@@ -21,6 +21,7 @@ import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef.enumConstant.GrEnumConstantImpl;
|
||||
@@ -38,12 +39,12 @@ public class GrEnumConstantElementType extends GrStubElementType<GrFieldStub, Gr
|
||||
super("Enumeration constant");
|
||||
}
|
||||
|
||||
public GrEnumConstant createPsi(GrFieldStub stub) {
|
||||
public GrEnumConstant createPsi(@NotNull GrFieldStub stub) {
|
||||
return new GrEnumConstantImpl(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrFieldStub createStub(GrEnumConstant psi, StubElement parentStub) {
|
||||
public GrFieldStub createStub(@NotNull GrEnumConstant psi, StubElement parentStub) {
|
||||
String[] annNames = GrStubUtils.getAnnotationNames(psi);
|
||||
return new GrFieldStub(parentStub, StringRef.fromString(psi.getName()), annNames, ArrayUtil.EMPTY_STRING_ARRAY, GroovyElementTypes.ENUM_CONSTANT, GrFieldStub.buildFlags(psi), null);
|
||||
}
|
||||
|
||||
+3
-2
@@ -20,6 +20,7 @@ import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.GrFieldImpl;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrFieldStub;
|
||||
@@ -43,11 +44,11 @@ public class GrFieldElementType extends GrStubElementType<GrFieldStub, GrField>
|
||||
super("field");
|
||||
}
|
||||
|
||||
public GrField createPsi(GrFieldStub stub) {
|
||||
public GrField createPsi(@NotNull GrFieldStub stub) {
|
||||
return new GrFieldImpl(stub);
|
||||
}
|
||||
|
||||
public GrFieldStub createStub(GrField psi, StubElement parentStub) {
|
||||
public GrFieldStub createStub(@NotNull GrField psi, StubElement parentStub) {
|
||||
String[] annNames = GrStubUtils.getAnnotationNames(psi);
|
||||
|
||||
Set<String> namedParameters = Collections.emptySet();
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrMethodStub;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrStubUtils;
|
||||
@@ -38,7 +39,7 @@ public abstract class GrMethodElementType extends GrStubElementType<GrMethodStub
|
||||
super(debugName);
|
||||
}
|
||||
|
||||
public GrMethodStub createStub(GrMethod psi, StubElement parentStub) {
|
||||
public GrMethodStub createStub(@NotNull GrMethod psi, StubElement parentStub) {
|
||||
|
||||
Set<String> namedParameters = psi.getNamedParameters().keySet();
|
||||
return new GrMethodStub(parentStub, StringRef.fromString(psi.getName()), GrStubUtils.getAnnotationNames(psi),
|
||||
|
||||
+3
-2
@@ -18,6 +18,7 @@ package org.jetbrains.plugins.groovy.lang.psi.stubs.elements;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary.modifiers.GrModifierListImpl;
|
||||
@@ -34,12 +35,12 @@ public class GrModifierListElementType extends GrStubElementType<GrModifierListS
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrModifierList createPsi(GrModifierListStub stub) {
|
||||
public GrModifierList createPsi(@NotNull GrModifierListStub stub) {
|
||||
return new GrModifierListImpl(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrModifierListStub createStub(GrModifierList psi, StubElement parentStub) {
|
||||
public GrModifierListStub createStub(@NotNull GrModifierList psi, StubElement parentStub) {
|
||||
return new GrModifierListStub(parentStub, GroovyElementTypes.MODIFIERS, GrModifierListStub.buildFlags(psi));
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
import com.intellij.psi.stubs.StubOutputStream;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrReferenceList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrReferenceListStub;
|
||||
@@ -41,7 +42,7 @@ public abstract class GrReferenceListElementType<T extends GrReferenceList> exte
|
||||
super(debugName);
|
||||
}
|
||||
|
||||
public GrReferenceListStub createStub(T psi, StubElement parentStub) {
|
||||
public GrReferenceListStub createStub(@NotNull T psi, StubElement parentStub) {
|
||||
List<String> refNames = new ArrayList<String>();
|
||||
for (GrCodeReferenceElement element : psi.getReferenceElements()) {
|
||||
final String name = element.getText();
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ public abstract class GrTypeDefinitionElementType<TypeDef extends GrTypeDefiniti
|
||||
super(debugName);
|
||||
}
|
||||
|
||||
public GrTypeDefinitionStub createStub(TypeDef psi, StubElement parentStub) {
|
||||
public GrTypeDefinitionStub createStub(@NotNull TypeDef psi, StubElement parentStub) {
|
||||
String[] superClassNames = psi.getSuperClassNames();
|
||||
final byte flags = GrTypeDefinitionStub.buildFlags(psi);
|
||||
return new GrTypeDefinitionStub(parentStub, psi.getName(), superClassNames, this, psi.getQualifiedName(), GrStubUtils
|
||||
|
||||
+2
-1
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.plugins.groovy.lang.resolve.ast;
|
||||
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import com.intellij.psi.impl.light.LightMethodBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
@@ -34,7 +35,7 @@ public class AutoCloneContributor extends AstTransformContributor {
|
||||
public void collectMethods(@NotNull GrTypeDefinition clazz, Collection<PsiMethod> collector) {
|
||||
if (PsiImplUtil.getAnnotation(clazz, GroovyCommonClassNames.GROOVY_TRANSFORM_AUTO_CLONE) == null) return;
|
||||
|
||||
final LightMethodBuilder clone = new LightMethodBuilder(clazz.getManager(), "clone");
|
||||
final LightMethodBuilder clone = new LightMethodBuilder(clazz.getManager(), "clone").addModifier(PsiModifier.PUBLIC);
|
||||
clone.setContainingClass(clazz);
|
||||
clone.addException(CloneNotSupportedException.class.getName());
|
||||
collector.add(clone);
|
||||
|
||||
+1
@@ -57,6 +57,7 @@ public class DelegatedMethodsContributor extends AstTransformContributor {
|
||||
for (PsiMethod method : methods) {
|
||||
if (method.isConstructor()) continue;
|
||||
if (!deprecated && PsiImplUtil.getAnnotation(method, "java.lang.Deprecated") != null) continue;
|
||||
if (clazz.findCodeMethodsBySignature(method, false).length > 0) continue;
|
||||
collector.add(generateDelegateMethod(method, clazz, resolveResult.getSubstitutor()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +102,10 @@ public class GeneratorTest extends LightGroovyTestCase {
|
||||
myFixture.addClass("package groovy.lang; public @interface Delegate {}");
|
||||
doTest();
|
||||
}
|
||||
public void testAutoCloneAnno() throws Throwable {
|
||||
myFixture.addClass("package groovy.transform; public @interface AutoClone {}");
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void doTest() {
|
||||
final String relTestPath = getTestName(true) + ".test";
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
@groovy.transform.AutoClone
|
||||
class Foo {}
|
||||
-----
|
||||
public class Foo extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public java.lang.Object clone() throws java.lang.CloneNotSupportedException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String property) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String property, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass metaClass) {
|
||||
return ;
|
||||
}
|
||||
|
||||
}
|
||||
---
|
||||
@@ -9,6 +9,10 @@ class DelegateBarImpl {
|
||||
private @Delegate(interfaces=false) Runnable zoo;
|
||||
private @Delegate Doo doo;
|
||||
}
|
||||
class Del2 implements DelegateFoo {
|
||||
@Delegate DelegateFoo foo;
|
||||
def foo() {}
|
||||
}
|
||||
-----
|
||||
public interface DelegateFoo {
|
||||
public java.lang.Object foo() ;
|
||||
@@ -79,4 +83,40 @@ private DelegateFoo foo = null;
|
||||
private java.lang.Runnable zoo = null;
|
||||
private Doo doo = null;
|
||||
}
|
||||
---
|
||||
public class Del2 extends groovy.lang.GroovyObjectSupport implements DelegateFoo, groovy.lang.GroovyObject {
|
||||
public java.lang.Object foo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public DelegateFoo getFoo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setFoo(DelegateFoo foo) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String property) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String property, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass metaClass) {
|
||||
return ;
|
||||
}
|
||||
|
||||
private DelegateFoo foo = null;
|
||||
}
|
||||
---
|
||||
+3
-2
@@ -24,6 +24,7 @@ import com.intellij.lang.properties.psi.PropertiesListStub;
|
||||
import com.intellij.lang.properties.psi.impl.PropertiesListImpl;
|
||||
import com.intellij.lang.properties.psi.impl.PropertiesListStubImpl;
|
||||
import com.intellij.psi.stubs.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -32,11 +33,11 @@ public class PropertyListStubElementType extends IStubElementType<PropertiesList
|
||||
super("PROPERTIES_LIST", PropertiesElementTypes.LANG);
|
||||
}
|
||||
|
||||
public PropertiesList createPsi(final PropertiesListStub stub) {
|
||||
public PropertiesList createPsi(@NotNull final PropertiesListStub stub) {
|
||||
return new PropertiesListImpl(stub);
|
||||
}
|
||||
|
||||
public PropertiesListStub createStub(final PropertiesList psi, final StubElement parentStub) {
|
||||
public PropertiesListStub createStub(@NotNull final PropertiesList psi, final StubElement parentStub) {
|
||||
return new PropertiesListStubImpl(parentStub);
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -26,6 +26,7 @@ import com.intellij.lang.properties.psi.impl.PropertyImpl;
|
||||
import com.intellij.lang.properties.psi.impl.PropertyStubImpl;
|
||||
import com.intellij.psi.stubs.*;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -34,11 +35,11 @@ public class PropertyStubElementType extends IStubElementType<PropertyStub, Prop
|
||||
super("PROPERTY", PropertiesElementTypes.LANG);
|
||||
}
|
||||
|
||||
public Property createPsi(final PropertyStub stub) {
|
||||
public Property createPsi(@NotNull final PropertyStub stub) {
|
||||
return new PropertyImpl(stub, this);
|
||||
}
|
||||
|
||||
public PropertyStub createStub(final Property psi, final StubElement parentStub) {
|
||||
public PropertyStub createStub(@NotNull final Property psi, final StubElement parentStub) {
|
||||
return new PropertyStubImpl(parentStub, psi.getKey());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user