mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
+12
@@ -25,6 +25,7 @@ import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.JdkOrderEntry;
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -62,6 +63,17 @@ public class IdeaProjectSettingsService extends ProjectSettingsService implement
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openLibrary(@NotNull final Library library) {
|
||||
final ProjectStructureConfigurable config = ProjectStructureConfigurable.getInstance(myProject);
|
||||
ShowSettingsUtil.getInstance().editConfigurable(myProject, config, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
config.selectProjectOrGlobalLibrary(library, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canOpenModuleSettings() {
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -13,31 +13,24 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.psi.impl.source.tree;
|
||||
|
||||
import com.intellij.lang.ASTFactory;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.lang.java.parser.JavaParser;
|
||||
import com.intellij.lang.java.parser.JavaParserUtil;
|
||||
import com.intellij.lexer.JavaLexer;
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.GeneratedMarkerVisitor;
|
||||
import com.intellij.psi.impl.light.LightTypeElement;
|
||||
import com.intellij.psi.impl.source.*;
|
||||
import com.intellij.psi.impl.source.codeStyle.CodeEditUtil;
|
||||
import com.intellij.psi.impl.source.parsing.ParseUtilBase;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.CharTable;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -61,15 +54,16 @@ public class JavaTreeGenerator implements TreeGenerator {
|
||||
final String text = original.getText();
|
||||
return createLeafFromText(text, table, manager, original, ((PsiJavaToken)original).getTokenType());
|
||||
}
|
||||
|
||||
if (original instanceof PsiModifierList) {
|
||||
final String text = original.getText();
|
||||
assert text != null : "Text is null for " + original + "; " + original.getClass();
|
||||
final LanguageLevel level = PsiUtil.getLanguageLevel(original);
|
||||
final DummyHolder holder = DummyHolderFactory.createHolder(original.getManager(), new JavaDummyElement(text, MOD_LIST, level), null);
|
||||
final TreeElement modifierListElement = holder.getTreeElement().getFirstChildNode();
|
||||
if (CodeEditUtil.isNodeGenerated(original.getNode())) modifierListElement.acceptTree(new GeneratedMarkerVisitor());
|
||||
return modifierListElement;
|
||||
return markGeneratedIfNeeded(original, modifierListElement);
|
||||
}
|
||||
|
||||
if (original instanceof PsiReferenceExpression) {
|
||||
TreeElement element = createReferenceExpression(original.getProject(), original.getText(), original);
|
||||
PsiElement refElement = ((PsiJavaCodeReferenceElement)original).resolve();
|
||||
@@ -78,6 +72,7 @@ public class JavaTreeGenerator implements TreeGenerator {
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
if (original instanceof PsiJavaCodeReferenceElement) {
|
||||
PsiElement refElement = ((PsiJavaCodeReferenceElement)original).resolve();
|
||||
final boolean generated = refElement != null && CodeEditUtil.isNodeGenerated(refElement.getNode());
|
||||
@@ -115,6 +110,7 @@ public class JavaTreeGenerator implements TreeGenerator {
|
||||
}
|
||||
return createReference(original.getProject(), original.getText(), generated);
|
||||
}
|
||||
|
||||
if (original instanceof PsiCompiledElement) {
|
||||
PsiElement sourceVersion = original.getNavigationElement();
|
||||
if (sourceVersion != original) {
|
||||
@@ -123,84 +119,44 @@ public class JavaTreeGenerator implements TreeGenerator {
|
||||
ASTNode mirror = SourceTreeToPsiMap.psiElementToTree(((PsiCompiledElement)original).getMirror());
|
||||
return ChangeUtil.generateTreeElement(SourceTreeToPsiMap.treeElementToPsi(mirror), table,manager);
|
||||
}
|
||||
|
||||
if (original instanceof PsiTypeElement) {
|
||||
final boolean generated = CodeEditUtil.isNodeGenerated(original.getNode());
|
||||
PsiTypeElement typeElement = (PsiTypeElement)original;
|
||||
PsiType type = typeElement.getType();
|
||||
if (type instanceof PsiEllipsisType) {
|
||||
TreeElement componentTypeCopy = ChangeUtil.generateTreeElement(
|
||||
new LightTypeElement(original.getManager(), ((PsiEllipsisType)type).getComponentType()),
|
||||
table,
|
||||
manager);
|
||||
if (componentTypeCopy == null) return null;
|
||||
CompositeElement element = ASTFactory.composite(JavaElementType.TYPE);
|
||||
CodeEditUtil.setNodeGenerated(element, generated);
|
||||
element.rawAddChildren(componentTypeCopy);
|
||||
element.rawAddChildren(createLeafFromText("...", table, manager, original, JavaTokenType.ELLIPSIS));
|
||||
return element;
|
||||
}
|
||||
if (type instanceof PsiArrayType) {
|
||||
TreeElement componentTypeCopy = ChangeUtil.generateTreeElement(
|
||||
new LightTypeElement(original.getManager(), ((PsiArrayType)type).getComponentType()),
|
||||
table,
|
||||
manager);
|
||||
if (componentTypeCopy == null) return null;
|
||||
CompositeElement element = ASTFactory.composite(JavaElementType.TYPE);
|
||||
CodeEditUtil.setNodeGenerated(element, generated);
|
||||
element.rawAddChildren(componentTypeCopy);
|
||||
element.rawAddChildren(createLeafFromText("[", table, manager, original, JavaTokenType.LBRACKET));
|
||||
element.rawAddChildren(createLeafFromText("]", table, manager, original, JavaTokenType.RBRACKET));
|
||||
return element;
|
||||
}
|
||||
if (type instanceof PsiPrimitiveType) {
|
||||
@NonNls String text = typeElement.getText();
|
||||
if (text.equals("null")) return null;
|
||||
Lexer lexer = new JavaLexer(LanguageLevel.JDK_1_3);
|
||||
lexer.start(text);
|
||||
TreeElement keyword = ParseUtilBase.createTokenElement(lexer, table);
|
||||
CodeEditUtil.setNodeGenerated(keyword, generated);
|
||||
CompositeElement element = ASTFactory.composite(JavaElementType.TYPE);
|
||||
CodeEditUtil.setNodeGenerated(element, generated);
|
||||
element.rawAddChildren(keyword);
|
||||
return element;
|
||||
}
|
||||
if (type instanceof PsiWildcardType || type instanceof PsiCapturedWildcardType || type instanceof PsiDisjunctionType) {
|
||||
final String originalText = original.getText();
|
||||
return createType(original.getProject(), originalText, null, generated);
|
||||
}
|
||||
|
||||
if (type instanceof PsiIntersectionType) {
|
||||
LightTypeElement te = new LightTypeElement(original.getManager(), ((PsiIntersectionType)type).getRepresentative());
|
||||
return ChangeUtil.generateTreeElement(te, table, manager);
|
||||
type = ((PsiIntersectionType)type).getRepresentative();
|
||||
}
|
||||
if (type instanceof PsiMethodReferenceType || type instanceof PsiLambdaExpressionType) {
|
||||
else if (type instanceof PsiMethodReferenceType || type instanceof PsiLambdaExpressionType) {
|
||||
type = PsiType.getJavaLangObject(manager, GlobalSearchScope.projectScope(manager.getProject()));
|
||||
}
|
||||
|
||||
PsiClassType classType = (PsiClassType)type;
|
||||
String text = type.getPresentableText();
|
||||
PsiJavaParserFacade parserFacade = JavaPsiFacade.getInstance(original.getProject()).getParserFacade();
|
||||
TreeElement element = (TreeElement)parserFacade.createTypeElementFromText(text, original).getNode();
|
||||
|
||||
String text = classType.getPresentableText();
|
||||
final TreeElement element = createType(original.getProject(), text, original, false);
|
||||
PsiTypeElementImpl result = SourceTreeToPsiMap.treeToPsiNotNull(element);
|
||||
|
||||
CodeEditUtil.setNodeGenerated(result, generated);
|
||||
if (generated) {
|
||||
PsiJavaCodeReferenceElement ref = result.getInnermostComponentReferenceElement();
|
||||
if (ref != null) ((CompositeElement)ref.getNode()).acceptTree(new GeneratedMarkerVisitor());
|
||||
PsiTypeElementImpl result = (PsiTypeElementImpl)element.getPsi();
|
||||
markGeneratedIfNeeded(original, result);
|
||||
if (type instanceof PsiClassType) {
|
||||
encodeInfoInTypeElement(result, type);
|
||||
}
|
||||
encodeInfoInTypeElement(result, classType);
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static LeafElement createLeafFromText(final String text,
|
||||
final CharTable table,
|
||||
final PsiManager manager,
|
||||
final PsiElement original,
|
||||
final IElementType type) {
|
||||
private static LeafElement createLeafFromText(String text, CharTable table, PsiManager manager, PsiElement original, IElementType type) {
|
||||
return Factory.createSingleLeafElement(type, text, 0, text.length(), table, manager, CodeEditUtil.isNodeGenerated(original.getNode()));
|
||||
}
|
||||
|
||||
private static TreeElement markGeneratedIfNeeded(PsiElement original, TreeElement copy) {
|
||||
if (CodeEditUtil.isNodeGenerated(original.getNode())) {
|
||||
copy.acceptTree(new GeneratedMarkerVisitor());
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
private static TreeElement createReference(final Project project, final String text, boolean mark) {
|
||||
final PsiJavaParserFacade parserFacade = JavaPsiFacade.getInstance(project).getParserFacade();
|
||||
final TreeElement element = (TreeElement)parserFacade.createReferenceFromText(text, null).getNode();
|
||||
@@ -214,13 +170,6 @@ public class JavaTreeGenerator implements TreeGenerator {
|
||||
return (TreeElement)expression.getNode();
|
||||
}
|
||||
|
||||
private static TreeElement createType(final Project project, final String text, final PsiElement context, final boolean mark) {
|
||||
final PsiJavaParserFacade parserFacade = JavaPsiFacade.getInstance(project).getParserFacade();
|
||||
final TreeElement element = (TreeElement)parserFacade.createTypeElementFromText(text, context).getNode();
|
||||
if (mark) element.acceptTree(new GeneratedMarkerVisitor());
|
||||
return element;
|
||||
}
|
||||
|
||||
private static void encodeInfoInTypeElement(ASTNode typeElement, PsiType type) {
|
||||
if (type instanceof PsiPrimitiveType) return;
|
||||
LOG.assertTrue(typeElement.getElementType() == JavaElementType.TYPE);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -36,14 +36,14 @@ public class PsiArrayType extends PsiType {
|
||||
this(componentType, PsiAnnotation.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
public PsiArrayType(@NotNull PsiType componentType, PsiAnnotation[] annotations) {
|
||||
public PsiArrayType(@NotNull PsiType componentType, @NotNull PsiAnnotation[] annotations) {
|
||||
super(annotations);
|
||||
myComponentType = componentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return StringUtil.joinOrNull(myComponentType.getPresentableText(), "[]");
|
||||
return StringUtil.joinOrNull(myComponentType.getPresentableText(), getAnnotationsTextPrefix(true, true), "[]");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,7 +53,7 @@ public class PsiArrayType extends PsiType {
|
||||
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
return StringUtil.joinOrNull(myComponentType.getInternalCanonicalText(), "[]");
|
||||
return StringUtil.joinOrNull(myComponentType.getInternalCanonicalText(), getAnnotationsTextPrefix(true, true), "[]");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -36,7 +36,7 @@ public class PsiEllipsisType extends PsiArrayType {
|
||||
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return StringUtil.joinOrNull(getComponentType().getPresentableText(), "...");
|
||||
return StringUtil.joinOrNull(getComponentType().getPresentableText(), getAnnotationsTextPrefix(true, true), "...");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,13 +46,13 @@ public class PsiEllipsisType extends PsiArrayType {
|
||||
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
return StringUtil.joinOrNull(getComponentType().getInternalCanonicalText(), "...");
|
||||
return StringUtil.joinOrNull(getComponentType().getInternalCanonicalText(), getAnnotationsTextPrefix(true, true), "...");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsToText(String text) {
|
||||
return text.endsWith("...") && getComponentType().equalsToText(text.substring(0, text.length() - 3))
|
||||
|| super.equalsToText(text);
|
||||
return text.endsWith("...") && getComponentType().equalsToText(text.substring(0, text.length() - 3)) ||
|
||||
super.equalsToText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -169,10 +169,11 @@ public class PsiIntersectionType extends PsiType {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String s = "PsiIntersectionType: ";
|
||||
for (PsiType conjunct : myConjuncts) {
|
||||
s += conjunct.getPresentableText() +", ";
|
||||
StringBuilder sb = new StringBuilder("PsiIntersectionType: ");
|
||||
for (int i = 0; i < myConjuncts.length; i++) {
|
||||
if (i > 0) sb.append(", ");
|
||||
sb.append(myConjuncts[i].getPresentableText());
|
||||
}
|
||||
return s;
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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,7 +53,7 @@ public class PsiPrimitiveType extends PsiType {
|
||||
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return myName;
|
||||
return getAnnotationsTextPrefix() + myName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,7 +63,7 @@ public class PsiPrimitiveType extends PsiType {
|
||||
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
return getAnnotationsTextPrefix() + getCanonicalText();
|
||||
return getAnnotationsTextPrefix() + myName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,8 +17,6 @@ package com.intellij.psi;
|
||||
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -41,6 +39,7 @@ public abstract class PsiType implements PsiAnnotationOwner {
|
||||
public static final PsiType[] EMPTY_ARRAY = new PsiType[0];
|
||||
|
||||
private final PsiAnnotation[] myAnnotations;
|
||||
|
||||
protected PsiType(@NotNull PsiAnnotation[] annotations) {
|
||||
myAnnotations = annotations;
|
||||
}
|
||||
@@ -52,22 +51,31 @@ public abstract class PsiType implements PsiAnnotationOwner {
|
||||
public PsiArrayType createArrayType() {
|
||||
return new PsiArrayType(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates array type with this type as a component.
|
||||
*/
|
||||
@NotNull
|
||||
public PsiArrayType createArrayType(PsiAnnotation... annotations) {
|
||||
return new PsiArrayType(this,annotations);
|
||||
return new PsiArrayType(this, annotations);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return text of this type that can be presented to user.
|
||||
* @return text of the type that can be presented to a user (non-qualified references, with annotations).
|
||||
*/
|
||||
@NonNls
|
||||
public abstract String getPresentableText();
|
||||
|
||||
/**
|
||||
* @return text of the type (fully-qualified references, no annotations).
|
||||
*/
|
||||
@NonNls
|
||||
public abstract String getCanonicalText();
|
||||
|
||||
/**
|
||||
* @return text of the type (fully-qualified references, with annotations).
|
||||
*/
|
||||
@NonNls
|
||||
public abstract String getInternalCanonicalText();
|
||||
|
||||
/**
|
||||
@@ -109,7 +117,8 @@ public abstract class PsiType implements PsiAnnotationOwner {
|
||||
*/
|
||||
@NotNull
|
||||
public static PsiClassType getJavaLangObject(@NotNull PsiManager manager, @NotNull GlobalSearchScope resolveScope) {
|
||||
return JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createTypeByFQClassName(CommonClassNames.JAVA_LANG_OBJECT, resolveScope);
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
|
||||
return factory.createTypeByFQClassName(CommonClassNames.JAVA_LANG_OBJECT, resolveScope);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +129,8 @@ public abstract class PsiType implements PsiAnnotationOwner {
|
||||
* @return the class instance.
|
||||
*/
|
||||
public static PsiClassType getJavaLangClass(PsiManager manager, GlobalSearchScope resolveScope) {
|
||||
return JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createTypeByFQClassName(CommonClassNames.JAVA_LANG_CLASS, resolveScope);
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
|
||||
return factory.createTypeByFQClassName(CommonClassNames.JAVA_LANG_CLASS, resolveScope);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +141,8 @@ public abstract class PsiType implements PsiAnnotationOwner {
|
||||
* @return the class instance.
|
||||
*/
|
||||
public static PsiClassType getJavaLangThrowable(PsiManager manager, GlobalSearchScope resolveScope) {
|
||||
return JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createTypeByFQClassName(CommonClassNames.JAVA_LANG_THROWABLE, resolveScope);
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
|
||||
return factory.createTypeByFQClassName(CommonClassNames.JAVA_LANG_THROWABLE, resolveScope);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +154,8 @@ public abstract class PsiType implements PsiAnnotationOwner {
|
||||
*/
|
||||
@NotNull
|
||||
public static PsiClassType getJavaLangString(PsiManager manager, GlobalSearchScope resolveScope) {
|
||||
return JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createTypeByFQClassName(CommonClassNames.JAVA_LANG_STRING, resolveScope);
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
|
||||
return factory.createTypeByFQClassName(CommonClassNames.JAVA_LANG_STRING, resolveScope);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,7 +166,8 @@ public abstract class PsiType implements PsiAnnotationOwner {
|
||||
* @return the class instance.
|
||||
*/
|
||||
public static PsiClassType getJavaLangError(PsiManager manager, GlobalSearchScope resolveScope) {
|
||||
return JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createTypeByFQClassName(CommonClassNames.JAVA_LANG_ERROR, resolveScope);
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
|
||||
return factory.createTypeByFQClassName(CommonClassNames.JAVA_LANG_ERROR, resolveScope);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,7 +178,8 @@ public abstract class PsiType implements PsiAnnotationOwner {
|
||||
* @return the class instance.
|
||||
*/
|
||||
public static PsiClassType getJavaLangRuntimeException(PsiManager manager, GlobalSearchScope resolveScope) {
|
||||
return JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createTypeByFQClassName(CommonClassNames.JAVA_LANG_RUNTIME_EXCEPTION, resolveScope);
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
|
||||
return factory.createTypeByFQClassName(CommonClassNames.JAVA_LANG_RUNTIME_EXCEPTION, resolveScope);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,7 +209,7 @@ public abstract class PsiType implements PsiAnnotationOwner {
|
||||
* Returns the innermost component type for an array type.
|
||||
*
|
||||
* @return the innermost (non-array) component of the type, or <code>this</code> if the type is not
|
||||
* an array type.
|
||||
* an array type.
|
||||
*/
|
||||
@NotNull
|
||||
public final PsiType getDeepComponentType() {
|
||||
@@ -214,11 +228,6 @@ public abstract class PsiType implements PsiAnnotationOwner {
|
||||
@Nullable
|
||||
public abstract GlobalSearchScope getResolveScope();
|
||||
|
||||
public String toString() {
|
||||
//noinspection HardCodedStringLiteral
|
||||
return "PsiType:" + getPresentableText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of superclass types for a class type.
|
||||
*
|
||||
@@ -251,13 +260,27 @@ public abstract class PsiType implements PsiAnnotationOwner {
|
||||
}
|
||||
|
||||
protected String getAnnotationsTextPrefix() {
|
||||
PsiAnnotation[] annotations = getAnnotations();
|
||||
return StringUtil.join(annotations, new Function<PsiAnnotation, String>() {
|
||||
@Override
|
||||
public String fun(PsiAnnotation annotation) {
|
||||
return "@"+annotation.getQualifiedName();
|
||||
}
|
||||
}, " ") + (annotations.length == 0 ? "" : " ");
|
||||
return getAnnotationsTextPrefix(false, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected String getAnnotationsTextPrefix(boolean leadingSpace, boolean trailingSpace) {
|
||||
PsiAnnotation[] annotations = getAnnotations();
|
||||
if (annotations.length == 0) return "";
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (leadingSpace) sb.append(' ');
|
||||
for (int i = 0; i < annotations.length; i++) {
|
||||
if (i > 0) sb.append(' ');
|
||||
sb.append('@').append(annotations[i].getQualifiedName());
|
||||
}
|
||||
if (trailingSpace) sb.append(' ');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
//noinspection HardCodedStringLiteral
|
||||
return "PsiType:" + getPresentableText();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -180,7 +180,9 @@ public class PsiImmediateClassType extends PsiClassType {
|
||||
enclosingClass = (PsiClass)parent;
|
||||
}
|
||||
}
|
||||
buffer.append(getAnnotationsTextPrefix());
|
||||
if (canonical == internal) {
|
||||
buffer.append(getAnnotationsTextPrefix());
|
||||
}
|
||||
if (enclosingClass != null) {
|
||||
buildText(enclosingClass, substitutor, buffer, canonical, false);
|
||||
buffer.append('.');
|
||||
@@ -203,7 +205,7 @@ public class PsiImmediateClassType extends PsiClassType {
|
||||
buffer.append(name);
|
||||
}
|
||||
|
||||
final PsiTypeParameter[] typeParameters = aClass.getTypeParameters();
|
||||
PsiTypeParameter[] typeParameters = aClass.getTypeParameters();
|
||||
if (typeParameters.length > 0) {
|
||||
StringBuilder pineBuffer = new StringBuilder();
|
||||
pineBuffer.append('<');
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Cast to 'int[]'" "true"
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
|
||||
@Target({TYPE_USE}) @interface TA { }
|
||||
|
||||
class C {
|
||||
{
|
||||
Object o = null;
|
||||
@TA <caret>int @TA [] a = (@TA int[]) o;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Cast to 'int'" "true"
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
|
||||
@Target({TYPE_USE}) @interface TA { }
|
||||
|
||||
class C {
|
||||
{
|
||||
Object o = null;
|
||||
@TA <caret>int i = (@TA int) o;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Cast to 'java.lang.Integer'" "true"
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
|
||||
@Target({TYPE_USE}) @interface TA { }
|
||||
|
||||
class C {
|
||||
{
|
||||
Object o = null;
|
||||
@TA <caret>Integer i = (@TA Integer) o;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Cast to 'java.util.List<java.lang.String>'" "true"
|
||||
import java.lang.annotation.*;
|
||||
import java.util.List;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
|
||||
@Target({TYPE_USE}) @interface TA { }
|
||||
|
||||
class C {
|
||||
{
|
||||
Object o = null;
|
||||
@TA <caret>List<@TA String> l = (@TA List<@TA String>) o;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Cast to 'java.util.List<? extends java.lang.String>'" "true"
|
||||
import java.lang.annotation.*;
|
||||
import java.util.List;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
|
||||
@Target({TYPE_USE}) @interface TA { }
|
||||
|
||||
class C {
|
||||
{
|
||||
Object o = null;
|
||||
@TA <caret>List<@TA ? extends @TA String> l = (@TA List<? extends @TA String>) o;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Cast to 'int[]'" "true"
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
|
||||
@Target({TYPE_USE}) @interface TA { }
|
||||
|
||||
class C {
|
||||
{
|
||||
Object o = null;
|
||||
@TA <caret>int @TA [] a = o;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Cast to 'int'" "true"
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
|
||||
@Target({TYPE_USE}) @interface TA { }
|
||||
|
||||
class C {
|
||||
{
|
||||
Object o = null;
|
||||
@TA <caret>int i = o;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Cast to 'java.lang.Integer'" "true"
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
|
||||
@Target({TYPE_USE}) @interface TA { }
|
||||
|
||||
class C {
|
||||
{
|
||||
Object o = null;
|
||||
@TA <caret>Integer i = o;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Cast to 'java.util.List<java.lang.String>'" "true"
|
||||
import java.lang.annotation.*;
|
||||
import java.util.List;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
|
||||
@Target({TYPE_USE}) @interface TA { }
|
||||
|
||||
class C {
|
||||
{
|
||||
Object o = null;
|
||||
@TA <caret>List<@TA String> l = o;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Cast to 'java.util.List<? extends java.lang.String>'" "true"
|
||||
import java.lang.annotation.*;
|
||||
import java.util.List;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
|
||||
@Target({TYPE_USE}) @interface TA { }
|
||||
|
||||
class C {
|
||||
{
|
||||
Object o = null;
|
||||
@TA <caret>List<@TA ? extends @TA String> l = o;
|
||||
}
|
||||
}
|
||||
+20
-7
@@ -1,16 +1,29 @@
|
||||
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon.quickFix;
|
||||
|
||||
public class AddTypeCastTest extends LightQuickFixTestCase {
|
||||
public void test() {
|
||||
doAllTests();
|
||||
|
||||
|
||||
public class AddTypeCastTest extends LightQuickFix15TestCase {
|
||||
|
||||
public void test() throws Exception { doAllTests(); }
|
||||
Object o = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -22,8 +22,8 @@ import com.intellij.pom.java.LanguageLevel;
|
||||
*/
|
||||
public abstract class LightQuickFix15TestCase extends LightQuickFixTestCase {
|
||||
@Override
|
||||
protected void doAllTests() throws Exception {
|
||||
setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
protected void doAllTests() {
|
||||
setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
super.doAllTests();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -121,7 +121,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
if (comment == null) {
|
||||
comment = commenter.getBlockCommentPrefix();
|
||||
}
|
||||
|
||||
|
||||
// "quick fix action text to perform" "should be available"
|
||||
assert comment != null : commenter;
|
||||
Pattern pattern = Pattern.compile("^" + comment.replace("*", "\\*") + actionPattern, Pattern.DOTALL);
|
||||
@@ -197,7 +197,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void doAllTests(QuickFixTestCase testCase) throws Exception {
|
||||
public static void doAllTests(QuickFixTestCase testCase) {
|
||||
assertNotNull("getBasePath() should not return null!", testCase.getBasePath());
|
||||
|
||||
final String testDirPath = testCase.getTestDataPath().replace(File.separatorChar, '/') + testCase.getBasePath();
|
||||
@@ -224,7 +224,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
doTestFor(fileSuffix, createWrapper());
|
||||
}
|
||||
|
||||
protected void doAllTests() throws Exception {
|
||||
protected void doAllTests() {
|
||||
doAllTests(createWrapper());
|
||||
}
|
||||
|
||||
|
||||
+6
-5
@@ -83,15 +83,16 @@ public class JpsProjectLoader extends JpsLoaderBase {
|
||||
new JpsProjectLoader(project, pathVariables, file.getParentFile()).loadFromIpr(file);
|
||||
}
|
||||
else {
|
||||
File dotIdea = new File(file, PathMacroUtil.DIRECTORY_STORE_NAME);
|
||||
File directory;
|
||||
if (file.isDirectory() && file.getName().equals(PathMacroUtil.DIRECTORY_STORE_NAME)) {
|
||||
if (dotIdea.isDirectory()) {
|
||||
directory = dotIdea;
|
||||
}
|
||||
else if (file.isDirectory() && file.getName().equals(PathMacroUtil.DIRECTORY_STORE_NAME)) {
|
||||
directory = file;
|
||||
}
|
||||
else {
|
||||
directory = new File(file, PathMacroUtil.DIRECTORY_STORE_NAME);
|
||||
if (!directory.isDirectory()) {
|
||||
throw new IOException("Cannot find IntelliJ IDEA project files at " + projectPath);
|
||||
}
|
||||
throw new IOException("Cannot find IntelliJ IDEA project files at " + projectPath);
|
||||
}
|
||||
new JpsProjectLoader(project, pathVariables, directory.getParentFile()).loadFromDirectory(directory);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
||||
+8
-4
@@ -23,10 +23,7 @@ import org.jetbrains.jps.model.JpsDummyElement;
|
||||
import org.jetbrains.jps.model.JpsEncodingConfigurationService;
|
||||
import org.jetbrains.jps.model.JpsEncodingProjectConfiguration;
|
||||
import org.jetbrains.jps.model.artifact.JpsArtifactService;
|
||||
import org.jetbrains.jps.model.java.JpsJavaDependencyExtension;
|
||||
import org.jetbrains.jps.model.java.JpsJavaDependencyScope;
|
||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
|
||||
import org.jetbrains.jps.model.java.JpsJavaSdkType;
|
||||
import org.jetbrains.jps.model.java.*;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsOrderRootType;
|
||||
import org.jetbrains.jps.model.library.sdk.JpsSdkReference;
|
||||
@@ -135,6 +132,13 @@ public class JpsProjectSerializationTest extends JpsSerializationTestCase {
|
||||
assertSameElements(lib2.getRootUrls(JpsOrderRootType.COMPILED), getUrl("data/lib2"));
|
||||
}
|
||||
|
||||
public void testDotIdeaUnderDotIdea() {
|
||||
loadProject("/jps/model-serialization/testData/matryoshka/.idea");
|
||||
JpsJavaProjectExtension extension = JpsJavaExtensionService.getInstance().getProjectExtension(myProject);
|
||||
assertNotNull(extension);
|
||||
assertEquals(getUrl("out"), extension.getOutputUrl());
|
||||
}
|
||||
|
||||
public void testLoadEncoding() {
|
||||
loadProject(SAMPLE_PROJECT_PATH);
|
||||
JpsEncodingConfigurationService service = JpsEncodingConfigurationService.getInstance();
|
||||
|
||||
@@ -76,10 +76,8 @@ public interface PsiBuilder extends UserDataHolder, UserDataHolderUnprotected {
|
||||
/**
|
||||
* Subscribe for notification on default whitespace and comments skipped events.
|
||||
* @param callback an implementation for the callback
|
||||
* @return previously registered callback
|
||||
*/
|
||||
@Nullable
|
||||
WhitespaceSkippedCallback setWhitespaceSkippedCallback(@Nullable WhitespaceSkippedCallback callback);
|
||||
void setWhitespaceSkippedCallback(@Nullable WhitespaceSkippedCallback callback);
|
||||
|
||||
/**
|
||||
* See what token type is in <code>steps</code> ahead
|
||||
|
||||
@@ -62,9 +62,8 @@ public class PsiBuilderAdapter implements PsiBuilder {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public WhitespaceSkippedCallback setWhitespaceSkippedCallback(@Nullable final WhitespaceSkippedCallback callback) {
|
||||
return myDelegate.setWhitespaceSkippedCallback(callback);
|
||||
public void setWhitespaceSkippedCallback(@Nullable final WhitespaceSkippedCallback callback) {
|
||||
myDelegate.setWhitespaceSkippedCallback(callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -734,11 +734,8 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public WhitespaceSkippedCallback setWhitespaceSkippedCallback(@Nullable final WhitespaceSkippedCallback callback) {
|
||||
final WhitespaceSkippedCallback oldCallback = myWhitespaceSkippedCallback;
|
||||
public void setWhitespaceSkippedCallback(@Nullable final WhitespaceSkippedCallback callback) {
|
||||
myWhitespaceSkippedCallback = callback;
|
||||
return oldCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -586,7 +586,7 @@ public abstract class TabbedLanguageCodeStylePanel extends CodeStyleAbstractPane
|
||||
|
||||
@Override
|
||||
protected int getRightMargin() {
|
||||
return getSettings().RIGHT_MARGIN;
|
||||
return myProvider.getRightMargin(LanguageCodeStyleSettingsProvider.SettingsType.INDENT_SETTINGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -406,9 +406,10 @@ public class QuickEditHandler extends DocumentAdapter implements Disposable {
|
||||
String newText = myNewDocument.getText();
|
||||
// prepare guarded blocks
|
||||
LinkedHashMap<String, String> replacementMap = new LinkedHashMap<String, String>();
|
||||
int count = 0;
|
||||
for (RangeMarker o : ContainerUtil.reverse(((DocumentEx)myNewDocument).getGuardedBlocks())) {
|
||||
String replacement = o.getUserData(REPLACEMENT_KEY);
|
||||
String tempText = "REPLACE"+Long.toHexString(StringHash.calc(replacement));
|
||||
String tempText = "REPLACE"+(count++)+Long.toHexString(StringHash.calc(replacement));
|
||||
newText = newText.substring(0, o.getStartOffset()) + tempText + newText.substring(o.getEndOffset());
|
||||
replacementMap.put(tempText, replacement);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.ide.macro;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
public class FileNameWithoutAllExtensions extends FileNameMacro {
|
||||
public String getName() {
|
||||
return "FileNameWithoutAllExtensions";
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return IdeBundle.message("macro.file.name.without.all.extensions");
|
||||
}
|
||||
|
||||
public String expand(DataContext dataContext) {
|
||||
VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
|
||||
if (file == null) {
|
||||
return null;
|
||||
}
|
||||
String fileName = file.getName();
|
||||
int index = fileName.indexOf('.');
|
||||
return index > 0 ? fileName.substring(0, index) : fileName;
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,7 @@ public final class MacroManager {
|
||||
registerMacro(new FileExtMacro());
|
||||
registerMacro(new FileNameMacro());
|
||||
registerMacro(new FileNameWithoutExtension());
|
||||
registerMacro(new FileNameWithoutAllExtensions());
|
||||
registerMacro(new FilePathMacro());
|
||||
registerMacro(new FileEncodingMacro());
|
||||
registerMacro(new FileDirRelativeToProjectRootMacro());
|
||||
|
||||
+3
@@ -45,6 +45,9 @@ public class ProjectSettingsService {
|
||||
public void openGlobalLibraries() {
|
||||
}
|
||||
|
||||
public void openLibrary(@NotNull Library library) {
|
||||
}
|
||||
|
||||
public void openModuleSettings(final Module module) {
|
||||
}
|
||||
|
||||
|
||||
+39
-20
@@ -1,6 +1,7 @@
|
||||
package com.intellij.execution.configurations;
|
||||
|
||||
import com.intellij.execution.process.UnixProcessManager;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -14,6 +15,9 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* @author Sergey Simonchik
|
||||
@@ -22,40 +26,55 @@ public class PathEnvironmentVariableUtil {
|
||||
|
||||
public static final String PATH_ENV_VAR_NAME = "PATH";
|
||||
private static final Logger LOG = Logger.getInstance(PathEnvironmentVariableUtil.class);
|
||||
private static final String FIXED_MAC_PATH_VALUE;
|
||||
|
||||
static {
|
||||
String fixedPathValue = null;
|
||||
try {
|
||||
fixedPathValue = calcFixedMacPathEnvVarValue();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
LOG.error("Can't initialize class " + PathEnvironmentVariableUtil.class.getName(), t);
|
||||
}
|
||||
FIXED_MAC_PATH_VALUE = fixedPathValue;
|
||||
}
|
||||
private static final int MAX_BLOCKING_TIMEOUT_MILLIS = 1000;
|
||||
private static final AtomicBoolean INITIALIZED = new AtomicBoolean(false);
|
||||
private static volatile String FIXED_MAC_PATH_VALUE;
|
||||
|
||||
private PathEnvironmentVariableUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to return a real value for PATH environment variable.
|
||||
* Tries to return a real value for PATH environment variable on OSX.
|
||||
* Workaround for http://youtrack.jetbrains.com/issue/IDEA-99154
|
||||
*
|
||||
* @return <code>null</code>, if the platform isn't OSX, any troubles were encountered or time limit exceeded,
|
||||
* otherwise returns <code>String</code> instance - PATH env var value
|
||||
*/
|
||||
@Nullable
|
||||
public static String getFixedPathEnvVarValueOnMac() {
|
||||
if (INITIALIZED.compareAndSet(false, true)) {
|
||||
final Semaphore semaphore = new Semaphore(0, true);
|
||||
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod")
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
FIXED_MAC_PATH_VALUE = calcFixedMacPathEnvVarValue();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
LOG.error("Can't calculate proper value for PATH environment variable", t);
|
||||
}
|
||||
finally {
|
||||
semaphore.release();
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
semaphore.tryAcquire(MAX_BLOCKING_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
LOG.info("Thread interrupted", e);
|
||||
}
|
||||
}
|
||||
return FIXED_MAC_PATH_VALUE;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String calcFixedMacPathEnvVarValue() {
|
||||
if (SystemInfo.isMac) {
|
||||
final String originalPath = getOriginalPathEnvVarValue();
|
||||
Map<? extends String, ? extends String> envVars = UnixProcessManager.getOrLoadConsoleEnvironment();
|
||||
String consolePath = envVars.get(PATH_ENV_VAR_NAME);
|
||||
return mergePaths(ContainerUtil.newArrayList(originalPath, consolePath));
|
||||
}
|
||||
return null;
|
||||
final String originalPath = getOriginalPathEnvVarValue();
|
||||
Map<? extends String, ? extends String> envVars = UnixProcessManager.getOrLoadConsoleEnvironment();
|
||||
String consolePath = envVars.get(PATH_ENV_VAR_NAME);
|
||||
return mergePaths(ContainerUtil.newArrayList(originalPath, consolePath));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -258,7 +258,7 @@ public class Utils{
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
if (UIUtil.isUnderWindowsClassicLookAndFeel() || UIUtil.isUnderDarcula()) {
|
||||
if (UIUtil.isUnderWindowsClassicLookAndFeel() || UIUtil.isUnderDarcula() || UIUtil.isUnderWindowsLookAndFeel()) {
|
||||
g.setColor(component.getBackground());
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
+2
-1
@@ -688,7 +688,8 @@ public abstract class LocalFileSystemBase extends LocalFileSystem {
|
||||
|
||||
@Override
|
||||
public FileAttributes getAttributes(@NotNull final VirtualFile file) {
|
||||
final String path = file.getPath();
|
||||
String path = normalize(file.getPath());
|
||||
if (path == null) return null;
|
||||
if (StringUtil.isEmpty(path) || file.getParent() == null && path.startsWith("//")) {
|
||||
return FAKE_ROOT_ATTRIBUTES; // fake Windows roots
|
||||
}
|
||||
|
||||
-13
@@ -380,19 +380,6 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
|
||||
public int getId(@NotNull final VirtualFile parent, @NotNull final String childName, @NotNull final NewVirtualFileSystem fs) {
|
||||
int parentId = getFileId(parent);
|
||||
|
||||
if (parent == myFakeRoot) {
|
||||
// children of the fake root must be the FS roots only
|
||||
myRootsLock.readLock().lock();
|
||||
try {
|
||||
String rootUrl = fs.getProtocol() + "://" + VfsImplUtil.normalize(fs, childName);
|
||||
VirtualFileSystemEntry root = myRoots.get(rootUrl);
|
||||
return root == null ? 0 : root.getId();
|
||||
}
|
||||
finally {
|
||||
myRootsLock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
int[] children = FSRecords.list(parentId);
|
||||
|
||||
if (children.length > 0) {
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import java.awt.*;
|
||||
import java.awt.event.AWTEventListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
@@ -55,6 +56,7 @@ import java.util.ArrayList;
|
||||
public class IdeMenuBar extends JMenuBar {
|
||||
|
||||
private static final int COLLAPSED_HEIGHT = 2;
|
||||
private IdeMenuBar.MyBorderDelegator myBorderDelegator;
|
||||
|
||||
private enum State {
|
||||
EXPANDED, COLLAPSING, COLLAPSED, EXPANDING, TEMPORARY_EXPANDED;
|
||||
@@ -88,7 +90,7 @@ public class IdeMenuBar extends JMenuBar {
|
||||
myPresentationFactory = new MenuItemPresentationFactory();
|
||||
myDataManager = dataManager;
|
||||
if (SystemInfo.isWindows) {
|
||||
myAnimator = new Animator("MenuBarAnimator", 8, 300, false) {
|
||||
myAnimator = new Animator("MenuBarAnimator", 16, 300, false) {
|
||||
@Override
|
||||
public void paintNow(int frame, int totalFrames, int cycle) {
|
||||
myProgress = (1 - Math.cos(Math.PI * ((float)frame / totalFrames))) / 2;
|
||||
@@ -116,11 +118,7 @@ public class IdeMenuBar extends JMenuBar {
|
||||
@Override
|
||||
public void eventDispatched(AWTEvent event) {
|
||||
MouseEvent mouseEvent = (MouseEvent)event;
|
||||
Component component = mouseEvent.getComponent();
|
||||
Component deepestComponent = SwingUtilities.getDeepestComponentAt(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
|
||||
if (deepestComponent != null) {
|
||||
component = deepestComponent;
|
||||
}
|
||||
Component component = findActualComponent(mouseEvent);
|
||||
|
||||
if (myState != State.EXPANDED && !myState.isInProgress()) {
|
||||
myMouseInside = myActivated || isDescendingFrom(component, IdeMenuBar.this);
|
||||
@@ -134,20 +132,39 @@ public class IdeMenuBar extends JMenuBar {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Component findActualComponent(MouseEvent mouseEvent) {
|
||||
Component component = mouseEvent.getComponent();
|
||||
Component deepestComponent;
|
||||
if (myState != State.EXPANDED &&
|
||||
!myState.isInProgress() &&
|
||||
contains(SwingUtilities.convertPoint(component, mouseEvent.getPoint(), IdeMenuBar.this))) {
|
||||
deepestComponent = IdeMenuBar.this;
|
||||
}
|
||||
else {
|
||||
deepestComponent = SwingUtilities.getDeepestComponentAt(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
|
||||
}
|
||||
if (deepestComponent != null) {
|
||||
component = deepestComponent;
|
||||
}
|
||||
return component;
|
||||
}
|
||||
}, AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK);
|
||||
myActivationWatcher = new Timer(100, new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (myState == State.EXPANDED || myState == State.EXPANDING)
|
||||
if (myState == State.EXPANDED || myState == State.EXPANDING) {
|
||||
return;
|
||||
}
|
||||
boolean activated = isActivated();
|
||||
if (myActivated && !activated && myState == State.TEMPORARY_EXPANDED) {
|
||||
myActivated = false;
|
||||
setState(State.COLLAPSING);
|
||||
restartAnimator();
|
||||
}
|
||||
if (activated)
|
||||
if (activated) {
|
||||
myActivated = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -157,6 +174,24 @@ public class IdeMenuBar extends JMenuBar {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBorder(Border border) {
|
||||
if (border == null || !SystemInfo.isWindows) {
|
||||
super.setBorder(border);
|
||||
myBorderDelegator = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (myBorderDelegator == null) {
|
||||
myBorderDelegator = new MyBorderDelegator(border);
|
||||
}
|
||||
else {
|
||||
myBorderDelegator.setSource(border);
|
||||
}
|
||||
|
||||
super.setBorder(myBorderDelegator);
|
||||
}
|
||||
|
||||
private static boolean isDescendingFrom(@Nullable Component a, @NotNull Component b) {
|
||||
while (a != null) {
|
||||
if (a == b) {
|
||||
@@ -165,7 +200,8 @@ public class IdeMenuBar extends JMenuBar {
|
||||
|
||||
if (a instanceof JPopupMenu) {
|
||||
a = ((JPopupMenu)a).getInvoker();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
a = a.getParent();
|
||||
}
|
||||
}
|
||||
@@ -174,8 +210,9 @@ public class IdeMenuBar extends JMenuBar {
|
||||
|
||||
private boolean isActivated() {
|
||||
int index = getSelectionModel().getSelectedIndex();
|
||||
if (index ==-1)
|
||||
if (index == -1) {
|
||||
return false;
|
||||
}
|
||||
return getMenu(index).isPopupMenuVisible();
|
||||
}
|
||||
|
||||
@@ -211,23 +248,19 @@ public class IdeMenuBar extends JMenuBar {
|
||||
public void addNotify() {
|
||||
super.addNotify();
|
||||
updateMenuActions();
|
||||
if (!ScreenUtil.isStandardAddRemoveNotify(this)) {
|
||||
Window window = SwingUtilities.getWindowAncestor(this);
|
||||
if (window instanceof IdeFrameImpl) {
|
||||
boolean fullScreen = WindowManagerEx.getInstanceEx().isFullScreen((IdeFrameImpl)window);
|
||||
if (fullScreen) {
|
||||
setState(State.COLLAPSING);
|
||||
restartAnimator();
|
||||
} else {
|
||||
if (myAnimator != null) {
|
||||
myAnimator.suspend();
|
||||
}
|
||||
setState(State.EXPANDED);
|
||||
revalidate();
|
||||
repaint();
|
||||
Window window = SwingUtilities.getWindowAncestor(this);
|
||||
if (SystemInfo.isWindows && window instanceof IdeFrameImpl) {
|
||||
boolean fullScreen = WindowManagerEx.getInstanceEx().isFullScreen((IdeFrameImpl)window);
|
||||
if (fullScreen) {
|
||||
setState(State.COLLAPSING);
|
||||
restartAnimator();
|
||||
}
|
||||
else {
|
||||
if (myAnimator != null) {
|
||||
myAnimator.suspend();
|
||||
}
|
||||
setState(State.EXPANDED);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Add updater for menus
|
||||
myActionManager.addTimerListener(1000, new WeakTimerListener(myActionManager, myTimerListener));
|
||||
@@ -308,12 +341,15 @@ public class IdeMenuBar extends JMenuBar {
|
||||
super.paintComponent(g);
|
||||
if (UIUtil.isUnderDarcula()) {
|
||||
g.setColor(UIManager.getColor("MenuItem.background"));
|
||||
g.fillRect(0,0,getWidth(), getHeight());
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintChildren(Graphics g) {
|
||||
if (SystemInfo.isWindows && myState == State.COLLAPSED) {
|
||||
return;
|
||||
}
|
||||
if (SystemInfo.isWindows && myState.isInProgress()) {
|
||||
Graphics2D g2 = (Graphics2D)g;
|
||||
AffineTransform oldTransform = g2.getTransform();
|
||||
@@ -322,7 +358,8 @@ public class IdeMenuBar extends JMenuBar {
|
||||
g2.setTransform(newTransform);
|
||||
super.paintChildren(g2);
|
||||
g2.setTransform(oldTransform);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
super.paintChildren(g);
|
||||
}
|
||||
}
|
||||
@@ -411,4 +448,35 @@ public class IdeMenuBar extends JMenuBar {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MyBorderDelegator implements Border {
|
||||
@NotNull private Border mySource;
|
||||
|
||||
private MyBorderDelegator(@NotNull Border source) {
|
||||
setSource(source);
|
||||
}
|
||||
|
||||
void setSource(@NotNull Border source) {
|
||||
mySource = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
||||
mySource.paintBorder(c, g, x, y, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets(Component c) {
|
||||
Insets insets = mySource.getBorderInsets(c);
|
||||
if (myState != State.EXPANDED) {
|
||||
insets.top = 0;//get rid of "passive top pixel" in fullscreen mode
|
||||
}
|
||||
return insets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBorderOpaque() {
|
||||
return mySource.isBorderOpaque();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import com.intellij.openapi.wm.impl.status.IdeStatusBarImpl;
|
||||
import com.intellij.openapi.wm.impl.status.MemoryUsagePanel;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.PopupHandler;
|
||||
import com.intellij.ui.ScreenUtil;
|
||||
import com.intellij.ui.components.JBLayeredPane;
|
||||
import com.intellij.ui.components.JBPanel;
|
||||
import com.intellij.util.IconUtil;
|
||||
@@ -49,6 +50,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -87,9 +90,10 @@ public class IdeRootPane extends JRootPane implements UISettingsListener {
|
||||
private final Disposable myDisposable= Disposer.newDisposable();
|
||||
|
||||
private static final Icon BG = IconLoader.getIcon("/frame_background.png");
|
||||
private boolean myFullScreen;
|
||||
|
||||
public IdeRootPane(ActionManagerEx actionManager, UISettings uiSettings, DataManager dataManager,
|
||||
final Application application, IdeFrame frame){
|
||||
final Application application, final IdeFrame frame){
|
||||
myActionManager = actionManager;
|
||||
myUISettings = uiSettings;
|
||||
|
||||
@@ -106,8 +110,24 @@ public class IdeRootPane extends JRootPane implements UISettingsListener {
|
||||
myContentPane.add(myStatusBar, BorderLayout.SOUTH);
|
||||
|
||||
myUISettingsListener=new MyUISettingsListenerImpl();
|
||||
setJMenuBar(new IdeMenuBar(actionManager, dataManager));
|
||||
|
||||
if (SystemInfo.isWindows) {
|
||||
menuBar = new IdeMenuBar(actionManager, dataManager);
|
||||
getLayeredPane().add(menuBar, new Integer(1));
|
||||
if (frame instanceof IdeFrameImpl) {
|
||||
final PropertyChangeListener propertyChangeListener = new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
if (evt.getNewValue() == null) {//fullscreen state has been just changed
|
||||
myFullScreen = ((IdeFrameImpl)frame).isInFullScreen();
|
||||
}
|
||||
}
|
||||
};
|
||||
addPropertyChangeListener(ScreenUtil.DISPOSE_TEMPORARY, propertyChangeListener);
|
||||
}
|
||||
}
|
||||
else {
|
||||
setJMenuBar(new IdeMenuBar(actionManager, dataManager));
|
||||
}
|
||||
|
||||
myGlassPane = new IdeGlassPaneImpl(this);
|
||||
setGlassPane(myGlassPane);
|
||||
@@ -117,6 +137,12 @@ public class IdeRootPane extends JRootPane implements UISettingsListener {
|
||||
Disposer.register(application, myDisposable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LayoutManager createRootLayout() {
|
||||
return SystemInfo.isWindows ? new MyRootLayout() : super.createRootLayout();
|
||||
}
|
||||
|
||||
|
||||
public void setGlassPane(final Component glass) {
|
||||
if (myGlassPaneInitialized) throw new IllegalStateException("Setting of glass pane for IdeFrame is prohibited");
|
||||
super.setGlassPane(glass);
|
||||
@@ -329,4 +355,90 @@ public class IdeRootPane extends JRootPane implements UISettingsListener {
|
||||
public ToolWindowsPane getToolWindowsPane() {
|
||||
return myToolWindowsPane;
|
||||
}
|
||||
|
||||
private class MyRootLayout extends RootLayout {
|
||||
public Dimension preferredLayoutSize(Container parent) {
|
||||
Dimension rd, mbd;
|
||||
Insets i = getInsets();
|
||||
|
||||
if (contentPane != null) {
|
||||
rd = contentPane.getPreferredSize();
|
||||
}
|
||||
else {
|
||||
rd = parent.getSize();
|
||||
}
|
||||
if (menuBar != null && menuBar.isVisible() && !myFullScreen) {
|
||||
mbd = menuBar.getPreferredSize();
|
||||
}
|
||||
else {
|
||||
mbd = new Dimension(0, 0);
|
||||
}
|
||||
return new Dimension(Math.max(rd.width, mbd.width) + i.left + i.right,
|
||||
rd.height + mbd.height + i.top + i.bottom);
|
||||
}
|
||||
|
||||
public Dimension minimumLayoutSize(Container parent) {
|
||||
Dimension rd, mbd;
|
||||
Insets i = getInsets();
|
||||
if (contentPane != null) {
|
||||
rd = contentPane.getMinimumSize();
|
||||
}
|
||||
else {
|
||||
rd = parent.getSize();
|
||||
}
|
||||
if (menuBar != null && menuBar.isVisible() && !myFullScreen) {
|
||||
mbd = menuBar.getMinimumSize();
|
||||
}
|
||||
else {
|
||||
mbd = new Dimension(0, 0);
|
||||
}
|
||||
return new Dimension(Math.max(rd.width, mbd.width) + i.left + i.right,
|
||||
rd.height + mbd.height + i.top + i.bottom);
|
||||
}
|
||||
|
||||
public Dimension maximumLayoutSize(Container target) {
|
||||
Dimension rd, mbd;
|
||||
Insets i = getInsets();
|
||||
if (menuBar != null && menuBar.isVisible() && !myFullScreen) {
|
||||
mbd = menuBar.getMaximumSize();
|
||||
}
|
||||
else {
|
||||
mbd = new Dimension(0, 0);
|
||||
}
|
||||
if (contentPane != null) {
|
||||
rd = contentPane.getMaximumSize();
|
||||
}
|
||||
else {
|
||||
rd = new Dimension(Integer.MAX_VALUE,
|
||||
Integer.MAX_VALUE - i.top - i.bottom - mbd.height - 1);
|
||||
}
|
||||
return new Dimension(Math.min(rd.width, mbd.width) + i.left + i.right,
|
||||
rd.height + mbd.height + i.top + i.bottom);
|
||||
}
|
||||
|
||||
public void layoutContainer(Container parent) {
|
||||
Rectangle b = parent.getBounds();
|
||||
Insets i = getInsets();
|
||||
int contentY = 0;
|
||||
int w = b.width - i.right - i.left;
|
||||
int h = b.height - i.top - i.bottom;
|
||||
|
||||
if (layeredPane != null) {
|
||||
layeredPane.setBounds(i.left, i.top, w, h);
|
||||
}
|
||||
if (glassPane != null) {
|
||||
glassPane.setBounds(i.left, i.top, w, h);
|
||||
}
|
||||
if (menuBar != null && menuBar.isVisible()) {
|
||||
Dimension mbd = menuBar.getPreferredSize();
|
||||
menuBar.setBounds(0, 0, w, mbd.height);
|
||||
if (!myFullScreen) {
|
||||
contentY += mbd.height;
|
||||
}
|
||||
}
|
||||
if (contentPane != null) {
|
||||
contentPane.setBounds(0, contentY, w, h - contentY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,6 +446,7 @@ macro.file.extension=File extension
|
||||
macro.file.fully.qualified.package=File fully qualified package
|
||||
macro.file.name=File name
|
||||
macro.file.name.without.extension=File name without extension
|
||||
macro.file.name.without.all.extensions=File name without all extensions
|
||||
macro.file.package=File package
|
||||
macro.file.path=File path
|
||||
macro.file.path.relative.to.root=File path relative to the module content root the file belongs to
|
||||
|
||||
@@ -238,7 +238,7 @@
|
||||
</action>
|
||||
<action id="IncrementWindowHeight" />
|
||||
<action id="InspectCode">
|
||||
<keyboard-shortcut first-keystroke="meta alt B" />
|
||||
<keyboard-shortcut first-keystroke="meta shift B" />
|
||||
</action>
|
||||
<action id="Instruments">
|
||||
<keyboard-shortcut first-keystroke="meta I" />
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.util.io;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileWithId;
|
||||
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
|
||||
import com.intellij.testFramework.PlatformTestCase;
|
||||
|
||||
@@ -48,7 +49,7 @@ public class PersistentFSTest extends PlatformTestCase {
|
||||
|
||||
public void testListChildrenOfTheRootOfTheRoot() {
|
||||
PersistentFS fs = PersistentFS.getInstance();
|
||||
VirtualFile fakeRoot = fs.findRoot("", LocalFileSystem.getInstance());
|
||||
NewVirtualFile fakeRoot = fs.findRoot("", LocalFileSystem.getInstance());
|
||||
int users = fs.getId(fakeRoot, "Users", LocalFileSystem.getInstance());
|
||||
assertEquals(0, users);
|
||||
int win = fs.getId(fakeRoot, "Windows", LocalFileSystem.getInstance());
|
||||
@@ -59,5 +60,14 @@ public class PersistentFSTest extends PlatformTestCase {
|
||||
int rid = fs.getId(fakeRoot, root.getName(), LocalFileSystem.getInstance());
|
||||
assertTrue(0 != rid);
|
||||
}
|
||||
|
||||
NewVirtualFile c = fakeRoot.refreshAndFindChild("Users");
|
||||
assertNull(c);
|
||||
c = fakeRoot.refreshAndFindChild("Users");
|
||||
assertNull(c);
|
||||
c = fakeRoot.refreshAndFindChild("Windows");
|
||||
assertNull(c);
|
||||
c = fakeRoot.refreshAndFindChild("Windows");
|
||||
assertNull(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ public class PathMacrosImpl extends PathMacros implements ApplicationComponent,
|
||||
"FileFQPackage",
|
||||
"FileName",
|
||||
"FileNameWithoutExtension",
|
||||
"FileNameWithoutAllExtensions",
|
||||
"FilePackage",
|
||||
"FilePath",
|
||||
"FilePathRelativeToProjectRoot",
|
||||
|
||||
@@ -861,24 +861,28 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
|
||||
|
||||
@Override
|
||||
public void includeUsages(@NotNull Usage[] usages) {
|
||||
List<TreeNode> nodes = new ArrayList<TreeNode>(usages.length);
|
||||
for (Usage usage : usages) {
|
||||
final UsageNode node = myUsageNodes.get(usage);
|
||||
if (node != NULL_NODE && node != null) {
|
||||
node.setUsageExcluded(false);
|
||||
nodes.add(node);
|
||||
}
|
||||
}
|
||||
updateImmediately();
|
||||
updateImmediatelyNodesUpToRoot(nodes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void excludeUsages(@NotNull Usage[] usages) {
|
||||
List<TreeNode> nodes = new ArrayList<TreeNode>(usages.length);
|
||||
for (Usage usage : usages) {
|
||||
final UsageNode node = myUsageNodes.get(usage);
|
||||
if (node != NULL_NODE && node != null) {
|
||||
node.setUsageExcluded(true);
|
||||
nodes.add(node);
|
||||
}
|
||||
}
|
||||
updateImmediately();
|
||||
updateImmediatelyNodesUpToRoot(nodes);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -920,6 +924,24 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
|
||||
updateOnSelectionChanged();
|
||||
}
|
||||
|
||||
private void updateImmediatelyNodesUpToRoot(@NotNull List<TreeNode> nodes) {
|
||||
if (myProject.isDisposed()) return;
|
||||
TreeNode root = (TreeNode)myTree.getModel().getRoot();
|
||||
|
||||
for (int i=0; i<nodes.size(); i++) {
|
||||
TreeNode node = nodes.get(i);
|
||||
if (node instanceof Node) {
|
||||
((Node)node).update(this);
|
||||
TreeNode parent = node.getParent();
|
||||
if (parent != root && parent != null) {
|
||||
nodes.add(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
updateImmediately();
|
||||
}
|
||||
|
||||
|
||||
private void updateOnSelectionChanged() {
|
||||
List<UsageInfo> infos = getSelectedUsageInfos();
|
||||
if (myCurrentUsageContextPanel != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011 Bas Leijdekkers
|
||||
* Copyright 2011-2013 Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,21 +16,15 @@
|
||||
package com.siyeh.ipp.exceptions;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.siyeh.ipp.base.PsiElementPredicate;
|
||||
|
||||
class MulticatchPredicate implements PsiElementPredicate {
|
||||
|
||||
public boolean satisfiedBy(PsiElement element) {
|
||||
if (!(element instanceof PsiKeyword)) {
|
||||
if (element instanceof PsiCodeBlock) {
|
||||
return false;
|
||||
}
|
||||
final PsiJavaToken javaToken = (PsiJavaToken)element;
|
||||
final IElementType tokenType = javaToken.getTokenType();
|
||||
if (!tokenType.equals(JavaTokenType.CATCH_KEYWORD)) {
|
||||
return false;
|
||||
}
|
||||
final PsiElement parent = javaToken.getParent();
|
||||
final PsiElement parent = element.getParent();
|
||||
if (!(parent instanceof PsiCatchSection)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package git4idea.roots;
|
||||
|
||||
import com.intellij.ProjectTopics;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.DumbAwareRunnable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModuleRootEvent;
|
||||
@@ -69,6 +70,7 @@ public class GitRootScanner implements BulkFileListener, ModuleRootListener, Dis
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
myAlarm.cancelAllRequests();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,6 +113,11 @@ public class GitRootScanner implements BulkFileListener, ModuleRootListener, Dis
|
||||
}
|
||||
|
||||
private void scheduleScan() {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
// don't scan in tests
|
||||
return;
|
||||
}
|
||||
|
||||
myAlarm.cancelAllRequests(); // one scan is enough, no need to queue, they all do the same
|
||||
myAlarm.addRequest(new Runnable() {
|
||||
@Override
|
||||
|
||||
+32
-36
@@ -81,52 +81,48 @@ public class MavenModuleImporter {
|
||||
}
|
||||
|
||||
public void preConfigFacets() {
|
||||
if (myModule.isDisposed()) return;
|
||||
MavenUtil.invokeAndWaitWriteAction(myModule.getProject(), new Runnable() {
|
||||
public void run() {
|
||||
if (myModule.isDisposed()) return;
|
||||
|
||||
final ModuleType moduleType = ModuleType.get(myModule);
|
||||
final ModuleType moduleType = ModuleType.get(myModule);
|
||||
|
||||
for (final MavenImporter importer : getSuitableImporters()) {
|
||||
final MavenProjectChanges changes;
|
||||
if (myMavenProjectChanges == null) {
|
||||
if (importer.processChangedModulesOnly()) continue;
|
||||
changes = MavenProjectChanges.NONE;
|
||||
}
|
||||
else {
|
||||
changes = myMavenProjectChanges;
|
||||
}
|
||||
for (final MavenImporter importer : getSuitableImporters()) {
|
||||
final MavenProjectChanges changes;
|
||||
if (myMavenProjectChanges == null) {
|
||||
if (importer.processChangedModulesOnly()) continue;
|
||||
changes = MavenProjectChanges.NONE;
|
||||
}
|
||||
else {
|
||||
changes = myMavenProjectChanges;
|
||||
}
|
||||
|
||||
if (importer.getModuleType() == moduleType) {
|
||||
// facets use FacetConfiguration and like that do not have modifiable models,
|
||||
// therefore we have to take write lock
|
||||
MavenUtil.invokeAndWaitWriteAction(myModule.getProject(), new Runnable() {
|
||||
public void run() {
|
||||
if (importer.getModuleType() == moduleType) {
|
||||
importer.preProcess(myModule, myMavenProject, changes, myModifiableModelsProvider);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void configFacets(final List<MavenProjectsProcessorTask> postTasks) {
|
||||
if (myModule.isDisposed()) return;
|
||||
MavenUtil.invokeAndWaitWriteAction(myModule.getProject(), new Runnable() {
|
||||
public void run() {
|
||||
if (myModule.isDisposed()) return;
|
||||
|
||||
final ModuleType moduleType = ModuleType.get(myModule);
|
||||
final ModuleType moduleType = ModuleType.get(myModule);
|
||||
|
||||
for (final MavenImporter importer : getSuitableImporters()) {
|
||||
final MavenProjectChanges changes;
|
||||
if (myMavenProjectChanges == null) {
|
||||
if (importer.processChangedModulesOnly()) continue;
|
||||
changes = MavenProjectChanges.NONE;
|
||||
}
|
||||
else {
|
||||
changes = myMavenProjectChanges;
|
||||
}
|
||||
for (final MavenImporter importer : getSuitableImporters()) {
|
||||
final MavenProjectChanges changes;
|
||||
if (myMavenProjectChanges == null) {
|
||||
if (importer.processChangedModulesOnly()) continue;
|
||||
changes = MavenProjectChanges.NONE;
|
||||
}
|
||||
else {
|
||||
changes = myMavenProjectChanges;
|
||||
}
|
||||
|
||||
if (importer.getModuleType() == moduleType) {
|
||||
// facets use FacetConfiguration and like that do not have modifiable models,
|
||||
// therefore we have to take write lock
|
||||
MavenUtil.invokeAndWaitWriteAction(myModule.getProject(), new Runnable() {
|
||||
public void run() {
|
||||
if (importer.getModuleType() == moduleType) {
|
||||
importer.process(myModifiableModelsProvider,
|
||||
myModule,
|
||||
myRootModelAdapter,
|
||||
@@ -136,9 +132,9 @@ public class MavenModuleImporter {
|
||||
myMavenProjectToModuleName,
|
||||
postTasks);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<MavenImporter> getSuitableImporters() {
|
||||
|
||||
Reference in New Issue
Block a user