Search in sources :

Example 1 with DefaultClassRef

use of com.intellij.struts2.dom.struts.strutspackage.DefaultClassRef in project intellij-plugins by JetBrains.

the class ActionImpl method searchActionClass.

@Nullable
public PsiClass searchActionClass() {
    final GenericAttributeValue<PsiClass> actionClassAttribute = getActionClass();
    if (DomUtil.hasXml(actionClassAttribute)) {
        return actionClassAttribute.getValue();
    }
    // resolve parent package <default-class-ref> (walk upwards)
    final DefaultClassRef ref = getStrutsPackage().searchDefaultClassRef();
    if (ref != null) {
        return ref.getDefaultClass().getValue();
    }
    // nothing found in parents --> error highlighting
    return null;
}
Also used : PsiClass(com.intellij.psi.PsiClass) DefaultClassRef(com.intellij.struts2.dom.struts.strutspackage.DefaultClassRef) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with DefaultClassRef

use of com.intellij.struts2.dom.struts.strutspackage.DefaultClassRef 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)

Aggregations

DefaultClassRef (com.intellij.struts2.dom.struts.strutspackage.DefaultClassRef)2 Nullable (org.jetbrains.annotations.Nullable)2 Ref (com.intellij.openapi.util.Ref)1 PsiClass (com.intellij.psi.PsiClass)1 StrutsPackageHierarchyWalker (com.intellij.struts2.dom.struts.strutspackage.StrutsPackageHierarchyWalker)1