use of com.intellij.struts2.dom.struts.strutspackage.StrutsPackageHierarchyWalker in project intellij-plugins by JetBrains.
the class ResultTypeResolvingConverterImpl method getVariants.
@NotNull
public Collection<? extends ResultType> getVariants(final ConvertContext context) {
final List<ResultType> results = new SmartList<>();
final Processor<StrutsPackage> processor = strutsPackage -> {
results.addAll(strutsPackage.getResultTypes());
return true;
};
final StrutsPackageHierarchyWalker walker = new StrutsPackageHierarchyWalker(ConverterUtil.getCurrentStrutsPackage(context), processor);
walker.walkUp();
return results;
}
use of com.intellij.struts2.dom.struts.strutspackage.StrutsPackageHierarchyWalker in project intellij-plugins by JetBrains.
the class StrutsPackageImpl method searchNamespace.
@NotNull
public String searchNamespace() {
final Ref<String> result = new Ref<>();
final StrutsPackageHierarchyWalker walker = new StrutsPackageHierarchyWalker(this, strutsPackage -> {
if (DomUtil.hasXml(strutsPackage.getNamespace())) {
result.set(strutsPackage.getNamespace().getStringValue());
return false;
}
return true;
});
walker.walkUp();
return result.isNull() ? DEFAULT_NAMESPACE : result.get();
}
use of com.intellij.struts2.dom.struts.strutspackage.StrutsPackageHierarchyWalker 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.StrutsPackageHierarchyWalker 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();
}
Aggregations