Search in sources :

Example 1 with StrutsConstantManager

use of com.intellij.struts2.model.constant.StrutsConstantManager in project intellij-plugins by JetBrains.

the class StrutsConstantValueReference method getElementConverterPair.

/**
   * Gets the DomElement and corresponding converter.
   *
   * @return {@code null} on errors or if one of both could not be resolved.
   */
@Nullable
private Pair<DomElement, Converter> getElementConverterPair() {
    final DomElement paramValueElement = DomUtil.getDomElement(myElement);
    assert paramValueElement != null;
    final DomElement domElement = paramValueElement.getParent();
    assert domElement instanceof ParamValue;
    final ParamValue initParamElement = (ParamValue) domElement;
    final String paramName = initParamElement.getParamName().getStringValue();
    if (StringUtil.isEmpty(paramName)) {
        return null;
    }
    final StrutsConstantManager constantManager = StrutsConstantManager.getInstance(myElement.getProject());
    @SuppressWarnings({ "ConstantConditions" }) final Converter converter = constantManager.findConverter(myElement, StrutsConstantKey.create(paramName));
    if (converter == null) {
        return null;
    }
    return Pair.create(paramValueElement, converter);
}
Also used : ParamValue(com.intellij.javaee.model.xml.ParamValue) StrutsConstantManager(com.intellij.struts2.model.constant.StrutsConstantManager) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with StrutsConstantManager

use of com.intellij.struts2.model.constant.StrutsConstantManager in project intellij-plugins by JetBrains.

the class ConstantValueConverterImpl method getConverter.

@Nullable
public Converter<?> getConverter(@NotNull final GenericDomValue domElement) {
    final Constant constant = (Constant) domElement.getParent();
    assert constant != null;
    final String constantName = constant.getName().getStringValue();
    if (StringUtil.isEmpty(constantName)) {
        return null;
    }
    final XmlTag xmlTag = domElement.getXmlTag();
    final StrutsConstantManager constantManager = StrutsConstantManager.getInstance(xmlTag.getProject());
    return constantManager.findConverter(xmlTag, StrutsConstantKey.create(constantName));
}
Also used : StrutsConstantManager(com.intellij.struts2.model.constant.StrutsConstantManager) XmlTag(com.intellij.psi.xml.XmlTag) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with StrutsConstantManager

use of com.intellij.struts2.model.constant.StrutsConstantManager in project intellij-plugins by JetBrains.

the class ConstantNameConverterImpl method getVariants.

@NotNull
public Collection<? extends String> getVariants(final ConvertContext context) {
    final Module module = context.getModule();
    if (module == null) {
        return Collections.emptyList();
    }
    final StrutsConstantManager constantManager = StrutsConstantManager.getInstance(module.getProject());
    return ContainerUtil.map(constantManager.getConstants(module), CONSTANT_NAME_FUNCTION);
}
Also used : StrutsConstantManager(com.intellij.struts2.model.constant.StrutsConstantManager) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

StrutsConstantManager (com.intellij.struts2.model.constant.StrutsConstantManager)3 Nullable (org.jetbrains.annotations.Nullable)2 ParamValue (com.intellij.javaee.model.xml.ParamValue)1 Module (com.intellij.openapi.module.Module)1 XmlTag (com.intellij.psi.xml.XmlTag)1 NotNull (org.jetbrains.annotations.NotNull)1