Skip to content

Commit

Permalink
support "Symfony\Component\Routing\Attribute\Route" for method comple…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
Haehnchen committed Aug 3, 2024
1 parent d5da735 commit 2131dfe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ public void getPropertyValueCompletions(AnnotationPropertyParameter parameter, A
return;
}

if("methods".equals(parameter.getPropertyName()) && PhpLangUtil.equalsClassNames(StringUtils.stripStart(parameter.getPhpClass().getFQN(), "\\"), "Symfony\\Component\\Routing\\Annotation\\Route")) {
boolean b = "methods".equals(parameter.getPropertyName()) &&
(PhpLangUtil.equalsClassNames(StringUtils.stripStart(parameter.getPhpClass().getFQN(), "\\"), "Symfony\\Component\\Routing\\Annotation\\Route") || PhpLangUtil.equalsClassNames(StringUtils.stripStart(parameter.getPhpClass().getFQN(), "\\"), "Symfony\\Component\\Routing\\Attribute\\Route")
);

if(b) {
for (String s : new String[]{"HEAD", "GET", "POST", "PUT", "PATCH", "DELETE", "PURGE", "OPTIONS", "TRACE", "CONNECT"}) {
completion.getResult().addElement(LookupElementBuilder.create(s));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ public static void visitElement(@NotNull PhpFile psiFile, @NotNull Processor<Pai
if (topLevelElement instanceof PhpClass clazz) {
PhpDocComment docComment = clazz.getDocComment();
if (docComment != null) {
PhpDocUtil.consumeTagElementsByName(docComment, null, docTag -> {
visitPhpDocTag(docTag, processor);
});
PhpDocUtil.consumeTagElementsByName(docComment, null, docTag -> visitPhpDocTag(docTag, processor));
}

for (PhpAttribute attribute : clazz.getAttributes()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private static void addAttribute(@NotNull Document document, @NotNull PhpNamedEl
if (forElement instanceof PhpClass) {
// on class scope: class Foobar {}
List<PhpAttributesList> childrenOfTypeAsList = PsiTreeUtil.getChildrenOfTypeAsList(forElement, PhpAttributesList.class);
CodeStyleManager.getInstance(forElement.getProject()).reformatRange(forElement, childrenOfTypeAsList.get(0).getTextRange().getStartOffset(), childrenOfTypeAsList.get(childrenOfTypeAsList.size() - 1).getNextPsiSibling().getTextRange().getEndOffset());
CodeStyleManager.getInstance(forElement.getProject()).reformatRange(forElement, childrenOfTypeAsList.getFirst().getTextRange().getStartOffset(), childrenOfTypeAsList.getLast().getNextPsiSibling().getTextRange().getEndOffset());
} else {
// on attribute scope: private $foo;
PhpClassFieldsList f = PsiTreeUtil.getParentOfType(forElement, PhpClassFieldsList.class);
Expand Down

0 comments on commit 2131dfe

Please sign in to comment.