This commit is contained in:
Alexey Kudravtsev
2014-06-03 13:05:00 +04:00
parent c1810c18f5
commit 53723716f4
479 changed files with 3068 additions and 513 deletions
@@ -57,6 +57,7 @@ import java.util.*;
public class NavigationGutterIconBuilder<T> {
@NonNls private static final String PATTERN = "&nbsp;&nbsp;&nbsp;&nbsp;{0}";
private static final NotNullFunction<PsiElement,Collection<? extends PsiElement>> DEFAULT_PSI_CONVERTOR = new NotNullFunction<PsiElement, Collection<? extends PsiElement>>() {
@Override
@NotNull
public Collection<? extends PsiElement> fun(final PsiElement element) {
return ContainerUtil.createMaybeSingletonList(element);
@@ -77,6 +78,7 @@ public class NavigationGutterIconBuilder<T> {
private NullableFunction<T,String> myNamer = ElementPresentationManager.namer();
private final NotNullFunction<T, Collection<? extends GotoRelatedItem>> myGotoRelatedItemProvider;
public static final NotNullFunction<DomElement,Collection<? extends PsiElement>> DEFAULT_DOM_CONVERTOR = new NotNullFunction<DomElement, Collection<? extends PsiElement>>() {
@Override
@NotNull
public Collection<? extends PsiElement> fun(final DomElement o) {
return ContainerUtil.createMaybeSingletonList(o.getXmlElement());
@@ -295,6 +297,7 @@ public class NavigationGutterIconBuilder<T> {
}
return new NotNullLazyValue<List<SmartPsiElementPointer>>() {
@Override
@NotNull
public List<SmartPsiElementPointer> compute() {
return calcPsiTargets(project, targets.create(), converter);
@@ -359,16 +362,19 @@ public class NavigationGutterIconBuilder<T> {
return !myEmpty;
}
@Override
@NotNull
public Icon getIcon() {
return myIcon;
}
@Override
@Nullable
public String getTooltipText() {
return myTooltipText;
}
@Override
public Alignment getAlignment() {
return myAlignment;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,12 +58,14 @@ public abstract class NavigationGutterIconRenderer extends GutterIconRenderer im
myPointers = pointers;
}
@Override
public boolean isNavigateAction() {
return true;
}
public List<PsiElement> getTargetElements() {
return ContainerUtil.mapNotNull(myPointers.getValue(), new NullableFunction<SmartPsiElementPointer, PsiElement>() {
@Override
public PsiElement fun(final SmartPsiElementPointer smartPsiElementPointer) {
return smartPsiElementPointer.getElement();
}
@@ -91,15 +93,18 @@ public abstract class NavigationGutterIconRenderer extends GutterIconRenderer im
return result;
}
@Override
@Nullable
public AnAction getClickAction() {
return new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
navigate(e == null ? null : (MouseEvent)e.getInputEvent(), null);
}
};
}
@Override
public void navigate(@Nullable final MouseEvent event, @Nullable final PsiElement elt) {
final List<PsiElement> list = getTargetElements();
if (list.isEmpty()) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@ import org.jetbrains.annotations.Nullable;
*/
public abstract class AbstractDomDeclarationSearcher extends PomDeclarationSearcher {
@Override
public void findDeclarationsAt(@NotNull PsiElement psiElement, int offsetInElement, Consumer<PomTarget> consumer) {
if (!(psiElement instanceof XmlToken)) return;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,14 +29,17 @@ import java.util.List;
*/
public class DomDocumentationProvider implements DocumentationProvider {
@Override
public String getQuickNavigateInfo(final PsiElement element, PsiElement originalElement) {
return null;
}
@Override
public List<String> getUrlFor(final PsiElement element, final PsiElement originalElement) {
return null;
}
@Override
public String generateDoc(PsiElement element, final PsiElement originalElement) {
if (element instanceof PomTargetPsiElement) {
PomTarget target = ((PomTargetPsiElement)element).getTarget();
@@ -56,10 +59,12 @@ public class DomDocumentationProvider implements DocumentationProvider {
return ElementPresentationManager.getDocumentationForElement(domElement);
}
@Override
public PsiElement getDocumentationElementForLookupItem(final PsiManager psiManager, final Object object, final PsiElement element) {
return null;
}
@Override
public PsiElement getDocumentationElementForLink(final PsiManager psiManager, final String link, final PsiElement context) {
return null;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@ import java.util.Set;
* @author Gregory.Shrago
*/
public class DomNameSuggestionProvider implements NameSuggestionProvider {
@Override
public SuggestedNameInfo getSuggestedNames(final PsiElement element, final PsiElement nameSuggestionContext, final Set<String> result) {
if (element instanceof PsiMetaOwner) {
final PsiMetaData psiMetaData = ((PsiMetaOwner)element).getMetaData();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@ import org.jetbrains.annotations.Nullable;
* @author Gregory.Shrago
*/
public class DomUsageTypeProvider implements UsageTypeProvider {
@Override
@Nullable
public UsageType getUsageType(PsiElement element) {
final PsiFile psiFile = element.getContainingFile();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import java.util.List;
*/
public class ElementPresentationManagerImpl extends ElementPresentationManager {
@Override
@NotNull
public <T> Object[] createVariants(Collection<T> elements, Function<T, String> namer, int iconFlags) {
List<Object> result = new ArrayList<Object>(elements.size());
@@ -43,6 +44,7 @@ public class ElementPresentationManagerImpl extends ElementPresentationManager {
return result.toArray();
}
@Override
public Object createVariant(final Object variant, final String name, final PsiElement psiElement) {
final LookupElementBuilder builder;
if (psiElement != null) {
@@ -34,6 +34,7 @@ import java.util.HashSet;
*/
public class EnumConverter<T extends Enum> extends ResolvingConverter<T>{
private static final ConcurrentFactoryMap<Class,EnumConverter> ourCache = new ConcurrentFactoryMap<Class, EnumConverter>() {
@Override
@NotNull
protected EnumConverter create(final Class key) {
return new EnumConverter(key);
@@ -53,18 +54,22 @@ public class EnumConverter<T extends Enum> extends ResolvingConverter<T>{
return NamedEnumUtil.getEnumValueByElement(anEnum);
}
@Override
public final T fromString(final String s, final ConvertContext context) {
return s==null?null:(T)NamedEnumUtil.getEnumElementByValue((Class)myType, s);
}
@Override
public final String toString(final T t, final ConvertContext context) {
return t == null? null:getStringValue(t);
}
@Override
public String getErrorMessage(@Nullable final String s, final ConvertContext context) {
return CodeInsightBundle.message("error.unknown.enum.value.message", s);
}
@Override
@NotNull
public Collection<? extends T> getVariants(final ConvertContext context) {
final XmlElement element = context.getXmlElement();
@@ -45,6 +45,7 @@ public class ModelMergerImpl implements ModelMerger {
private static final Class<MergedObject> MERGED_OBJECT_CLASS = MergedObject.class;
private final ConcurrentFactoryMap<Method,List<Pair<InvocationStrategy,Class>>> myAcceptsCache = new ConcurrentFactoryMap<Method,List<Pair<InvocationStrategy,Class>>>() {
@Override
protected List<Pair<InvocationStrategy,Class>> create(final Method method) {
List<Pair<InvocationStrategy,Class>> result = new ArrayList<Pair<InvocationStrategy,Class>>();
for (int i = myInvocationStrategies.size() - 1; i >= 0; i--) {
@@ -59,10 +60,12 @@ public class ModelMergerImpl implements ModelMerger {
public ModelMergerImpl() {
addInvocationStrategy(Object.class, new InvocationStrategy<Object>() {
@Override
public boolean accepts(final Method method) {
return true;
}
@Override
public Object invokeMethod(final JavaMethod javaMethod, final Object proxy, final Object[] args, final List<Object> implementations)
throws IllegalAccessException, InvocationTargetException {
final Method method = javaMethod.getMethod();
@@ -72,10 +75,12 @@ public class ModelMergerImpl implements ModelMerger {
});
addInvocationStrategy(Object.class, new InvocationStrategy<Object>() {
@Override
public boolean accepts(final Method method) {
return Collection.class.isAssignableFrom(method.getReturnType());
}
@Override
public Object invokeMethod(final JavaMethod method, final Object proxy, final Object[] args, final List<Object> implementations)
throws IllegalAccessException, InvocationTargetException {
@@ -87,10 +92,12 @@ public class ModelMergerImpl implements ModelMerger {
addInvocationStrategy(Object.class, new InvocationStrategy<Object>() {
@Override
public boolean accepts(final Method method) {
return Object.class.equals(method.getDeclaringClass());
}
@Override
public Object invokeMethod(final JavaMethod method, final Object proxy, final Object[] args, final List<Object> implementations) {
@NonNls String methodName = method.getName();
if ("toString".equals(methodName)) {
@@ -114,10 +121,12 @@ public class ModelMergerImpl implements ModelMerger {
});
addInvocationStrategy(Object.class, new InvocationStrategy<Object>() {
@Override
public boolean accepts(final Method method) {
return "isValid".equals(method.getName());
}
@Override
public Object invokeMethod(final JavaMethod method, final Object proxy, final Object[] args, final List<Object> implementations)
throws IllegalAccessException, InvocationTargetException {
for (final Object implementation : implementations) {
@@ -130,10 +139,12 @@ public class ModelMergerImpl implements ModelMerger {
});
addInvocationStrategy(Object.class, new InvocationStrategy<Object>() {
@Override
public boolean accepts(final Method method) {
return void.class.equals(method.getReturnType());
}
@Override
public Object invokeMethod(final JavaMethod method, final Object proxy, final Object[] args, final List<Object> implementations)
throws IllegalAccessException, InvocationTargetException {
for (final Object t : implementations) {
@@ -144,10 +155,12 @@ public class ModelMergerImpl implements ModelMerger {
});
addInvocationStrategy(Object.class, new InvocationStrategy<Object>() {
@Override
public boolean accepts(final Method method) {
return MERGED_OBJECT_CLASS.equals(method.getDeclaringClass());
}
@Override
public Object invokeMethod(final JavaMethod method, final Object proxy, final Object[] args, final List<Object> implementations)
throws IllegalAccessException, InvocationTargetException {
assert "getImplementations".equals(method.getName());
@@ -156,10 +169,12 @@ public class ModelMergerImpl implements ModelMerger {
});
addInvocationStrategy(DomElement.class, new InvocationStrategy<DomElement>() {
@Override
public boolean accepts(final Method method) {
return DomInvocationHandler.ACCEPT_METHOD.equals(method);
}
@Override
public Object invokeMethod(final JavaMethod method, final DomElement proxy, final Object[] args, final List<DomElement> implementations)
throws IllegalAccessException, InvocationTargetException {
final DomElementVisitor visitor = (DomElementVisitor)args[0];
@@ -169,10 +184,12 @@ public class ModelMergerImpl implements ModelMerger {
});
addInvocationStrategy(DomElement.class, new InvocationStrategy<DomElement>() {
@Override
public boolean accepts(final Method method) {
return DomInvocationHandler.ACCEPT_CHILDREN_METHOD.equals(method);
}
@Override
public Object invokeMethod(final JavaMethod method, final DomElement proxy, final Object[] args, final List<DomElement> implementations)
throws IllegalAccessException, InvocationTargetException {
final DomElementVisitor visitor = (DomElementVisitor)args[0];
@@ -191,21 +208,25 @@ public class ModelMergerImpl implements ModelMerger {
return javaMethod.getMethod().getAnnotation(Intersect.class) != null;
}
@Override
public final <T> void addInvocationStrategy(Class<T> aClass, InvocationStrategy<T> strategy) {
myInvocationStrategies.add(Pair.<InvocationStrategy,Class>create(strategy, aClass));
}
@Override
public final <T> void addMergingStrategy(Class<T> aClass, MergingStrategy<T> strategy) {
myMergingStrategies.add(strategy);
myMergingStrategyClasses.add(aClass);
}
@Override
public <T> T mergeModels(final Class<T> aClass, final T... implementations) {
if (implementations.length == 1) return implementations[0];
final MergingInvocationHandler<T> handler = new MergingInvocationHandler<T>(aClass, Arrays.asList(implementations));
return _mergeModels(aClass, handler, implementations);
}
@Override
public <T> T mergeModels(final Class<T> aClass, final Collection<? extends T> implementations) {
return (T)mergeModels((Class)aClass, implementations.toArray());
}
@@ -232,7 +253,7 @@ public class ModelMergerImpl implements ModelMerger {
}
private static final Map<Class<? extends Object>, Method> ourPrimaryKeyMethods = new HashMap<Class<? extends Object>, Method>();
private static final Map<Class<?>, Method> ourPrimaryKeyMethods = new HashMap<Class<?>, Method>();
public class MergingInvocationHandler<T> implements InvocationHandler {
private final Class<? super T> myClass;
@@ -262,6 +283,7 @@ public class ModelMergerImpl implements ModelMerger {
throw new AssertionError("impossible");
}
@Override
public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable {
try {
return findStrategy(proxy, method).invokeMethod(getJavaMethod(method), proxy, args, myImplementations);
@@ -300,7 +322,7 @@ public class ModelMergerImpl implements ModelMerger {
}
@Nullable
private static Method getPrimaryKeyMethod(final Class<? extends Object> aClass) {
private static Method getPrimaryKeyMethod(final Class<?> aClass) {
Method method = ourPrimaryKeyMethods.get(aClass);
if (method == null) {
if (ourPrimaryKeyMethods.containsKey(aClass)) return null;
@@ -332,6 +354,7 @@ public class ModelMergerImpl implements ModelMerger {
if (returnType.isInterface()) {
final List<Object> orderedPrimaryKeys = new SmartList<Object>();
final FactoryMap<Object, List<Set<Object>>> map = new FactoryMap<Object, List<Set<Object>>>() {
@Override
@NotNull
protected List<Set<Object>> create(final Object key) {
orderedPrimaryKeys.add(key);
@@ -339,6 +362,7 @@ public class ModelMergerImpl implements ModelMerger {
}
};
final FactoryMap<Object, int[]> counts = new FactoryMap<Object, int[]>() {
@Override
@NotNull
protected int[] create(final Object key) {
return new int[implementations.size()];
@@ -402,7 +426,7 @@ public class ModelMergerImpl implements ModelMerger {
final int index,
final List<Object> results,
final boolean singleValuedInvocation,
final boolean intersect) throws IllegalAccessException, InvocationTargetException {
final boolean intersect) {
final Object primaryKey = getPrimaryKey(o, singleValuedInvocation);
if (primaryKey != null || singleValuedInvocation) {
final List<Set<Object>> list = map.get(primaryKey);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,6 +47,7 @@ public class DomCollectionProblemDescriptorImpl extends DomElementProblemDescrip
return super.toString() + "; " + myChildDescription;
}
@Override
public DomCollectionChildDescription getChildDescription() {
return myChildDescription;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,11 +49,13 @@ public class DomElementAnnotationHolderImpl extends SmartList<DomElementProblemD
return myOnTheFly;
}
@Override
@NotNull
public DomElementProblemDescriptor createProblem(@NotNull DomElement domElement, @Nullable String message, LocalQuickFix... fixes) {
return createProblem(domElement, HighlightSeverity.ERROR, message, fixes);
}
@Override
@NotNull
public DomElementProblemDescriptor createProblem(@NotNull DomElement domElement,
DomCollectionChildDescription childDescription,
@@ -61,11 +63,13 @@ public class DomElementAnnotationHolderImpl extends SmartList<DomElementProblemD
return addProblem(new DomCollectionProblemDescriptorImpl(domElement, message, HighlightSeverity.ERROR, childDescription));
}
@Override
@NotNull
public final DomElementProblemDescriptor createProblem(@NotNull DomElement domElement, HighlightSeverity highlightType, String message) {
return createProblem(domElement, highlightType, message, LocalQuickFix.EMPTY_ARRAY);
}
@Override
public DomElementProblemDescriptor createProblem(@NotNull final DomElement domElement,
final HighlightSeverity highlightType,
final String message,
@@ -73,6 +77,7 @@ public class DomElementAnnotationHolderImpl extends SmartList<DomElementProblemD
return createProblem(domElement, highlightType, message, null, fixes);
}
@Override
public DomElementProblemDescriptor createProblem(@NotNull final DomElement domElement,
final HighlightSeverity highlightType,
final String message,
@@ -81,6 +86,7 @@ public class DomElementAnnotationHolderImpl extends SmartList<DomElementProblemD
return addProblem(new DomElementProblemDescriptorImpl(domElement, message, highlightType, textRange, null, fixes));
}
@Override
public DomElementProblemDescriptor createProblem(@NotNull DomElement domElement,
ProblemHighlightType highlightType,
String message,
@@ -89,11 +95,13 @@ public class DomElementAnnotationHolderImpl extends SmartList<DomElementProblemD
return addProblem(new DomElementProblemDescriptorImpl(domElement, message, HighlightSeverity.ERROR, textRange, highlightType, fixes));
}
@Override
@NotNull
public DomElementResolveProblemDescriptor createResolveProblem(@NotNull GenericDomValue element, @NotNull PsiReference reference) {
return addProblem(new DomElementResolveProblemDescriptorImpl(element, reference, getQuickFixes(element, reference)));
}
@Override
@NotNull
public Annotation createAnnotation(@NotNull DomElement element, HighlightSeverity severity, @Nullable String message) {
final XmlElement xmlElement = element.getXmlElement();
@@ -110,6 +118,7 @@ public class DomElementAnnotationHolderImpl extends SmartList<DomElementProblemD
return myAnnotations;
}
@Override
public int getSize() {
return size();
}
@@ -92,26 +92,31 @@ public class DomElementProblemDescriptorImpl implements DomElementProblemDescrip
myHighlightType = highlightType;
}
@Override
@NotNull
public DomElement getDomElement() {
return myDomElement;
}
@Override
@NotNull
public HighlightSeverity getHighlightSeverity() {
return mySeverity;
}
@Override
@NotNull
public String getDescriptionTemplate() {
return myMessage == null ? "" : myMessage;
}
@Override
@NotNull
public LocalQuickFix[] getFixes() {
return myFixes;
}
@Override
@NotNull
public final List<Annotation> getAnnotations() {
if (myAnnotations == null) {
@@ -120,6 +125,7 @@ public class DomElementProblemDescriptorImpl implements DomElementProblemDescrip
return myAnnotations;
}
@Override
public void highlightWholeElement() {
final PsiElement psiElement = getPsiElement();
if (psiElement instanceof XmlAttributeValue) {
@@ -230,6 +236,7 @@ public class DomElementProblemDescriptorImpl implements DomElementProblemDescrip
return null;
}
@Override
@Nullable
public ProblemHighlightType getHighlightType() {
return myHighlightType;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,16 +40,19 @@ class DomElementResolveProblemDescriptorImpl extends DomElementProblemDescriptor
myReference = reference;
}
@Override
@NotNull
public PsiReference getPsiReference() {
return myReference;
}
@Override
@NotNull
public GenericDomValue getDomElement() {
return (GenericDomValue)super.getDomElement();
}
@Override
@NotNull
protected Pair<TextRange, PsiElement> computeProblemRange() {
final PsiReference reference = myReference;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,12 +68,14 @@ public class DomElementsErrorPanel extends JPanel implements CommittablePanel, H
addUpdateRequest();
domManager.addDomEventListener(new DomChangeAdapter() {
@Override
protected void elementChanged(DomElement element) {
addUpdateRequest();
}
}, this);
}
@Override
public void updateHighlighting() {
updatePanel();
}
@@ -105,8 +107,10 @@ public class DomElementsErrorPanel extends JPanel implements CommittablePanel, H
private void addUpdateRequest() {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
myAlarm.addRequest(new Runnable() {
@Override
public void run() {
if (myProject.isOpen() && !myProject.isDisposed()) {
updatePanel();
@@ -117,23 +121,28 @@ public class DomElementsErrorPanel extends JPanel implements CommittablePanel, H
});
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
myErrorStripeRenderer.paint(this, g, new Rectangle(0, 0, getWidth(), getHeight()));
}
@Override
public void dispose() {
myAlarm.cancelAllRequests();
}
@Override
public JComponent getComponent() {
return this;
}
@Override
public void commit() {
}
@Override
public void reset() {
updatePanel();
}
@@ -149,6 +158,7 @@ public class DomElementsErrorPanel extends JPanel implements CommittablePanel, H
PsiDocumentManager.getInstance(xmlFile.getProject()).getDocument(xmlFile), xmlFile);
}
@Override
protected DaemonCodeAnalyzerStatus getDaemonCodeAnalyzerStatus(boolean fillErrorsCount, SeverityRegistrar severityRegistrar) {
final DaemonCodeAnalyzerStatus status = super.getDaemonCodeAnalyzerStatus(fillErrorsCount, severityRegistrar);
if (status != null && isInspectionCompleted()) {
@@ -179,6 +189,7 @@ public class DomElementsErrorPanel extends JPanel implements CommittablePanel, H
protected boolean isInspectionCompleted() {
return ContainerUtil.and(myDomElements, new Condition<DomElement>() {
@Override
public boolean value(final DomElement element) {
return myAnnotationsManager.getHighlightStatus(element) == DomHighlightStatus.INSPECTIONS_FINISHED;
}
@@ -187,6 +198,7 @@ public class DomElementsErrorPanel extends JPanel implements CommittablePanel, H
protected boolean isErrorAnalyzingFinished() {
return ContainerUtil.and(myDomElements, new Condition<DomElement>() {
@Override
public boolean value(final DomElement element) {
return myAnnotationsManager.getHighlightStatus(element).compareTo(DomHighlightStatus.ANNOTATORS_FINISHED) >= 0;
}
@@ -43,6 +43,7 @@ public class DomElementsHighlightingUtil {
public static ProblemDescriptor createProblemDescriptors(final InspectionManager manager, final DomElementProblemDescriptor problemDescriptor) {
final ProblemHighlightType type = getProblemHighlightType(problemDescriptor);
return createProblemDescriptors(problemDescriptor, new Function<Pair<TextRange, PsiElement>, ProblemDescriptor>() {
@Override
public ProblemDescriptor fun(final Pair<TextRange, PsiElement> s) {
return manager
.createProblemDescriptor(s.second, s.first, problemDescriptor.getDescriptionTemplate(), type, true, problemDescriptor.getFixes());
@@ -68,6 +69,7 @@ public class DomElementsHighlightingUtil {
public static Annotation createAnnotation(final DomElementProblemDescriptor problemDescriptor) {
return createProblemDescriptors(problemDescriptor, new Function<Pair<TextRange, PsiElement>, Annotation>() {
@Override
public Annotation fun(final Pair<TextRange, PsiElement> s) {
String text = problemDescriptor.getDescriptionTemplate();
if (StringUtil.isEmpty(text)) text = null;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,6 +45,7 @@ public class DomElementsProblemsHolderImpl implements DomElementsProblemsHolder
private final Function<DomElement, List<DomElementProblemDescriptor>> myDomProblemsGetter =
new Function<DomElement, List<DomElementProblemDescriptor>>() {
@Override
public List<DomElementProblemDescriptor> fun(final DomElement s) {
final Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> map = myCachedErrors.get(s);
return map != null ? ContainerUtil.concat(map.values()) : Collections.<DomElementProblemDescriptor>emptyList();
@@ -54,11 +55,13 @@ public class DomElementsProblemsHolderImpl implements DomElementsProblemsHolder
private final DomFileElement myElement;
private static final Factory<Map<Class<? extends DomElementsInspection>,List<DomElementProblemDescriptor>>> CONCURRENT_HASH_MAP_FACTORY = new Factory<Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>>>() {
@Override
public Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> create() {
return new ConcurrentHashMap<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>>();
}
};
private static final Factory<List<DomElementProblemDescriptor>> SMART_LIST_FACTORY = new Factory<List<DomElementProblemDescriptor>>() {
@Override
public List<DomElementProblemDescriptor> create() {
return new SmartList<DomElementProblemDescriptor>();
}
@@ -79,6 +82,7 @@ public class DomElementsProblemsHolderImpl implements DomElementsProblemsHolder
myPassedInspections.add(inspectionClass);
}
@Override
public final boolean isInspectionCompleted(@NotNull final DomElementsInspection inspection) {
return isInspectionCompleted(inspection.getClass());
}
@@ -99,16 +103,19 @@ public class DomElementsProblemsHolderImpl implements DomElementsProblemsHolder
myCachedChildrenErrors.clear();
}
@Override
@NotNull
public synchronized List<DomElementProblemDescriptor> getProblems(DomElement domElement) {
if (domElement == null || !domElement.isValid()) return Collections.emptyList();
return myDomProblemsGetter.fun(domElement);
}
@Override
public List<DomElementProblemDescriptor> getProblems(final DomElement domElement, boolean includeXmlProblems) {
return getProblems(domElement);
}
@Override
public List<DomElementProblemDescriptor> getProblems(final DomElement domElement,
final boolean includeXmlProblems,
final boolean withChildren) {
@@ -119,6 +126,7 @@ public class DomElementsProblemsHolderImpl implements DomElementsProblemsHolder
return ContainerUtil.concat(getProblemsMap(domElement).values());
}
@Override
public List<DomElementProblemDescriptor> getProblems(DomElement domElement,
final boolean includeXmlProblems,
final boolean withChildren,
@@ -126,8 +134,10 @@ public class DomElementsProblemsHolderImpl implements DomElementsProblemsHolder
return getProblems(domElement, withChildren, minSeverity);
}
@Override
public List<DomElementProblemDescriptor> getProblems(final DomElement domElement, final boolean withChildren, final HighlightSeverity minSeverity) {
return ContainerUtil.findAll(getProblems(domElement, true, withChildren), new Condition<DomElementProblemDescriptor>() {
@Override
public boolean value(final DomElementProblemDescriptor object) {
return SeverityRegistrar.getSeverityRegistrar(domElement.getManager().getProject()).compare(object.getHighlightSeverity(), minSeverity) >= 0;
}
@@ -151,6 +161,7 @@ public class DomElementsProblemsHolderImpl implements DomElementsProblemsHolder
mergeMaps(problems, myCachedErrors.get(domElement));
if (DomUtil.hasXml(domElement)) {
domElement.acceptChildren(new DomElementVisitor() {
@Override
public void visitDomElement(DomElement element) {
mergeMaps(problems, getProblemsMap(element));
}
@@ -169,10 +180,12 @@ public class DomElementsProblemsHolderImpl implements DomElementsProblemsHolder
}
}
@Override
public List<DomElementProblemDescriptor> getAllProblems() {
return getProblems(myElement, false, true);
}
@Override
public List<DomElementProblemDescriptor> getAllProblems(@NotNull DomElementsInspection inspection) {
if (!myElement.isValid()) {
return Collections.emptyList();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,6 +56,7 @@ public class DomHighlightingHelperImpl extends DomHighlightingHelper {
private final GenericValueReferenceProvider myProvider = new GenericValueReferenceProvider();
private final DomApplicationComponent myDomApplicationComponent = DomApplicationComponent.getInstance();
@Override
public void runAnnotators(DomElement element, DomElementAnnotationHolder holder, Class<? extends DomElement> rootClass) {
final DomElementsAnnotator annotator = myDomApplicationComponent.getAnnotator(rootClass);
if (annotator != null) {
@@ -63,6 +64,7 @@ public class DomHighlightingHelperImpl extends DomHighlightingHelper {
}
}
@Override
@NotNull
public List<DomElementProblemDescriptor> checkRequired(final DomElement element, final DomElementAnnotationHolder holder) {
final Required required = element.getAnnotation(Required.class);
@@ -105,6 +107,7 @@ public class DomHighlightingHelperImpl extends DomHighlightingHelper {
return Collections.emptyList();
}
@Override
@NotNull
public List<DomElementProblemDescriptor> checkResolveProblems(GenericDomValue element, final DomElementAnnotationHolder holder) {
if (StringUtil.isEmpty(element.getStringValue())) {
@@ -156,6 +159,7 @@ public class DomHighlightingHelperImpl extends DomHighlightingHelper {
converter instanceof ResolvingConverter && ((ResolvingConverter)converter).getAdditionalVariants(domReference.getConvertContext()).contains(element.getStringValue());
}
@Override
@NotNull
public List<DomElementProblemDescriptor> checkNameIdentity(DomElement element, final DomElementAnnotationHolder holder) {
final String elementName = ElementPresentationManager.getElementName(element);
@@ -243,33 +247,40 @@ public class DomHighlightingHelperImpl extends DomHighlightingHelper {
parentTag = _parentTag;
}
@Override
@NotNull
public String getName() {
return XmlBundle.message("insert.required.tag.fix", tagName);
}
@Override
@NotNull
public String getText() {
return getName();
}
@Override
@NotNull
public String getFamilyName() {
return getName();
}
@Override
public boolean isAvailable(@NotNull final Project project, final Editor editor, final PsiFile file) {
return true;
}
@Override
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException {
doFix();
}
@Override
public boolean startInWriteAction() {
return true;
}
@Override
public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
doFix();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,24 +29,28 @@ public class MockAnnotatingDomInspection<T extends DomElement> extends BasicDomE
super(domClass);
}
@Override
protected void checkDomElement(DomElement element, DomElementAnnotationHolder holder, DomHighlightingHelper helper) {
for (final Class aClass : getDomClasses()) {
helper.runAnnotators(element, holder, aClass);
}
}
@Override
@Nls
@NotNull
public String getGroupDisplayName() {
throw new UnsupportedOperationException("Method getGroupDisplayName is not yet implemented in " + getClass().getName());
}
@Override
@Nls
@NotNull
public String getDisplayName() {
throw new UnsupportedOperationException("Method getDisplayName is not yet implemented in " + getClass().getName());
}
@Override
@NonNls
@NotNull
public String getShortName() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,18 +29,21 @@ public class MockDomInspection<T extends DomElement> extends BasicDomElementsIns
super(domClass);
}
@Override
@Nls
@NotNull
public String getGroupDisplayName() {
throw new UnsupportedOperationException("Method getGroupDisplayName is not yet implemented in " + getClass().getName());
}
@Override
@Nls
@NotNull
public String getDisplayName() {
throw new UnsupportedOperationException("Method getDisplayName is not yet implemented in " + getClass().getName());
}
@Override
@NonNls
@NotNull
public String getShortName() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,6 @@ import com.intellij.openapi.util.NullableLazyValue;
import com.intellij.pom.references.PomService;
import com.intellij.psi.PsiElement;
import com.intellij.psi.SmartPsiElementPointer;
import com.intellij.util.xml.Stubbed;
import com.intellij.util.ReflectionUtil;
import com.intellij.util.xml.*;
import com.intellij.util.xml.reflect.AbstractDomChildrenDescription;
@@ -100,15 +99,18 @@ public abstract class AbstractDomChildDescriptionImpl implements AbstractDomChil
myUserMap = userMap;
}
@Override
@Nullable
public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) {
return myCustomAnnotations == null ? null : (T)myCustomAnnotations.get(annotationClass);
}
@Override
public <T> T getUserData(final Key<T> key) {
return myUserMap == null ? null : (T)myUserMap.get(key);
}
@Override
@NotNull
public final List<? extends DomElement> getStableValues(@NotNull final DomElement parent) {
final List<? extends DomElement> list = getValues(parent);
@@ -117,6 +119,7 @@ public abstract class AbstractDomChildDescriptionImpl implements AbstractDomChil
for (int i = 0; i < list.size(); i++) {
final int i1 = i;
result.add(domManager.createStableValue(new Factory<DomElement>() {
@Override
@Nullable
public DomElement create() {
if (!parent.isValid()) return null;
@@ -130,11 +133,13 @@ public abstract class AbstractDomChildDescriptionImpl implements AbstractDomChil
}
@Override
@NotNull
public final Type getType() {
return myType;
}
@Override
@NotNull
public DomNameStrategy getDomNameStrategy(@NotNull DomElement parent) {
final DomNameStrategy strategy = DomImplUtil.getDomNameStrategy(ReflectionUtil.getRawType(getType()), false);
@@ -166,6 +171,7 @@ public abstract class AbstractDomChildDescriptionImpl implements AbstractDomChil
return myPresentationTemplate.getValue();
}
@Override
@Nullable
public PsiElement getDeclaration(final Project project) {
DomElement domDeclaration = getDomDeclaration();
@@ -38,6 +38,7 @@ public class AddChildInvocation implements Invocation{
myType = type;
}
@Override
public Object invoke(final DomInvocationHandler<?, ?> handler, final Object[] args) throws Throwable {
return handler.addCollectionChild(myDescription, myClassGetter.fun(args), myIndexGetter.fun(args));
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@ class AddToCompositeCollectionInvocation implements Invocation {
myType = type;
}
@Override
public Object invoke(final DomInvocationHandler<?, ?> handler, final Object[] args) throws Throwable {
Set<XmlTag> set = ContainerUtil.newTroveSet();
for (final CollectionChildDescriptionImpl qname : myQnames) {
@@ -43,6 +43,7 @@ public class AttributeChildDescriptionImpl extends DomChildDescriptionImpl imple
myGetterMethod = null;
}
@Override
@NotNull
public DomNameStrategy getDomNameStrategy(@NotNull DomElement parent) {
final DomNameStrategy strategy = DomImplUtil.getDomNameStrategy(ReflectionUtil.getRawType(getType()), true);
@@ -50,6 +51,7 @@ public class AttributeChildDescriptionImpl extends DomChildDescriptionImpl imple
}
@Override
public final JavaMethod getGetterMethod() {
return myGetterMethod;
}
@@ -59,22 +61,26 @@ public class AttributeChildDescriptionImpl extends DomChildDescriptionImpl imple
return "Attribute:" + getXmlName();
}
@Override
@Nullable
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
final JavaMethod method = getGetterMethod();
return method == null ? super.getAnnotation(annotationClass) : method.getAnnotation(annotationClass);
}
@Override
@NotNull
public List<? extends DomElement> getValues(@NotNull DomElement parent) {
return Arrays.asList(getDomAttributeValue(parent));
}
@Override
@NotNull
public String getCommonPresentableName(@NotNull DomNameStrategy strategy) {
throw new UnsupportedOperationException("Method getCommonPresentableName is not yet implemented in " + getClass().getName());
}
@Override
public GenericAttributeValue getDomAttributeValue(DomElement parent) {
final DomInvocationHandler handler = DomManagerImpl.getDomInvocationHandler(parent);
if (handler != null) {
@@ -48,17 +48,21 @@ public class AttributeChildInvocationHandler extends DomInvocationHandler<Attrib
super(description.getType(), strategy, attributeName, description, manager, false, stub);
}
@Override
public void acceptChildren(DomElementVisitor visitor) {
}
@Override
protected final XmlTag setEmptyXmlTag() {
return ensureTagExists();
}
@Override
protected boolean isAttribute() {
return true;
}
@Override
protected XmlElement recomputeXmlElement(@NotNull final DomInvocationHandler parent) {
if (!parent.isValid()) return null;
@@ -80,6 +84,7 @@ public class AttributeChildInvocationHandler extends DomInvocationHandler<Attrib
return tag.getNamespace().equals(ns) ? null : ns;
}
@Override
public final XmlAttribute ensureXmlElementExists() {
XmlAttribute attribute = (XmlAttribute)getXmlElement();
if (attribute != null) return attribute;
@@ -103,19 +108,23 @@ public class AttributeChildInvocationHandler extends DomInvocationHandler<Attrib
}
}
@Override
public <T extends DomElement> T createStableCopy() {
final DomElement parentCopy = getParent().createStableCopy();
return getManager().createStableValue(new Factory<T>() {
@Override
public T create() {
return parentCopy.isValid() ? (T) getChildDescription().getValues(parentCopy).get(0) : null;
}
});
}
@Override
public final void undefineInternal() {
final XmlTag tag = getXmlTag();
if (tag != null) {
getManager().runChange(new Runnable() {
@Override
public void run() {
try {
setXmlElement(null);
@@ -130,18 +139,21 @@ public class AttributeChildInvocationHandler extends DomInvocationHandler<Attrib
}
}
@Override
@Nullable
public final XmlTag getXmlTag() {
final DomInvocationHandler handler = getParentHandler();
return handler == null ? null : handler.getXmlTag();
}
@Override
public final XmlTag ensureTagExists() {
final DomInvocationHandler parent = getParentHandler();
assert parent != null : "write operations should be performed on the DOM having a parent, your DOM may be not very fresh";
return parent.ensureTagExists();
}
@Override
@Nullable
protected String getValue() {
if (myStub != null) {
@@ -157,10 +169,12 @@ public class AttributeChildInvocationHandler extends DomInvocationHandler<Attrib
return null;
}
@Override
public void copyFrom(final DomElement other) {
setValue(((GenericAttributeValue) other).getStringValue());
}
@Override
protected void setValue(@Nullable final String value) {
final XmlTag tag = ensureTagExists();
final String attributeName = getXmlElementName();
@@ -170,6 +184,7 @@ public class AttributeChildInvocationHandler extends DomInvocationHandler<Attrib
if (Comparing.equal(oldValue, newValue, true)) return;
getManager().runChange(new Runnable() {
@Override
public void run() {
try {
XmlAttribute attribute = tag.setAttribute(attributeName, namespace, newValue);
@@ -41,6 +41,7 @@ import java.util.List;
public class CollectionChildDescriptionImpl extends DomChildDescriptionImpl implements DomCollectionChildDescription, AbstractCollectionChildDescription {
private final Collection<JavaMethod> myGetterMethods;
private final NotNullFunction<DomInvocationHandler, List<XmlTag>> myTagsGetter = new NotNullFunction<DomInvocationHandler, List<XmlTag>>() {
@Override
@NotNull
public List<XmlTag> fun(final DomInvocationHandler handler) {
XmlTag tag = handler.getXmlTag();
@@ -65,6 +66,7 @@ public class CollectionChildDescriptionImpl extends DomChildDescriptionImpl impl
return myTagsGetter;
}
@Override
public DomElement addValue(@NotNull DomElement element) {
assert element.getGenericInfo().getCollectionChildrenDescriptions().contains(this);
return addChild(element, getType(), Integer.MAX_VALUE);
@@ -81,24 +83,29 @@ public class CollectionChildDescriptionImpl extends DomChildDescriptionImpl impl
}
}
@Override
public DomElement addValue(@NotNull DomElement element, int index) {
return addChild(element, getType(), index);
}
@Override
public DomElement addValue(@NotNull DomElement parent, Type type) {
return addValue(parent, type, Integer.MAX_VALUE);
}
@Override
public final DomElement addValue(@NotNull DomElement parent, Type type, int index) {
return addChild(parent, type, index);
}
@Override
@Nullable
public final JavaMethod getGetterMethod() {
final Collection<JavaMethod> methods = myGetterMethods;
return methods.isEmpty() ? null : methods.iterator().next();
}
@Override
@NotNull
public List<? extends DomElement> getValues(@NotNull final DomElement element) {
final DomInvocationHandler handler = DomManagerImpl.getDomInvocationHandler(element);
@@ -109,6 +116,7 @@ public class CollectionChildDescriptionImpl extends DomChildDescriptionImpl impl
if (getterMethod == null) {
final Collection<DomElement> collection = ModelMergerUtil.getFilteredImplementations(element);
return ContainerUtil.concat(collection, new Function<DomElement, Collection<? extends DomElement>>() {
@Override
public Collection<? extends DomElement> fun(final DomElement domElement) {
final DomInvocationHandler handler = DomManagerImpl.getDomInvocationHandler(domElement);
assert handler != null : domElement;
@@ -119,12 +127,14 @@ public class CollectionChildDescriptionImpl extends DomChildDescriptionImpl impl
return (List<? extends DomElement>)getterMethod.invoke(element, ArrayUtil.EMPTY_OBJECT_ARRAY);
}
@Override
@NotNull
public String getCommonPresentableName(@NotNull DomNameStrategy strategy) {
String words = strategy.splitIntoWords(getXmlElementName());
return StringUtil.capitalizeWords(words.endsWith("es") ? words: StringUtil.pluralize(words), true);
}
@Override
@Nullable
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
final JavaMethod method = getGetterMethod();
@@ -137,10 +147,12 @@ public class CollectionChildDescriptionImpl extends DomChildDescriptionImpl impl
return elemType instanceof AnnotatedElement ? ((AnnotatedElement)elemType).getAnnotation(annotationClass) : super.getAnnotation(annotationClass);
}
@Override
public List<XmlTag> getSubTags(final DomInvocationHandler handler, final XmlTag[] subTags, final XmlFile file) {
return DomImplUtil.findSubTags(subTags, handler.createEvaluatedXmlName(getXmlName()), file);
}
@Override
public EvaluatedXmlName createEvaluatedXmlName(final DomInvocationHandler parent, final XmlTag childTag) {
return parent.createEvaluatedXmlName(getXmlName());
}
@@ -50,10 +50,12 @@ public class CollectionElementInvocationHandler extends DomInvocationHandler<Abs
}
@Override
protected Type narrowType(@NotNull final Type nominalType) {
return getStub() == null ? getManager().getTypeChooserManager().getTypeChooser(nominalType).chooseType(getXmlTag()) : nominalType;
}
@Override
protected final XmlTag setEmptyXmlTag() {
throw new UnsupportedOperationException("CollectionElementInvocationHandler.setXmlTag() shouldn't be called;" +
"\nparent=" + getParent() + ";\n" +
@@ -74,6 +76,7 @@ public class CollectionElementInvocationHandler extends DomInvocationHandler<Abs
return null;
}
@Override
public final void undefineInternal() {
final DomElement parent = getParent();
final XmlTag tag = getXmlTag();
@@ -85,6 +88,7 @@ public class CollectionElementInvocationHandler extends DomInvocationHandler<Abs
getManager().fireEvent(new DomEvent(parent, false));
}
@Override
public DomElement createPathStableCopy() {
final AbstractDomChildDescriptionImpl description = getChildDescription();
final DomElement parent = getParent();
@@ -92,6 +96,7 @@ public class CollectionElementInvocationHandler extends DomInvocationHandler<Abs
final DomElement parentCopy = parent.createStableCopy();
final int index = description.getValues(parent).indexOf(getProxy());
return getManager().createStableValue(new Factory<DomElement>() {
@Override
@Nullable
public DomElement create() {
if (parentCopy.isValid()) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@ public class ConvertAnnotationImpl implements Convert {
mySoft = soft;
}
@Override
public Class<? extends Annotation> annotationType() {
return Convert.class;
}
@@ -40,10 +41,12 @@ public class ConvertAnnotationImpl implements Convert {
return myConverter;
}
@Override
public Class<? extends Converter> value() {
return myConverter.getClass();
}
@Override
public boolean soft() {
return mySoft;
}
@@ -21,6 +21,7 @@ import com.intellij.util.xml.DomElement;
public class ConvertContextFactory {
public static ConvertContext createConvertContext(final DomElement element) {
return new ConvertContextImpl(DomManagerImpl.getDomInvocationHandler(element)) {
@Override
public DomElement getInvocationElement() {
return element;
}
@@ -35,15 +35,18 @@ public class ConvertContextImpl extends AbstractConvertContext {
this(DomManagerImpl.getDomInvocationHandler(element));
}
@Override
@NotNull
public DomElement getInvocationElement() {
return myHandler.getProxy();
}
@Override
public PsiManager getPsiManager() {
return myHandler.getFile().getManager();
}
@Override
public Module getModule() {
final DomElement domElement = getInvocationElement();
if (domElement.getManager().isMockElement(domElement)) {
@@ -52,10 +52,12 @@ class ConverterManagerImpl implements ConverterManager {
mySimpleConverters.put(PathReference.class, PathReferenceConverter.INSTANCE);
}
@Override
public void addConverter(Class clazz, Converter converter) {
mySimpleConverters.put(clazz, converter);
}
@Override
@NotNull
public final Converter getConverterInstance(final Class<? extends Converter> converterClass) {
Converter converter = getInstance(converterClass);
@@ -67,6 +69,7 @@ class ConverterManagerImpl implements ConverterManager {
return (T)myConverterInstances.get(clazz);
}
@Override
@Nullable
public final Converter getConverterByClass(final Class<?> convertingClass) {
final Converter converter = mySimpleConverters.get(convertingClass);
@@ -83,6 +86,7 @@ class ConverterManagerImpl implements ConverterManager {
return null;
}
@Override
public <T extends Converter> void registerConverterImplementation(Class<T> converterInterface, T converterImpl) {
myConverterInstances.put(converterInterface, converterImpl);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@ import java.util.List;
public class CustomDomChildrenDescriptionImpl extends AbstractDomChildDescriptionImpl implements CustomDomChildrenDescription, AbstractCollectionChildDescription {
@Nullable private final JavaMethod myGetter;
public static final NotNullFunction<DomInvocationHandler,List<XmlTag>> CUSTOM_TAGS_GETTER = new NotNullFunction<DomInvocationHandler, List<XmlTag>>() {
@Override
@NotNull
public List<XmlTag> fun(final DomInvocationHandler handler) {
return DomImplUtil.getCustomSubTags(handler, handler.getXmlTag().getSubTags(), handler.getFile());
@@ -75,6 +76,7 @@ public class CustomDomChildrenDescriptionImpl extends AbstractDomChildDescriptio
return parent.getCollectionChildren(this, CUSTOM_TAGS_GETTER);
}
@Override
@NotNull
public List<? extends DomElement> getValues(@NotNull final DomElement parent) {
final DomInvocationHandler handler = DomManagerImpl.getDomInvocationHandler(parent);
@@ -84,14 +86,17 @@ public class CustomDomChildrenDescriptionImpl extends AbstractDomChildDescriptio
return (List<? extends DomElement>)myGetter.invoke(parent, ArrayUtil.EMPTY_OBJECT_ARRAY);
}
@Override
public int compareTo(final AbstractDomChildDescriptionImpl o) {
return equals(o) ? 0 : -1;
}
@Override
public List<XmlTag> getSubTags(final DomInvocationHandler handler, final XmlTag[] subTags, final XmlFile file) {
return DomImplUtil.getCustomSubTags(handler, subTags, file);
}
@Override
public EvaluatedXmlName createEvaluatedXmlName(final DomInvocationHandler parent, final XmlTag childTag) {
return new DummyEvaluatedXmlName(childTag.getLocalName(), childTag.getNamespace());
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,6 +63,7 @@ public class DefaultDomAnnotator implements Annotator {
}
@Override
public void annotate(@NotNull final PsiElement psiElement, @NotNull AnnotationHolder holder) {
final List<Annotation> list = (List<Annotation>)holder;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import org.jetbrains.annotations.NotNull;
* @author peter
*/
public class DefaultDomTargetDescriptionProvider extends PomDescriptionProvider {
@Override
public String getElementDescription(@NotNull PomTarget element, @NotNull ElementDescriptionLocation location) {
if (!(element instanceof DomTarget)) return null;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ import javax.swing.*;
* @author peter
*/
public class DefaultDomTargetIconProvider extends DomIconProvider implements DumbAware {
@Override
public Icon getIcon(@NotNull DomElement element, int flags) {
Icon icon = element.getPresentation().getIcon();
return icon == null ? ElementPresentationManager.getIconOld(element) : icon;
@@ -140,9 +140,11 @@ public abstract class DomAnchorImpl<T extends DomElement> implements DomAnchor<T
return t == null ? null : t.getXmlElement();
}
@Override
@Nullable
public abstract T retrieveDomElement();
@Override
@NotNull
public abstract XmlFile getContainingFile();
@@ -184,6 +186,7 @@ public abstract class DomAnchorImpl<T extends DomElement> implements DomAnchor<T
return result;
}
@Override
public T retrieveDomElement() {
final DomElement parent = myParent.retrieveDomElement();
if (parent == null) return null;
@@ -203,6 +206,7 @@ public abstract class DomAnchorImpl<T extends DomElement> implements DomAnchor<T
return null;
}
@Override
@NotNull
public XmlFile getContainingFile() {
return myParent.getContainingFile();
@@ -243,6 +247,7 @@ public abstract class DomAnchorImpl<T extends DomElement> implements DomAnchor<T
return result;
}
@Override
public T retrieveDomElement() {
final DomElement parent = myParent.retrieveDomElement();
if (parent == null) return null;
@@ -254,6 +259,7 @@ public abstract class DomAnchorImpl<T extends DomElement> implements DomAnchor<T
return (T)list.get(myIndex);
}
@Override
@NotNull
public XmlFile getContainingFile() {
return myParent.getContainingFile();
@@ -290,11 +296,13 @@ public abstract class DomAnchorImpl<T extends DomElement> implements DomAnchor<T
return result;
}
@Override
public T retrieveDomElement() {
final DomFileElement<T> fileElement = DomManager.getDomManager(myFile.getProject()).getFileElement(myFile, myClass);
return fileElement == null ? null : fileElement.getRootElement();
}
@Override
@NotNull
public XmlFile getContainingFile() {
return myFile;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,6 +43,7 @@ import static com.intellij.util.containers.ContainerUtil.newArrayList;
*/
public class DomApplicationComponent {
private final FactoryMap<String,Set<DomFileDescription>> myRootTagName2FileDescription = new FactoryMap<String, Set<DomFileDescription>>() {
@Override
protected Set<DomFileDescription> create(final String key) {
return new THashSet<DomFileDescription>();
}
@@ -76,6 +77,7 @@ public class DomApplicationComponent {
});
private final ConcurrentFactoryMap<Class<? extends DomElementVisitor>, VisitorDescription> myVisitorDescriptions =
new ConcurrentFactoryMap<Class<? extends DomElementVisitor>, VisitorDescription>() {
@Override
@NotNull
protected VisitorDescription create(final Class<? extends DomElementVisitor> key) {
return new VisitorDescription(key);
@@ -33,20 +33,24 @@ public abstract class DomChildDescriptionImpl extends AbstractDomChildDescriptio
myTagName = tagName;
}
@Override
public String getName() {
return myTagName.getLocalName();
}
@Override
@NotNull
public String getXmlElementName() {
return myTagName.getLocalName();
}
@Override
@NotNull
public final XmlName getXmlName() {
return myTagName;
}
@Override
@NotNull
public String getCommonPresentableName(@NotNull DomElement parent) {
return getCommonPresentableName(getDomNameStrategy(parent));
@@ -69,6 +73,7 @@ public abstract class DomChildDescriptionImpl extends AbstractDomChildDescriptio
return result;
}
@Override
public int compareTo(final AbstractDomChildDescriptionImpl o) {
return o instanceof DomChildDescriptionImpl ? myTagName.compareTo(((DomChildDescriptionImpl)o).myTagName) : 1;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ import org.jetbrains.annotations.Nullable;
*/
public class DomDeclarationSearcher extends AbstractDomDeclarationSearcher {
@Override
@Nullable
protected DomTarget createDomTarget(DomElement parent, DomElement nameElement) {
final NameValue nameValue = nameElement.getAnnotation(NameValue.class);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@ import org.jetbrains.annotations.Nullable;
*/
public class DomDescriptorProvider implements XmlElementDescriptorProvider {
@Override
@Nullable
public XmlElementDescriptor getDescriptor(final XmlTag tag) {
Project project = tag.getProject();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,6 +43,7 @@ public class DomElementsNavigationManagerImpl extends DomElementsNavigationManag
myProviders.put(myTextEditorProvider.getProviderName(), myTextEditorProvider);
}
@Override
public Set<DomElementNavigationProvider> getDomElementsNavigateProviders(DomElement domElement) {
Set<DomElementNavigationProvider> result = new HashSet<DomElementNavigationProvider>();
@@ -52,20 +53,24 @@ public class DomElementsNavigationManagerImpl extends DomElementsNavigationManag
return result;
}
@Override
public DomElementNavigationProvider getDomElementsNavigateProvider(String providerName) {
return myProviders.get(providerName);
}
@Override
public void registerDomElementsNavigateProvider(DomElementNavigationProvider provider) {
myProviders.put(provider.getProviderName(), provider);
}
private class MyDomElementNavigateProvider extends DomElementNavigationProvider {
@Override
public String getProviderName() {
return DEFAULT_PROVIDER_NAME;
}
@Override
public void navigate(DomElement domElement, boolean requestFocus) {
if (!domElement.isValid()) return;
@@ -84,6 +89,7 @@ public class DomElementsNavigationManagerImpl extends DomElementsNavigationManag
FileEditorManagerEx.getInstanceEx(myProject).openTextEditor(fileDescriptor, requestFocus);
}
@Override
public boolean canNavigate(DomElement domElement) {
return domElement != null && domElement.isValid();
}
@@ -18,6 +18,7 @@ package com.intellij.util.xml.impl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.util.Factory;
import com.intellij.openapi.util.Key;
import com.intellij.psi.search.GlobalSearchScope;
@@ -47,74 +48,89 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
private static final Logger LOG = Logger.getInstance("#com.intellij.util.xml.impl.DomFileElementImpl");
private static final DomGenericInfo EMPTY_DOM_GENERIC_INFO = new DomGenericInfo() {
@Override
@Nullable
public XmlElement getNameElement(DomElement element) {
return null;
}
@Override
@Nullable
public GenericDomValue getNameDomElement(DomElement element) {
return null;
}
@Override
@NotNull
public List<? extends CustomDomChildrenDescription> getCustomNameChildrenDescription() {
return Collections.emptyList();
}
@Override
@Nullable
public String getElementName(DomElement element) {
return null;
}
@Override
@NotNull
public List<DomChildrenDescription> getChildrenDescriptions() {
return Collections.emptyList();
}
@Override
@NotNull
public List<DomFixedChildDescription> getFixedChildrenDescriptions() {
return Collections.emptyList();
}
@Override
@NotNull
public List<DomCollectionChildDescription> getCollectionChildrenDescriptions() {
return Collections.emptyList();
}
@Override
@NotNull
public List<DomAttributeChildDescription> getAttributeChildrenDescriptions() {
return Collections.emptyList();
}
@Override
public boolean isTagValueElement() {
return false;
}
@Override
@Nullable
public DomFixedChildDescription getFixedChildDescription(String tagName) {
return null;
}
@Override
@Nullable
public DomFixedChildDescription getFixedChildDescription(@NonNls String tagName, @NonNls String namespace) {
return null;
}
@Override
@Nullable
public DomCollectionChildDescription getCollectionChildDescription(String tagName) {
return null;
}
@Override
@Nullable
public DomCollectionChildDescription getCollectionChildDescription(@NonNls String tagName, @NonNls String namespace) {
return null;
}
@Override
public DomAttributeChildDescription getAttributeChildDescription(String attributeName) {
return null;
}
@Override
@Nullable
public DomAttributeChildDescription getAttributeChildDescription(@NonNls String attributeName, @NonNls String namespace) {
return null;
@@ -144,16 +160,19 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
stub == null ? null : stub.getRootTagStub());
}
@Override
@NotNull
public final XmlFile getFile() {
return myFile;
}
@Override
@NotNull
public XmlFile getOriginalFile() {
return (XmlFile)myFile.getOriginalFile();
}
@Override
@Nullable
public XmlTag getRootTag() {
if (!myFile.isValid()) {
@@ -195,65 +214,80 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
return result;
}
@Override
@NotNull
public final DomManagerImpl getManager() {
return myManager;
}
@Override
public final Type getDomElementType() {
return getClass();
}
@Override
@NotNull
public AbstractDomChildrenDescription getChildDescription() {
throw new UnsupportedOperationException("Method getChildDescription is not yet implemented in " + getClass().getName());
}
@Override
public DomNameStrategy getNameStrategy() {
return getRootHandler().getNameStrategy();
}
@Override
@NotNull
public ElementPresentation getPresentation() {
return new ElementPresentation() {
@Override
public @NonNls String getElementName() {
return "<ROOT>";
}
@Override
public @NonNls String getTypeName() {
return "<ROOT>";
}
@Override
public Icon getIcon() {
return null;
}
};
}
@Override
public GlobalSearchScope getResolveScope() {
return myFile.getResolveScope();
}
@Override
@Nullable
public <T extends DomElement> T getParentOfType(Class<T> requiredClass, boolean strict) {
return DomFileElement.class.isAssignableFrom(requiredClass) && !strict ? (T)this : null;
}
@Override
public Module getModule() {
return ModuleUtil.findModuleForPsiElement(getFile());
return ModuleUtilCore.findModuleForPsiElement(getFile());
}
@Override
public void copyFrom(DomElement other) {
throw new UnsupportedOperationException("Method copyFrom is not yet implemented in " + getClass().getName());
}
@Override
public final <T extends DomElement> T createMockCopy(final boolean physical) {
throw new UnsupportedOperationException("Method createMockCopy is not yet implemented in " + getClass().getName());
}
@Override
public final <T extends DomElement> T createStableCopy() {
return myManager.createStableValue(new Factory<T>() {
@Override
@Nullable
public T create() {
return (T)myManager.getFileElement(myFile);
@@ -261,17 +295,20 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
});
}
@Override
@NotNull
public String getXmlElementNamespace() {
return "";
}
@Override
@Nullable
@NonNls
public String getXmlElementNamespaceKey() {
return null;
}
@Override
@NotNull
public final T getRootElement() {
if (!isValid()) {
@@ -291,11 +328,13 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
return (T)getRootHandler().getProxy();
}
@Override
@NotNull
public Class<T> getRootElementClass() {
return myRootElementClass;
}
@Override
@NotNull
public DomFileDescription<T> getFileDescription() {
return myFileDescription;
@@ -310,10 +349,12 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
return "File " + myFile.toString();
}
@Override
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
return null;
}
@Override
public final XmlTag getXmlTag() {
return null;
}
@@ -323,26 +364,32 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
return (DomFileElementImpl<T>)this;
}
@Override
@Nullable
public DomElement getParent() {
return null;
}
@Override
public final XmlTag ensureTagExists() {
return null;
}
@Override
public final XmlElement getXmlElement() {
return getFile();
}
@Override
public final XmlElement ensureXmlElementExists() {
return ensureTagExists();
}
@Override
public void undefine() {
}
@Override
public final boolean isValid() {
return checkValidity() == null;
}
@@ -364,32 +411,39 @@ public class DomFileElementImpl<T extends DomElement> implements DomFileElement<
return null;
}
@Override
@NotNull
public final DomGenericInfo getGenericInfo() {
return EMPTY_DOM_GENERIC_INFO;
}
@Override
@NotNull
public String getXmlElementName() {
return "";
}
@Override
public void accept(final DomElementVisitor visitor) {
myManager.getApplicationComponent().getVisitorDescription(visitor.getClass()).acceptElement(visitor, this);
}
@Override
public void acceptChildren(DomElementVisitor visitor) {
getRootElement().accept(visitor);
}
@Override
public <T> T getUserData(@NotNull Key<T> key) {
return (T)myUserData.get(key);
}
@Override
public <T> void putUserData(@NotNull Key<T> key, T value) {
myUserData.put(key, value);
}
@Override
public final long getModificationCount() {
return myFile.getModificationStamp();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@ public abstract class DomGenericInfoEx implements DomGenericInfo {
@Nullable
public abstract Invocation createInvocation(final JavaMethod method);
@Override
@NotNull
public abstract List<AttributeChildDescriptionImpl> getAttributeChildrenDescriptions();
@@ -152,6 +152,7 @@ public class DomImplUtil {
}
return ContainerUtil.findAll(tags, new Condition<XmlTag>() {
@Override
public boolean value(XmlTag childTag) {
try {
return isNameSuitable(name, childTag.getLocalName(), childTag.getName(), childTag.getNamespace(), file);
@@ -176,6 +177,7 @@ public class DomImplUtil {
}
return ContainerUtil.findAll(tags, new Condition<XmlTag>() {
@Override
public boolean value(XmlTag childTag) {
return isNameSuitable(name, childTag, file);
}
@@ -272,6 +274,7 @@ public class DomImplUtil {
usedNames.add(description.getXmlName());
}
return ContainerUtil.findAll(subTags, new Condition<XmlTag>() {
@Override
public boolean value(final XmlTag tag) {
if (StringUtil.isEmpty(tag.getName())) return false;
@@ -18,6 +18,7 @@ package com.intellij.util.xml.impl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.NullableFactory;
import com.intellij.openapi.util.Pair;
@@ -108,6 +109,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
return nominalType;
}
@Override
@Nullable
public DomElement getParent() {
final DomInvocationHandler handler = getParentHandler();
@@ -131,6 +133,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
return myStub;
}
@Override
@NotNull
public final Type getDomElementType() {
return myType;
@@ -145,6 +148,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
protected void setValue(@Nullable final String value) {
final XmlTag tag = ensureTagExists();
myManager.runChange(new Runnable() {
@Override
public void run() {
setTagValue(tag, value);
}
@@ -152,6 +156,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
myManager.fireEvent(new DomEvent(getProxy(), false));
}
@Override
public void copyFrom(final DomElement other) {
if (other == getProxy()) return;
assert other.getDomElementType().equals(myType) : "Can't copy from " + other.getDomElementType() + " to " + myType;
@@ -162,6 +167,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
}
myManager.performAtomicChange(new Runnable() {
@Override
public void run() {
ensureXmlElementExists();
final DomGenericInfoEx genericInfo = getGenericInfo();
@@ -203,6 +209,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
}
}
@Override
public <T extends DomElement> T createStableCopy() {
XmlTag tag = getXmlTag();
if (tag != null && tag.isPhysical()) {
@@ -221,12 +228,14 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
throw new UnsupportedOperationException();
}
@Override
public final <T extends DomElement> T createMockCopy(final boolean physical) {
final T copy = myManager.createMockElement((Class<? extends T>)getRawType(), getProxy().getModule(), physical);
copy.copyFrom(getProxy());
return copy;
}
@Override
@NotNull
public String getXmlElementNamespace() {
final DomInvocationHandler parent = getParentHandler();
@@ -236,16 +245,19 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
return getXmlName().getNamespace(element, getFile());
}
@Override
@Nullable
public String getXmlElementNamespaceKey() {
return getXmlName().getXmlName().getNamespaceKey();
}
@Override
public final Module getModule() {
final Module module = ModuleUtil.findModuleForPsiElement(getFile());
return module != null ? module : DomUtil.getFile(this).getUserData(DomManagerImpl.MOCK_ELEMENT_MODULE);
final Module module = ModuleUtilCore.findModuleForPsiElement(getFile());
return module != null ? module : DomUtil.getFile(this).getUserData(DomManager.MOCK_ELEMENT_MODULE);
}
@Override
public XmlTag ensureTagExists() {
assertValid();
@@ -262,10 +274,12 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
return getXmlTag();
}
@Override
public XmlElement getXmlElement() {
return getParentStrategy().getXmlElement();
}
@Override
public boolean exists() {
return getParentStrategy().isPhysical();
}
@@ -275,6 +289,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
return myParentStrategy;
}
@Override
public XmlElement ensureXmlElementExists() {
return ensureTagExists();
}
@@ -295,6 +310,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
return getXmlTag().createChildTag(localName, tagName.getNamespace(element, getFile()), null, false);
}
@Override
public final boolean isValid() {
return checkValidity() == null;
}
@@ -342,6 +358,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
}
@Override
@NotNull
public final DomGenericInfoEx getGenericInfo() {
return myGenericInfo;
@@ -349,6 +366,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
protected abstract void undefineInternal();
@Override
public final void undefine() {
undefineInternal();
}
@@ -398,6 +416,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
}
}
@Override
@NotNull
public final String getXmlElementName() {
return myTagName.getXmlName().getLocalName();
@@ -408,11 +427,13 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
return myTagName;
}
@Override
public void accept(final DomElementVisitor visitor) {
ProgressManager.checkCanceled();
myManager.getApplicationComponent().getVisitorDescription(visitor.getClass()).acceptElement(visitor, getProxy());
}
@Override
@SuppressWarnings("ForLoopReplaceableByForEach")
public void acceptChildren(DomElementVisitor visitor) {
ProgressManager.checkCanceled();
@@ -463,10 +484,12 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
return converter;
}
@Override
public final T getChildDescription() {
return myChildDescription;
}
@Override
@Nullable
public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) {
final AnnotatedElement childDescription = getChildDescription();
@@ -529,6 +552,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
return getParentStrategy().getContainingFile(this);
}
@Override
@NotNull
public DomNameStrategy getNameStrategy() {
final Class<?> rawType = getRawType();
@@ -544,6 +568,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
return false;
}
@Override
@NotNull
public ElementPresentation getPresentation() {
ElementPresentationTemplate template = getChildDescription().getPresentationTemplate();
@@ -551,20 +576,24 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
return template.createPresentation(getProxy());
}
return new ElementPresentation() {
@Override
public String getElementName() {
return ElementPresentationManager.getElementName(getProxy());
}
@Override
public String getTypeName() {
return ElementPresentationManager.getTypeNameForObject(getProxy());
}
@Override
public Icon getIcon() {
return ElementPresentationManager.getIconOld(getProxy());
}
};
}
@Override
public final GlobalSearchScope getResolveScope() {
return DomUtil.getFile(this).getResolveScope();
}
@@ -576,6 +605,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
return (T)element;
}
@Override
public final <T extends DomElement> T getParentOfType(Class<T> requiredClass, boolean strict) {
return _getParentOfType(requiredClass, strict ? getParent() : getProxy());
}
@@ -643,6 +673,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
return new AttributeChildInvocationHandler(evaluatedXmlName, description, myManager, new VirtualDomParentStrategy(this), null);
}
@Override
@Nullable
public final Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
try {
@@ -700,6 +731,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
return ReflectionUtil.getRawType(myType);
}
@Override
@Nullable
public XmlTag getXmlTag() {
return (XmlTag) getXmlElement();
@@ -743,6 +775,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
myGenericInfo = dynamic ? new DynamicGenericInfo(this, staticInfo) : staticInfo;
}
@Override
@NotNull
public final DomManagerImpl getManager() {
return myManager;
@@ -855,6 +888,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
myHandlerClass = aClass;
}
@Override
public T create() {
final XmlTag tag = myPointer.getElement();
if (tag == null || !tag.isValid()) return null;
@@ -93,6 +93,7 @@ public final class DomManagerImpl extends DomManager {
final PomModel pomModel = PomManager.getModel(project);
pomModel.addModelListener(new PomModelListener() {
@Override
public void modelChanged(PomModelEvent event) {
if (myChanging) return;
@@ -107,6 +108,7 @@ public final class DomManagerImpl extends DomManager {
}
}
@Override
public boolean isAspectChangeInteresting(PomModelAspect aspect) {
return aspect instanceof XmlAspect;
}
@@ -115,6 +117,7 @@ public final class DomManagerImpl extends DomManager {
VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() {
private final List<DomEvent> myDeletionEvents = new SmartList<DomEvent>();
@Override
public void contentsChanged(@NotNull VirtualFileEvent event) {
if (!event.isFromSave()) {
fireEvents(calcDomChangeEvents(event.getFile()));
@@ -126,10 +129,12 @@ public final class DomManagerImpl extends DomManager {
fireEvents(calcDomChangeEvents(event.getFile()));
}
@Override
public void beforeFileDeletion(@NotNull final VirtualFileEvent event) {
myDeletionEvents.addAll(calcDomChangeEvents(event.getFile()));
}
@Override
public void fileDeleted(@NotNull VirtualFileEvent event) {
if (!myDeletionEvents.isEmpty()) {
fireEvents(myDeletionEvents);
@@ -137,6 +142,7 @@ public final class DomManagerImpl extends DomManager {
}
}
@Override
public void propertyChanged(@NotNull VirtualFilePropertyEvent event) {
final VirtualFile file = event.getFile();
if (!file.isDirectory() && VirtualFile.PROP_NAME.equals(event.getPropertyName())) {
@@ -193,18 +199,22 @@ public final class DomManagerImpl extends DomManager {
return (DomManagerImpl)DomManager.getDomManager(project);
}
@Override
public void addDomEventListener(DomEventListener listener, Disposable parentDisposable) {
myListeners.addListener(listener, parentDisposable);
}
@Override
public final ConverterManager getConverterManager() {
return ServiceManager.getService(ConverterManager.class);
}
@Override
public final void addPsiReferenceFactoryForClass(Class clazz, PsiReferenceFactory psiReferenceFactory) {
myGenericValueReferenceProvider.addReferenceProviderForClass(clazz, psiReferenceFactory);
}
@Override
public final ModelMerger createModelMerger() {
return new ModelMergerImpl();
}
@@ -221,6 +231,7 @@ public final class DomManagerImpl extends DomManager {
}
}
@Override
public final DomGenericInfo getGenericInfo(final Type type) {
return myApplicationComponent.getStaticGenericInfo(type);
}
@@ -262,10 +273,12 @@ public final class DomManagerImpl extends DomManager {
return myApplicationComponent;
}
@Override
public final Project getProject() {
return myProject;
}
@Override
@NotNull
public final <T extends DomElement> DomFileElementImpl<T> getFileElement(final XmlFile file, final Class<T> aClass, String rootTagName) {
//noinspection unchecked
@@ -319,6 +332,7 @@ public final class DomManagerImpl extends DomManager {
return oldChanging;
}
@Override
@Nullable
public final <T extends DomElement> DomFileElementImpl<T> getFileElement(XmlFile file) {
if (file == null) return null;
@@ -334,6 +348,7 @@ public final class DomManagerImpl extends DomManager {
return SoftReference.dereference(file.getUserData(CACHED_FILE_ELEMENT));
}
@Override
@Nullable
public final <T extends DomElement> DomFileElementImpl<T> getFileElement(XmlFile file, Class<T> domClass) {
final DomFileDescription description = getDomFileDescription(file);
@@ -343,6 +358,7 @@ public final class DomManagerImpl extends DomManager {
return null;
}
@Override
@Nullable
public final DomElement getDomElement(final XmlTag element) {
if (myChanging) return null;
@@ -351,6 +367,7 @@ public final class DomManagerImpl extends DomManager {
return handler != null ? handler.getProxy() : null;
}
@Override
@Nullable
public GenericAttributeValue getDomElement(final XmlAttribute attribute) {
if (myChanging) return null;
@@ -372,6 +389,7 @@ public final class DomManagerImpl extends DomManager {
return mySemService.getSemElement(DOM_HANDLER_KEY, tag);
}
@Override
@Nullable
public AbstractDomChildrenDescription findChildrenDescription(@NotNull final XmlTag tag, @NotNull final DomElement parent) {
return findChildrenDescription(tag, getDomInvocationHandler(parent));
@@ -397,6 +415,7 @@ public final class DomManagerImpl extends DomManager {
return null;
}
@Override
public final <T extends DomElement> T createMockElement(final Class<T> aClass, final Module module, final boolean physical) {
final XmlFile file = (XmlFile)PsiFileFactory.getInstance(myProject).createFileFromText("a.xml", StdFileTypes.XML, "", (long)0, physical);
file.putUserData(MOCK_ELEMENT_MODULE, module);
@@ -404,18 +423,22 @@ public final class DomManagerImpl extends DomManager {
return getFileElement(file, aClass, "I_sincerely_hope_that_nobody_will_have_such_a_root_tag_name").getRootElement();
}
@Override
public final boolean isMockElement(DomElement element) {
return DomUtil.getFile(element).getUserData(MOCK) != null;
}
@Override
public final <T extends DomElement> T createStableValue(final Factory<T> provider) {
return createStableValue(provider, new Condition<T>() {
@Override
public boolean value(T t) {
return t.isValid();
}
});
}
@Override
public final <T> T createStableValue(final Factory<T> provider, final Condition<T> validator) {
final T initial = provider.create();
assert initial != null;
@@ -433,6 +456,7 @@ public final class DomManagerImpl extends DomManager {
public final <T extends DomElement> void registerFileDescription(final DomFileDescription<T> description, Disposable parentDisposable) {
registerFileDescription(description);
Disposer.register(parentDisposable, new Disposable() {
@Override
public void dispose() {
getFileDescriptions(description.getRootTagName()).remove(description);
getAcceptingOtherRootTagNameDescriptions().remove(description);
@@ -440,28 +464,33 @@ public final class DomManagerImpl extends DomManager {
});
}
@Override
public final void registerFileDescription(final DomFileDescription description) {
mySemService.clearCache();
myApplicationComponent.registerFileDescription(description);
}
@Override
@NotNull
public final DomElement getResolvingScope(GenericDomValue element) {
final DomFileDescription<?> description = DomUtil.getFileElement(element).getFileDescription();
return description.getResolveScope(element);
}
@Override
@Nullable
public final DomElement getIdentityScope(DomElement element) {
final DomFileDescription description = DomUtil.getFileElement(element).getFileDescription();
return description.getIdentityScope(element);
}
@Override
public TypeChooserManager getTypeChooserManager() {
return myApplicationComponent.getTypeChooserManager();
}
@Override
public long getModificationCount() {
return myModificationCount + PsiManager.getInstance(myProject).getModificationTracker().getOutOfCodeBlockModificationCount();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@ public class DomMetaDataContributor implements MetaDataContributor {
@Override
public void contributeMetaData(MetaDataRegistrar registrar) {
registrar.registerMetaData(new ElementFilter() {
@Override
public boolean isAcceptable(Object element, PsiElement context) {
if (element instanceof XmlTag) {
final XmlTag tag = (XmlTag)element;
@@ -42,6 +43,7 @@ public class DomMetaDataContributor implements MetaDataContributor {
return false;
}
@Override
public boolean isClassAcceptable(Class hintClass) {
return XmlTag.class.isAssignableFrom(hintClass);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import com.intellij.patterns.XmlPatterns;
* @author peter
*/
public class DomReferenceContributor extends PsiReferenceContributor{
@Override
public void registerReferenceProviders(final PsiReferenceRegistrar registrar) {
GenericValueReferenceProvider provider = new GenericValueReferenceProvider();
@@ -48,11 +48,13 @@ public class DomRootInvocationHandler extends DomInvocationHandler<AbstractDomCh
@Nullable ElementStub stub
) {
super(aClass, strategy, tagName, new AbstractDomChildDescriptionImpl(aClass) {
@Override
@NotNull
public List<? extends DomElement> getValues(@NotNull final DomElement parent) {
throw new UnsupportedOperationException();
}
@Override
public int compareTo(final AbstractDomChildDescriptionImpl o) {
throw new UnsupportedOperationException();
}
@@ -60,6 +62,7 @@ public class DomRootInvocationHandler extends DomInvocationHandler<AbstractDomCh
myParent = fileElement;
}
@Override
public void undefineInternal() {
try {
final XmlTag tag = getXmlTag();
@@ -91,6 +94,7 @@ public class DomRootInvocationHandler extends DomInvocationHandler<AbstractDomCh
getXmlElement() != null;
}
@Override
@NotNull
public String getXmlElementNamespace() {
return getXmlName().getNamespace(getFile(), getFile());
@@ -111,23 +115,28 @@ public class DomRootInvocationHandler extends DomInvocationHandler<AbstractDomCh
return null;
}
@Override
@NotNull
public DomFileElementImpl getParent() {
return myParent;
}
@Override
public DomElement createPathStableCopy() {
final DomFileElement stableCopy = myParent.createStableCopy();
return getManager().createStableValue(new NullableFactory<DomElement>() {
@Override
public DomElement create() {
return stableCopy.isValid() ? stableCopy.getRootElement() : null;
}
});
}
@Override
protected XmlTag setEmptyXmlTag() {
final XmlTag[] result = new XmlTag[]{null};
getManager().runChange(new Runnable() {
@Override
public void run() {
try {
final String namespace = getXmlElementNamespace();
@@ -144,6 +153,7 @@ public class DomRootInvocationHandler extends DomInvocationHandler<AbstractDomCh
return result[0];
}
@Override
@NotNull
public final DomNameStrategy getNameStrategy() {
final Class<?> rawType = getRawType();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,8 +60,10 @@ public class DomSemContributor extends SemContributor {
mySemService = semService;
}
@Override
public void registerSemProviders(SemRegistrar registrar) {
registrar.registerSemElementProvider(DomManagerImpl.FILE_DESCRIPTION_KEY, xmlFile(), new NullableFunction<XmlFile, FileDescriptionCachedValueProvider>() {
@Override
public FileDescriptionCachedValueProvider fun(XmlFile xmlFile) {
ApplicationManager.getApplication().assertReadAccessAllowed();
return new FileDescriptionCachedValueProvider(DomManagerImpl.getDomManager(xmlFile.getProject()), xmlFile);
@@ -69,6 +71,7 @@ public class DomSemContributor extends SemContributor {
});
registrar.registerSemElementProvider(DomManagerImpl.DOM_HANDLER_KEY, xmlTag().withParent(psiElement(XmlElementType.XML_DOCUMENT).withParent(xmlFile())), new NullableFunction<XmlTag, DomInvocationHandler>() {
@Override
public DomInvocationHandler fun(XmlTag xmlTag) {
final FileDescriptionCachedValueProvider provider =
mySemService.getSemElement(DomManagerImpl.FILE_DESCRIPTION_KEY, xmlTag.getContainingFile());
@@ -86,6 +89,7 @@ public class DomSemContributor extends SemContributor {
final ElementPattern<XmlTag> nonRootTag = xmlTag().withParent(or(xmlTag(), xmlEntityRef().withParent(xmlTag())));
registrar.registerSemElementProvider(DomManagerImpl.DOM_INDEXED_HANDLER_KEY, nonRootTag, new NullableFunction<XmlTag, IndexedElementInvocationHandler>() {
@Override
public IndexedElementInvocationHandler fun(XmlTag tag) {
final XmlTag parentTag = PhysicalDomParentStrategy.getParentTag(tag);
assert parentTag != null;
@@ -129,6 +133,7 @@ public class DomSemContributor extends SemContributor {
});
registrar.registerSemElementProvider(DomManagerImpl.DOM_COLLECTION_HANDLER_KEY, nonRootTag, new NullableFunction<XmlTag, CollectionElementInvocationHandler>() {
@Override
public CollectionElementInvocationHandler fun(XmlTag tag) {
final XmlTag parentTag = PhysicalDomParentStrategy.getParentTag(tag);
assert parentTag != null;
@@ -156,6 +161,7 @@ public class DomSemContributor extends SemContributor {
registrar.registerSemElementProvider(DomManagerImpl.DOM_CUSTOM_HANDLER_KEY, nonRootTag, new NullableFunction<XmlTag, CollectionElementInvocationHandler>() {
private final RecursionGuard myGuard = RecursionManager.createGuard("customDomParent");
@Override
public CollectionElementInvocationHandler fun(XmlTag tag) {
if (StringUtil.isEmpty(tag.getName())) return null;
@@ -199,6 +205,7 @@ public class DomSemContributor extends SemContributor {
});
registrar.registerSemElementProvider(DomManagerImpl.DOM_ATTRIBUTE_HANDLER_KEY, xmlAttribute(), new NullableFunction<XmlAttribute, AttributeChildInvocationHandler>() {
@Override
public AttributeChildInvocationHandler fun(final XmlAttribute attribute) {
final XmlTag tag = PhysicalDomParentStrategy.getParentTag(attribute);
final DomInvocationHandler handler = getParentDom(tag);
@@ -207,6 +214,7 @@ public class DomSemContributor extends SemContributor {
final String localName = attribute.getLocalName();
final Ref<AttributeChildInvocationHandler> result = Ref.create(null);
handler.getGenericInfo().processAttributeChildrenDescriptions(new Processor<AttributeChildDescriptionImpl>() {
@Override
public boolean process(AttributeChildDescriptionImpl description) {
if (description.getXmlName().getLocalName().equals(localName)) {
final EvaluatedXmlName evaluatedXmlName = handler.createEvaluatedXmlName(description.getXmlName());
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,8 +56,10 @@ import java.util.List;
public class DomServiceImpl extends DomService {
private static final Key<CachedValue<XmlFileHeader>> ROOT_TAG_NS_KEY = Key.create("rootTag&ns");
private static final UserDataCache<CachedValue<XmlFileHeader>,XmlFile,Object> ourRootTagCache = new UserDataCache<CachedValue<XmlFileHeader>, XmlFile, Object>() {
@Override
protected CachedValue<XmlFileHeader> compute(final XmlFile file, final Object o) {
return CachedValuesManager.getManager(file.getProject()).createCachedValue(new CachedValueProvider<XmlFileHeader>() {
@Override
public Result<XmlFileHeader> compute() {
return new Result<XmlFileHeader>(calcXmlFileHeader(file), file);
}
@@ -128,6 +130,7 @@ public class DomServiceImpl extends DomService {
return XmlFileHeader.EMPTY;
}
@Override
public ModelMerger createModelMerger() {
return new ModelMergerImpl();
}
@@ -137,6 +140,7 @@ public class DomServiceImpl extends DomService {
return DomAnchorImpl.createAnchor(domElement);
}
@Override
@NotNull
public XmlFile getContainingFile(@NotNull DomElement domElement) {
if (domElement instanceof DomFileElement) {
@@ -145,21 +149,25 @@ public class DomServiceImpl extends DomService {
return DomManagerImpl.getNotNullHandler(domElement).getFile();
}
@Override
@NotNull
public EvaluatedXmlName getEvaluatedXmlName(@NotNull final DomElement element) {
return DomManagerImpl.getNotNullHandler(element).getXmlName();
}
@Override
@NotNull
public XmlFileHeader getXmlFileHeader(XmlFile file) {
return file.isValid() ? ourRootTagCache.get(ROOT_TAG_NS_KEY, file, null).getValue() : XmlFileHeader.EMPTY;
}
@Override
public Collection<VirtualFile> getDomFileCandidates(Class<? extends DomElement> description, Project project) {
return FileBasedIndex.getInstance().getContainingFiles(DomFileIndex.NAME, description.getName(), GlobalSearchScope.allScope(project));
}
@Override
public <T extends DomElement> List<DomFileElement<T>> getFileElements(final Class<T> clazz, final Project project, @Nullable final GlobalSearchScope scope) {
final Collection<VirtualFile> list = scope == null ? getDomFileCandidates(clazz, project) : getDomFileCandidates(clazz, project, scope);
final ArrayList<DomFileElement<T>> result = new ArrayList<DomFileElement<T>>(list.size());
@@ -177,6 +185,7 @@ public class DomServiceImpl extends DomService {
}
@Override
public StructureViewBuilder createSimpleStructureViewBuilder(final XmlFile file, final Function<DomElement, StructureViewMode> modeProvider) {
return new DomStructureViewBuilder(file, modeProvider);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,6 +40,7 @@ public class DomTemplateRunnerImpl extends DomTemplateRunner {
myProject = project;
}
@Override
public <T extends DomElement> void runTemplate(final T t, final String mappingId, final Editor editor) {
runTemplate(t, mappingId, editor, new HashMap<String, String>());
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -66,10 +66,12 @@ public class DynamicGenericInfo extends DomGenericInfoEx {
myCollections = staticGenericInfo.getCollections();
}
@Override
public Invocation createInvocation(final JavaMethod method) {
return myStaticGenericInfo.createInvocation(method);
}
@Override
public final boolean checkInitialized() {
if (myInitialized) return true;
myStaticGenericInfo.buildMethodMaps();
@@ -177,14 +179,17 @@ public class DynamicGenericInfo extends DomGenericInfoEx {
return registrar;
}
@Override
public XmlElement getNameElement(DomElement element) {
return myStaticGenericInfo.getNameElement(element);
}
@Override
public GenericDomValue getNameDomElement(DomElement element) {
return myStaticGenericInfo.getNameDomElement(element);
}
@Override
@NotNull
public List<? extends CustomDomChildrenDescription> getCustomNameChildrenDescription() {
checkInitialized();
@@ -192,10 +197,12 @@ public class DynamicGenericInfo extends DomGenericInfoEx {
return myStaticGenericInfo.getCustomNameChildrenDescription();
}
@Override
public String getElementName(DomElement element) {
return myStaticGenericInfo.getElementName(element);
}
@Override
@NotNull
public List<AbstractDomChildDescriptionImpl> getChildrenDescriptions() {
checkInitialized();
@@ -207,53 +214,63 @@ public class DynamicGenericInfo extends DomGenericInfoEx {
return list;
}
@Override
@NotNull
public final List<FixedChildDescriptionImpl> getFixedChildrenDescriptions() {
checkInitialized();
return myFixeds.getDescriptions();
}
@Override
@NotNull
public final List<CollectionChildDescriptionImpl> getCollectionChildrenDescriptions() {
checkInitialized();
return myCollections.getDescriptions();
}
@Override
public FixedChildDescriptionImpl getFixedChildDescription(String tagName) {
checkInitialized();
return myFixeds.findDescription(tagName);
}
@Override
public DomFixedChildDescription getFixedChildDescription(@NonNls String tagName, @NonNls String namespace) {
checkInitialized();
return myFixeds.getDescription(tagName, namespace);
}
@Override
public CollectionChildDescriptionImpl getCollectionChildDescription(String tagName) {
checkInitialized();
return myCollections.findDescription(tagName);
}
@Override
public DomCollectionChildDescription getCollectionChildDescription(@NonNls String tagName, @NonNls String namespace) {
checkInitialized();
return myCollections.getDescription(tagName, namespace);
}
@Override
public AttributeChildDescriptionImpl getAttributeChildDescription(String attributeName) {
checkInitialized();
return myAttributes.findDescription(attributeName);
}
@Override
public DomAttributeChildDescription getAttributeChildDescription(@NonNls String attributeName, @NonNls String namespace) {
checkInitialized();
return myAttributes.getDescription(attributeName, namespace);
}
@Override
public boolean isTagValueElement() {
return myStaticGenericInfo.isTagValueElement();
}
@Override
@NotNull
public List<AttributeChildDescriptionImpl> getAttributeChildrenDescriptions() {
checkInitialized();
@@ -264,6 +281,7 @@ public class DynamicGenericInfo extends DomGenericInfoEx {
public boolean processAttributeChildrenDescriptions(final Processor<AttributeChildDescriptionImpl> processor) {
final Set<AttributeChildDescriptionImpl> visited = new THashSet<AttributeChildDescriptionImpl>();
if (!myStaticGenericInfo.processAttributeChildrenDescriptions(new Processor<AttributeChildDescriptionImpl>() {
@Override
public boolean process(AttributeChildDescriptionImpl attributeChildDescription) {
visited.add(attributeChildDescription);
return processor.process(attributeChildDescription);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -202,6 +202,7 @@ class FileDescriptionCachedValueProvider<T extends DomElement> implements SemEle
private class MyCondition implements Condition<DomFileDescription> {
public Module module;
@Override
public boolean value(final DomFileDescription description) {
return description.isMyFile(myXmlFile, module);
}
@@ -48,6 +48,7 @@ public class FixedChildDescriptionImpl extends DomChildDescriptionImpl implement
myGetterMethods = getterMethods;
}
@Override
public JavaMethod getGetterMethod(int index) {
if (myGetterMethods.length == 0) return null;
@@ -55,6 +56,7 @@ public class FixedChildDescriptionImpl extends DomChildDescriptionImpl implement
return methods == null || methods.isEmpty() ? null : methods.iterator().next();
}
@Override
@Nullable
public <T extends Annotation> T getAnnotation(int index, Class<? extends T> annotationClass) {
final JavaMethod method = getGetterMethod(index);
@@ -72,10 +74,12 @@ public class FixedChildDescriptionImpl extends DomChildDescriptionImpl implement
return super.getAnnotation(annotationClass);
}
@Override
public int getCount() {
return myCount;
}
@Override
@NotNull
public List<? extends DomElement> getValues(@NotNull final DomElement element) {
final List<DomElement> result = new SmartList<DomElement>();
@@ -95,11 +99,13 @@ public class FixedChildDescriptionImpl extends DomChildDescriptionImpl implement
return result;
}
@Override
@NotNull
public String getCommonPresentableName(@NotNull DomNameStrategy strategy) {
return StringUtil.capitalizeWords(strategy.splitIntoWords(getXmlElementName()), true);
}
@Override
@Nullable
public final <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
return getAnnotation(0, annotationClass);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -76,6 +76,7 @@ public class GenericDomValueReference<T> extends PsiReferenceBase<XmlElement> im
return myGenericValue;
}
@Override
public boolean isSoft() {
return true;
}
@@ -106,6 +107,7 @@ public class GenericDomValueReference<T> extends PsiReferenceBase<XmlElement> im
return o != null ? getElement() : null;
}
@Override
public boolean isReferenceTo(final PsiElement element) {
final Converter<T> converter = getConverter();
if (converter instanceof ResolvingConverter) {
@@ -131,17 +133,20 @@ public class GenericDomValueReference<T> extends PsiReferenceBase<XmlElement> im
return WrappingConverter.getDeepestConverter(myGenericValue.getConverter(), myGenericValue);
}
@Override
@Nullable
public PsiElement resolve() {
final T value = myGenericValue.getValue();
return value == null ? null : resolveInner(value);
}
@Override
@NotNull
public String getCanonicalText() {
return StringUtil.notNullize(getStringValue());
}
@Override
@NotNull
public String getUnresolvedMessagePattern() {
final ConvertContext context = getConvertContext();
@@ -152,6 +157,7 @@ public class GenericDomValueReference<T> extends PsiReferenceBase<XmlElement> im
return ConvertContextFactory.createConvertContext(DomManagerImpl.getDomInvocationHandler(myGenericValue));
}
@Override
public PsiElement handleElementRename(final String newElementName) throws IncorrectOperationException {
final Converter<T> converter = getConverter();
if (converter instanceof ResolvingConverter) {
@@ -161,6 +167,7 @@ public class GenericDomValueReference<T> extends PsiReferenceBase<XmlElement> im
return super.handleElementRename(newElementName);
}
@Override
public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
final Converter<T> converter = getConverter();
if (converter instanceof ResolvingConverter) {
@@ -180,6 +187,7 @@ public class GenericDomValueReference<T> extends PsiReferenceBase<XmlElement> im
return null;
}
@Override
@NotNull
public Object[] getVariants() {
final Converter<T> converter = getConverter();
@@ -43,6 +43,7 @@ public class GenericValueReferenceProvider extends PsiReferenceProvider {
myProviders.put(clazz, provider);
}
@Override
@NotNull
public final PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull final ProcessingContext context) {
final DomManager domManager = DomManager.getDomManager(psiElement.getProject());
@@ -147,6 +148,7 @@ public class GenericValueReferenceProvider extends PsiReferenceProvider {
if (ReflectionUtil.isAssignable(Integer.class, clazz)) {
return new PsiReference[]{new GenericDomValueReference<Integer>((GenericDomValue<Integer>)domValue) {
@Override
@NotNull
public Object[] getVariants() {
return new Object[]{"0"};
@@ -25,6 +25,7 @@ public class GetAttributeChildInvocation implements Invocation {
myDescription = description;
}
@Override
public Object invoke(final DomInvocationHandler<?, ?> handler, final Object[] args) throws Throwable {
return handler.getAttributeChild(myDescription).getProxy();
}
@@ -25,6 +25,7 @@ public class GetCollectionChildInvocation implements Invocation {
myDescription = qname;
}
@Override
public Object invoke(final DomInvocationHandler<?, ?> handler, final Object[] args) throws Throwable {
return handler.getCollectionChildren(myDescription, myDescription.getTagsGetter());
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@ class GetCompositeCollectionInvocation implements Invocation {
myQnames = qnames;
}
@Override
public Object invoke(final DomInvocationHandler<?, ?> handler, final Object[] args) throws Throwable {
Map<XmlTag,DomElement> map = new THashMap<XmlTag, DomElement>();
for (final CollectionChildDescriptionImpl qname : myQnames) {
@@ -27,6 +27,7 @@ public class GetFixedChildInvocation implements Invocation {
myPair = pair;
}
@Override
public Object invoke(final DomInvocationHandler<?, ?> handler, final Object[] args) throws Throwable {
return handler.getFixedChild(myPair).getProxy();
}
@@ -35,6 +35,7 @@ import java.util.TreeSet;
*/
class ImplementationClassCache {
private static final Comparator<Class> CLASS_COMPARATOR = new Comparator<Class>() {
@Override
public int compare(final Class o1, final Class o2) {
if (o1.isAssignableFrom(o2)) return 1;
if (o2.isAssignableFrom(o1)) return -1;
@@ -98,6 +99,7 @@ class ImplementationClassCache {
myImplementationClasses.putValue(domElementClass.getName(), ep);
if (parentDisposable != null) {
Disposer.register(parentDisposable, new Disposable() {
@Override
public void dispose() {
myImplementationClasses.remove(domElementClass.getName());
}
@@ -57,6 +57,7 @@ public class IndexedElementInvocationHandler extends DomInvocationHandler<FixedC
return super.hashCode() * 239 + myIndex;
}
@Override
protected XmlElement recomputeXmlElement(@NotNull final DomInvocationHandler parentHandler) {
final XmlTag tag = parentHandler.getXmlTag();
if (tag == null) return null;
@@ -67,6 +68,7 @@ public class IndexedElementInvocationHandler extends DomInvocationHandler<FixedC
return tags.get(myIndex);
}
@Override
protected XmlTag setEmptyXmlTag() {
final DomInvocationHandler parent = getParentHandler();
assert parent != null : "write operations should be performed on the DOM having a parent, your DOM may be not very fresh";
@@ -80,6 +82,7 @@ public class IndexedElementInvocationHandler extends DomInvocationHandler<FixedC
final XmlTag[] newTag = new XmlTag[1];
getManager().runChange(new Runnable() {
@Override
public void run() {
try {
final XmlTag parentTag = parent.getXmlTag();
@@ -93,6 +96,7 @@ public class IndexedElementInvocationHandler extends DomInvocationHandler<FixedC
return newTag[0];
}
@Override
public void undefineInternal() {
final DomInvocationHandler parent = getParentHandler();
assert parent != null : "write operations should be performed on the DOM having a parent, your DOM may be not very fresh";
@@ -134,6 +138,7 @@ public class IndexedElementInvocationHandler extends DomInvocationHandler<FixedC
fireUndefinedEvent();
}
@Override
public final <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
final T annotation = getChildDescription().getAnnotation(myIndex, annotationClass);
if (annotation != null) return annotation;
@@ -141,10 +146,12 @@ public class IndexedElementInvocationHandler extends DomInvocationHandler<FixedC
return getClassAnnotation(annotationClass);
}
@Override
public final DomElement createPathStableCopy() {
final DomFixedChildDescription description = getChildDescription();
final DomElement parentCopy = getParent().createStableCopy();
return getManager().createStableValue(new Factory<DomElement>() {
@Override
public DomElement create() {
return parentCopy.isValid() ? description.getValues(parentCopy).get(myIndex) : null;
}
@@ -83,11 +83,13 @@ public class InvocationCache {
addCoreInvocations(AnnotatedElement.class);
addCoreInvocations(Object.class);
ourCoreInvocations.put(new JavaMethodSignature("getUserData", Key.class), new Invocation() {
@Override
public Object invoke(DomInvocationHandler<?, ?> handler, Object[] args) throws Throwable {
return handler.getUserData((Key<?>)args[0]);
}
});
ourCoreInvocations.put(new JavaMethodSignature("putUserData", Key.class, Object.class), new Invocation() {
@Override
public Object invoke(DomInvocationHandler<?, ?> handler, Object[] args) throws Throwable {
//noinspection unchecked
handler.putUserData((Key)args[0], args[1]);
@@ -95,49 +97,58 @@ public class InvocationCache {
}
});
ourCoreInvocations.put(new JavaMethodSignature("getXmlElement"), new Invocation() {
@Override
public Object invoke(DomInvocationHandler<?, ?> handler, Object[] args) throws Throwable {
return handler.getXmlElement();
}
});
ourCoreInvocations.put(new JavaMethodSignature("getXmlTag"), new Invocation() {
@Override
public Object invoke(DomInvocationHandler<?, ?> handler, Object[] args) throws Throwable {
return handler.getXmlTag();
}
});
ourCoreInvocations.put(new JavaMethodSignature("getParent"), new Invocation() {
@Override
public Object invoke(DomInvocationHandler<?, ?> handler, Object[] args) throws Throwable {
return handler.getParent();
}
});
ourCoreInvocations.put(new JavaMethodSignature("accept", DomElementVisitor.class), new Invocation() {
@Override
public Object invoke(DomInvocationHandler<?, ?> handler, Object[] args) throws Throwable {
handler.accept((DomElementVisitor)args[0]);
return null;
}
});
ourCoreInvocations.put(new JavaMethodSignature("acceptChildren", DomElementVisitor.class), new Invocation() {
@Override
public Object invoke(DomInvocationHandler<?, ?> handler, Object[] args) throws Throwable {
handler.acceptChildren((DomElementVisitor)args[0]);
return null;
}
});
ourCoreInvocations.put(new JavaMethodSignature("getAnnotation", Class.class), new Invocation() {
@Override
public Object invoke(DomInvocationHandler<?, ?> handler, Object[] args) throws Throwable {
//noinspection unchecked
return handler.getAnnotation((Class<Annotation>)args[0]);
}
});
ourCoreInvocations.put(new JavaMethodSignature("getRawText"), new Invocation() {
@Override
public final Object invoke(final DomInvocationHandler<?, ?> handler, final Object[] args) throws Throwable {
return handler.getValue();
}
});
ourCoreInvocations.put(new JavaMethodSignature("getXmlAttribute"), new Invocation() {
@Override
public final Object invoke(final DomInvocationHandler<?, ?> handler, final Object[] args) throws Throwable {
return handler.getXmlElement();
}
});
ourCoreInvocations.put(new JavaMethodSignature("getXmlAttributeValue"), new Invocation() {
@Override
@Nullable
public final Object invoke(final DomInvocationHandler<?, ?> handler, final Object[] args) throws Throwable {
final XmlAttribute attribute = (XmlAttribute)handler.getXmlElement();
@@ -145,6 +156,7 @@ public class InvocationCache {
}
});
ourCoreInvocations.put(new JavaMethodSignature("getConverter"), new Invocation() {
@Override
public final Object invoke(final DomInvocationHandler<?, ?> handler, final Object[] args) throws Throwable {
try {
return handler.getScalarConverter();
@@ -164,6 +176,7 @@ public class InvocationCache {
for (final Method method : ReflectionUtil.getClassDeclaredMethods(aClass)) {
if ("equals".equals(method.getName())) {
ourCoreInvocations.put(new JavaMethodSignature(method), new Invocation() {
@Override
public Object invoke(DomInvocationHandler<?, ?> handler, Object[] args) throws Throwable {
final DomElement proxy = handler.getProxy();
final Object arg = args[0];
@@ -182,6 +195,7 @@ public class InvocationCache {
}
else if ("hashCode".equals(method.getName())) {
ourCoreInvocations.put(new JavaMethodSignature(method), new Invocation() {
@Override
public Object invoke(DomInvocationHandler<?, ?> handler, Object[] args) throws Throwable {
return handler.hashCode();
}
@@ -189,6 +203,7 @@ public class InvocationCache {
}
else {
ourCoreInvocations.put(new JavaMethodSignature(method), new Invocation() {
@Override
public Object invoke(DomInvocationHandler<?, ?> handler, Object[] args) throws Throwable {
return method.invoke(handler, args);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,17 +31,21 @@ public class MockDomFileDescription<T> extends DomFileDescription<T> {
myFile = file;
}
@Override
public boolean isMyFile(@NotNull final XmlFile xmlFile, final Module module) {
return myFile == xmlFile;
}
@Override
public boolean acceptsOtherRootTagNames() {
return true;
}
@Override
protected void initializeFileDescription() {
}
@Override
public boolean isAutomaticHighlightingEnabled() {
return false;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,6 +40,7 @@ public class PhysicalDomParentStrategy implements DomParentStrategy {
myDomManager = domManager;
}
@Override
public DomInvocationHandler getParentHandler() {
final XmlTag parentTag = getParentTag(myElement);
assert parentTag != null;
@@ -55,16 +56,19 @@ public class PhysicalDomParentStrategy implements DomParentStrategy {
return parent instanceof XmlEntityRef ? parent.getParent() : parent;
}
@Override
@NotNull
public final XmlElement getXmlElement() {
return myElement;
}
@Override
@NotNull
public DomParentStrategy refreshStrategy(final DomInvocationHandler handler) {
return this;
}
@Override
@NotNull
public DomParentStrategy setXmlElement(@NotNull final XmlElement element) {
myElement = element;
@@ -76,6 +80,7 @@ public class PhysicalDomParentStrategy implements DomParentStrategy {
return "Physical:" + myElement;
}
@Override
@NotNull
public DomParentStrategy clearXmlElement() {
final DomInvocationHandler parent = getParentHandler();
@@ -83,6 +88,7 @@ public class PhysicalDomParentStrategy implements DomParentStrategy {
return new VirtualDomParentStrategy(parent);
}
@Override
public String checkValidity() {
return myElement.isValid() ? null : "Invalid PSI";
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@ class PropertyAccessorInvocation implements Invocation {
myLastElement = myMethods.length - 1;
}
@Override
public final Object invoke(final DomInvocationHandler<?, ?> handler, final Object[] args) throws Throwable {
return invoke(0, handler.getProxy());
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,25 +30,30 @@ public class RootDomParentStrategy implements DomParentStrategy {
myFileElement = fileElement;
}
@Override
@NotNull
public DomInvocationHandler getParentHandler() {
throw new UnsupportedOperationException("Method getParentHandler is not yet implemented in " + getClass().getName());
}
@Override
public XmlTag getXmlElement() {
return myFileElement.getRootTag();
}
@Override
@NotNull
public DomParentStrategy refreshStrategy(final DomInvocationHandler handler) {
return this;
}
@Override
@NotNull
public DomParentStrategy setXmlElement(@NotNull final XmlElement element) {
return this;
}
@Override
@NotNull
public DomParentStrategy clearXmlElement() {
return this;
@@ -28,6 +28,7 @@ public class SetInvocation implements Invocation {
myConverter = converter;
}
@Override
public Object invoke(final DomInvocationHandler<?, ?> handler, final Object[] args) throws Throwable {
handler.assertValid();
final SubTag annotation = handler.getAnnotation(SubTag.class);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,6 +53,7 @@ class StableInvocationHandler<T> implements InvocationHandler, StableElement {
}
@Override
public final Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable {
if (StableElement.class.equals(method.getDeclaringClass())) {
try {
@@ -113,6 +114,7 @@ class StableInvocationHandler<T> implements InvocationHandler, StableElement {
}
}
@Override
public final void revalidate() {
final T t = myProvider.create();
if (!isNotValid(t) && !t.equals(myCachedValue)) {
@@ -120,12 +122,14 @@ class StableInvocationHandler<T> implements InvocationHandler, StableElement {
}
}
@Override
public final void invalidate() {
if (!isNotValid(myCachedValue)) {
myCachedValue = null;
}
}
@Override
public final T getWrappedElement() {
if (isNotValid(myCachedValue)) {
myCachedValue = myProvider.create();
@@ -86,6 +86,7 @@ public class StaticGenericInfo extends DomGenericInfoEx {
}
final NotNullFunction<String, CollectionChildDescriptionImpl> mapper = new NotNullFunction<String, CollectionChildDescriptionImpl>() {
@Override
@NotNull
public CollectionChildDescriptionImpl fun(final String xmlName) {
return ObjectUtils.assertNotNull(myCollections.findDescription(xmlName));
@@ -115,10 +116,12 @@ public class StaticGenericInfo extends DomGenericInfoEx {
}
}
@Override
public boolean checkInitialized() {
return buildMethodMaps();
}
@Override
public final Invocation createInvocation(final JavaMethod method) {
buildMethodMaps();
@@ -143,6 +146,7 @@ public class StaticGenericInfo extends DomGenericInfoEx {
if (myCustomDescription != null && method.equals(myCustomDescription.getGetterMethod())) {
return new Invocation() {
@Override
@Nullable
public Object invoke(final DomInvocationHandler<?, ?> handler, final Object[] args) throws Throwable {
return myCustomDescription.getValues(handler);
@@ -176,6 +180,7 @@ public class StaticGenericInfo extends DomGenericInfoEx {
if (parameterTypes.length == 2 && parameterTypes[1].equals(Class.class)) {
return new Function<Object[], Type>() {
@Override
public Type fun(final Object[] s) {
return (Type)s[1];
}
@@ -183,6 +188,7 @@ public class StaticGenericInfo extends DomGenericInfoEx {
}
return new Function<Object[], Type>() {
@Override
public Type fun(final Object[] s) {
return method.getGenericReturnType();
}
@@ -198,6 +204,7 @@ public class StaticGenericInfo extends DomGenericInfoEx {
if (parameterTypes.length == 2 && parameterTypes[1].equals(int.class)) {
return new Function<Object[], Integer>() {
@Override
public Integer fun(final Object[] s) {
return (Integer)s[1];
}
@@ -207,6 +214,7 @@ public class StaticGenericInfo extends DomGenericInfoEx {
return new ConstantFunction<Object[], Integer>(Integer.MAX_VALUE);
}
@Override
@Nullable
public XmlElement getNameElement(DomElement element) {
buildMethodMaps();
@@ -222,6 +230,7 @@ public class StaticGenericInfo extends DomGenericInfoEx {
}
}
@Override
@Nullable
public GenericDomValue getNameDomElement(DomElement element) {
buildMethodMaps();
@@ -230,6 +239,7 @@ public class StaticGenericInfo extends DomGenericInfoEx {
return o instanceof GenericDomValue ? (GenericDomValue)o : null;
}
@Override
@NotNull
public List<? extends CustomDomChildrenDescriptionImpl> getCustomNameChildrenDescription() {
return myCustomDescription == null ? Collections.<CustomDomChildrenDescriptionImpl>emptyList() : Collections.singletonList(myCustomDescription);
@@ -240,6 +250,7 @@ public class StaticGenericInfo extends DomGenericInfoEx {
return myNameValueGetter == null ? null : myNameValueGetter.invoke(element);
}
@Override
@Nullable
public String getElementName(DomElement element) {
buildMethodMaps();
@@ -247,6 +258,7 @@ public class StaticGenericInfo extends DomGenericInfoEx {
return o == null || o instanceof String ? (String)o : ((GenericValue)o).getStringValue();
}
@Override
@NotNull
public List<AbstractDomChildDescriptionImpl> getChildrenDescriptions() {
buildMethodMaps();
@@ -258,23 +270,27 @@ public class StaticGenericInfo extends DomGenericInfoEx {
return list;
}
@Override
@NotNull
public List<? extends DomFixedChildDescription> getFixedChildrenDescriptions() {
buildMethodMaps();
return myFixed.getDescriptions();
}
@Override
@NotNull
public List<? extends DomCollectionChildDescription> getCollectionChildrenDescriptions() {
buildMethodMaps();
return myCollections.getDescriptions();
}
@Override
public boolean isTagValueElement() {
buildMethodMaps();
return myValueElement;
}
@Override
@NotNull
public List<AttributeChildDescriptionImpl> getAttributeChildrenDescriptions() {
buildMethodMaps();
@@ -287,36 +303,42 @@ public class StaticGenericInfo extends DomGenericInfoEx {
return ContainerUtil.process(descriptions, processor);
}
@Override
@Nullable
public DomFixedChildDescription getFixedChildDescription(@NonNls final String tagName) {
buildMethodMaps();
return myFixed.findDescription(tagName);
}
@Override
@Nullable
public DomFixedChildDescription getFixedChildDescription(@NonNls final String tagName, @NonNls final String namespaceKey) {
buildMethodMaps();
return myFixed.getDescription(tagName, namespaceKey);
}
@Override
@Nullable
public DomCollectionChildDescription getCollectionChildDescription(@NonNls final String tagName) {
buildMethodMaps();
return myCollections.findDescription(tagName);
}
@Override
@Nullable
public DomCollectionChildDescription getCollectionChildDescription(@NonNls final String tagName, @NonNls final String namespaceKey) {
buildMethodMaps();
return myCollections.getDescription(tagName, namespaceKey);
}
@Override
@Nullable
public DomAttributeChildDescription getAttributeChildDescription(@NonNls final String attributeName) {
buildMethodMaps();
return myAttributes.findDescription(attributeName);
}
@Override
@Nullable
public DomAttributeChildDescription getAttributeChildDescription(@NonNls final String attributeName, @NonNls final String namespaceKey) {
buildMethodMaps();
@@ -52,6 +52,7 @@ public class StaticGenericInfoBuilder {
private final Map<JavaMethodSignature, String[]> myCompositeCollectionGetters = new THashMap<JavaMethodSignature, String[]>();
private final Map<JavaMethodSignature, Pair<String,String[]>> myCompositeCollectionAdders = new THashMap<JavaMethodSignature, Pair<String,String[]>>();
private final FactoryMap<XmlName, TIntObjectHashMap<Collection<JavaMethod>>> myFixedChildrenGetters = new FactoryMap<XmlName, TIntObjectHashMap<Collection<JavaMethod>>>() {
@Override
protected TIntObjectHashMap<Collection<JavaMethod>> create(final XmlName key) {
return new TIntObjectHashMap<Collection<JavaMethod>>();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,15 +38,18 @@ public class VirtualDomParentStrategy implements DomParentStrategy {
return myModificationTracker.getModificationStamp();
}
@Override
@NotNull
public DomInvocationHandler getParentHandler() {
return myParentHandler;
}
@Override
public XmlElement getXmlElement() {
return null;
}
@Override
@NotNull
public synchronized DomParentStrategy refreshStrategy(final DomInvocationHandler handler) {
if (!myParentHandler.isValid()) return this;
@@ -62,11 +65,13 @@ public class VirtualDomParentStrategy implements DomParentStrategy {
return this;
}
@Override
@NotNull
public DomParentStrategy setXmlElement(@NotNull final XmlElement element) {
return new PhysicalDomParentStrategy(element, DomManagerImpl.getDomManager(element.getProject()));
}
@Override
@NotNull
public synchronized DomParentStrategy clearXmlElement() {
myModCount = getModCount();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,6 +57,7 @@ public abstract class GoToSymbolProvider implements ChooseByNameContributor {
}
}
@Override
@NotNull
public String[] getNames(final Project project, boolean includeNonProjectItems) {
Set<String> result = new HashSet<String>();
@@ -70,6 +71,7 @@ public abstract class GoToSymbolProvider implements ChooseByNameContributor {
return ArrayUtil.toStringArray(result);
}
@Override
@NotNull
public NavigationItem[] getItemsByName(final String name, final String pattern, final Project project, boolean includeNonProjectItems) {
List<NavigationItem> result = new ArrayList<NavigationItem>();
@@ -126,27 +128,33 @@ public abstract class GoToSymbolProvider implements ChooseByNameContributor {
myIcon = icon;
}
@Override
@NotNull
public PsiElement getNavigationElement() {
return myPsiElement;
}
@Override
public Icon getIcon(boolean flags) {
return myIcon;
}
@Override
public ItemPresentation getPresentation() {
return new ItemPresentation() {
@Override
public String getPresentableText() {
return myText;
}
@Override
@Nullable
public String getLocationString() {
return '(' + myPsiElement.getContainingFile().getName() + ')';
}
@Override
@Nullable
public Icon getIcon(boolean open) {
return myIcon;
@@ -154,6 +162,7 @@ public abstract class GoToSymbolProvider implements ChooseByNameContributor {
};
}
@Override
public PsiElement getParent() {
return myPsiElement.getParent();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -78,11 +78,13 @@ public class DomExtensionImpl implements DomExtension {
return myXmlName;
}
@Override
@NotNull
public Type getType() {
return myType;
}
@Override
public DomExtension setDeclaringElement(@NotNull DomElement declaringElement) {
putUserData(KEY_DOM_DECLARATION, DomAnchorImpl.createAnchor(declaringElement, true));
return this;
@@ -94,26 +96,31 @@ public class DomExtensionImpl implements DomExtension {
return this;
}
@Override
public DomExtension setConverter(@NotNull Converter converter) {
return setConverter(converter, false);
}
@Override
public final DomExtension setConverter(@NotNull final Converter converter, final boolean soft) {
myConverter = converter;
mySoft = soft;
return this;
}
@Override
public DomExtension addCustomAnnotation(@NotNull final Annotation anno) {
myCustomAnnos.add(anno);
return this;
}
@Override
public <T> void putUserData(final Key<T> key, final T value) {
if (myUserMap == null) myUserMap = new THashMap();
myUserMap.put(key, value);
}
@Override
public DomExtension addExtender(final DomExtender extender) {
if (myUserMap == null || !myUserMap.containsKey(DOM_EXTENDER_KEY)) {
putUserData(DOM_EXTENDER_KEY, new SmartList<DomExtender>());
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,27 +60,32 @@ public class DomExtensionsRegistrarImpl implements DomExtensionsRegistrar {
return addExtension(myFixeds, name, type).setCount(count);
}
@Override
@NotNull
public DomExtension registerFixedNumberChildExtension(@NotNull final XmlName name, @NotNull final Type type) {
return registerFixedNumberChildrenExtension(name, type, 1);
}
@Override
@NotNull
public DomExtension registerCollectionChildrenExtension(@NotNull final XmlName name, @NotNull final Type type) {
return addExtension(myCollections, name, type);
}
@Override
@NotNull
public DomExtension registerGenericAttributeValueChildExtension(@NotNull final XmlName name, final Type parameterType) {
return addExtension(myAttributes, name, new ParameterizedTypeImpl(GenericAttributeValue.class, parameterType));
}
@Override
@NotNull
public DomExtension registerAttributeChildExtension(@NotNull final XmlName name, @NotNull final Type type) {
assert GenericAttributeValue.class.isAssignableFrom(ReflectionUtil.getRawType(type));
return addExtension(myAttributes, name, type);
}
@Override
@NotNull
public DomExtension registerCustomChildrenExtension(@NotNull final Type type) {
return registerCustomChildrenExtension(type, CustomDomChildrenDescription.TagNameDescriptor.EMPTY);
@@ -47,21 +47,25 @@ public class DomStructureTreeElement implements StructureViewTreeElement, ItemPr
return myElement;
}
@Override
@Nullable
public Object getValue() {
return myElement.isValid() ? myElement.getXmlElement() : null;
}
@Override
@NotNull
public ItemPresentation getPresentation() {
return this;
}
@Override
@NotNull
public TreeElement[] getChildren() {
if (!myElement.isValid()) return EMPTY_ARRAY;
final ArrayList<TreeElement> result = new ArrayList<TreeElement>();
final DomElementVisitor elementVisitor = new DomElementVisitor() {
@Override
public void visitDomElement(final DomElement element) {
if (element instanceof GenericDomValue) return;
final DomService.StructureViewMode viewMode = myDescriptor.fun(element);
@@ -85,18 +89,22 @@ public class DomStructureTreeElement implements StructureViewTreeElement, ItemPr
return new DomStructureTreeElement(element, myDescriptor, myNavigationProvider);
}
@Override
public void navigate(boolean requestFocus) {
if (myNavigationProvider != null) myNavigationProvider.navigate(myElement, true);
}
@Override
public boolean canNavigate() {
return myNavigationProvider != null && myNavigationProvider.canNavigate(myElement);
}
@Override
public boolean canNavigateToSource() {
return myNavigationProvider != null && myNavigationProvider.canNavigate(myElement);
}
@Override
public String getPresentableText() {
if (!myElement.isValid()) return "<unknown>";
final ElementPresentation presentation = myElement.getPresentation();
@@ -104,11 +112,13 @@ public class DomStructureTreeElement implements StructureViewTreeElement, ItemPr
return name != null? name : presentation.getTypeName();
}
@Override
@Nullable
public String getLocationString() {
return null;
}
@Override
@Nullable
public Icon getIcon(boolean open) {
if (!myElement.isValid()) return null;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,6 +51,7 @@ public abstract class DomStub extends ObjectStubBase<DomStub> {
myLocalName = localName;
}
@Override
public abstract List<DomStub> getChildrenStubs();
public String getName() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -69,6 +69,7 @@ public class ElementStub extends DomStub {
return StringUtil.isEmpty(key) ? getName() : key + ":" + getName();
}
@Override
public boolean isCustom() {
return myCustom;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,16 +28,19 @@ import org.jetbrains.annotations.Nullable;
public class AddDomElementActionGroup extends ActionGroup {
private final AddElementInCollectionAction myAction = new AddElementInCollectionAction() {
@Override
protected boolean showAsPopup() {
return false;
}
};
@Override
@NotNull
public AnAction[] getChildren(@Nullable AnActionEvent e) {
return myAction.getChildren(e);
}
@Override
public void update(AnActionEvent e) {
// myAction.getChildren(e).length
getTemplatePresentation().setText(myAction.getTemplatePresentation().getText());
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -61,6 +61,7 @@ public class AddElementInCollectionAction extends AddDomElementAction {
return DomModelTreeView.DATA_KEY.getData(e.getDataContext());
}
@Override
protected boolean isEnabled(final AnActionEvent e) {
final DomModelTreeView treeView = getTreeView(e);
@@ -71,6 +72,7 @@ public class AddElementInCollectionAction extends AddDomElementAction {
}
@Override
protected void showPopup(final ListPopup groupPopup, final AnActionEvent e) {
if (myTreeView == null) {
if (e.getPlace().equals(DomModelTreeView.DOM_MODEL_TREE_VIEW_POPUP)) {
@@ -85,6 +87,7 @@ public class AddElementInCollectionAction extends AddDomElementAction {
}
}
@Override
@NotNull
protected DomCollectionChildDescription[] getDomCollectionChildDescriptions(final AnActionEvent e) {
final DomModelTreeView view = getTreeView(e);
@@ -104,6 +107,7 @@ public class AddElementInCollectionAction extends AddDomElementAction {
: new DomCollectionChildDescription[]{groupNode.getChildDescription()};
}
@Override
protected DomElement getParentDomElement(final AnActionEvent e) {
final DomModelTreeView view = getTreeView(e);
SimpleNode node = view.getTree().getSelectedNode();
@@ -117,14 +121,17 @@ public class AddElementInCollectionAction extends AddDomElementAction {
return groupNode == null ? null : groupNode.getDomElement();
}
@Override
protected JComponent getComponent(AnActionEvent e) {
return getTreeView(e);
}
@Override
protected boolean showAsPopup() {
return true;
}
@Override
protected String getActionText(final AnActionEvent e) {
String text = ApplicationBundle.message("action.add");
if (e.getPresentation().isEnabled()) {
@@ -150,6 +157,7 @@ public class AddElementInCollectionAction extends AddDomElementAction {
}
@Override
protected AnAction createAddingAction(final AnActionEvent e,
final String name,
final Icon icon,
@@ -192,22 +200,27 @@ public class AddElementInCollectionAction extends AddDomElementAction {
myView = getTreeView(e);
}
@Override
protected Type getElementType() {
return myType;
}
@Override
protected DomCollectionChildDescription getDomCollectionChildDescription() {
return myDescription;
}
@Override
protected DomElement getParentDomElement() {
return myParent;
}
protected void afterAddition(final DomElement newElement) {
@Override
protected void afterAddition(@NotNull final DomElement newElement) {
final DomElement copy = newElement.createStableCopy();
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
myView.setSelectedDomElement(copy);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@ abstract public class BaseDomTreeAction extends AnAction {
myTreeView = treeView;
}
@Override
final public void update(AnActionEvent e) {
final DomModelTreeView treeView = getTreeView(e);
@@ -50,6 +51,7 @@ abstract public class BaseDomTreeAction extends AnAction {
return DomModelTreeView.DATA_KEY.getData(e.getDataContext());
}
@Override
final public void actionPerformed(AnActionEvent e) {
final DomModelTreeView treeView = getTreeView(e);
if (treeView != null) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,6 +43,7 @@ public class DeleteDomElement extends BaseDomTreeAction {
super(treeView);
}
@Override
public void actionPerformed(AnActionEvent e, DomModelTreeView treeView) {
final SimpleNode selectedNode = treeView.getTree().getSelectedNode();
@@ -59,6 +60,7 @@ public class DeleteDomElement extends BaseDomTreeAction {
Messages.getQuestionIcon());
if (ret == Messages.OK) {
new WriteCommandAction(domElement.getManager().getProject(), DomUtil.getFile(domElement)) {
@Override
protected void run(final Result result) throws Throwable {
domElement.undefine();
}
@@ -67,6 +69,7 @@ public class DeleteDomElement extends BaseDomTreeAction {
}
}
@Override
public void update(AnActionEvent e, DomModelTreeView treeView) {
final SimpleNode selectedNode = treeView.getTree().getSelectedNode();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.util.xml.DomUtil;
import com.intellij.util.xml.ElementPresentationManager;
import com.intellij.util.xml.tree.AbstractDomElementNode;
import com.intellij.util.xml.tree.BaseDomElementNode;
import com.intellij.util.xml.tree.DomModelTreeView;
@@ -51,11 +52,12 @@ public class DomElementsToggleAction extends ToggleAction {
myText = TypePresentationService.getService().getTypePresentableName(myClass);
if(getHiders() == null) DomUtil.getFile(myTreeView.getRootElement()).putUserData(BaseDomElementNode.TREE_NODES_HIDERS_KEY, new HashMap<Class, Boolean>());
if(getHiders() == null) DomUtil.getFile(myTreeView.getRootElement()).putUserData(AbstractDomElementNode.TREE_NODES_HIDERS_KEY, new HashMap<Class, Boolean>());
if(getHiders().get(myClass) == null) getHiders().put(myClass, true);
}
@Override
public void update(final AnActionEvent e) {
super.update(e);
@@ -65,6 +67,7 @@ public class DomElementsToggleAction extends ToggleAction {
e.getPresentation().setEnabled(getHiders() != null && getHiders().get(myClass)!=null);
}
@Override
public boolean isSelected(AnActionEvent e) {
return getHiders().get(myClass);
}
@@ -73,6 +76,7 @@ public class DomElementsToggleAction extends ToggleAction {
return DomUtil.getFile(myTreeView.getRootElement()).getUserData(BaseDomElementNode.TREE_NODES_HIDERS_KEY);
}
@Override
public void setSelected(AnActionEvent e, boolean state) {
getHiders().put(myClass, state);
myTreeView.getBuilder().updateFromRoot();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,21 +16,21 @@
package com.intellij.util.xml.tree.actions;
import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.util.xml.tree.DomModelTreeView;
import com.intellij.util.xml.tree.BaseDomElementNode;
import com.intellij.util.xml.DomElementsNavigationManager;
import com.intellij.ui.treeStructure.SimpleNode;
import com.intellij.util.xml.DomElement;
import com.intellij.util.xml.DomElementNavigationProvider;
import com.intellij.ui.treeStructure.SimpleNode;
import com.intellij.idea.ActionsBundle;
import com.intellij.util.xml.DomElementsNavigationManager;
import com.intellij.util.xml.tree.BaseDomElementNode;
import com.intellij.util.xml.tree.DomModelTreeView;
/**
* User: Sergey.Vasiliev
*/
public class GotoDomElementDeclarationAction extends BaseDomTreeAction {
@Override
public void actionPerformed(AnActionEvent e, DomModelTreeView treeView) {
final SimpleNode simpleNode = treeView.getTree().getSelectedNode();
@@ -44,6 +44,7 @@ public class GotoDomElementDeclarationAction extends BaseDomTreeAction {
}
}
@Override
public void update(AnActionEvent e, DomModelTreeView treeView) {
e.getPresentation().setVisible(treeView.getTree().getSelectedNode() instanceof BaseDomElementNode);
e.getPresentation().setText(ActionsBundle.message("action.EditSource.text"));
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,6 +60,7 @@ public class DomUIFactoryImpl extends DomUIFactory {
public DomUIFactoryImpl() {
final Function<DomElement, TableCellEditor> booleanCreator = new Function<DomElement, TableCellEditor>() {
@Override
public TableCellEditor fun(final DomElement domElement) {
return new BooleanTableCellEditor();
}
@@ -67,6 +68,7 @@ public class DomUIFactoryImpl extends DomUIFactory {
registerCustomCellEditor(Boolean.class, booleanCreator);
registerCustomCellEditor(boolean.class, booleanCreator);
registerCustomCellEditor(String.class, new Function<DomElement, TableCellEditor>() {
@Override
public TableCellEditor fun(final DomElement domElement) {
return new DefaultCellEditor(removeBorder(new JTextField()));
}
@@ -77,6 +79,7 @@ public class DomUIFactoryImpl extends DomUIFactory {
}
}
@Override
protected TableCellEditor createCellEditor(DomElement element, Class type) {
if (Enum.class.isAssignableFrom(type)) {
return new ComboTableCellEditor((Class<? extends Enum>)type, false);
@@ -87,14 +90,17 @@ public class DomUIFactoryImpl extends DomUIFactory {
return function.fun(element);
}
@Override
public final UserActivityWatcher createEditorAwareUserActivityWatcher() {
return new UserActivityWatcher() {
private final DocumentAdapter myListener = new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
fireUIChanged();
}
};
@Override
protected void processComponent(final Component component) {
super.processComponent(component);
if (component instanceof EditorComponentImpl) {
@@ -102,6 +108,7 @@ public class DomUIFactoryImpl extends DomUIFactory {
}
}
@Override
protected void unprocessComponent(final Component component) {
super.unprocessComponent(component);
if (component instanceof EditorComponentImpl) {
@@ -111,11 +118,13 @@ public class DomUIFactoryImpl extends DomUIFactory {
};
}
@Override
public void setupErrorOutdatingUserActivityWatcher(final CommittablePanel panel, final DomElement... elements) {
final UserActivityWatcher userActivityWatcher = createEditorAwareUserActivityWatcher();
userActivityWatcher.addUserActivityListener(new UserActivityListener() {
private boolean isProcessingChange;
@Override
public void stateChanged() {
if (isProcessingChange) return;
isProcessingChange = true;
@@ -133,19 +142,23 @@ public class DomUIFactoryImpl extends DomUIFactory {
userActivityWatcher.register(panel.getComponent());
}
@Override
@Nullable
public BaseControl createCustomControl(final Type type, DomWrapper<String> wrapper, final boolean commitOnEveryChange) {
final Function<DomWrapper<String>, BaseControl> factory = myCustomControlCreators.get(ReflectionUtil.getRawType(type));
return factory == null ? null : factory.fun(wrapper);
}
@Override
public CaptionComponent addErrorPanel(CaptionComponent captionComponent, DomElement... elements) {
captionComponent.initErrorPanel(new DomElementsErrorPanel(elements));
return captionComponent;
}
@Override
public BackgroundEditorHighlighter createDomHighlighter(final Project project, final PerspectiveFileEditor editor, final DomElement element) {
return new BackgroundEditorHighlighter() {
@Override
@NotNull
public HighlightingPass[] createPassesForEditor() {
if (!element.isValid()) return HighlightingPass.EMPTY_ARRAY;
@@ -168,6 +181,7 @@ public class DomUIFactoryImpl extends DomUIFactory {
return new HighlightingPass[]{ghp, lip};
}
@Override
@NotNull
public HighlightingPass[] createPassesForVisibleArea() {
return createPassesForEditor();
@@ -176,14 +190,17 @@ public class DomUIFactoryImpl extends DomUIFactory {
}
@Override
public BaseControl createTextControl(DomWrapper<String> wrapper, final boolean commitOnEveryChange) {
return new TextControl(wrapper, commitOnEveryChange);
}
@Override
public void registerCustomControl(Class aClass, Function<DomWrapper<String>, BaseControl> creator) {
myCustomControlCreators.put(aClass, creator);
}
@Override
public void registerCustomCellEditor(final Class aClass, final Function<DomElement, TableCellEditor> creator) {
myCustomCellEditorCreators.put(aClass, creator);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,16 +47,19 @@ import java.util.List;
*/
public abstract class EditorTextFieldControl<T extends JComponent> extends BaseModifiableControl<T, String> {
private static final JTextField J_TEXT_FIELD = new JTextField() {
@Override
public void addNotify() {
throw new UnsupportedOperationException("Shouldn't be shown");
}
@Override
public void setVisible(boolean aFlag) {
throw new UnsupportedOperationException("Shouldn't be shown");
}
};
private final boolean myCommitOnEveryChange;
private final DocumentListener myListener = new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
setModified();
if (myCommitOnEveryChange) {
@@ -77,6 +80,7 @@ public abstract class EditorTextFieldControl<T extends JComponent> extends BaseM
protected abstract EditorTextField getEditorTextField(@NotNull T component);
@Override
protected void doReset() {
final EditorTextField textField = getEditorTextField(getComponent());
textField.getDocument().removeDocumentListener(myListener);
@@ -84,14 +88,17 @@ public abstract class EditorTextFieldControl<T extends JComponent> extends BaseM
textField.getDocument().addDocumentListener(myListener);
}
@Override
protected JComponent getComponentToListenFocusLost(final T component) {
return getEditorTextField(getComponent());
}
@Override
protected JComponent getHighlightedComponent(final T component) {
return J_TEXT_FIELD;
}
@Override
protected T createMainComponent(T boundedComponent) {
final Project project = getProject();
boundedComponent = createMainComponent(boundedComponent, project);
@@ -104,15 +111,19 @@ public abstract class EditorTextFieldControl<T extends JComponent> extends BaseM
protected abstract T createMainComponent(T boundedComponent, Project project);
@Override
@NotNull
protected String getValue() {
return getEditorTextField(getComponent()).getText();
}
@Override
protected void setValue(final String value) {
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
@Override
public void run() {
new WriteAction() {
@Override
protected void run(Result result) throws Throwable {
final T component = getComponent();
final Document document = getEditorTextField(component).getDocument();
@@ -123,6 +134,7 @@ public abstract class EditorTextFieldControl<T extends JComponent> extends BaseM
});
}
@Override
protected void updateComponent() {
final DomElement domElement = getDomElement();
if (domElement == null || !domElement.isValid()) return;
@@ -130,6 +142,7 @@ public abstract class EditorTextFieldControl<T extends JComponent> extends BaseM
final EditorTextField textField = getEditorTextField(getComponent());
final Project project = getProject();
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (!project.isOpen()) return;
if (!getDomWrapper().isValid()) return;
@@ -170,13 +183,16 @@ public abstract class EditorTextFieldControl<T extends JComponent> extends BaseM
}
@Override
public boolean canNavigate(final DomElement element) {
return getDomElement().equals(element);
}
@Override
public void navigate(final DomElement element) {
final EditorTextField field = getEditorTextField(getComponent());
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
field.requestFocus();
field.selectAll();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,6 +47,7 @@ public class TextControl extends EditorTextFieldControl<TextPanel> {
super(domWrapper, commitOnEveryChange);
}
@Override
protected EditorTextField getEditorTextField(@NotNull final TextPanel panel) {
final Component component = panel.getComponent(0);
if (component instanceof ReferenceEditorWithBrowseButton) {
@@ -55,12 +56,14 @@ public class TextControl extends EditorTextFieldControl<TextPanel> {
return (EditorTextField)component;
}
@Override
protected TextPanel createMainComponent(TextPanel boundedComponent, final Project project) {
if (boundedComponent == null) {
boundedComponent = new TextPanel();
}
boundedComponent.removeAll();
final Function<String, Document> factory = new Function<String, Document>() {
@Override
public Document fun(final String s) {
return PsiDocumentManager.getInstance(project)
.getDocument(PsiFileFactory.getInstance(project).createFileFromText("a.txt", PlainTextLanguage.INSTANCE, "", true, false));
@@ -68,6 +71,7 @@ public class TextControl extends EditorTextFieldControl<TextPanel> {
};
final TextPanel boundedComponent1 = boundedComponent;
final EditorTextField editorTextField = new EditorTextField(factory.fun(""), project, FileTypes.PLAIN_TEXT) {
@Override
protected EditorEx createEditor() {
final EditorEx editor = super.createEditor();
return boundedComponent1 instanceof MultiLineTextPanel ? makeBigEditor(editor, ((MultiLineTextPanel)boundedComponent1).getRowCount()) : editor;
@@ -82,8 +86,10 @@ public class TextControl extends EditorTextFieldControl<TextPanel> {
final ReferenceEditorWithBrowseButton editor = new ReferenceEditorWithBrowseButton(null, editorTextField, factory);
boundedComponent.add(editor);
editor.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
EditorTextField textArea = new EditorTextField(editorTextField.getDocument(), project, FileTypes.PLAIN_TEXT) {
@Override
protected EditorEx createEditor() {
final EditorEx editor = super.createEditor();
editor.setEmbeddedIntoDialogWrapper(true);
@@ -49,6 +49,7 @@ public abstract class AbstractDomChildrenDescriptor implements XmlElementDescrip
myManager = manager;
}
@Override
public XmlElementDescriptor[] getElementsDescriptors(final XmlTag context) {
final DomElement domElement = myManager.getDomElement(context);
if (domElement == null) return EMPTY_ARRAY;
@@ -104,6 +105,7 @@ public abstract class AbstractDomChildrenDescriptor implements XmlElementDescrip
return null;
}
@Override
@Nullable
public XmlElementDescriptor getElementDescriptor(@NotNull final XmlTag childTag, @Nullable XmlTag contextTag) {
DomElement domElement = myManager.getDomElement(childTag);
@@ -147,6 +149,7 @@ public abstract class AbstractDomChildrenDescriptor implements XmlElementDescrip
return new DomElementXmlDescriptor((DomChildrenDescription)description, myManager);
}
@Override
public XmlAttributeDescriptor[] getAttributesDescriptors(final @Nullable XmlTag context) {
if (context == null) return XmlAttributeDescriptor.EMPTY;
@@ -172,6 +175,7 @@ public abstract class AbstractDomChildrenDescriptor implements XmlElementDescrip
return descriptors.toArray(new XmlAttributeDescriptor[descriptors.size()]);
}
@Override
@Nullable
public XmlAttributeDescriptor getAttributeDescriptor(final String attributeName, final @Nullable XmlTag context) {
DomElement domElement = myManager.getDomElement(context);
@@ -185,57 +189,69 @@ public abstract class AbstractDomChildrenDescriptor implements XmlElementDescrip
return null;
}
@Override
@Nullable
public XmlAttributeDescriptor getAttributeDescriptor(final XmlAttribute attribute) {
return getAttributeDescriptor(attribute.getName(), attribute.getParent());
}
@Override
public XmlNSDescriptor getNSDescriptor() {
return new XmlNSDescriptor() {
@Override
@Nullable
public XmlElementDescriptor getElementDescriptor(@NotNull final XmlTag tag) {
throw new UnsupportedOperationException("Method getElementDescriptor not implemented in " + getClass());
}
@Override
@NotNull
public XmlElementDescriptor[] getRootElementsDescriptors(@Nullable final XmlDocument document) {
throw new UnsupportedOperationException("Method getRootElementsDescriptors not implemented in " + getClass());
}
@Override
@Nullable
public XmlFile getDescriptorFile() {
return null;
}
@Override
public boolean isHierarhyEnabled() {
throw new UnsupportedOperationException("Method isHierarhyEnabled not implemented in " + getClass());
}
@Override
@Nullable
public PsiElement getDeclaration() {
throw new UnsupportedOperationException("Method getDeclaration not implemented in " + getClass());
}
@Override
@NonNls
public String getName(final PsiElement context) {
throw new UnsupportedOperationException("Method getName not implemented in " + getClass());
}
@Override
@NonNls
public String getName() {
throw new UnsupportedOperationException("Method getName not implemented in " + getClass());
}
@Override
public void init(final PsiElement element) {
throw new UnsupportedOperationException("Method init not implemented in " + getClass());
}
@Override
public Object[] getDependences() {
throw new UnsupportedOperationException("Method getDependences not implemented in " + getClass());
}
};
}
@Override
public int getContentType() {
return CONTENT_TYPE_UNKNOWN;
}
@@ -245,19 +261,23 @@ public abstract class AbstractDomChildrenDescriptor implements XmlElementDescrip
return null;
}
@Override
public void init(final PsiElement element) {
throw new UnsupportedOperationException("Method init not implemented in " + getClass());
}
@Override
public Object[] getDependences() {
throw new UnsupportedOperationException("Method getDependences not implemented in " + getClass());
}
@Override
@NonNls
public String getName() {
return getDefaultName();
}
@Override
public String getQualifiedName() {
return getDefaultName();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,47 +43,57 @@ public class DomAttributeXmlDescriptor implements NamespaceAwareXmlAttributeDesc
myProject = project;
}
@Override
public boolean isRequired() {
final Required required = myDescription.getAnnotation(Required.class);
return required != null && required.value();
}
@Override
public boolean isFixed() {
return false;
}
@Override
public boolean hasIdType() {
return false;
}
@Override
public boolean hasIdRefType() {
return false;
}
@Override
@Nullable
public String getDefaultValue() {
return null;
}//todo: refactor to hierarchy of value descriptor?
@Override
public boolean isEnumerated() {
return false;
}
@Override
@Nullable
public String[] getEnumeratedValues() {
return null;
}
@Override
@Nullable
public String validateValue(final XmlElement context, final String value) {
return null;
}
@Override
@Nullable
public PsiElement getDeclaration() {
return myDescription.getDeclaration(myProject);
}
@Override
@NonNls
public String getName(final PsiElement context) {
return getQualifiedAttributeName(context, myDescription.getXmlName());
@@ -108,6 +118,7 @@ public class DomAttributeXmlDescriptor implements NamespaceAwareXmlAttributeDesc
return localName;
}
@Override
@NonNls
public String getName() {
return getLocalName();
@@ -117,6 +128,7 @@ public class DomAttributeXmlDescriptor implements NamespaceAwareXmlAttributeDesc
return myDescription.getXmlName().getLocalName();
}
@Override
@Nullable
public String getNamespace(@NotNull XmlTag context) {
final DomInvocationHandler handler = DomManagerImpl.getDomManager(myProject).getDomHandler(context);
@@ -127,10 +139,12 @@ public class DomAttributeXmlDescriptor implements NamespaceAwareXmlAttributeDesc
return handler.createEvaluatedXmlName(myDescription.getXmlName()).getNamespace(context, handler.getFile());
}
@Override
public void init(final PsiElement element) {
throw new UnsupportedOperationException("Method init not implemented in " + getClass());
}
@Override
public Object[] getDependences() {
throw new UnsupportedOperationException("Method getDependences not implemented in " + getClass());
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,15 +50,18 @@ public class DomElementXmlDescriptor extends AbstractDomChildrenDescriptor imple
myChildrenDescription = childrenDescription;
}
@Override
public String getDefaultName() {
return myChildrenDescription.getXmlElementName();
}
@Override
@Nullable
public PsiElement getDeclaration() {
return myChildrenDescription.getDeclaration(myManager.getProject());
}
@Override
@NonNls
public String getName(final PsiElement context) {
final String name = getDefaultName();
@@ -95,65 +98,79 @@ public class DomElementXmlDescriptor extends AbstractDomChildrenDescriptor imple
myDomElement = domElement;
}
@Override
public String getName() {
return getXmlElementName();
}
@Override
public boolean isValid() {
return true;
}
@Override
public void navigate(boolean requestFocus) {
}
@Override
public boolean canNavigate() {
return false;
}
@Override
public boolean canNavigateToSource() {
return false;
}
@Override
@NotNull
public XmlName getXmlName() {
throw new UnsupportedOperationException("Method getXmlName not implemented in " + getClass());
}
@Override
@NotNull
public String getXmlElementName() {
return myDomElement.getXmlElementName();
}
@Override
@NotNull
public String getCommonPresentableName(@NotNull final DomNameStrategy strategy) {
throw new UnsupportedOperationException("Method getCommonPresentableName not implemented in " + getClass());
}
@Override
@NotNull
public String getCommonPresentableName(@NotNull final DomElement parent) {
throw new UnsupportedOperationException("Method getCommonPresentableName not implemented in " + getClass());
}
@Override
@NotNull
public List<? extends DomElement> getValues(@NotNull final DomElement parent) {
throw new UnsupportedOperationException("Method getValues not implemented in " + getClass());
}
@Override
@NotNull
public List<? extends DomElement> getStableValues(@NotNull final DomElement parent) {
throw new UnsupportedOperationException("Method getStableValues not implemented in " + getClass());
}
@Override
@NotNull
public Type getType() {
throw new UnsupportedOperationException("Method getType not implemented in " + getClass());
}
@Override
@NotNull
public DomNameStrategy getDomNameStrategy(@NotNull final DomElement parent) {
throw new UnsupportedOperationException("Method getDomNameStrategy not implemented in " + getClass());
}
@Override
public <T> T getUserData(final Key<T> key) {
return null;
}
@@ -163,11 +180,13 @@ public class DomElementXmlDescriptor extends AbstractDomChildrenDescriptor imple
return null;
}
@Override
@Nullable
public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) {
throw new UnsupportedOperationException("Method getAnnotation not implemented in " + getClass());
}
@Override
@Nullable
public PsiElement getDeclaration(final Project project) {
return PomService.convertToPsi(project, this);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,13 +38,16 @@ public class DomElementPattern<T extends DomElement,Self extends DomElementPatte
super(condition);
}
@Override
protected DomElement getParent(@NotNull DomElement t) {
return t.getParent();
}
@Override
protected DomElement[] getChildren(@NotNull final DomElement domElement) {
final List<DomElement> children = new ArrayList<DomElement>();
domElement.acceptChildren(new DomElementVisitor() {
@Override
public void visitDomElement(final DomElement element) {
children.add(element);
}
@@ -61,6 +64,7 @@ public class DomElementPattern<T extends DomElement,Self extends DomElementPatte
public Self withChild(@NonNls @NotNull final String localName, final ElementPattern pattern) {
return with(new PatternCondition<T>("withChild") {
@Override
public boolean accepts(@NotNull final T t, final ProcessingContext context) {
for (final AbstractDomChildrenDescription description : t.getGenericInfo().getChildrenDescriptions()) {
if (!(description instanceof DomChildrenDescription) || localName.equals(((DomChildrenDescription)description).getXmlElementName())) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,6 +52,7 @@ public class DomPatterns {
public static XmlElementPattern.Capture withDom(final ElementPattern<? extends DomElement> pattern) {
return new XmlElementPattern.Capture().with(new PatternCondition<XmlElement>("tagWithDom") {
@Override
public boolean accepts(@NotNull final XmlElement xmlElement, final ProcessingContext context) {
final DomManager manager = DomManager.getDomManager(xmlElement.getProject());
if (xmlElement instanceof XmlAttribute) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ import org.jetbrains.annotations.Nullable;
*/
public class GenericDomValuePattern<T> extends DomElementPattern<GenericDomValue<T>, GenericDomValuePattern<T>>{
private static final InitialPatternCondition CONDITION = new InitialPatternCondition(GenericDomValue.class) {
@Override
public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
return o instanceof GenericDomValue;
}
@@ -37,6 +38,7 @@ public class GenericDomValuePattern<T> extends DomElementPattern<GenericDomValue
protected GenericDomValuePattern(final Class<T> aClass) {
super(new InitialPatternCondition(aClass) {
@Override
public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
return o instanceof GenericDomValue && aClass.equals(DomUtil.getGenericValueParameter(((GenericDomValue)o).getDomElementType()));
}
@@ -46,6 +48,7 @@ public class GenericDomValuePattern<T> extends DomElementPattern<GenericDomValue
public GenericDomValuePattern<T> withStringValue(final ElementPattern<String> pattern) {
return with(new PatternCondition<GenericDomValue<T>>("withStringValue") {
@Override
public boolean accepts(@NotNull final GenericDomValue<T> genericDomValue, final ProcessingContext context) {
return pattern.getCondition().accepts(genericDomValue.getStringValue(), context);
}
@@ -59,6 +62,7 @@ public class GenericDomValuePattern<T> extends DomElementPattern<GenericDomValue
public GenericDomValuePattern<T> withValue(final ElementPattern<?> pattern) {
return with(new PatternCondition<GenericDomValue<T>>("withValue") {
@Override
public boolean accepts(@NotNull final GenericDomValue<T> genericDomValue, final ProcessingContext context) {
return pattern.getCondition().accepts(genericDomValue.getValue(), context);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,20 +34,24 @@ import org.jetbrains.annotations.Nullable;
*/
public abstract class AbstractConvertContext extends ConvertContext {
@Override
public final XmlTag getTag() {
return getInvocationElement().getXmlTag();
}
@Override
@Nullable
public XmlElement getXmlElement() {
return getInvocationElement().getXmlElement();
}
@Override
@NotNull
public final XmlFile getFile() {
return DomUtil.getFile(getInvocationElement());
}
@Override
public Module getModule() {
final DomFileElement<DomElement> fileElement = DomUtil.getFileElement(getInvocationElement());
if (fileElement == null) {
@@ -57,10 +61,12 @@ public abstract class AbstractConvertContext extends ConvertContext {
return fileElement.isValid() ? fileElement.getRootElement().getModule() : null;
}
@Override
public PsiManager getPsiManager() {
return getFile().getManager();
}
@Override
@Nullable
public GlobalSearchScope getSearchScope() {
GlobalSearchScope scope = null;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,6 +53,7 @@ public abstract class Converter<T> {
*/
@Deprecated
public static final Converter<Integer> INTEGER_CONVERTER = new Converter<Integer>() {
@Override
public Integer fromString(final String s, final ConvertContext context) {
if (s == null) return null;
try {
@@ -63,10 +64,12 @@ public abstract class Converter<T> {
}
}
@Override
public String toString(final Integer t, final ConvertContext context) {
return t == null? null: t.toString();
}
@Override
public String getErrorMessage(final String s, final ConvertContext context) {
return IdeBundle.message("value.should.be.integer");
}
@@ -74,10 +77,12 @@ public abstract class Converter<T> {
@Deprecated
public static final Converter<String> EMPTY_CONVERTER = new Converter<String>() {
@Override
public String fromString(final String s, final ConvertContext context) {
return s;
}
@Override
public String toString(final String t, final ConvertContext context) {
return t;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -220,7 +220,7 @@ public class DomFileDescription<T> {
* @return dependency item set
*/
@NotNull
public Set<? extends Object> getDependencyItems(XmlFile file) {
public Set<?> getDependencyItems(XmlFile file) {
return Collections.emptySet();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@ import javax.swing.*;
* @see com.intellij.ide.presentation.Presentation
*/
public abstract class DomIconProvider extends PomIconProvider {
@Override
public Icon getIcon(@NotNull PomTarget target, int flags) {
if (target instanceof DomTarget) {
return getIcon(((DomTarget)target).getDomElement(), flags);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@ public class DomMetaData<T extends DomElement> implements PsiWritableMetaData, P
@Nullable
private GenericDomValue myNameElement;
@Override
public final PsiElement getDeclaration() {
return myElement.getXmlTag();
}
@@ -42,11 +43,13 @@ public class DomMetaData<T extends DomElement> implements PsiWritableMetaData, P
return myElement;
}
@Override
@NonNls
public String getName(PsiElement context) {
return getName();
}
@Override
@NonNls
public final String getName() {
final String s = ElementPresentationManager.getElementName(myElement);
@@ -56,6 +59,7 @@ public class DomMetaData<T extends DomElement> implements PsiWritableMetaData, P
return value == null ? null : value.getStringValue();
}
@Override
public void init(PsiElement element) {
myElement = (T) DomManager.getDomManager(element.getProject()).getDomElement((XmlTag)element);
assert myElement != null : element;
@@ -71,6 +75,7 @@ public class DomMetaData<T extends DomElement> implements PsiWritableMetaData, P
return myElement.getGenericInfo().getNameDomElement(t);
}
@Override
public Object[] getDependences() {
final PsiElement declaration = getDeclaration();
if (myElement != null && myElement.isValid()) {
@@ -79,16 +84,19 @@ public class DomMetaData<T extends DomElement> implements PsiWritableMetaData, P
return new Object[]{declaration};
}
@Override
public void setName(String name) throws IncorrectOperationException {
if (myNameElement != null) {
myNameElement.setStringValue(name);
}
}
@Override
public String getTypeName() {
return ElementPresentationManager.getTypeNameForObject(myElement);
}
@Override
public Icon getIcon() {
return ElementPresentationManager.getIcon(myElement);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,6 +44,7 @@ import java.util.Map;
*/
public class DomResolveConverter<T extends DomElement> extends ResolvingConverter<T>{
private static final FactoryMap<Class<? extends DomElement>,DomResolveConverter> ourCache = new ConcurrentFactoryMap<Class<? extends DomElement>, DomResolveConverter>() {
@Override
@NotNull
protected DomResolveConverter create(final Class<? extends DomElement> key) {
return new DomResolveConverter(key);
@@ -51,11 +52,13 @@ public class DomResolveConverter<T extends DomElement> extends ResolvingConverte
};
private final boolean myAttribute;
private final SoftFactoryMap<DomElement, CachedValue<Map<String, DomElement>>> myResolveCache = new SoftFactoryMap<DomElement, CachedValue<Map<String, DomElement>>>() {
@Override
@NotNull
protected CachedValue<Map<String, DomElement>> create(final DomElement scope) {
final DomManager domManager = scope.getManager();
final Project project = domManager.getProject();
return CachedValuesManager.getManager(project).createCachedValue(new CachedValueProvider<Map<String, DomElement>>() {
@Override
public Result<Map<String, DomElement>> compute() {
final Map<String, DomElement> map = new THashMap<String, DomElement>();
visitDomElement(scope, map);
@@ -91,6 +94,7 @@ public class DomResolveConverter<T extends DomElement> extends ResolvingConverte
return ourCache.get(aClass);
}
@Override
public final T fromString(final String s, final ConvertContext context) {
if (s == null) return null;
return (T) myResolveCache.get(getResolvingScope(context)).getValue().get(s);
@@ -113,16 +117,19 @@ public class DomResolveConverter<T extends DomElement> extends ResolvingConverte
return invocationElement.getManager().getResolvingScope((GenericDomValue)invocationElement);
}
@Override
public String getErrorMessage(final String s, final ConvertContext context) {
return CodeInsightBundle.message("error.cannot.resolve.0.1", TypePresentationService.getService().getTypePresentableName(myClass), s);
}
@Override
public final String toString(final T t, final ConvertContext context) {
if (t == null) return null;
return ElementPresentationManager.getElementName(t);
}
@Override
@NotNull
public Collection<? extends T> getVariants(final ConvertContext context) {
final DomElement reference = context.getInvocationElement();
@@ -130,6 +137,7 @@ public class DomResolveConverter<T extends DomElement> extends ResolvingConverte
return (Collection<T>)myResolveCache.get(scope).getValue().values();
}
@Override
public LocalQuickFix[] getQuickFixes(final ConvertContext context) {
final DomElement element = context.getInvocationElement();
final GenericDomValue value = ((GenericDomValue)element).createStableCopy();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,6 +54,7 @@ public abstract class DomService {
*/
public Collection<VirtualFile> getDomFileCandidates(Class<? extends DomElement> rootElementClass, Project project, final GlobalSearchScope scope) {
return ContainerUtil.findAll(getDomFileCandidates(rootElementClass, project), new Condition<VirtualFile>() {
@Override
public boolean value(final VirtualFile file) {
return scope.contains(file);
}

Some files were not shown because too many files have changed in this diff Show More