use of com.intellij.struts2.dom.struts.model.StrutsModel in project intellij-plugins by JetBrains.
the class IncludeFileResolvingConverterImpl method createReferences.
@NotNull
public PsiReference[] createReferences(@NotNull final GenericDomValue genericDomValue, @NotNull final PsiElement element, @NotNull final ConvertContext context) {
final String s = genericDomValue.getStringValue();
if (s == null) {
return PsiReference.EMPTY_ARRAY;
}
final StrutsModel model = ConverterUtil.getStrutsModel(context);
if (model == null) {
return PsiReference.EMPTY_ARRAY;
}
final int offset = ElementManipulators.getOffsetInElement(element);
return new FilePathReferenceProvider() {
protected boolean isPsiElementAccepted(final PsiElement element) {
return super.isPsiElementAccepted(element) && (!(element instanceof PsiFile) || isFileAccepted(model, (PsiFile) element));
}
}.getReferencesByElement(element, s, offset, true);
}
use of com.intellij.struts2.dom.struts.model.StrutsModel in project intellij-plugins by JetBrains.
the class ActionChainOrRedirectResultContributor method createReferences.
public boolean createReferences(@NotNull final PsiElement psiElement, @NotNull final List<PsiReference> references, final boolean soft) {
final StrutsModel model = StrutsManager.getInstance(psiElement.getProject()).getModelByFile((XmlFile) psiElement.getContainingFile());
if (model == null) {
return false;
}
final String currentPackage = getNamespace(psiElement);
if (currentPackage == null) {
return false;
}
final PsiReference chainReference = new ActionChainReference((XmlTag) psiElement, currentPackage, model);
references.add(chainReference);
return true;
}
use of com.intellij.struts2.dom.struts.model.StrutsModel in project intellij-plugins by JetBrains.
the class StrutsModelFactory method computeAllModels.
protected List<StrutsModel> computeAllModels(@NotNull final Module module) {
final PsiManager psiManager = PsiManager.getInstance(module.getProject());
final StrutsManager strutsManager = StrutsManager.getInstance(module.getProject());
final Set<StrutsFileSet> fileSets = strutsManager.getAllConfigFileSets(module);
final List<StrutsModel> models = new ArrayList<>(fileSets.size());
for (final StrutsFileSet set : fileSets) {
if (set.isRemoved()) {
continue;
}
final Set<XmlFile> files = new LinkedHashSet<>(set.getFiles().size());
for (final VirtualFilePointer filePointer : set.getFiles()) {
if (!filePointer.isValid())
continue;
final VirtualFile file = filePointer.getFile();
if (file == null) {
continue;
}
final PsiFile psiFile = psiManager.findFile(file);
if (psiFile instanceof XmlFile) {
final StrutsRoot strutsRootDom = getDom((XmlFile) psiFile);
if (strutsRootDom != null) {
files.add((XmlFile) psiFile);
// TODO addIncludes(files, strutsRootDom);
}
}
}
if (!files.isEmpty()) {
final DomFileElement<StrutsRoot> element = createMergedModelRoot(files);
final StrutsModel model;
if (element != null) {
model = new StrutsModelImpl(element, files);
models.add(model);
}
}
}
return models;
}
use of com.intellij.struts2.dom.struts.model.StrutsModel in project intellij-plugins by JetBrains.
the class ActionAnnotatorBase method collectNavigationMarkers.
@Override
protected void collectNavigationMarkers(@NotNull final PsiElement element, final Collection<? super RelatedItemLineMarkerInfo> lineMarkerInfos) {
if (!(element instanceof PsiIdentifier))
return;
final PsiClass clazz = getActionPsiClass(element.getParent());
if (clazz == null || clazz.getNameIdentifier() != element) {
return;
}
// do not run on non-public, abstract classes or interfaces
if (clazz.isInterface() || clazz.isAnnotationType() || !clazz.hasModifierProperty(PsiModifier.PUBLIC) || clazz.hasModifierProperty(PsiModifier.ABSTRACT)) {
return;
}
// short exit if Struts Facet not present
final Module module = ModuleUtilCore.findModuleForPsiElement(clazz);
if (module == null || StrutsFacet.getInstance(module) == null) {
return;
}
final StrutsManager strutsManager = StrutsManager.getInstance(element.getProject());
final StrutsModel strutsModel = strutsManager.getCombinedModel(module);
if (strutsModel == null) {
return;
}
installValidationTargets(element, lineMarkerInfos, clazz);
final List<Action> actions = strutsModel.findActionsByClass(clazz);
if (actions.isEmpty()) {
return;
}
installActionTargets(element, lineMarkerInfos, actions);
installActionMethods(lineMarkerInfos, clazz, actions);
}
use of com.intellij.struts2.dom.struts.model.StrutsModel in project intellij-plugins by JetBrains.
the class ActionPropertyReferenceProvider method getReferencesByElement.
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull final PsiElement psiElement, @NotNull final ProcessingContext processingContext) {
if (TaglibUtil.isDynamicExpression(((XmlAttributeValue) psiElement).getValue())) {
return PsiReference.EMPTY_ARRAY;
}
final XmlTag tag = PsiTreeUtil.getParentOfType(psiElement, XmlTag.class);
assert tag != null;
final XmlTag actionTag = findEnclosingTag(tag, tag.getNamespacePrefix());
if (actionTag == null) {
return PsiReference.EMPTY_ARRAY;
}
final String actionName = Comparing.equal(actionTag.getLocalName(), "action") ? actionTag.getAttributeValue("name") : actionTag.getAttributeValue("action");
if (actionName == null || TaglibUtil.isDynamicExpression(actionName)) {
return PsiReference.EMPTY_ARRAY;
}
final StrutsManager strutsManager = StrutsManager.getInstance(psiElement.getProject());
final StrutsModel strutsModel = strutsManager.getCombinedModel(psiElement);
if (strutsModel == null) {
return PsiReference.EMPTY_ARRAY;
}
final List<Action> actions = strutsModel.findActionsByName(actionName, actionTag.getAttributeValue("namespace"));
if (actions.size() != 1) {
return PsiReference.EMPTY_ARRAY;
}
final Action action = actions.get(0);
return new BeanPropertyPathReferenceSet(psiElement, action.searchActionClass(), supportsReadOnlyProperties) {
// TODO CTOR creates references eagerly, so we have to subclass here
@Override
public boolean isSoft() {
return false;
}
}.getPsiReferences();
}
Aggregations