Skip to content

Commit

Permalink
Merge pull request #311 from Haehnchen/feature/attributes-method
Browse files Browse the repository at this point in the history
support "Symfony\Component\Routing\Attribute\Route" for method completion
  • Loading branch information
Haehnchen authored Aug 3, 2024
2 parents d5da735 + 862276b commit 9decec7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 0 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

fun properties(key: String) = project.findProperty(key).toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
public class SymfonyCompletionProvider implements PhpAnnotationCompletionProvider {
@Override
public void getPropertyValueCompletions(AnnotationPropertyParameter parameter, AnnotationCompletionProviderParameter completion) {
if(parameter.getType() != AnnotationPropertyParameter.Type.PROPERTY_ARRAY) {
if (parameter.getType() != AnnotationPropertyParameter.Type.PROPERTY_ARRAY) {
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 9decec7

Please sign in to comment.