use of com.intellij.openapi.paths.PathReference in project intellij-plugins by JetBrains.
the class StrutsDataModel method updateDataModel.
private void updateDataModel() {
final StrutsModel model = StrutsManager.getInstance(myProject).getModelByFile(myFile);
if (model == null) {
return;
}
for (final StrutsPackage strutsPackage : model.getStrutsPackages()) {
for (final Action action : strutsPackage.getActions()) {
final ActionNode actionNode = new ActionNode(action, action.getName().getStringValue());
addNode(actionNode);
for (final Result result : action.getResults()) {
final PathReference pathReference = result.getValue();
final String path = pathReference != null ? pathReference.getPath() : UNKNOWN;
final ResultNode resultNode = new ResultNode(result, path);
addNode(resultNode);
final String resultName = result.getName().getStringValue();
addEdge(new BasicStrutsEdge(actionNode, resultNode, resultName != null ? resultName : Result.DEFAULT_NAME));
}
}
}
}
use of com.intellij.openapi.paths.PathReference in project intellij-plugins by JetBrains.
the class Struts2UrlConverter method getTargetPaths.
public Collection<String> getTargetPaths(@NotNull final PsiFile sourceFile, @NotNull final WebFacet webFacet) {
final StrutsModel combinedModel = StrutsManager.getInstance(sourceFile.getProject()).getCombinedModel(webFacet.getModule());
if (combinedModel == null) {
return Collections.emptyList();
}
final List<String> actionExtensions = StrutsConstantHelper.getActionExtensions(sourceFile);
if (actionExtensions.isEmpty()) {
return Collections.emptyList();
}
final String actionExtension = actionExtensions.get(0);
@NonNls final ArrayList<String> list = new ArrayList<>();
combinedModel.processActions(action -> {
for (final Result result : action.getResults()) {
final PathReference pathReference = result.getValue();
if (pathReference != null) {
final PsiElement psiElement = pathReference.resolve();
if (psiElement != null && psiElement.equals(sourceFile)) {
String namespace = action.getNamespace();
if (!Comparing.equal(namespace, StrutsPackage.DEFAULT_NAMESPACE)) {
namespace += "/";
}
list.add(namespace + action.getName().getStringValue() + actionExtension);
}
}
}
return true;
});
return list;
}
use of com.intellij.openapi.paths.PathReference in project intellij-plugins by JetBrains.
the class ActionAnnotatorBase method installActionMethods.
/**
* Annotate action-methods of this class with result(s).
*
* @param lineMarkerInfos Current line markers.
* @param clazz Class to annotate.
* @param actions Corresponding Actions.
*/
private static void installActionMethods(final Collection<? super RelatedItemLineMarkerInfo> lineMarkerInfos, final PsiClass clazz, final List<Action> actions) {
final Map<PsiMethod, Set<PathReference>> pathReferenceMap = new HashMap<>();
for (final Action action : actions) {
final PsiMethod method = action.searchActionMethod();
if (method == null || !clazz.equals(method.getContainingClass())) {
continue;
}
final Set<PathReference> pathReferences = new HashSet<>();
final List<Result> results = action.getResults();
for (final Result result : results) {
final PathReference pathReference = result.getValue();
ContainerUtil.addIfNotNull(pathReferences, pathReference);
}
final Set<PathReference> toStore = ContainerUtil.getOrCreate(pathReferenceMap, method, new HashSet<>());
toStore.addAll(pathReferences);
pathReferenceMap.put(method, toStore);
}
for (final Map.Entry<PsiMethod, Set<PathReference>> entries : pathReferenceMap.entrySet()) {
final NavigationGutterIconBuilder<PathReference> gutterIconBuilder = NavigationGutterIconBuilder.create(AllIcons.Hierarchy.Base, PATH_REFERENCE_CONVERTER, PATH_REFERENCE_GOTO_RELATED_ITEM_PROVIDER).setAlignment(GutterIconRenderer.Alignment.LEFT).setPopupTitle(StrutsBundle.message("annotators.action.goto.result")).setTargets(entries.getValue()).setTooltipTitle(StrutsBundle.message("annotators.action.goto.result.tooltip"));
lineMarkerInfos.add(gutterIconBuilder.createLineMarkerInfo(entries.getKey()));
}
}
Aggregations