Skip to content

Commit

Permalink
TASK: Fix findTemplate() Method in ResolveEngine
Browse files Browse the repository at this point in the history
  • Loading branch information
cvette committed Sep 29, 2017
1 parent 3fc4b34 commit 076f0a7
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,15 @@ public static VirtualFile findTemplate(Method method) {
PsiFile file = method.getContainingFile();
if (method.getContainingClass() != null) {
String actionName = method.getName();
if (!actionName.endsWith("Action")) {
return null;
}

actionName = actionName.replace("Action", "");
if (actionName.length() < 2) {
return null;
}

actionName = actionName.substring(0, 1).toUpperCase() + actionName.substring(1);

String controllerName = method.getContainingClass().getName();
Expand All @@ -284,8 +292,13 @@ public static VirtualFile findTemplate(Method method) {
for(String key : namespaceMappings.keySet()) {
if (namespace.startsWith(key)) {
namespace = namespace.replace(key, "")
.replace("\\", "/")
.replace("/Controller/", "");
.replace("\\", "/");

if (namespace.startsWith("/") && namespace.length() > 1) {
namespace = namespace.substring(1);
}

namespace = namespace.replace("Controller/", "");
break;
}
}
Expand Down

0 comments on commit 076f0a7

Please sign in to comment.