use of com.intellij.util.xml.GenericDomValue in project intellij-community by JetBrains.
the class GoToSymbolProvider method createNavigationItem.
@Nullable
protected static NavigationItem createNavigationItem(final DomElement domElement) {
final GenericDomValue name = domElement.getGenericInfo().getNameDomElement(domElement);
assert name != null;
final XmlElement psiElement = name.getXmlElement();
final String value = name.getStringValue();
if (psiElement == null || value == null) {
return null;
}
final Icon icon = ElementPresentationManager.getIcon(domElement);
return createNavigationItem(psiElement, value, icon);
}
use of com.intellij.util.xml.GenericDomValue in project intellij-community by JetBrains.
the class BasicDomElementComponent method bindProperties.
protected final void bindProperties(final DomElement domElement) {
if (domElement == null)
return;
DomElementAnnotationsManager.getInstance(domElement.getManager().getProject()).addHighlightingListener(new DomElementAnnotationsManager.DomHighlightingListener() {
@Override
public void highlightingFinished(@NotNull final DomFileElement element) {
ApplicationManager.getApplication().invokeLater(() -> {
if (getComponent().isShowing() && element.isValid()) {
updateHighlighting();
}
});
}
}, this);
for (final AbstractDomChildrenDescription description : domElement.getGenericInfo().getChildrenDescriptions()) {
final JComponent boundComponent = getBoundComponent(description);
if (boundComponent != null) {
if (description instanceof DomFixedChildDescription && DomUtil.isGenericValueType(description.getType())) {
if ((description.getValues(domElement)).size() == 1) {
final GenericDomValue element = domElement.getManager().createStableValue(() -> domElement.isValid() ? (GenericDomValue) description.getValues(domElement).get(0) : null);
doBind(DomUIFactory.createControl(element, commitOnEveryChange(element)), boundComponent);
} else {
//todo not bound
}
} else if (description instanceof DomCollectionChildDescription) {
doBind(DomUIFactory.getDomUIFactory().createCollectionControl(domElement, (DomCollectionChildDescription) description), boundComponent);
}
}
}
reset();
}
use of com.intellij.util.xml.GenericDomValue in project intellij-community by JetBrains.
the class BasicDomElementsInspection method checkDomElement.
/**
* The default implementations checks for resolve problems (if {@link #shouldCheckResolveProblems(com.intellij.util.xml.GenericDomValue)}
* returns true), then runs annotators (see {@link com.intellij.util.xml.DomFileDescription#createAnnotator()}),
* checks for {@link com.intellij.util.xml.Required} and {@link com.intellij.util.xml.ExtendClass} annotation
* problems, checks for name identity (see {@link com.intellij.util.xml.NameValue} annotation) and custom annotation
* checkers (see {@link com.intellij.util.xml.highlighting.DomCustomAnnotationChecker}).
*
* @param element element to check
* @param holder a place to add problems to
* @param helper helper object
*/
@Override
protected void checkDomElement(DomElement element, DomElementAnnotationHolder holder, DomHighlightingHelper helper) {
final int oldSize = holder.getSize();
if (element instanceof GenericDomValue) {
final GenericDomValue genericDomValue = (GenericDomValue) element;
if (shouldCheckResolveProblems(genericDomValue)) {
helper.checkResolveProblems(genericDomValue, holder);
}
}
for (final Class<? extends T> aClass : getDomClasses()) {
helper.runAnnotators(element, holder, aClass);
}
if (oldSize != holder.getSize())
return;
if (!helper.checkRequired(element, holder).isEmpty())
return;
if (!(element instanceof GenericAttributeValue) && !GenericDomValue.class.equals(ReflectionUtil.getRawType(element.getDomElementType()))) {
if (!helper.checkNameIdentity(element, holder).isEmpty())
return;
}
helper.checkCustomAnnotations(element, holder);
}
use of com.intellij.util.xml.GenericDomValue in project intellij-community by JetBrains.
the class MavenVersionCompletionContributor method fillCompletionVariants.
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
if (parameters.getCompletionType() != CompletionType.BASIC)
return;
PsiElement element = parameters.getPosition();
PsiElement xmlText = element.getParent();
if (!(xmlText instanceof XmlText))
return;
PsiElement tagElement = xmlText.getParent();
if (!(tagElement instanceof XmlTag))
return;
XmlTag tag = (XmlTag) tagElement;
Project project = element.getProject();
DomElement domElement = DomManager.getDomManager(project).getDomElement(tag);
if (!(domElement instanceof GenericDomValue))
return;
DomElement parent = domElement.getParent();
if (parent instanceof MavenDomArtifactCoordinates && ((GenericDomValue) domElement).getConverter() instanceof MavenArtifactCoordinatesVersionConverter) {
MavenDomArtifactCoordinates coordinates = (MavenDomArtifactCoordinates) parent;
String groupId = coordinates.getGroupId().getStringValue();
String artifactId = coordinates.getArtifactId().getStringValue();
if (StringUtil.isEmptyOrSpaces(artifactId))
return;
CompletionResultSet newResultSet = result.withRelevanceSorter(CompletionService.getCompletionService().emptySorter().weigh(new LookupElementWeigher("mavenVersionWeigher") {
@Nullable
@Override
public Comparable weigh(@NotNull LookupElement element) {
return new NegatingComparable(new MavenVersionComparable(element.getLookupString()));
}
}));
MavenProjectIndicesManager indicesManager = MavenProjectIndicesManager.getInstance(project);
Set<String> versions;
if (StringUtil.isEmptyOrSpaces(groupId)) {
if (!(coordinates instanceof MavenDomPlugin))
return;
versions = indicesManager.getVersions(MavenArtifactUtil.DEFAULT_GROUPS[0], artifactId);
for (int i = 0; i < MavenArtifactUtil.DEFAULT_GROUPS.length; i++) {
versions = Sets.union(versions, indicesManager.getVersions(MavenArtifactUtil.DEFAULT_GROUPS[i], artifactId));
}
} else {
versions = indicesManager.getVersions(groupId, artifactId);
}
for (String version : versions) {
newResultSet.addElement(LookupElementBuilder.create(version));
}
newResultSet.addElement(LookupElementBuilder.create(RepositoryUtils.ReleaseVersionId));
newResultSet.addElement(LookupElementBuilder.create(RepositoryUtils.LatestVersionId));
}
}
use of com.intellij.util.xml.GenericDomValue in project intellij-plugins by JetBrains.
the class StrutsPackageExtendsResolveConverterImpl method removeCurrentElementFromVariants.
private static Collection<StrutsPackage> removeCurrentElementFromVariants(final ConvertContext context, final Collection<StrutsPackage> allVariants) {
final StrutsPackage currentElement = (StrutsPackage) DomUtil.getDomElement(context.getTag());
assert currentElement != null : "currentElement was null for " + context.getTag();
final GenericDomValue currentNameElement = currentElement.getGenericInfo().getNameDomElement(currentElement);
if (currentNameElement == null) {
// skip due to XML errors
return allVariants;
}
final String currentName = currentNameElement.getStringValue();
if (currentName == null) {
// skip due to XML errors
return allVariants;
}
final StrutsPackage currentElementInVariants = DomUtil.findByName(allVariants, currentName);
if (currentElementInVariants != null) {
allVariants.remove(currentElementInVariants);
}
return allVariants;
}
Aggregations