8000 add navigation for yaml constant "!php/const:" syntax in yaml tag for bc · Koc/idea-php-symfony2-plugin@443d25c · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 443d25c

Browse files
committed
add navigation for yaml constant "!php/const:" syntax in yaml tag for bc
1 parent 2713291 commit 443d25c

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/fr/adrienbrault/idea/symfony2plugin/config/yaml/YamlGoToDeclarationHandler.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.intellij.patterns.PsiElementPattern;
88
import com.intellij.psi.PsiElement;
99
import com.intellij.psi.PsiFile;
10+
import com.intellij.psi.tree.IElementType;
1011
import com.jetbrains.php.PhpIndex;
1112
import com.jetbrains.php.lang.psi.elements.Field;
1213
import com.jetbrains.php.lang.psi.elements.Method;
@@ -21,7 +22,6 @@
2122
import fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper;
2223
import org.jetbrains.annotations.NotNull;
2324
import org.jetbrains.annotations.Nullable;
24-
import org.jetbrains.yaml.YAMLLanguage;
2525
import org.jetbrains.yaml.YAMLTokenTypes;
2626
import org.jetbrains.yaml.psi.YAMLKeyValue;
2727
import org.jetbrains.yaml.psi.YAMLMapping;
@@ -43,21 +43,27 @@ public PsiElement[] getGotoDeclarationTargets(PsiElement psiElement, int i, Edit
4343
return null;
4444
}
4545

46-
// only string values like "foo", foo
47-
if (!PlatformPatterns.psiElement(YAMLTokenTypes.TEXT).withLanguage(YAMLLanguage.INSTANCE).accepts(psiElement)
48-
&& !PlatformPatterns.psiElement(YAMLTokenTypes.SCALAR_DSTRING).withLanguage(YAMLLanguage.INSTANCE).accepts(psiElement)
49-
&& !PlatformPatterns.psiElement(YAMLTokenTypes.SCALAR_STRING).withLanguage(YAMLLanguage.INSTANCE).accepts(psiElement)) {
46+
List<PsiElement> psiElements = new ArrayList<PsiElement>();
47+
48+
// yaml Plugin BC: "!php/const:" is a tag
49+
IElementType elementType = psiElement.getNode().getElementType();
50+
if(elementType == YAMLTokenTypes.TAG) {
51+
String psiText = PsiElementUtils.getText(psiElement);
52+
if(psiText != null && psiText.length() > 0 && psiText.startsWith("!php/const:")) {
53+
psiElements.addAll(constantGoto(psiElement, psiText));
54+
}
55+
}
5056

51-
return new PsiElement[]{};
57+
// only string values like "foo", foo
58+
if (elementType != YAMLTokenTypes.TEXT && elementType != YAMLTokenTypes.SCALAR_DSTRING && elementType != YAMLTokenTypes.SCALAR_STRING) {
59+
return psiElements.toArray(new PsiElement[psiElements.size()]);
5260
}
5361

5462
String psiText = PsiElementUtils.getText(psiElement);
5563
if(null == psiText || psiText.length() == 0) {
56-
return new PsiElement[]{};
64+
return psiElements.toArray(new PsiElement[psiElements.size()]);
5765
}
5866

59-
List<PsiElement> psiElements = new ArrayList<PsiElement>();
60-
6167
if(psiText.startsWith("@") && psiText.length() > 1) {
6268
psiElements.addAll(Arrays.asList((serviceGoToDeclaration(psiElement, psiText.substring(1)))));
6369
}

0 commit comments

Comments
 (0)
0