use of com.intellij.struts2.dom.struts.action.Result in project intellij-plugins by JetBrains.
the class ResultActionPropertyReferenceProvider method getReferencesByElement.
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull final PsiElement psiElement, @NotNull final ProcessingContext processingContext) {
final Result result = (Result) DomUtil.getDomElement(psiElement);
assert result != null : psiElement.getText();
final Action action = result.getParentOfType(Action.class, true);
assert action != null : psiElement.getText();
final PsiClass actionClass = action.searchActionClass();
if (actionClass == null) {
return PsiReference.EMPTY_ARRAY;
}
final int tagValueStartOffset = ElementManipulators.getOffsetInElement(result.getXmlTag());
PsiReference[] references = new PsiReference[1];
final String stringValue = result.getStringValue();
if (!StringUtil.isNotEmpty(stringValue)) {
return PsiReference.EMPTY_ARRAY;
}
final String resultText = StringUtil.replace(stringValue, "&", "&");
final int lastExpressionEnd = // missing '}'
Math.max(// missing '}'
resultText.length(), resultText.lastIndexOf(EXPRESSION_START));
int startOffset = 0;
while (startOffset < lastExpressionEnd) {
startOffset = resultText.indexOf(EXPRESSION_START, startOffset);
if (startOffset == -1) {
break;
}
startOffset += EXPRESSION_START.length();
final int closingBraceIdx = resultText.indexOf(EXPRESSION_END, startOffset);
final int length = (closingBraceIdx != -1 ? closingBraceIdx : resultText.length()) - startOffset;
final String expressionString = resultText.substring(startOffset, startOffset + length);
// we only "fake" OGNL here, skip method call expressions for now
if (StringUtil.containsChar(expressionString, '(')) {
continue;
}
final BeanPropertyPathReferenceSet propertyPathReferenceSet = new BeanPropertyPathReferenceSet(expressionString, psiElement, startOffset, '.', actionClass, true) {
// CTOR creates references eagerly, so we have to subclass here
@Override
public boolean isSoft() {
return false;
}
@NotNull
@Override
protected BeanPropertyPathReference createReference(final TextRange range, final int index) {
final TextRange shift = TextRange.from(range.getStartOffset() + tagValueStartOffset, // shift range to XmlTag value range
range.getLength());
return createBeanPropertyPathReference(shift, index);
}
};
references = ArrayUtil.mergeArrays(references, propertyPathReferenceSet.getPsiReferences());
}
return references;
}
use of com.intellij.struts2.dom.struts.action.Result in project intellij-plugins by JetBrains.
the class GoToPackageSymbolProvider method addItems.
protected void addItems(@NotNull final Module module, final String name, final List<NavigationItem> result) {
final StrutsModel strutsModel = StrutsManager.getInstance(module.getProject()).getCombinedModel(module);
if (strutsModel == null) {
return;
}
final List<StrutsPackage> strutsPackageList = strutsModel.getStrutsPackages();
for (final StrutsPackage strutsPackage : strutsPackageList) {
if (Comparing.strEqual(name, strutsPackage.getName().getStringValue())) {
final NavigationItem item = createNavigationItem(strutsPackage.getXmlTag(), name, StrutsIcons.STRUTS_PACKAGE);
result.add(item);
}
}
}
use of com.intellij.struts2.dom.struts.action.Result in project intellij-plugins by JetBrains.
the class ResultNode method getIcon.
@NotNull
public Icon getIcon() {
final Result result = getIdentifyingElement();
if (!result.isValid()) {
return UNKNOWN_RESULT_ICON;
}
final PathReference pathReference = result.getValue();
if (pathReference == null) {
return UNKNOWN_RESULT_ICON;
}
if (pathReference.resolve() == null) {
return UNKNOWN_RESULT_ICON;
}
final Icon pathReferenceIcon = pathReference.getIcon();
return pathReferenceIcon != null ? pathReferenceIcon : UNKNOWN_RESULT_ICON;
}
use of com.intellij.struts2.dom.struts.action.Result 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.action.Result in project intellij-plugins by JetBrains.
the class ResultTypeResolvingConverterImpl method fromString.
public ResultType fromString(@Nullable @NonNls final String name, final ConvertContext context) {
if (StringUtil.isEmpty(name)) {
return null;
}
final Condition<ResultType> nameCondition = resultType -> Comparing.equal(name, resultType.getName().getStringValue());
final Ref<ResultType> resolveResult = new Ref<>();
final Processor<StrutsPackage> processor = strutsPackage -> {
final ResultType result = ContainerUtil.find(strutsPackage.getResultTypes(), 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();
}
Aggregations