use of com.intellij.struts2.dom.struts.strutspackage.InterceptorOrStackBase in project intellij-plugins by JetBrains.
the class JamDefaultInterceptorRefTest method checkResolve.
private static void checkResolve(@NotNull final JamDefaultInterceptorRef jamDefaultInterceptorRef, @NotNull final String interceptorName) {
final InterceptorOrStackBase interceptorOrStackBase = jamDefaultInterceptorRef.getValue().getValue();
assertNotNull(interceptorOrStackBase);
assertEquals(interceptorName, interceptorOrStackBase.getName().getStringValue());
}
use of com.intellij.struts2.dom.struts.strutspackage.InterceptorOrStackBase in project intellij-plugins by JetBrains.
the class InterceptorRefResolveConverterImpl method fromString.
public InterceptorOrStackBase fromString(@Nullable @NonNls final String name, final ConvertContext context) {
if (name == null) {
return null;
}
final Condition<InterceptorOrStackBase> nameCondition = interceptorOrStackBase -> name.equals(interceptorOrStackBase.getName().getStringValue());
final Ref<InterceptorOrStackBase> resolveResult = new Ref<>();
final Processor<StrutsPackage> processor = strutsPackage -> {
final InterceptorOrStackBase result = ContainerUtil.find(getAllInterceptors(strutsPackage), nameCondition);
if (result != null) {
resolveResult.set(result);
return false;
}
return true;
};
final StrutsPackageHierarchyWalker walker = new StrutsPackageHierarchyWalker(ConverterUtil.getCurrentStrutsPackage(context), processor);
walker.walkUp();
return resolveResult.get();
}
use of com.intellij.struts2.dom.struts.strutspackage.InterceptorOrStackBase 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.InterceptorOrStackBase in project intellij-plugins by JetBrains.
the class InterceptorRefResolveConverterImpl method getVariants.
@NotNull
public Collection<? extends InterceptorOrStackBase> getVariants(final ConvertContext context) {
final List<InterceptorOrStackBase> results = new SmartList<>();
final Processor<StrutsPackage> processor = strutsPackage -> {
final List<InterceptorOrStackBase> allInterceptors = getAllInterceptors(strutsPackage);
results.addAll(allInterceptors);
return true;
};
final StrutsPackageHierarchyWalker walker = new StrutsPackageHierarchyWalker(ConverterUtil.getCurrentStrutsPackage(context), processor);
walker.walkUp();
return results;
}
use of com.intellij.struts2.dom.struts.strutspackage.InterceptorOrStackBase 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