use of com.intellij.struts2.dom.struts.model.StrutsModel in project intellij-plugins by JetBrains.
the class Struts2ModelValidator method getFilesToProcess.
public Collection<VirtualFile> getFilesToProcess(final Project project, final CompileContext context) {
final StrutsManager strutsManager = StrutsManager.getInstance(project);
final PsiManager psiManager = PsiManager.getInstance(project);
// cache validation settings per module
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection") final FactoryMap<Module, Boolean> enabledForModule = new FactoryMap<Module, Boolean>() {
protected Boolean create(final Module module) {
return isEnabledForModule(module);
}
};
final Set<VirtualFile> files = new THashSet<>();
for (final VirtualFile file : context.getCompileScope().getFiles(StdFileTypes.XML, false)) {
final Module module = context.getModuleByFile(file);
if (module != null && enabledForModule.get(module)) {
final PsiFile psiFile = psiManager.findFile(file);
if (psiFile instanceof XmlFile) {
final StrutsModel model = strutsManager.getModelByFile((XmlFile) psiFile);
if (model != null) {
for (final XmlFile configFile : model.getConfigFiles()) {
ContainerUtil.addIfNotNull(files, configFile.getVirtualFile());
}
}
}
}
}
InspectionValidatorUtil.expandCompileScopeIfNeeded(files, context);
return files;
}
use of com.intellij.struts2.dom.struts.model.StrutsModel in project intellij-plugins by JetBrains.
the class ActionPathResultContributor 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 TextRange rangeInElement = ElementManipulators.getManipulator(psiElement).getRangeInElement(psiElement);
final String fullPath = psiElement.getText();
final String trimmedPath = rangeInElement.substring(fullPath);
final TextRange trimmedPathRange = TextRange.from(rangeInElement.getStartOffset(), PathReference.trimPath(trimmedPath).length());
final PsiReference actionReference = new ActionPathReference((XmlTag) psiElement, trimmedPathRange, currentPackage, model);
references.add(actionReference);
return false;
}
use of com.intellij.struts2.dom.struts.model.StrutsModel in project intellij-plugins by JetBrains.
the class StrutsPackageExtendsResolveConverterImpl method getReferenceVariants.
@Override
protected Object[] getReferenceVariants(ConvertContext context, GenericDomValue<List<StrutsPackage>> genericDomValue) {
final StrutsModel strutsModel = ConverterUtil.getStrutsModel(context);
if (strutsModel == null) {
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
final Collection<StrutsPackage> variants = removeCurrentElementFromVariants(context, strutsModel.getStrutsPackages());
return ElementPresentationManager.getInstance().createVariants(variants);
}
use of com.intellij.struts2.dom.struts.model.StrutsModel in project intellij-plugins by JetBrains.
the class ActionLinkReferenceProvider method createReferences.
protected PsiReference[] createReferences(@NotNull final PsiElement psiElement, final int offset, final String text, @Nullable final ServletMappingInfo info, final boolean soft) {
final StrutsModel strutsModel = StrutsManager.getInstance(psiElement.getProject()).getCombinedModel(psiElement);
if (strutsModel == null) {
return PsiReference.EMPTY_ARRAY;
}
final List<String> actionExtensions = StrutsConstantHelper.getActionExtensions(psiElement);
if (actionExtensions.isEmpty()) {
return PsiReference.EMPTY_ARRAY;
}
if (text.indexOf('/') != -1) {
return new PsiReference[] { new ActionLinkPackageReference(psiElement, offset, text, soft, strutsModel), new ActionLinkReference(psiElement, offset, text, soft, strutsModel, actionExtensions) };
} else {
return new PsiReference[] { new ActionLinkReference(psiElement, offset, text, soft, strutsModel, actionExtensions) };
}
}
use of com.intellij.struts2.dom.struts.model.StrutsModel in project intellij-plugins by JetBrains.
the class NamespaceReferenceProvider method getReferencesByElement.
@NotNull
public PsiReference[] getReferencesByElement(@NotNull final PsiElement psiElement, @NotNull final ProcessingContext context) {
final StrutsManager strutsManager = StrutsManager.getInstance(psiElement.getProject());
final StrutsModel strutsModel = strutsManager.getCombinedModel(psiElement);
if (strutsModel == null) {
return PsiReference.EMPTY_ARRAY;
}
return new PsiReference[] { new NamespaceReference((XmlAttributeValue) psiElement, strutsModel) };
}
Aggregations