Package com.intellij.struts2.dom.struts.model

Examples of com.intellij.struts2.dom.struts.model.StrutsModel


    final String text = nameAttributeValue.getValue();
    final boolean hasDot = StringUtil.containsChar(text, '.');
    final int idx = hasDot ? text.indexOf('.') : text.length();
    final String refName = text.substring(0, idx);

    final InterceptorStack stack = (InterceptorStack) value;
    final InterceptorRef resolvedInterceptorRef =
        ContainerUtil.find(stack.getInterceptorRefs(), new Condition<InterceptorRef>() {
          @Override
          public boolean value(final InterceptorRef ref) {
            return Comparing.strEqual(refName, ref.getName().getStringValue());
          }
        });
View Full Code Here


        if (o instanceof Result) {
          final Result result = (Result) o;
          final PathReference pathReference = result.getValue();
          final String displayPath = pathReference != null ? pathReference.getPath() : "???";
          final ResultType resultType = result.getEffectiveResultType();
          final String resultTypeValue = resultType != null ? resultType.getName().getStringValue() : "???";

          final DocumentationBuilder builder = new DocumentationBuilder();
          builder.addLine("Path", displayPath)
                 .addLine("Type", resultTypeValue);
          return builder.getText();
View Full Code Here

    // hack for STRPL-85: suppress <param>-highlighting within <result> for certain result-types
    if (converter instanceof ParamNameConverter) {
      final Result result = DomUtil.getParentOfType(value, Result.class, false);
      if (result != null) {
        final ResultType resultType = result.getEffectiveResultType();
        if (resultType == null) {
          return false; // error
        }

        final String resultTypeValue = resultType.getName().getStringValue();
        if (resultTypeValue != null && ResultTypeResolver.isChainOrRedirectType(resultTypeValue)) {
          return false;
        }
      }
    }

    final String stringValue = value.getStringValue();

    // suppress <action> "method" when using wildcards
    if (converter instanceof ActionMethodConverter &&
        ConverterUtil.hasWildcardReference(stringValue)) {
      return false;
    }

    // suppress <result> path
    if (converter instanceof StrutsPathReferenceConverter) {

      if (stringValue == null) {
        return false;
      }

      // nested <param>-tags are present
      if (!((ParamsElement)value).getParams().isEmpty()) {
        return false;
      }

      // unsupported result-type
      final ResultType resultType = ((HasResultType)value).getEffectiveResultType();
      if (resultType == null) {
        return false;
      }

      if (!ResultTypeResolver.hasResultTypeContributor(resultType.getName().getStringValue())) {
        return false;
      }

      // suppress paths with wildcard reference
      if (ConverterUtil.hasWildcardReference(stringValue)) {
View Full Code Here

      @Override
      public boolean process(final Action action) {
        final PsiClass actionClass = action.searchActionClass();
        if (actionClass != null) {
          for (final Result result1 : action.getResults()) {
            final ResultType resultType = result1.getEffectiveResultType();
            if (resultType != null &&
                FreeMarkerStrutsResultContributor.FREEMARKER.equals(resultType.getName().getStringValue())) {
              final PathReference reference = result1.getValue();
              final PsiElement target = reference == null ? null : reference.resolve();
              if (target != null &&
                  (file.getManager().areElementsEquivalent(file, target) ||
                   file.getManager().areElementsEquivalent(file.getOriginalFile(), target))) {
View Full Code Here

    }

    final List<HasResultType> variants = new ArrayList<HasResultType>();
    variants.addAll(action.getResults()); // Action-local first

    final StrutsPackage strutsPackage = action.getStrutsPackage();
    final GlobalResults globalResults = strutsPackage.getGlobalResults();
    variants.addAll(globalResults.getResults());

    return variants;
  }
View Full Code Here

  private static void registerDocumentationProviders() {
    ElementPresentationManager.registerDocumentationProvider(new NullableFunction<Object, String>() {
      public String fun(final Object o) {
        if (o instanceof Action) {
          final Action action = (Action) o;
          final StrutsPackage strutsPackage = action.getStrutsPackage();

          final DocumentationBuilder builder = new DocumentationBuilder();
          final PsiClass actionClass = action.searchActionClass();
          builder.addLine("Action", action.getName().getStringValue())
                 .addLine("Class", actionClass != null ? actionClass.getQualifiedName() : null)
                 .addLine("Method", action.getMethod().getStringValue())
                 .addLine("Package", strutsPackage.getName().getStringValue())
                 .addLine("Namespace", strutsPackage.searchNamespace());

          return builder.getText();
        }

        if (o instanceof Result) {
View Full Code Here

   * @param context Invoking context.
   * @return Parent package.
   */
  @NotNull
  public static StrutsPackage getCurrentStrutsPackage(final ConvertContext context) {
    final StrutsPackage strutsPackage = DomUtil.getParentOfType(context.getInvocationElement(),
                                                                StrutsPackage.class,
                                                                true);
    assert strutsPackage != null : context.getInvocationElement();
    return strutsPackage;
  }
View Full Code Here

public abstract class StrutsPackageImpl extends BaseImpl implements StrutsPackage {

  @NotNull
  public String searchNamespace() {
    final Ref<String> result = new Ref<String>();
    final StrutsPackageHierarchyWalker walker = new StrutsPackageHierarchyWalker(this, new Processor<StrutsPackage>() {
      @Override
      public boolean process(final StrutsPackage strutsPackage) {
        if (DomUtil.hasXml(strutsPackage.getNamespace())) {
          result.set(strutsPackage.getNamespace().getStringValue());
          return false;
        }
        return true;
      }
    });
    walker.walkUp();

    return result.isNull() ? DEFAULT_NAMESPACE : result.get();
  }
View Full Code Here

  }

  @Nullable
  public DefaultClassRef searchDefaultClassRef() {
    final Ref<DefaultClassRef> result = new Ref<DefaultClassRef>();
    final StrutsPackageHierarchyWalker walker = new StrutsPackageHierarchyWalker(this, new Processor<StrutsPackage>() {
      @Override
      public boolean process(final StrutsPackage strutsPackage) {
        if (DomUtil.hasXml(strutsPackage.getDefaultClassRef())) {
          result.set(strutsPackage.getDefaultClassRef());
          return false;
        }
        return true;
      }
    });
    walker.walkUp();

    return result.get();
  }
View Full Code Here

          ValidatorModelInspection.class, ValidatorConfigModelInspection.class);
  }

  public Collection<VirtualFile> getFilesToProcess(final Project project, final CompileContext context) {
    final PsiManager psiManager = PsiManager.getInstance(project);
    final ValidatorManager validatorManager = ValidatorManager.getInstance(project);

    // cache S2facet/validation settings per module
    @SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
    final FactoryMap<Module, Boolean> enabledForModule = new FactoryMap<Module, Boolean>() {
      protected Boolean create(final Module module) {
        return isEnabledForModule(module) &&
               StrutsFacet.getInstance(module) != null;
      }
    };

    // collect all validation.xml files located in sources of S2-modules
    final Set<VirtualFile> files = new THashSet<VirtualFile>();
    for (final VirtualFile file : context.getProjectCompileScope().getFiles(StdFileTypes.XML, true)) {
      if (StringUtil.endsWith(file.getName(), FILENAME_EXTENSION_VALIDATION_XML)) {
        final PsiFile psiFile = psiManager.findFile(file);
        if (psiFile instanceof XmlFile &&
            validatorManager.isValidatorsFile((XmlFile) psiFile)) {
          final Module module = ModuleUtilCore.findModuleForFile(file, project);
          if (module != null &&
              enabledForModule.get(module)) {
            files.add(file);
          }
        }
      }
    }

    // add validator-config.xml if not default one from xwork.jar
    final Set<VirtualFile> descriptorFiles = new THashSet<VirtualFile>();
    for (final Module module : ModuleManager.getInstance(project).getModules()) {
      if (enabledForModule.get(module)) {
        final PsiFile psiFile = validatorManager.getValidatorConfigFile(module);
        if (psiFile != null &&
            validatorManager.isCustomValidatorConfigFile(psiFile)) {
          InspectionValidatorUtil.addFile(descriptorFiles, psiFile);
        }
      }
    }
    files.addAll(InspectionValidatorUtil.expandCompileScopeIfNeeded(descriptorFiles, context));
View Full Code Here

TOP

Related Classes of com.intellij.struts2.dom.struts.model.StrutsModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.