Search in sources :

Example 16 with Result

use of com.intellij.struts2.dom.struts.action.Result in project intellij-plugins by JetBrains.

the class StrutsPackageImpl method searchNamespace.

@NotNull
public String searchNamespace() {
    final Ref<String> result = new Ref<>();
    final StrutsPackageHierarchyWalker walker = new StrutsPackageHierarchyWalker(this, strutsPackage -> {
        if (DomUtil.hasXml(strutsPackage.getNamespace())) {
            result.set(strutsPackage.getNamespace().getStringValue());
            return false;
        }
        return true;
    });
    walker.walkUp();
    return result.isNull() ? DEFAULT_NAMESPACE : result.get();
}
Also used : StrutsPackageHierarchyWalker(com.intellij.struts2.dom.struts.strutspackage.StrutsPackageHierarchyWalker) DefaultClassRef(com.intellij.struts2.dom.struts.strutspackage.DefaultClassRef) Ref(com.intellij.openapi.util.Ref) NotNull(org.jetbrains.annotations.NotNull)

Example 17 with Result

use of com.intellij.struts2.dom.struts.action.Result in project intellij-plugins by JetBrains.

the class StrutsPackageImpl method searchDefaultResultType.

@Nullable
public ResultType searchDefaultResultType() {
    if (myCachedDefaultResultType == null) {
        final PsiFile containingFile = getContainingFile();
        if (containingFile == null) {
            return null;
        }
        myCachedDefaultResultType = CachedValuesManager.getManager(containingFile.getProject()).createCachedValue(() -> {
            final Ref<ResultType> result = new Ref<>();
            final StrutsPackageHierarchyWalker walker = new StrutsPackageHierarchyWalker(this, strutsPackage -> {
                final List<ResultType> resultTypes = strutsPackage.getResultTypes();
                for (final ResultType resultType : resultTypes) {
                    final GenericAttributeValue<Boolean> defaultAttribute = resultType.getDefault();
                    if (DomUtil.hasXml(defaultAttribute) && defaultAttribute.getValue() == Boolean.TRUE) {
                        result.set(resultType);
                        return false;
                    }
                }
                return true;
            });
            walker.walkUp();
            return CachedValueProvider.Result.createSingleDependency(result.get(), PsiModificationTracker.MODIFICATION_COUNT);
        }, false);
    }
    return myCachedDefaultResultType.getValue();
}
Also used : StrutsPackageHierarchyWalker(com.intellij.struts2.dom.struts.strutspackage.StrutsPackageHierarchyWalker) GenericAttributeValue(com.intellij.util.xml.GenericAttributeValue) StrutsPackageHierarchyWalker(com.intellij.struts2.dom.struts.strutspackage.StrutsPackageHierarchyWalker) CachedValuesManager(com.intellij.psi.util.CachedValuesManager) CachedValueProvider(com.intellij.psi.util.CachedValueProvider) PsiModificationTracker(com.intellij.psi.util.PsiModificationTracker) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) BaseImpl(com.intellij.jam.model.common.BaseImpl) CachedValue(com.intellij.psi.util.CachedValue) ResultType(com.intellij.struts2.dom.struts.strutspackage.ResultType) DefaultClassRef(com.intellij.struts2.dom.struts.strutspackage.DefaultClassRef) Processor(com.intellij.util.Processor) PsiFile(com.intellij.psi.PsiFile) StrutsPackage(com.intellij.struts2.dom.struts.strutspackage.StrutsPackage) NotNull(org.jetbrains.annotations.NotNull) Ref(com.intellij.openapi.util.Ref) DomUtil(com.intellij.util.xml.DomUtil) DefaultClassRef(com.intellij.struts2.dom.struts.strutspackage.DefaultClassRef) Ref(com.intellij.openapi.util.Ref) PsiFile(com.intellij.psi.PsiFile) List(java.util.List) ResultType(com.intellij.struts2.dom.struts.strutspackage.ResultType) GenericAttributeValue(com.intellij.util.xml.GenericAttributeValue) Nullable(org.jetbrains.annotations.Nullable)

Example 18 with Result

use of com.intellij.struts2.dom.struts.action.Result in project intellij-plugins by JetBrains.

the class StrutsPackageImpl method searchDefaultClassRef.

@Nullable
public DefaultClassRef searchDefaultClassRef() {
    final Ref<DefaultClassRef> result = new Ref<>();
    final StrutsPackageHierarchyWalker walker = new StrutsPackageHierarchyWalker(this, strutsPackage -> {
        if (DomUtil.hasXml(strutsPackage.getDefaultClassRef())) {
            result.set(strutsPackage.getDefaultClassRef());
            return false;
        }
        return true;
    });
    walker.walkUp();
    return result.get();
}
Also used : StrutsPackageHierarchyWalker(com.intellij.struts2.dom.struts.strutspackage.StrutsPackageHierarchyWalker) DefaultClassRef(com.intellij.struts2.dom.struts.strutspackage.DefaultClassRef) Ref(com.intellij.openapi.util.Ref) DefaultClassRef(com.intellij.struts2.dom.struts.strutspackage.DefaultClassRef) Nullable(org.jetbrains.annotations.Nullable)

Example 19 with Result

use of com.intellij.struts2.dom.struts.action.Result in project intellij-plugins by JetBrains.

the class ResultParamNameCustomConverter method getCustomReferences.

@NotNull
@Override
public PsiReference[] getCustomReferences(XmlAttributeValue nameAttributeValue, DomElement paramsElement) {
    if (!(paramsElement instanceof Result)) {
        return PsiReference.EMPTY_ARRAY;
    }
    Result result = (Result) paramsElement;
    Action action = DomUtil.getParentOfType(result, Action.class, true);
    assert action != null;
    return new PsiReference[] { new MergingBeanPropertyPathReference(nameAttributeValue, action, result) };
}
Also used : Action(com.intellij.struts2.dom.struts.action.Action) PsiReference(com.intellij.psi.PsiReference) Result(com.intellij.struts2.dom.struts.action.Result) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NotNull (org.jetbrains.annotations.NotNull)10 Result (com.intellij.struts2.dom.struts.action.Result)9 Action (com.intellij.struts2.dom.struts.action.Action)8 StrutsModel (com.intellij.struts2.dom.struts.model.StrutsModel)8 PathReference (com.intellij.openapi.paths.PathReference)6 Ref (com.intellij.openapi.util.Ref)6 StrutsPackage (com.intellij.struts2.dom.struts.strutspackage.StrutsPackage)6 StrutsPackageHierarchyWalker (com.intellij.struts2.dom.struts.strutspackage.StrutsPackageHierarchyWalker)6 Nullable (org.jetbrains.annotations.Nullable)6 Processor (com.intellij.util.Processor)5 List (java.util.List)5 NonNls (org.jetbrains.annotations.NonNls)5 ResultType (com.intellij.struts2.dom.struts.strutspackage.ResultType)4 Condition (com.intellij.openapi.util.Condition)3 DefaultClassRef (com.intellij.struts2.dom.struts.strutspackage.DefaultClassRef)3 SmartList (com.intellij.util.SmartList)3 ContainerUtil (com.intellij.util.containers.ContainerUtil)3 ConvertContext (com.intellij.util.xml.ConvertContext)3 Collection (java.util.Collection)3 NavigationItem (com.intellij.navigation.NavigationItem)2