Search in sources :

Example 6 with StrutsPackage

use of com.intellij.struts2.dom.struts.strutspackage.StrutsPackage 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;
}
Also used : StrutsPackage(com.intellij.struts2.dom.struts.strutspackage.StrutsPackage) GenericDomValue(com.intellij.util.xml.GenericDomValue)

Example 7 with StrutsPackage

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

the class JamParentPackageTest method checkResolve.

private static void checkResolve(@NotNull final JamParentPackage jamParentPackage) {
    final StrutsPackage strutsPackage = jamParentPackage.getValue().getValue();
    assertNotNull(strutsPackage);
    assertEquals("myPackage", strutsPackage.getName().getStringValue());
}
Also used : StrutsPackage(com.intellij.struts2.dom.struts.strutspackage.StrutsPackage)

Example 8 with StrutsPackage

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

the class ExceptionMappingResultResolveConverter method getVariants.

@NotNull
public Collection<? extends HasResultType> getVariants(final ConvertContext context) {
    final DomElement invocationElement = context.getInvocationElement();
    final Action action = invocationElement.getParentOfType(Action.class, true);
    if (action == null) {
        return Collections.emptySet();
    }
    final List<HasResultType> variants = new ArrayList<>();
    // Action-local first
    variants.addAll(action.getResults());
    final StrutsPackage strutsPackage = action.getStrutsPackage();
    final GlobalResults globalResults = strutsPackage.getGlobalResults();
    variants.addAll(globalResults.getResults());
    return variants;
}
Also used : DomElement(com.intellij.util.xml.DomElement) HasResultType(com.intellij.struts2.dom.struts.HasResultType) GlobalResults(com.intellij.struts2.dom.struts.strutspackage.GlobalResults) ArrayList(java.util.ArrayList) StrutsPackage(com.intellij.struts2.dom.struts.strutspackage.StrutsPackage) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with StrutsPackage

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

the class StrutsDataModel method updateDataModel.

private void updateDataModel() {
    final StrutsModel model = StrutsManager.getInstance(myProject).getModelByFile(myFile);
    if (model == null) {
        return;
    }
    for (final StrutsPackage strutsPackage : model.getStrutsPackages()) {
        for (final Action action : strutsPackage.getActions()) {
            final ActionNode actionNode = new ActionNode(action, action.getName().getStringValue());
            addNode(actionNode);
            for (final Result result : action.getResults()) {
                final PathReference pathReference = result.getValue();
                final String path = pathReference != null ? pathReference.getPath() : UNKNOWN;
                final ResultNode resultNode = new ResultNode(result, path);
                addNode(resultNode);
                final String resultName = result.getName().getStringValue();
                addEdge(new BasicStrutsEdge(actionNode, resultNode, resultName != null ? resultName : Result.DEFAULT_NAME));
            }
        }
    }
}
Also used : PathReference(com.intellij.openapi.paths.PathReference) Action(com.intellij.struts2.dom.struts.action.Action) BasicStrutsEdge(com.intellij.struts2.graph.beans.BasicStrutsEdge) ResultNode(com.intellij.struts2.graph.beans.ResultNode) StrutsModel(com.intellij.struts2.dom.struts.model.StrutsModel) ActionNode(com.intellij.struts2.graph.beans.ActionNode) StrutsPackage(com.intellij.struts2.dom.struts.strutspackage.StrutsPackage) Result(com.intellij.struts2.dom.struts.action.Result)

Example 10 with StrutsPackage

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

the class DefaultInterceptorRefResolveConverterImpl method getVariants.

@NotNull
public Collection<? extends InterceptorStack> getVariants(final ConvertContext context) {
    final List<InterceptorStack> results = new SmartList<>();
    final Processor<StrutsPackage> processor = strutsPackage -> {
        results.addAll(strutsPackage.getInterceptorStacks());
        return true;
    };
    final StrutsPackageHierarchyWalker walker = new StrutsPackageHierarchyWalker(getCurrentStrutsPackage(context), processor);
    walker.walkUp();
    return results;
}
Also used : DefaultInterceptorRefResolveConverter(com.intellij.struts2.dom.struts.strutspackage.DefaultInterceptorRefResolveConverter) Collection(java.util.Collection) NonNls(org.jetbrains.annotations.NonNls) ContainerUtil(com.intellij.util.containers.ContainerUtil) StrutsPackageHierarchyWalker(com.intellij.struts2.dom.struts.strutspackage.StrutsPackageHierarchyWalker) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) SmartList(com.intellij.util.SmartList) Processor(com.intellij.util.Processor) StrutsPackage(com.intellij.struts2.dom.struts.strutspackage.StrutsPackage) InterceptorStack(com.intellij.struts2.dom.struts.strutspackage.InterceptorStack) ConvertContext(com.intellij.util.xml.ConvertContext) NotNull(org.jetbrains.annotations.NotNull) Ref(com.intellij.openapi.util.Ref) DomUtil(com.intellij.util.xml.DomUtil) Condition(com.intellij.openapi.util.Condition) StrutsPackageHierarchyWalker(com.intellij.struts2.dom.struts.strutspackage.StrutsPackageHierarchyWalker) InterceptorStack(com.intellij.struts2.dom.struts.strutspackage.InterceptorStack) StrutsPackage(com.intellij.struts2.dom.struts.strutspackage.StrutsPackage) SmartList(com.intellij.util.SmartList) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

StrutsPackage (com.intellij.struts2.dom.struts.strutspackage.StrutsPackage)17 Nullable (org.jetbrains.annotations.Nullable)11 NotNull (org.jetbrains.annotations.NotNull)10 Ref (com.intellij.openapi.util.Ref)9 StrutsPackageHierarchyWalker (com.intellij.struts2.dom.struts.strutspackage.StrutsPackageHierarchyWalker)9 Processor (com.intellij.util.Processor)7 List (java.util.List)7 Condition (com.intellij.openapi.util.Condition)6 ResultType (com.intellij.struts2.dom.struts.strutspackage.ResultType)6 SmartList (com.intellij.util.SmartList)6 ContainerUtil (com.intellij.util.containers.ContainerUtil)6 ConvertContext (com.intellij.util.xml.ConvertContext)6 Collection (java.util.Collection)6 NonNls (org.jetbrains.annotations.NonNls)6 ConverterUtil (com.intellij.struts2.dom.ConverterUtil)4 StrutsModel (com.intellij.struts2.dom.struts.model.StrutsModel)3 DefaultClassRef (com.intellij.struts2.dom.struts.strutspackage.DefaultClassRef)3 InterceptorOrStackBase (com.intellij.struts2.dom.struts.strutspackage.InterceptorOrStackBase)3 InterceptorStack (com.intellij.struts2.dom.struts.strutspackage.InterceptorStack)3 DomUtil (com.intellij.util.xml.DomUtil)3