Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support "Symfony\Component\Routing\Attribute\Route" for method completion #311

Merged
merged 1 commit into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading