Java Code Examples for fr.adrienbrault.idea.symfony2plugin.util.PsiElementUtils#getText()
The following examples show how to use
fr.adrienbrault.idea.symfony2plugin.util.PsiElementUtils#getText() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: YamlParameterInspection.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private void invoke(@NotNull final PsiElement psiElement, @NotNull ProblemsHolder holder) { // at least %a% // and not this one: %kernel.root_dir%/../web/ // %kernel.root_dir%/../web/%webpath_modelmasks% String parameterName = PsiElementUtils.getText(psiElement); if(!YamlHelper.isValidParameterName(parameterName)) { return; } // strip "%" parameterName = parameterName.substring(1, parameterName.length() - 1); // parameter a always lowercase see #179 parameterName = parameterName.toLowerCase(); if (!ContainerCollectionResolver.getParameterNames(psiElement.getProject()).contains(parameterName)) { holder.registerProblem(psiElement, "Missing Parameter", ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } }
Example 2
Source File: YamlClassInspection.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private void invoke(@NotNull final PsiElement psiElement, @NotNull ProblemsHolder holder) { String className = PsiElementUtils.getText(psiElement); if (YamlHelper.isValidParameterName(className)) { String resolvedParameter = ContainerCollectionResolver.resolveParameter(psiElement.getProject(), className); if (resolvedParameter != null && PhpIndex.getInstance(psiElement.getProject()).getAnyByFQN(resolvedParameter).size() > 0) { return; } } PhpClass foundClass = PhpElementsUtil.getClassInterface(psiElement.getProject(), className); if (foundClass == null) { holder.registerProblem(psiElement, MESSAGE_MISSING_CLASS, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } else if (!foundClass.getPresentableFQN().equals(className)) { holder.registerProblem(psiElement, MESSAGE_WRONG_CASING, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new CorrectClassNameCasingYamlLocalQuickFix(foundClass.getPresentableFQN())); } }
Example 3
Source File: DoctrineYamlGotoCompletionRegistrar.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@NotNull @Override public Collection<PsiElement> getPsiTargets(PsiElement element) { String psiText = PsiElementUtils.getText(element); if(StringUtils.isBlank(psiText)) { return Collections.emptyList(); } return new ArrayList<>(DoctrineMetadataUtil.getClassInsideScope(element, psiText)); }
Example 4
Source File: YamlClassInspection.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@NotNull public PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, boolean isOnTheFly) { if (!Symfony2ProjectComponent.isEnabled(holder.getProject())) { return super.buildVisitor(holder, isOnTheFly); } return new PsiElementVisitor() { @Override public void visitElement(PsiElement psiElement) { if ((YamlElementPatternHelper.getSingleLineScalarKey("class", "factory_class").accepts(psiElement) || YamlElementPatternHelper.getParameterClassPattern().accepts(psiElement)) && YamlElementPatternHelper.getInsideServiceKeyPattern().accepts(psiElement)) { // foobar.foo: // class: Foobar\Foo invoke(psiElement, holder); } else if (psiElement.getNode().getElementType() == YAMLTokenTypes.SCALAR_KEY && YamlElementPatternHelper.getServiceIdKeyValuePattern().accepts(psiElement.getParent())) { // Foobar\Foo: ~ String text = PsiElementUtils.getText(psiElement); if (StringUtils.isNotBlank(text) && YamlHelper.isClassServiceId(text) && text.contains("\\")) { PsiElement yamlKeyValue = psiElement.getParent(); if (yamlKeyValue instanceof YAMLKeyValue && YamlHelper.getYamlKeyValue((YAMLKeyValue) yamlKeyValue, "resource") == null && YamlHelper.getYamlKeyValue((YAMLKeyValue) yamlKeyValue, "exclude") == null) { invoke(psiElement, holder); } } } super.visitElement(psiElement); } }; }
Example 5
Source File: TwigTemplateGoToDeclarationHandler.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@NotNull private Collection<PsiElement> getRouteGoTo(@NotNull PsiElement psiElement) { String text = PsiElementUtils.getText(psiElement); if(StringUtils.isBlank(text)) { return Collections.emptyList(); } PsiElement[] methods = RouteHelper.getMethods(psiElement.getProject(), text); if(methods.length > 0) { return Arrays.asList(methods); } return RouteHelper.getRouteDefinitionTargets(psiElement.getProject(), text); }
Example 6
Source File: YamlGoToDeclarationHandler.java From idea-php-symfony2-plugin with MIT License | 5 votes |
private boolean hasNewConst(@NotNull PsiElement psiElement) { PsiElement prevSibling = psiElement.getPrevSibling(); while (prevSibling != null) { IElementType elementType = prevSibling.getNode().getElementType(); if (elementType == YAMLTokenTypes.TEXT || elementType == YAMLTokenTypes.SCALAR_DSTRING || elementType == YAMLTokenTypes.SCALAR_STRING || elementType == YAMLTokenTypes.TAG) { String psiText = PsiElementUtils.getText(prevSibling); return psiText.equals("!php/const"); } prevSibling = prevSibling.getPrevSibling(); } return false; }