use of com.intellij.psi.xml.XmlElement in project android by JetBrains.
the class DimensionConverter method getVariants.
@NotNull
@Override
public Collection<String> getVariants(ConvertContext context) {
final XmlElement element = context.getXmlElement();
if (element == null) {
return Collections.emptyList();
}
final String value = ResourceReferenceConverter.getValue(element);
if (value == null) {
return Collections.emptyList();
}
final String intPrefix = getIntegerPrefix(value);
if (intPrefix.isEmpty()) {
return Collections.emptyList();
}
final List<String> result = new ArrayList<>(ourUnits.size());
for (String unit : ourUnits.keySet()) {
result.add(intPrefix + unit);
}
return result;
}
use of com.intellij.psi.xml.XmlElement in project intellij-community by JetBrains.
the class ExtendsClassChecker method checkExtendsClassInReferences.
public static List<DomElementProblemDescriptor> checkExtendsClassInReferences(final GenericDomValue element, final DomElementAnnotationHolder holder) {
if (!isPsiClassType(element)) {
return Collections.emptyList();
}
final Object valueObject = element.getValue();
if (!(valueObject instanceof PsiClass))
return Collections.emptyList();
final XmlElement valueElement = DomUtil.getValueElement(element);
if (valueElement == null)
return Collections.emptyList();
final PsiReference[] references = ourProvider.getReferencesByElement(valueElement, new ProcessingContext());
for (PsiReference reference : references) {
if (reference instanceof JavaClassReference) {
final PsiReferenceProvider psiReferenceProvider = ((JavaClassReference) reference).getProvider();
final String[] value = psiReferenceProvider instanceof JavaClassReferenceProvider ? JavaClassReferenceProvider.EXTEND_CLASS_NAMES.getValue(((JavaClassReferenceProvider) psiReferenceProvider).getOptions()) : null;
if (value != null && value.length != 0) {
for (String className : value) {
final List<DomElementProblemDescriptor> problemDescriptors = checkExtendClass(element, ((PsiClass) valueObject), className, false, false, true, false, true, true, holder);
if (!problemDescriptors.isEmpty()) {
return problemDescriptors;
}
}
}
}
}
return Collections.emptyList();
}
use of com.intellij.psi.xml.XmlElement in project intellij-plugins by JetBrains.
the class Struts2ModelInspectionVisitor method checkExtendableClassConverter.
private void checkExtendableClassConverter(final GenericAttributeValue clazzAttributeValue) {
if (myIgnoreExtendableClass)
return;
final XmlElement xmlElement = DomUtil.getValueElement(clazzAttributeValue);
if (xmlElement == null) {
return;
}
final PsiReference[] psiReferences = xmlElement.getReferences();
for (final PsiReference psiReference : psiReferences) {
final PsiElement resolveElement = psiReference.resolve();
if (resolveElement instanceof PsiClass) {
return;
}
}
final String[] referenceTypesUserData = clazzAttributeValue.getUserData(ExtendableClassConverter.REFERENCES_TYPES);
final String referenceTypes = referenceTypesUserData != null ? StringUtil.join(referenceTypesUserData, "|") : StrutsBundle.message("dom.extendable.class.converter.type.class");
final String message = StrutsBundle.message("dom.extendable.class.converter.cannot.resolve", referenceTypes, clazzAttributeValue.getStringValue());
// merge all available QuickFixes (create class/package(s)..)
LocalQuickFix[] quickFixes = LocalQuickFix.EMPTY_ARRAY;
for (final PsiReference psiReference : psiReferences) {
if (psiReference instanceof LocalQuickFixProvider) {
final LocalQuickFix[] fixes = ((LocalQuickFixProvider) psiReference).getQuickFixes();
if (fixes != null) {
quickFixes = ArrayUtil.mergeArrays(fixes, quickFixes);
}
}
}
holder.createProblem(clazzAttributeValue, message, quickFixes);
}
use of com.intellij.psi.xml.XmlElement in project intellij-plugins by JetBrains.
the class StrutsPathReferenceConverterImpl method fromString.
public PathReference fromString(@Nullable final String value, final ConvertContext context) {
if (value == null) {
return null;
}
final XmlElement element = context.getReferenceXmlElement();
if (element == null) {
return null;
}
final Module module = context.getModule();
if (module == null) {
return null;
}
return PathReferenceManager.getInstance().getCustomPathReference(value, module, element, getResultContributors());
}
use of com.intellij.psi.xml.XmlElement in project intellij-plugins by JetBrains.
the class IncludeFileResolvingConverterImpl method fromString.
public PsiFile fromString(@Nullable @NonNls final String value, final ConvertContext context) {
if (value == null) {
return null;
}
final XmlElement xmlElement = context.getReferenceXmlElement();
if (xmlElement == null) {
return null;
}
final PsiReference[] references = createReferences((GenericDomValue) context.getInvocationElement(), xmlElement, context);
if (references.length == 0) {
return null;
}
final PsiElement element = references[references.length - 1].resolve();
return element instanceof PsiFile ? (PsiFile) element : null;
}
Aggregations