use of com.intellij.struts2.dom.struts.strutspackage.StrutsPackage 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();
}
use of com.intellij.struts2.dom.struts.strutspackage.StrutsPackage 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();
}
use of com.intellij.struts2.dom.struts.strutspackage.StrutsPackage in project intellij-plugins by JetBrains.
the class StrutsResultContributor method getNamespace.
/**
* Gets the current namespace for the given element.
*
* @param psiElement Current element.
* @return {@code null} on XML errors or if {@link #matchesResultType(String)} returns {@code false}.
*/
@Nullable
protected final String getNamespace(@NotNull final PsiElement psiElement) {
final DomElement resultElement = DomUtil.getDomElement(psiElement);
if (resultElement == null) {
// XML syntax error
return null;
}
assert resultElement instanceof HasResultType : "not instance of HasResultType: " + resultElement + ", text: " + psiElement.getText();
final ResultType effectiveResultType = ((HasResultType) resultElement).getEffectiveResultType();
if (effectiveResultType == null) {
return null;
}
final String resultType = effectiveResultType.getName().getStringValue();
if (resultType == null || !matchesResultType(resultType)) {
return null;
}
final StrutsPackage strutsPackage = resultElement.getParentOfType(StrutsPackage.class, true);
if (strutsPackage == null) {
// XML syntax error
return null;
}
return strutsPackage.searchNamespace();
}
use of com.intellij.struts2.dom.struts.strutspackage.StrutsPackage in project intellij-plugins by JetBrains.
the class StrutsModelImpl method getAllInterceptorsAndStacks.
@NotNull
public Set<InterceptorOrStackBase> getAllInterceptorsAndStacks() {
final Set<InterceptorOrStackBase> interceptorOrStackBases = new HashSet<>();
for (final StrutsPackage strutsPackage : getStrutsPackages()) {
final List<InterceptorStack> interceptorList = strutsPackage.getInterceptorStacks();
interceptorOrStackBases.addAll(interceptorList);
final List<Interceptor> interceptors = strutsPackage.getInterceptors();
interceptorOrStackBases.addAll(interceptors);
}
return interceptorOrStackBases;
}
Aggregations