Merge remote-tracking branch 'origin/master'

This commit is contained in:
Kirill Likhodedov
2011-12-28 15:04:26 +03:00
48 changed files with 236 additions and 401 deletions
@@ -47,6 +47,7 @@ import com.intellij.peer.PeerFactory;
import com.intellij.psi.*;
import com.intellij.psi.search.scope.packageSet.PackageSetFactory;
import com.intellij.psi.util.PsiFormatUtil;
import com.intellij.psi.util.PsiFormatUtilBase;
import com.intellij.ui.*;
import com.intellij.ui.TextComponent;
import com.intellij.ui.content.ContentFactory;
@@ -197,18 +198,22 @@ public class PeerFactoryImpl extends PeerFactory {
private static String getPsiElementText(PsiElement psiElement) {
if (psiElement instanceof PsiClass) {
return PsiFormatUtil.formatClass((PsiClass)psiElement, PsiFormatUtil.SHOW_NAME |
PsiFormatUtil.SHOW_FQ_NAME);
return PsiFormatUtil.formatClass((PsiClass)psiElement, PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_FQ_NAME);
}
else if (psiElement instanceof PsiMethod) {
return PsiFormatUtil.formatMethod((PsiMethod)psiElement,
PsiSubstitutor.EMPTY,
PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS | PsiFormatUtil.SHOW_CONTAINING_CLASS,
PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_PARAMETERS |
PsiFormatUtilBase.SHOW_CONTAINING_CLASS,
0);
}
else if (psiElement instanceof PsiField) {
return PsiFormatUtil.formatVariable((PsiField)psiElement,
PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.SHOW_CONTAINING_CLASS,
PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_TYPE |
PsiFormatUtilBase.SHOW_CONTAINING_CLASS,
PsiSubstitutor.EMPTY);
}
else {
@@ -121,12 +121,12 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
}
@Nullable
public PsiAnnotation findExternalAnnotation(final PsiModifierListOwner listOwner, final String annotationFQN) {
public PsiAnnotation findExternalAnnotation(@NotNull final PsiModifierListOwner listOwner, @NotNull final String annotationFQN) {
return collectExternalAnnotations(listOwner).get(annotationFQN);
}
@Nullable
public PsiAnnotation[] findExternalAnnotations(final PsiModifierListOwner listOwner) {
public PsiAnnotation[] findExternalAnnotations(@NotNull final PsiModifierListOwner listOwner) {
final Map<String, PsiAnnotation> result = collectExternalAnnotations(listOwner);
return result.isEmpty() ? null : result.values().toArray(new PsiAnnotation[result.size()]);
}
@@ -136,43 +136,42 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
if (hasAnyAnnotationsRoots() == ThreeState.NO) return Collections.emptyMap();
final Map<String, PsiAnnotation> result = new HashMap<String, PsiAnnotation>();
final List<XmlFile> files = findExternalAnnotationsFile(listOwner);
if (files != null) {
for (XmlFile file : files) {
if (file.isValid()) {
final XmlDocument document = file.getDocument();
if (document != null) {
final XmlTag rootTag = document.getRootTag();
if (rootTag != null) {
final String externalName = PsiFormatUtil.getExternalName(listOwner, false);
final String oldExternalName = getNormalizedExternalName(listOwner);
for (final XmlTag tag : rootTag.getSubTags()) {
final String className = tag.getAttributeValue("name");
if (Comparing.strEqual(className, externalName) || Comparing.strEqual(className, oldExternalName)) {
for (XmlTag annotationTag : tag.getSubTags()) {
final String annotationFQN = annotationTag.getAttributeValue("name");
final StringBuilder buf = new StringBuilder();
for (XmlTag annotationaParameter : annotationTag.getSubTags()) {
buf.append(",");
final String nameValue = annotationaParameter.getAttributeValue("name");
if (nameValue != null) {
buf.append(nameValue).append("=");
}
buf.append(StringUtil.unescapeXml(annotationaParameter.getAttributeValue("val")));
}
final String annotationText =
"@" + annotationFQN + (buf.length() > 0 ? "(" + StringUtil.trimStart(buf.toString(), ",") + ")" : "");
try {
result.put(annotationFQN,
JavaPsiFacade.getInstance(listOwner.getProject()).getElementFactory().createAnnotationFromText(
annotationText, null));
}
catch (IncorrectOperationException e) {
LOG.error(e);
}
}
}
}
if (files == null) {
return Collections.emptyMap();
}
for (XmlFile file : files) {
if (!file.isValid()) continue;
final XmlDocument document = file.getDocument();
if (document == null) continue;
final XmlTag rootTag = document.getRootTag();
if (rootTag == null) continue;
final String externalName = PsiFormatUtil.getExternalName(listOwner, false);
final String oldExternalName = getNormalizedExternalName(listOwner);
for (final XmlTag tag : rootTag.getSubTags()) {
final String className = tag.getAttributeValue("name");
if (!Comparing.strEqual(className, externalName) && !Comparing.strEqual(className, oldExternalName)) {
continue;
}
for (XmlTag annotationTag : tag.getSubTags()) {
final String annotationFQN = annotationTag.getAttributeValue("name");
final StringBuilder buf = new StringBuilder();
for (XmlTag annotationParameter : annotationTag.getSubTags()) {
buf.append(",");
final String nameValue = annotationParameter.getAttributeValue("name");
if (nameValue != null) {
buf.append(nameValue).append("=");
}
buf.append(StringUtil.unescapeXml(annotationParameter.getAttributeValue("val")));
}
final String annotationText =
"@" + annotationFQN + (buf.length() > 0 ? "(" + StringUtil.trimStart(buf.toString(), ",") + ")" : "");
try {
result.put(annotationFQN,
JavaPsiFacade.getInstance(listOwner.getProject()).getElementFactory().createAnnotationFromText(
annotationText, null));
}
catch (IncorrectOperationException e) {
LOG.error(e);
}
}
}
@@ -181,9 +180,9 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
}
public void annotateExternally(final PsiModifierListOwner listOwner,
final String annotationFQName,
final PsiFile fromFile,
public void annotateExternally(@NotNull final PsiModifierListOwner listOwner,
@NotNull final String annotationFQName,
@NotNull final PsiFile fromFile,
final PsiNameValuePair[] value) {
final Project project = listOwner.getProject();
final PsiFile containingFile = listOwner.getContainingFile();
@@ -246,7 +245,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
}
}
private void chooseRootAndAnnotateExternally(final PsiModifierListOwner listOwner, final String annotationFQName, final PsiFile fromFile,
private void chooseRootAndAnnotateExternally(final PsiModifierListOwner listOwner, final String annotationFQName, @NotNull final PsiFile fromFile,
final Project project, final String packageName, final VirtualFile virtualFile,
final VirtualFile[] virtualFiles, final PsiNameValuePair[] value) {
if (virtualFiles.length > 1) {
@@ -277,7 +276,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
final String packageName,
final VirtualFile virtualFile,
final String annotationFQName,
final PsiFile fromFile,
@NotNull final PsiFile fromFile,
final PsiNameValuePair[] value) {
final XmlFile[] annotationsXml = new XmlFile[1];
List<XmlFile> xmlFiles = findExternalAnnotationsFile(listOwner);
@@ -309,7 +308,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
}.execute();
}
public boolean deannotate(final PsiModifierListOwner listOwner, final String annotationFQN) {
public boolean deannotate(@NotNull final PsiModifierListOwner listOwner, @NotNull final String annotationFQN) {
final List<XmlFile> files = findExternalAnnotationsFile(listOwner);
if (files != null) {
for (XmlFile file : files) {
@@ -440,7 +439,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
private static void annotateExternally(final PsiModifierListOwner listOwner,
final String annotationFQName,
@Nullable final XmlFile xmlFile,
final PsiFile codeUsageFile, PsiNameValuePair[] values) {
@NotNull PsiFile codeUsageFile, PsiNameValuePair[] values) {
if (xmlFile == null) return;
try {
final XmlDocument document = xmlFile.getDocument();
@@ -535,7 +534,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
}
@Nullable
private List<XmlFile> findExternalAnnotationsFile(PsiModifierListOwner listOwner) {
private List<XmlFile> findExternalAnnotationsFile(@NotNull PsiModifierListOwner listOwner) {
final Project project = listOwner.getProject();
final PsiFile containingFile = listOwner.getContainingFile();
if (containingFile instanceof PsiJavaFile) {
@@ -90,7 +90,7 @@ public class ModifierChooser {
final String[] keywords = keywordSets[keywordSets.length - i - 1];
boolean containModifierFlag = false;
if (list != null) {
for (@Modifier String keyword : keywords) {
for (String keyword : keywords) {
if (list.hasExplicitModifier(keyword)) {
containModifierFlag = true;
break;
@@ -18,6 +18,7 @@ package com.intellij.codeInsight.daemon.impl.analysis;
import com.intellij.lang.LangBundle;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiFormatUtil;
import com.intellij.psi.util.PsiFormatUtilBase;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -41,8 +42,8 @@ public class HighlightMessageUtil {
}
else if (symbol instanceof PsiMethod) {
symbolName = PsiFormatUtil.formatMethod((PsiMethod)symbol,
substitutor, PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS,
PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.SHOW_FQ_CLASS_NAMES);
substitutor, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS,
PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.SHOW_FQ_CLASS_NAMES);
}
else if (symbol instanceof PsiVariable) {
symbolName = ((PsiVariable)symbol).getName();
@@ -400,7 +400,7 @@ public class CreateFromUsageUtils {
return null;
}
if (!facade.getResolveHelper().isAccessible(targetClass, contextElement, null)) {
PsiUtil.setModifierProperty(targetClass, PsiKeyword.PUBLIC, true);
PsiUtil.setModifierProperty(targetClass, PsiModifier.PUBLIC, true);
}
}
else { //tests
@@ -25,6 +25,7 @@ import com.intellij.openapi.util.Pair;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.util.PsiFormatUtil;
import com.intellij.psi.util.PsiFormatUtilBase;
import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.ContainerUtil;
@@ -50,8 +51,11 @@ public class CreateMethodQuickFix implements LocalQuickFix {
public String getName() {
String signature = PsiFormatUtil.formatMethod(createMethod(myTargetClass.getProject()), PsiSubstitutor.EMPTY,
PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.SHOW_PARAMETERS | PsiFormatUtil.SHOW_RAW_TYPE,
PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.SHOW_RAW_TYPE, 2);
PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_TYPE |
PsiFormatUtilBase.SHOW_PARAMETERS |
PsiFormatUtilBase.SHOW_RAW_TYPE,
PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.SHOW_RAW_TYPE, 2);
return QuickFixBundle.message("create.method.from.usage.text", signature);
}
@@ -95,7 +95,7 @@ public class CreateParameterFromUsageFix extends CreateVarFromUsageFix {
if (ApplicationManager.getApplication().isUnitTestMode()) {
ParameterInfoImpl[] array = parameterInfos.toArray(new ParameterInfoImpl[parameterInfos.size()]);
@Modifier String modifier = PsiUtil.getAccessModifier(PsiUtil.getAccessLevel(method.getModifierList()));
String modifier = PsiUtil.getAccessModifier(PsiUtil.getAccessLevel(method.getModifierList()));
ChangeSignatureProcessor processor =
new ChangeSignatureProcessor(project, method, false, modifier, method.getName(), method.getReturnType(), array);
processor.run();
@@ -255,7 +255,7 @@ public class SimplifyBooleanExpressionFix implements IntentionAction {
}
else {
final PsiJavaToken javaToken = expression.getTokenBeforeOperand(operand);
if (javaToken != null && !PsiTreeUtil.hasErrorElements(operand)) {
if (javaToken != null && !PsiTreeUtil.hasErrorElements(operand) && !PsiTreeUtil.hasErrorElements(lExpr)) {
resultExpression = JavaPsiFacade.getElementFactory(expression.getProject()).createExpressionFromText(lExpr.getText() + javaToken.getText() + operand.getText(), expression);
} else {
resultExpression = null;
@@ -18,9 +18,9 @@ package com.intellij.codeInsight.generation.ui;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.psi.PsiField;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.PsiSubstitutor;
import com.intellij.psi.util.PsiFormatUtil;
import com.intellij.psi.util.PsiFormatUtilBase;
import com.intellij.ui.components.JBList;
import javax.swing.*;
@@ -68,14 +68,14 @@ public class SimpleFieldChooser extends DialogWrapper {
return myList.getSelectedValues();
}
private class MyListCellRenderer extends DefaultListCellRenderer {
private static class MyListCellRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Icon icon = null;
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
Icon icon = null;
if (value instanceof PsiField) {
PsiField field = (PsiField)value;
icon = field.getIcon(0);
final String text = PsiFormatUtil.formatVariable(field, PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE, PsiSubstitutor.EMPTY);
final String text = PsiFormatUtil.formatVariable(field, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_TYPE, PsiSubstitutor.EMPTY);
setText(text);
}
super.setIcon(icon);
@@ -144,21 +144,23 @@ public class DfaUtil {
return codeBlock;
}
@NotNull
public static Collection<? extends PsiElement> getPossibleInitializationElements(final PsiElement qualifierExpression) {
if (qualifierExpression instanceof PsiMethodCallExpression) {
return Collections.singletonList(qualifierExpression);
}
else if (qualifierExpression instanceof PsiReferenceExpression) {
if (qualifierExpression instanceof PsiReferenceExpression) {
final PsiElement targetElement = ((PsiReferenceExpression)qualifierExpression).resolve();
if (targetElement instanceof PsiVariable) {
final Collection<? extends PsiElement> variableValues = getCachedVariableValues((PsiVariable)targetElement, qualifierExpression);
if ((variableValues == null || variableValues.isEmpty())) {
return getVariableAssignmentsInFile((PsiVariable)targetElement, false, qualifierExpression);
}
return variableValues;
if (!(targetElement instanceof PsiVariable)) {
return Collections.emptyList();
}
final Collection<? extends PsiElement> variableValues = getCachedVariableValues((PsiVariable)targetElement, qualifierExpression);
if (variableValues == null || variableValues.isEmpty()) {
return getVariableAssignmentsInFile((PsiVariable)targetElement, false, qualifierExpression);
}
return variableValues;
}
else if (qualifierExpression instanceof PsiLiteralExpression) {
if (qualifierExpression instanceof PsiLiteralExpression) {
return Collections.singletonList(qualifierExpression);
}
return Collections.emptyList();
@@ -239,7 +241,7 @@ public class DfaUtil {
final Set<PsiVariable> myNotNulls = new THashSet<PsiVariable>();
private final PsiElement myContext;
public ValuableInstructionVisitor(PsiElement context) {
public ValuableInstructionVisitor(@NotNull PsiElement context) {
myContext = context;
}
@@ -152,7 +152,6 @@ public abstract class RefJavaElementImpl extends RefElementImpl implements RefJa
setFlag(b, IS_SYNTHETIC_JSP_ELEMENT);
}
@Modifier
@Nullable
public String getAccessModifier() {
long access_id = myFlags & ACCESS_MODIFIER_MASK;
@@ -46,6 +46,7 @@ import com.intellij.psi.infos.CandidateInfo;
import com.intellij.psi.javadoc.PsiDocComment;
import com.intellij.psi.javadoc.PsiDocTag;
import com.intellij.psi.util.PsiFormatUtil;
import com.intellij.psi.util.PsiFormatUtilBase;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.containers.HashMap;
import org.jetbrains.annotations.NonNls;
@@ -130,7 +131,7 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext
}
private static void generateModifiers(StringBuilder buffer, PsiElement element) {
String modifiers = PsiFormatUtil.formatModifiers(element, PsiFormatUtil.JAVADOC_MODIFIERS_ONLY);
String modifiers = PsiFormatUtil.formatModifiers(element, PsiFormatUtilBase.JAVADOC_MODIFIERS_ONLY);
if (modifiers.length() > 0) {
buffer.append(modifiers);
@@ -531,8 +532,10 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext
}
final String str = PsiFormatUtil.formatMethod((PsiMethod)element, candidate.getSubstitutor(),
PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.SHOW_PARAMETERS,
PsiFormatUtil.SHOW_TYPE);
PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_TYPE |
PsiFormatUtilBase.SHOW_PARAMETERS,
PsiFormatUtilBase.SHOW_TYPE);
createElementLink(sb, element, StringUtil.escapeXml(str));
}
@@ -583,8 +586,8 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext
urls.add(classUrl + "#" + signature);
}
signature = PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY,
PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS,
PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.SHOW_FQ_CLASS_NAMES, 999);
PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS,
PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.SHOW_FQ_CLASS_NAMES, 999);
for (String classUrl : classUrls) {
urls.add(classUrl + "#" + signature);
}
@@ -614,8 +617,12 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext
public static String formatMethodSignature(PsiMethod method) {
return PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY,
PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS | PsiFormatUtil.SHOW_RAW_NON_TOP_TYPE,
PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.SHOW_FQ_CLASS_NAMES | PsiFormatUtil.SHOW_RAW_NON_TOP_TYPE,
PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_PARAMETERS |
PsiFormatUtilBase.SHOW_RAW_NON_TOP_TYPE,
PsiFormatUtilBase.SHOW_TYPE |
PsiFormatUtilBase.SHOW_FQ_CLASS_NAMES |
PsiFormatUtilBase.SHOW_RAW_NON_TOP_TYPE,
999);
}
@@ -119,7 +119,7 @@ public class LightField extends LightElement implements PsiField {
}
@Override
public boolean hasModifierProperty(@Modifier @NonNls @NotNull final String name) {
public boolean hasModifierProperty(@NonNls @NotNull final String name) {
return myField.hasModifierProperty(name);
}
@@ -33,6 +33,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.presentation.java.SymbolPresentationUtil;
import com.intellij.psi.util.PsiFormatUtil;
import com.intellij.psi.util.PsiFormatUtilBase;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.typeMigration.ChangeTypeSignatureHandler;
@@ -456,28 +457,19 @@ public class MigrationPanel extends JPanel implements Disposable {
else {
final PsiMember member = PsiTreeUtil.getParentOfType(element, PsiMember.class);
if (member instanceof PsiField) {
location = PsiFormatUtil.formatVariable((PsiVariable)member, PsiFormatUtil
.SHOW_NAME |
PsiFormatUtil
.SHOW_CONTAINING_CLASS |
PsiFormatUtil
.SHOW_FQ_NAME, PsiSubstitutor.EMPTY);
location = PsiFormatUtil.formatVariable((PsiVariable)member, PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_CONTAINING_CLASS |
PsiFormatUtilBase.SHOW_FQ_NAME, PsiSubstitutor.EMPTY);
}
else if (member instanceof PsiMethod) {
location = PsiFormatUtil.formatMethod((PsiMethod)member, PsiSubstitutor.EMPTY, PsiFormatUtil
.SHOW_NAME |
PsiFormatUtil
.SHOW_CONTAINING_CLASS |
PsiFormatUtil
.SHOW_FQ_NAME, PsiFormatUtil.SHOW_TYPE);
location = PsiFormatUtil.formatMethod((PsiMethod)member, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_CONTAINING_CLASS |
PsiFormatUtilBase.SHOW_FQ_NAME,
PsiFormatUtilBase.SHOW_TYPE);
}
else if (member instanceof PsiClass) {
location = PsiFormatUtil.formatClass((PsiClass)member, PsiFormatUtil
.SHOW_NAME |
PsiFormatUtil
.SHOW_CONTAINING_CLASS |
PsiFormatUtil
.SHOW_FQ_NAME);
location = PsiFormatUtil.formatClass((PsiClass)member, PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_FQ_NAME);
}
else {
location = null;
@@ -42,9 +42,7 @@ public class MethodCellRenderer extends DefaultListCellRenderer {
PsiFormatUtil.SHOW_TYPE);
setText(text);
final int flags = Iconable.ICON_FLAG_VISIBILITY;
Icon icon = method.getIcon(flags);
Icon icon = method.getIcon(Iconable.ICON_FLAG_VISIBILITY);
if(icon != null) setIcon(icon);
return this;
}
@@ -369,7 +369,7 @@ public class MethodDuplicatesHandler implements RefactoringActionHandler {
@Nullable
public String getConfirmDuplicatePrompt(final Match match) {
final PsiElement matchStart = match.getMatchStart();
@Modifier String visibility = VisibilityUtil.getPossibleVisibility(myMethod, matchStart);
String visibility = VisibilityUtil.getPossibleVisibility(myMethod, matchStart);
final boolean shouldBeStatic = isEssentialStaticContextAbsent(match);
final String signature = match.getChangedSignature(myMethod, myMethod.hasModifierProperty(PsiModifier.STATIC) || shouldBeStatic, visibility);
if (signature != null) {
@@ -37,6 +37,7 @@ import com.intellij.psi.impl.compiled.ClassFileStubBuilder;
import com.intellij.psi.impl.compiled.ClsStubBuilderFactory;
import com.intellij.psi.impl.compiled.DefaultClsStubBuilderFactory;
import com.intellij.psi.impl.file.PsiPackageImplementationHelper;
import com.intellij.psi.impl.source.resolve.JavaResolveCache;
import com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl;
import com.intellij.psi.impl.source.tree.CoreJavaASTFactory;
import com.intellij.psi.stubs.BinaryFileStubBuilders;
@@ -80,7 +81,8 @@ public class JavaCoreEnvironment extends CoreEnvironment {
myProject.registerService(PsiResolveHelper.class, new PsiResolveHelperImpl(myPsiManager));
myProject.registerService(LanguageLevelProjectExtension.class, new CoreLanguageLevelProjectExtension());
myProject.registerService(PackageIndex.class, myFileManager);
myProject.registerService(JavaResolveCache.class, new JavaResolveCache(null));
myApplication.registerService(EmptySubstitutor.class, new EmptySubstitutorImpl());
myApplication.registerService(JavaDirectoryService.class, new CoreJavaDirectoryService());
}
@@ -113,7 +113,7 @@ public class PsiMethodReceiverImpl extends CompositePsiElement implements PsiMet
}
@Override
public boolean hasModifierProperty(@Modifier @NonNls @NotNull String name) {
public boolean hasModifierProperty(@NonNls @NotNull String name) {
return false;
}
@@ -70,16 +70,18 @@ public class JavaResolveCache {
myVarToConstValueMapPhysical = new ConcurrentWeakHashMap<PsiVariable, Object>();
myVarToConstValueMapNonPhysical = new ConcurrentWeakHashMap<PsiVariable, Object>();
messageBus.connect().subscribe(PsiManagerImpl.ANY_PSI_CHANGE_TOPIC, new AnyPsiChangeListener() {
@Override
public void beforePsiChanged(boolean isPhysical) {
clearCaches(isPhysical);
}
@Override
public void afterPsiChanged(boolean isPhysical) {
}
});
if (messageBus != null) {
messageBus.connect().subscribe(PsiManagerImpl.ANY_PSI_CHANGE_TOPIC, new AnyPsiChangeListener() {
@Override
public void beforePsiChanged(boolean isPhysical) {
clearCaches(isPhysical);
}
@Override
public void afterPsiChanged(boolean isPhysical) {
}
});
}
}
private void clearCaches(boolean isPhysical) {
@@ -67,26 +67,28 @@ public class JavaVariableConflictResolver implements PsiConflictResolver{
final PsiElement scope = currentResult.getCurrentFileResolveScope();
Boolean oldClassIsInheritor = null;
if (newClass.isInheritor(oldClass, true)) {
if (!(scope instanceof PsiClass) ||
scope.equals(oldClass) ||
scope.equals(newClass) ||
!((PsiClass)scope).isInheritorDeep(oldClass, newClass)) {
// candidate is better
conflicts.remove(currentResult);
currentResult = candidate;
currentElement = currentResult.getElement();
continue;
if (newClass != null && oldClass != null) {
if (newClass.isInheritor(oldClass, true)) {
if (!(scope instanceof PsiClass) ||
scope.equals(oldClass) ||
scope.equals(newClass) ||
!((PsiClass)scope).isInheritorDeep(oldClass, newClass)) {
// candidate is better
conflicts.remove(currentResult);
currentResult = candidate;
currentElement = currentResult.getElement();
continue;
}
}
}
else if (oldClassIsInheritor = oldClass.isInheritor(newClass, true)) {
if (!(scope instanceof PsiClass) ||
scope.equals(oldClass) ||
scope.equals(newClass) ||
!((PsiClass)scope).isInheritorDeep(newClass, oldClass)) {
// candidate is worse
conflicts.remove(candidate);
continue;
else if (oldClassIsInheritor = oldClass.isInheritor(newClass, true)) {
if (!(scope instanceof PsiClass) ||
scope.equals(oldClass) ||
scope.equals(newClass) ||
!((PsiClass)scope).isInheritorDeep(newClass, oldClass)) {
// candidate is worse
conflicts.remove(candidate);
continue;
}
}
}
@@ -108,7 +110,7 @@ public class JavaVariableConflictResolver implements PsiConflictResolver{
}
if (oldClassIsInheritor == null) {
oldClassIsInheritor = oldClass.isInheritor(newClass, true);
oldClassIsInheritor = oldClass != null && newClass != null && oldClass.isInheritor(newClass, true);
}
if (oldClassIsInheritor) {
// both fields are accessible
@@ -131,13 +131,11 @@ public class EncapsulateFieldsTest extends MultiFileTestCase{
}
@Override
@Modifier
public String getFieldsVisibility() {
return null;
}
@Override
@Modifier
public String getAccessorsVisibility() {
return PsiModifier.PUBLIC;
}
@@ -25,6 +25,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.NotNullLazyKey;
import com.intellij.psi.*;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class ExternalAnnotationsManager {
@@ -38,23 +39,23 @@ public abstract class ExternalAnnotationsManager {
private static final NotNullLazyKey<ExternalAnnotationsManager, Project> INSTANCE_KEY = ServiceManager.createLazyKey(ExternalAnnotationsManager.class);
public static ExternalAnnotationsManager getInstance(Project project) {
public static ExternalAnnotationsManager getInstance(@NotNull Project project) {
return INSTANCE_KEY.getValue(project);
}
@Nullable
public abstract PsiAnnotation findExternalAnnotation(final PsiModifierListOwner listOwner, final String annotationFQN);
public abstract PsiAnnotation findExternalAnnotation(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN);
@Nullable
public abstract PsiAnnotation[] findExternalAnnotations(final PsiModifierListOwner listOwner);
public abstract PsiAnnotation[] findExternalAnnotations(@NotNull PsiModifierListOwner listOwner);
public abstract void annotateExternally(final PsiModifierListOwner listOwner,
final String annotationFQName,
final PsiFile fromFile,
final PsiNameValuePair[] value);
public abstract void annotateExternally(@NotNull PsiModifierListOwner listOwner,
@NotNull String annotationFQName,
@NotNull PsiFile fromFile,
PsiNameValuePair[] value);
public abstract boolean deannotate(final PsiModifierListOwner listOwner, final String annotationFQN);
public abstract boolean deannotate(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN);
public abstract AnnotationPlace chooseAnnotationsPlace(final PsiElement element);
public abstract AnnotationPlace chooseAnnotationsPlace(@NotNull PsiElement element);
}
@@ -150,7 +150,7 @@ public abstract class ElementBase extends UserDataHolderBase implements Iconable
}
public static boolean isNativeFileType(FileType fileType) {
return (fileType instanceof INativeFileType && ((INativeFileType) fileType).useNativeIcon()) || fileType instanceof UnknownFileType;
return fileType instanceof INativeFileType && ((INativeFileType) fileType).useNativeIcon() || fileType instanceof UnknownFileType;
}
protected Icon getAdjustedBaseIcon(Icon icon, int flags) {
@@ -381,8 +381,8 @@ public class ColorAndFontDescriptionPanel extends JPanel {
public void apply(ColorAndFontDescription description, EditorColorsScheme scheme) {
if (description != null) {
int fontType = Font.PLAIN;
if (myCbBold.isSelected()) fontType += Font.BOLD;
if (myCbItalic.isSelected()) fontType += Font.ITALIC;
if (myCbBold.isSelected()) fontType |= Font.BOLD;
if (myCbItalic.isSelected()) fontType |= Font.ITALIC;
description.setFontType(fontType);
description.setForegroundChecked(myCbForeground.isSelected());
description.setForegroundColor(myForegroundChooser.getSelectedColor());
@@ -61,7 +61,6 @@ public class DefaultLookupItemRenderer extends LookupElementRenderer<LookupItem>
Object o = item.getObject();
int flags = Iconable.ICON_FLAG_VISIBILITY;
if (!real) {
if (item.getObject() instanceof String) {
return EmptyIcon.ICON_0;
@@ -71,7 +70,7 @@ public class DefaultLookupItemRenderer extends LookupElementRenderer<LookupItem>
}
if (o instanceof Iconable && !(o instanceof PsiElement)) {
return ((Iconable)o).getIcon(flags);
return ((Iconable)o).getIcon(Iconable.ICON_FLAG_VISIBILITY);
}
if (o instanceof LookupValueWithPsiElement) {
@@ -80,7 +79,7 @@ public class DefaultLookupItemRenderer extends LookupElementRenderer<LookupItem>
if (o instanceof PsiElement) {
final PsiElement element = (PsiElement)o;
if (element.isValid()) {
return element.getIcon(flags);
return element.getIcon(Iconable.ICON_FLAG_VISIBILITY);
}
}
return null;
@@ -71,7 +71,7 @@ public class LookupItem<T> extends MutableLookupElement<T> implements Comparable
private AutoCompletionPolicy myAutoCompletionPolicy = AutoCompletionPolicy.SETTINGS_DEPENDENT;
/**
* @deprecated use LookupElementBuilder
* @deprecated use {@link LookupElementBuilder}
*/
public LookupItem(T o, @NotNull @NonNls String lookupString) {
setObject(o);
@@ -16,25 +16,18 @@
package com.intellij.ide.util;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.commander.CommanderPanel;
import com.intellij.ide.commander.ProjectListBuilder;
import com.intellij.ide.structureView.StructureViewBuilder;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.ide.structureView.StructureViewTreeElement;
import com.intellij.ide.structureView.TreeBasedStructureViewBuilder;
import com.intellij.ide.structureView.newStructureView.StructureViewComponent;
import com.intellij.ide.structureView.newStructureView.TreeActionsOwner;
import com.intellij.ide.structureView.newStructureView.TreeModelWrapper;
import com.intellij.ide.util.treeView.AbstractTreeNode;
import com.intellij.ide.util.treeView.smartTree.*;
import com.intellij.lang.LanguageStructureViewBuilder;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.MnemonicHelper;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.project.Project;
@@ -49,7 +42,6 @@ import com.intellij.pom.Navigatable;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.ui.ListScrollingUtil;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.SpeedSearchBase;
import com.intellij.ui.TreeSpeedSearch;
@@ -61,22 +53,18 @@ import com.intellij.ui.treeStructure.filtered.FilteringTreeBuilder;
import com.intellij.ui.treeStructure.filtered.FilteringTreeStructure;
import com.intellij.util.Alarm;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashSet;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.tree.DefaultMutableTreeNode;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -100,8 +88,7 @@ public class FileStructurePopup implements Disposable {
private FilteringTreeBuilder myAbstractTreeBuilder;
private String myTitle;
private TreeSpeedSearch mySpeedSearch;
private final FilteringTreeStructure myStructure;
private SmartTreeStructure mySmartTreeStructure;
private SmartTreeStructure myTreeStructure;
public FileStructurePopup(StructureViewModel structureViewModel,
@Nullable Editor editor,
@@ -127,18 +114,7 @@ public class FileStructurePopup implements Disposable {
final PsiElement psiElement = getCurrentElement(psiFile);
//myDialog.setUndecorated(true);
if (psiElement != null) {
if (structureViewModel.shouldEnterElement(psiElement)) {
//myCommanderPanel.getBuilder().enterElement(psiElement, PsiUtilBase.getVirtualFile(psiElement));
}
else {
//myCommanderPanel.getBuilder().selectElement(psiElement, PsiUtilBase.getVirtualFile(psiElement));
}
}
mySmartTreeStructure = new SmartTreeStructure(project, myTreeModel){
myTreeStructure = new SmartTreeStructure(project, myTreeModel){
public void rebuildTree() {
if (!myPopup.isDisposed()) {
super.rebuildTree();
@@ -158,16 +134,12 @@ public class FileStructurePopup implements Disposable {
return "structure view tree structure(model=" + myTreeModel + ")";
}
};
ElementFilter filter = new FileStructurePopupFilter();
myStructure = new FilteringTreeStructure(project, filter, mySmartTreeStructure);
//final DefaultTreeModel model = new DefaultTreeModel(new DefaultMutableTreeNode(treeStructure.getRootElement()));
myTree = new Tree(new DefaultMutableTreeNode(myStructure.getRootElement()));
myTree = new Tree(new DefaultMutableTreeNode(myTreeStructure.getRootElement()));
myTree.setRootVisible(false);
myTree.setShowsRootHandles(true);
mySpeedSearch = new TreeSpeedSearch(myTree, TreeSpeedSearch.NODE_DESCRIPTOR_TOSTRING, true);
myAbstractTreeBuilder = new FilteringTreeBuilder(project, myTree, filter, myStructure, null) {
myAbstractTreeBuilder = new FilteringTreeBuilder(project, myTree, new FileStructurePopupFilter(), myTreeStructure, null) {
@Override
protected boolean validateNode(Object child) {
return StructureViewComponent.isValid(child);
@@ -225,11 +197,6 @@ public class FileStructurePopup implements Disposable {
return PsiDocumentManager.getInstance(project).getPsiFile(myEditor.getDocument());
}
@Nullable
protected Border createContentPaneBorder() {
return null;
}
public void dispose() {
}
@@ -313,7 +280,7 @@ public class FileStructurePopup implements Disposable {
return panel;
}
@Nullable
private AbstractTreeNode getSelectedNode() {
Object component = myTree.getSelectionPath().getLastPathComponent();
@@ -321,11 +288,8 @@ public class FileStructurePopup implements Disposable {
component = ((DefaultMutableTreeNode)component).getUserObject();
if (component instanceof FilteringTreeStructure.Node) {
component = ((FilteringTreeStructure.Node)component).getDelegate();
if (component instanceof FilteringTreeStructure.Node) {
component = ((FilteringTreeStructure.Node)component).getDelegate();
if (component instanceof AbstractTreeNode) {
return (AbstractTreeNode)component;
}
if (component instanceof AbstractTreeNode) {
return (AbstractTreeNode)component;
}
}
}
@@ -359,11 +323,6 @@ public class FileStructurePopup implements Disposable {
return succeeded.get();
}
protected boolean isShowRoot(final PsiFile psiFile) {
StructureViewBuilder viewBuilder = LanguageStructureViewBuilder.INSTANCE.getStructureViewBuilder(psiFile);
return viewBuilder instanceof TreeBasedStructureViewBuilder && ((TreeBasedStructureViewBuilder)viewBuilder).isRootNodeShown();
}
private void addNarrowDownCheckbox(final JPanel panel) {
final JCheckBox checkBox = new JCheckBox(IdeBundle.message("checkbox.narrow.down.the.list.on.typing"));
checkBox.setSelected(PropertiesComponent.getInstance().isTrueValue(ourPropertyKey));
@@ -378,7 +337,6 @@ public class FileStructurePopup implements Disposable {
checkBox.setFocusable(false);
panel.add(checkBox);
//,new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0));
}
private void addCheckbox(final JPanel panel, final TreeAction action) {
@@ -405,7 +363,7 @@ public class FileStructurePopup implements Disposable {
}
final boolean state = chkFilter.isSelected();
myTreeActionsOwner.setActionIncluded(action, action instanceof FileStructureFilter ? !state : state);
mySmartTreeStructure.rebuildTree();
myTreeStructure.rebuildTree();
myAbstractTreeBuilder.refilter(); //todo full update
myAbstractTreeBuilder.queueUpdate();
if (currentParent != null) {
@@ -436,163 +394,12 @@ public class FileStructurePopup implements Disposable {
}
chkFilter.setText(text);
panel.add(chkFilter);
//,new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0));
}
@Nullable
protected JComponent createSouthPanel() {
return null;
}
public void setTitle(String title) {
myTitle = title;
}
private class MyCommanderPanel extends CommanderPanel implements DataProvider {
@Override
protected boolean shouldDrillDownOnEmptyElement(final AbstractTreeNode node) {
return false;
}
public MyCommanderPanel(Project _project) {
super(_project, false, true);
myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
myListSpeedSearch.addChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
ProjectListBuilder builder = (ProjectListBuilder)getBuilder();
if (builder == null) {
return;
}
builder.addUpdateRequest(hasPrefixShortened(evt));
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
int index = myList.getSelectedIndex();
if (index != -1 && index < myList.getModel().getSize()) {
myList.clearSelection();
ListScrollingUtil.selectItem(myList, index);
}
else {
ListScrollingUtil.ensureSelectionExists(myList);
}
}
});
myList.repaint(); // to update match highlighting
}
});
myListSpeedSearch.setComparator(createSpeedSearchComparator());
}
private boolean hasPrefixShortened(final PropertyChangeEvent evt) {
return evt.getNewValue() != null && evt.getOldValue() != null &&
((String)evt.getNewValue()).length() < ((String)evt.getOldValue()).length();
}
public boolean navigateSelectedElement() {
final Ref<Boolean> succeeded = new Ref<Boolean>();
final CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.executeCommand(myProject, new Runnable() {
public void run() {
final AbstractTreeNode selectedNode = getSelectedNode();
if (selectedNode != null) {
if (selectedNode.canNavigateToSource()) {
selectedNode.navigate(true);
succeeded.set(true);
} else {
succeeded.set(false);
}
} else {
succeeded.set(false);
}
IdeDocumentHistory.getInstance(myProject).includeCurrentCommandAsNavigation();
}
}, "Navigate", null);
if (succeeded.get()) {
myPopup.cancel();
}
return succeeded.get();
}
public Object getData(String dataId) {
Object selectedElement = ContainerUtil.getFirstItem(myAbstractTreeBuilder.getSelectedElements());
if (selectedElement instanceof TreeElement) selectedElement = ((StructureViewTreeElement)selectedElement).getValue();
if (PlatformDataKeys.NAVIGATABLE.is(dataId)) {
return selectedElement instanceof Navigatable ? selectedElement : myNavigatable;
}
if (OpenFileDescriptor.NAVIGATE_IN_EDITOR.is(dataId)) return myEditor;
return getDataImpl(dataId);
}
public String getEnteredPrefix() {
return myListSpeedSearch.getEnteredPrefix();
}
public void updateSpeedSearch() {
myListSpeedSearch.refreshSelection();
}
public void scrollSelectionInView() {
int selectedIndex = myList.getSelectedIndex();
if (selectedIndex >= 0) {
ListScrollingUtil.ensureIndexIsVisible(myList, selectedIndex, 0);
}
}
}
private class MyStructureTreeStructure extends SmartTreeStructure {
public MyStructureTreeStructure(Project project) {
super(project, myTreeModel);
}
public Object[] getChildElements(Object element) {
Object[] childElements = super.getChildElements(element);
if (!myShouldNarrowDown) {
return childElements;
}
String enteredPrefix = null;//todo myCommanderPanel.getEnteredPrefix();
if (enteredPrefix == null) {
return childElements;
}
ArrayList<Object> filteredElements = new ArrayList<Object>(childElements.length);
SpeedSearchBase.SpeedSearchComparator speedSearchComparator = createSpeedSearchComparator();
for (Object child : childElements) {
if (child instanceof AbstractTreeNode) {
Object value = ((AbstractTreeNode)child).getValue();
if (value instanceof TreeElement) {
String name = ((TreeElement)value).getPresentation().getPresentableText();
if (name == null) {
continue;
}
if (speedSearchComparator.matchingFragments(enteredPrefix, name) == null) {
continue;
}
}
}
filteredElements.add(child);
}
return ArrayUtil.toObjectArray(filteredElements);
}
public void rebuildTree() {
getChildElements(getRootElement()); // for some reason necessary to rebuild tree correctly
super.rebuildTree();
}
}
private static SpeedSearchBase.SpeedSearchComparator createSpeedSearchComparator() {
return new SpeedSearchBase.SpeedSearchComparator(false);
}
private class MyTreeActionsOwner implements TreeActionsOwner {
private final Set<TreeAction> myActions = new HashSet<TreeAction>();
@@ -54,11 +54,11 @@ abstract class InspectionsConfigTreeRenderer extends CheckboxTree.CheckboxTreeCe
selected ? UIUtil.getTreeSelectionForeground() : node.isProperSetting ? Color.BLUE : UIUtil.getTreeTextForeground();
@NonNls String text = null;
int style = Font.PLAIN;
int style = SimpleTextAttributes.STYLE_PLAIN;
String hint = null;
if (object instanceof String) {
text = (String)object;
style = Font.BOLD;
style = SimpleTextAttributes.STYLE_BOLD;
}
else {
final Descriptor descriptor = node.getDesriptor();
@@ -53,7 +53,6 @@ import com.intellij.util.ui.table.JBListTable;
import com.intellij.util.ui.table.JBTableRow;
import com.intellij.util.ui.table.JBTableRowEditor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
@@ -65,8 +64,10 @@ import javax.swing.table.TableCellEditor;
import java.awt.*;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
/**
* @author Konstantin Bulenkov
@@ -114,7 +114,7 @@ public class FileReferenceContextUtil {
}
private static PsiElement bindElement(final PsiElement element, PsiFileSystemItem item) {
if (item != null && item.isValid()) {
if (item != null && item.isValid() && item.getVirtualFile() != null) {
PsiReference[] refs = element.getReferences();
for (PsiReference ref : refs) {
if (ref instanceof FileReferenceOwner) {
@@ -161,7 +161,7 @@ public class FocusDebugger implements UiDebuggerExtension, PropertyChangeListene
return greyOut ? attr.derive(attr.getStyle(), Color.gray, attr.getBgColor(), attr.getWaveColor()) : attr;
}
class FocusElementRenderer extends ColoredListCellRenderer {
static class FocusElementRenderer extends ColoredListCellRenderer {
@Override
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
clear();
@@ -175,7 +175,7 @@ public class FocusDebugger implements UiDebuggerExtension, PropertyChangeListene
}
}
class FocusElement {
static class FocusElement {
private final SimpleColoredText myText;
private final Throwable myAllocation;
@@ -111,7 +111,7 @@ public abstract class ActionPlaces {
public static final String CHANGES_LOCAL_DIFF_SETTINGS = "CHANGES_LOCAL_DIFF_SETTINGS";
private static final String[] ourToolbarPlaces = new String[]{EDITOR_TOOLBAR, PROJECT_VIEW_TOOLBAR, TESTTREE_VIEW_TOOLBAR, MAIN_TOOLBAR,
private static final String[] ourToolbarPlaces = {EDITOR_TOOLBAR, PROJECT_VIEW_TOOLBAR, TESTTREE_VIEW_TOOLBAR, MAIN_TOOLBAR,
ANT_EXPLORER_TOOLBAR, ANT_MESSAGES_TOOLBAR, COMPILER_MESSAGES_TOOLBAR, TODO_VIEW_TOOLBAR, STRUCTURE_VIEW_TOOLBAR, USAGE_VIEW_TOOLBAR,
DEBUGGER_TOOLBAR, CALL_HIERARCHY_VIEW_TOOLBAR, METHOD_HIERARCHY_VIEW_TOOLBAR, TYPE_HIERARCHY_VIEW_TOOLBAR, JAVADOC_TOOLBAR,
FILE_HISTORY_TOOLBAR, FILEHISTORY_VIEW_TOOLBAR, LVCS_DIRECTORY_HISTORY_TOOLBAR, CHANGES_VIEW_TOOLBAR, PHING_EXPLORER_TOOLBAR,
@@ -122,7 +122,7 @@ public abstract class ActionPlaces {
return ArrayUtil.find(ourToolbarPlaces, place) != -1;
}
private static final String[] ourPopupPlaces = new String[]{EDITOR_POPUP, EDITOR_TAB_POPUP, COMMANDER_POPUP,
private static final String[] ourPopupPlaces = {EDITOR_POPUP, EDITOR_TAB_POPUP, COMMANDER_POPUP,
PROJECT_VIEW_POPUP, FAVORITES_VIEW_POPUP, SCOPE_VIEW_POPUP, TESTTREE_VIEW_POPUP, TESTSTATISTICS_VIEW_POPUP, TYPE_HIERARCHY_VIEW_POPUP,
METHOD_HIERARCHY_VIEW_POPUP, CALL_HIERARCHY_VIEW_POPUP, J2EE_ATTRIBUTES_VIEW_POPUP, J2EE_VIEW_POPUP, USAGE_VIEW_POPUP,
STRUCTURE_VIEW_POPUP, TODO_VIEW_POPUP, COMPILER_MESSAGES_POPUP, ANT_MESSAGES_POPUP, ANT_EXPLORER_POPUP, UPDATE_POPUP,
@@ -24,8 +24,8 @@ public class VerticalFlowLayout extends FlowLayout implements Serializable {
public static final int TOP = 0;
private boolean myVerticalFill;
private boolean myHorizontalFill;
private int vGap;
private int hGap;
private final int vGap;
private final int hGap;
public VerticalFlowLayout() {
this(TOP, 5, 5, true, false);
@@ -65,7 +65,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible {
/**
* Gap between icon and text. It is used only if icon is defined.
*/
private int myIconTextGap;
protected int myIconTextGap;
/**
* Defines whether the focus border around the text is painted or not.
* For example, text can have a border if the component represents a selected item
@@ -46,9 +46,6 @@ public class FilteringTreeStructure extends AbstractTreeStructure {
}
public void refilter() {
if (myStructure instanceof FilteringTreeStructure) {
((FilteringTreeStructure)myStructure).refilter();
}
myRoot.clear();
myNodeObject2Node.clear();
fillChildren(myRoot, getStructure().getRootElement());
@@ -218,7 +215,10 @@ public class FilteringTreeStructure extends AbstractTreeStructure {
@Override
public boolean isAlwaysLeaf(Object element) {
return ((Node)element).isAlwaysLeaf();
if (element instanceof Node) {
return ((Node)element).isAlwaysLeaf();
}
return false;
}
@NotNull
@@ -248,17 +248,20 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
*/
private UIManager.LookAndFeelInfo getDefaultLaf() {
final String lowercaseProductName = ApplicationNamesInfo.getInstance().getLowercaseProductName();
final String systemLafClassName = UIManager.getSystemLookAndFeelClassName();
if (SystemInfo.isMac) {
UIManager.LookAndFeelInfo laf = findLaf(UIManager.getSystemLookAndFeelClassName());
UIManager.LookAndFeelInfo laf = findLaf(systemLafClassName);
LOG.assertTrue(laf != null);
return laf;
}
if ("Rubymine".equals(lowercaseProductName) || "Pycharm".equals(lowercaseProductName)) {
final String desktop = AccessController.doPrivileged(new GetPropertyAction("sun.desktop"));
if ("gnome".equals(desktop)) {
UIManager.LookAndFeelInfo laf=findLaf(UIManager.getSystemLookAndFeelClassName());
LOG.assertTrue(laf!=null);
return laf;
UIManager.LookAndFeelInfo laf=findLaf(systemLafClassName);
if (laf != null) {
return laf;
}
LOG.info("Could not find system look and feel: " + laf);
}
}
// Default
@@ -104,11 +104,11 @@ public class ComplementaryFontsRegistry {
if (!SystemInfo.isMac || style == 0) return Pair.create(familyName, style);
StringBuilder st = new StringBuilder(familyName).append('-');
if ((style & Font.BOLD) == Font.BOLD) {
if ((style & Font.BOLD) != 0) {
st.append("Bold");
}
if ((style & Font.ITALIC) == Font.ITALIC) {
if ((style & Font.ITALIC) != 0) {
st.append("Italic");
}
@@ -100,6 +100,7 @@ public class WelcomeScreen implements Disposable {
@NonNls private static final String HTML_SUFFIX = "</html>";
@NonNls private static final String ___HTML_SUFFIX = "...</html>";
@NonNls private static final String ESC_NEW_LINE = "\\n";
public static final Icon ICON = IconLoader.getIcon("/actions/closeNew.png");
private final JPanel myWelcomePanel;
private final JPanel myMainPanel;
@@ -242,7 +243,19 @@ public class WelcomeScreen implements Disposable {
int row = 1;
for (final AnAction action : recentProjectsActions) {
final SimpleColoredComponent actionLabel = new SimpleColoredComponent();
final SimpleColoredComponent actionLabel = new SimpleColoredComponent() {
@Override
public Dimension getPreferredSize() {
boolean hasIcon = getIcon() != null;
Dimension preferredSize = super.getPreferredSize();
return new Dimension(preferredSize.width + (hasIcon ? 0 : ICON.getIconWidth() + myIconTextGap), preferredSize.height);
}
@Override
public Dimension getMinimumSize() {
return getPreferredSize();
}
};
actionLabel.append(String.valueOf(row), CAPTION_UNDERLINE_ATTRIBUTES);
actionLabel.append(". ", new SimpleTextAttributes(0, CAPTION_COLOR));
actionLabel.append(action.getTemplatePresentation().getText(), CAPTION_BOLD_UNDERLINE_ATTRIBUTES);
@@ -298,9 +311,7 @@ public class WelcomeScreen implements Disposable {
@Override
public void mouseEntered(MouseEvent e) {
if (actionLabel.getSize().width > actionLabel.getPreferredSize().width) {
actionLabel.setIcon(IconLoader.getIcon("/actions/closeNew.png"));
}
actionLabel.setIcon(ICON);
}
@Override
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.patterns.ElementPattern;
import com.intellij.patterns.ElementPatternCondition;
import com.intellij.patterns.InitialPatternCondition;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
import com.intellij.util.ProcessingContext;
import com.intellij.util.ReflectionCache;
@@ -88,7 +89,7 @@ public class PatternCompilerImpl<T> implements PatternCompiler<T> {
for (int i = 0, argsLength = args.length; i < argsLength; i++) {
args[i] = args[i] instanceof String ? myStringInterner.intern((String)args[i]) : args[i];
}
return new Node((Node)frame.target, myStringInterner.intern(frame.methodName), args);
return new Node((Node)frame.target, myStringInterner.intern(frame.methodName), args.length == 0 ? ArrayUtil.EMPTY_OBJECT_ARRAY : args);
}
});
return new LazyPresentablePattern(node);
@@ -384,12 +384,12 @@ public class PsiAdapter {
// is it public static void main(String[] args)
for (PsiMethod method : methods) {
// must be public
if (!method.hasModifierProperty("public")) {
if (!method.hasModifierProperty(PsiModifier.PUBLIC)) {
continue;
}
// must be static
if (!method.hasModifierProperty("static")) {
if (!method.hasModifierProperty(PsiModifier.STATIC)) {
continue;
}
@@ -566,12 +566,12 @@ public class PsiAdapter {
// is it public boolean equals(Object o)
for (PsiMethod method : methods) {
// must be public
if (!method.hasModifierProperty("public")) {
if (!method.hasModifierProperty(PsiModifier.PUBLIC)) {
continue;
}
// must not be static
if (method.hasModifierProperty("static")) {
if (method.hasModifierProperty(PsiModifier.STATIC)) {
continue;
}
@@ -613,12 +613,12 @@ public class PsiAdapter {
// is it public int hashCode()
for (PsiMethod method : methods) {
// must be public
if (!method.hasModifierProperty("public")) {
if (!method.hasModifierProperty(PsiModifier.PUBLIC)) {
continue;
}
// must not be static
if (method.hasModifierProperty("static")) {
if (method.hasModifierProperty(PsiModifier.STATIC)) {
continue;
}
@@ -109,7 +109,7 @@ public abstract class CreateClassActionBase implements IntentionAction {
if (contextElement != null &&
!JavaPsiFacade.getInstance(manager.getProject()).getResolveHelper().isAccessible(targetClass, contextElement, null) &&
modifiers != null) {
modifiers.setModifierProperty(PsiKeyword.PUBLIC, true);
modifiers.setModifierProperty(PsiModifier.PUBLIC, true);
}
return targetClass;
}
@@ -17,7 +17,6 @@
package org.jetbrains.plugins.groovy.lang.psi.impl.toplevel.packaging;
import com.intellij.lang.ASTNode;
import com.intellij.psi.Modifier;
import com.intellij.psi.PsiModifierList;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -66,7 +65,7 @@ public class GrPackageDefinitionImpl extends GroovyPsiElementImpl implements GrP
}
@Override
public boolean hasModifierProperty(@Modifier @NonNls @NotNull String name) {
public boolean hasModifierProperty(@NonNls @NotNull String name) {
final PsiModifierList list = getModifierList();
return list != null && list.hasExplicitModifier(name);
}
@@ -52,7 +52,7 @@ import static org.jetbrains.plugins.groovy.refactoring.convertToJava.GenerationU
* @author Maxim.Medvedev
*/
public class StubGenerator implements ClassItemGenerator {
public static final String[] STUB_MODIFIERS = new String[]{
public static final String[] STUB_MODIFIERS = {
PsiModifier.PUBLIC,
PsiModifier.PROTECTED,
PsiModifier.PRIVATE,
@@ -118,7 +118,7 @@ public class GrDynamicMethodImpl extends LightElement implements GrMethod {
return myMethod.getModifierList();
}
public boolean hasModifierProperty(@Modifier @NonNls @NotNull String name) {
public boolean hasModifierProperty(@NonNls @NotNull String name) {
return myMethod.hasModifierProperty(name);
}
@@ -107,7 +107,7 @@ public class GrDynamicPropertyImpl extends LightElement implements GrField {
return myField.getTypeElement();
}
public boolean hasModifierProperty(@Modifier @NonNls @NotNull String name) {
public boolean hasModifierProperty(@NonNls @NotNull String name) {
return myField.hasModifierProperty(name);
}
@@ -169,13 +169,13 @@ public abstract class TestColumnInfo extends ColumnInfo implements Comparator {
}
private static class CountDefectsRenderer extends JPanel implements TableCellRenderer {
private static final SimpleTextAttributes RUNNING_COLOR = new SimpleTextAttributes(Font.PLAIN, Color.BLACK);
private static final SimpleTextAttributes DEFECT_ATTRIBUTE = new SimpleTextAttributes(Font.BOLD, Color.RED);
private static final SimpleTextAttributes RUNNING_COLOR = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, Color.BLACK);
private static final SimpleTextAttributes DEFECT_ATTRIBUTE = new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, Color.RED);
private final SimpleColoredRenderer myCounters = new SimpleColoredRenderer();
private final SimpleColoredRenderer myProgressIndicator = new SimpleColoredRenderer();
private final TableCellState myCellState = new TableCellState();
private static final SimpleTextAttributes TERMINATED_ATTRIBUTE = new SimpleTextAttributes(Font.BOLD, Color.ORANGE);
private static final SimpleTextAttributes TERMINATED_ATTRIBUTE = new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, Color.ORANGE);
public CountDefectsRenderer() {
super(new BorderLayout());
@@ -27,7 +27,6 @@ import com.intellij.ui.SimpleTextAttributes;
import com.intellij.util.containers.HashMap;
import javax.swing.*;
import java.awt.*;
import java.util.Map;
class TestRenderer {
@@ -42,7 +41,7 @@ class TestRenderer {
}
private static SimpleTextAttributes getSpecialAttributes() {
return new SimpleTextAttributes(Font.BOLD, TestsUIUtil.PASSED_COLOR);
return new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, TestsUIUtil.PASSED_COLOR);
}
static {
@@ -18,15 +18,18 @@ package com.theoryinpractice.testng.configuration.browser;
import com.intellij.ide.structureView.impl.StructureNodeRenderer;
import com.intellij.openapi.ui.DialogBuilder;
import com.intellij.openapi.util.Condition;
import com.intellij.psi.*;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiSubstitutor;
import com.intellij.psi.util.PsiFormatUtil;
import com.intellij.psi.util.PsiFormatUtilBase;
import com.intellij.ui.*;
import com.intellij.ui.components.JBList;
import com.theoryinpractice.testng.util.TestNGUtil;
import java.awt.BorderLayout;
import java.util.Comparator;
import javax.swing.*;
import java.awt.*;
import java.util.Comparator;
public class MethodList extends JPanel
{
@@ -64,7 +67,7 @@ public class MethodList extends JPanel
protected void customizeCellRenderer(JList jlist, Object obj, int i, boolean flag, boolean flag1)
{
PsiMethod psimethod = (PsiMethod)obj;
append(PsiFormatUtil.formatMethod(psimethod, PsiSubstitutor.EMPTY, 1, 0), StructureNodeRenderer.applyDeprecation(psimethod, SimpleTextAttributes.REGULAR_ATTRIBUTES));
append(PsiFormatUtil.formatMethod(psimethod, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME, 0), StructureNodeRenderer.applyDeprecation(psimethod, SimpleTextAttributes.REGULAR_ATTRIBUTES));
PsiClass psiclass1 = psimethod.getContainingClass();
if(!MethodList.this.psiClass.equals(psiclass1)) {
append(" (" + psiclass1.getQualifiedName() + ')', StructureNodeRenderer.applyDeprecation(psiclass1, SimpleTextAttributes.GRAY_ATTRIBUTES));