use of com.intellij.struts2.dom.struts.strutspackage.InterceptorStack in project intellij-plugins by JetBrains.
the class DefaultInterceptorRefResolveConverterImpl method fromString.
public InterceptorStack fromString(@Nullable @NonNls final String name, final ConvertContext context) {
if (name == null) {
return null;
}
final Condition<InterceptorStack> nameCondition = interceptorStack -> name.equals(interceptorStack.getName().getStringValue());
final Ref<InterceptorStack> resolveResult = new Ref<>();
final Processor<StrutsPackage> processor = strutsPackage -> {
final InterceptorStack result = ContainerUtil.find(strutsPackage.getInterceptorStacks(), nameCondition);
if (result != null) {
resolveResult.set(result);
return false;
}
return true;
};
final StrutsPackageHierarchyWalker walker = new StrutsPackageHierarchyWalker(getCurrentStrutsPackage(context), processor);
walker.walkUp();
return resolveResult.get();
}
use of com.intellij.struts2.dom.struts.strutspackage.InterceptorStack in project intellij-plugins by JetBrains.
the class InterceptorRefInStackParamNameCustomConverter method getCustomReferences.
@NotNull
@Override
public PsiReference[] getCustomReferences(final XmlAttributeValue nameAttributeValue, final DomElement paramsElement) {
if (!(paramsElement instanceof InterceptorRef)) {
return PsiReference.EMPTY_ARRAY;
}
InterceptorRef interceptorRef = (InterceptorRef) paramsElement;
final InterceptorOrStackBase value = interceptorRef.getName().getValue();
if (!(value instanceof InterceptorStack)) {
return PsiReference.EMPTY_ARRAY;
}
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(), ref -> Comparing.strEqual(refName, ref.getName().getStringValue()));
final List<PsiReference> customReferences = new ArrayList<>(2);
customReferences.add(new InterceptorRefPsiReference(nameAttributeValue, TextRange.from(1, idx), resolvedInterceptorRef, stack));
if (resolvedInterceptorRef == null) {
return ArrayUtil.toObjectArray(customReferences, PsiReference.class);
}
final String propertyText = text.substring(idx + 1, text.length());
final PsiClass paramsClass = resolvedInterceptorRef.getParamsClass();
final BeanPropertyPathReferenceSet beanPropertyPathReferenceSet = new BeanPropertyPathReferenceSet(propertyText, nameAttributeValue, idx + 2, '.', paramsClass, false);
Collections.addAll(customReferences, beanPropertyPathReferenceSet.getPsiReferences());
return ArrayUtil.toObjectArray(customReferences, PsiReference.class);
}
use of com.intellij.struts2.dom.struts.strutspackage.InterceptorStack 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;
}
use of com.intellij.struts2.dom.struts.strutspackage.InterceptorStack 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