Java Code Examples for fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent#isEnabled()
The following examples show how to use
fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent#isEnabled() .
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: TwigFoldingBuilder.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@NotNull @Override public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement psiElement, @NotNull Document document, boolean b) { if (!Symfony2ProjectComponent.isEnabled(psiElement) || !(psiElement instanceof TwigFile)) { return new FoldingDescriptor[0]; } List<FoldingDescriptor> descriptors = new ArrayList<>(); if(Settings.getInstance(psiElement.getProject()).codeFoldingTwigRoute) { attachPathFoldingDescriptors(psiElement, descriptors); } if(Settings.getInstance(psiElement.getProject()).codeFoldingTwigTemplate) { attachTemplateFoldingDescriptors(psiElement, descriptors); } if(Settings.getInstance(psiElement.getProject()).codeFoldingTwigConstant) { attachConstantFoldingDescriptors(psiElement, descriptors); } return descriptors.toArray(new FoldingDescriptor[descriptors.size()]); }
Example 2
Source File: RouteSymbolContributor.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@NotNull @Override public String[] getNames(Project project, boolean b) { if(!Symfony2ProjectComponent.isEnabled(project)) { return new String[0]; } Set<String> routeNames = new HashSet<>(); Map<String, Route> routes = RouteHelper.getAllRoutes(project); for (Route route : routes.values()) { routeNames.add(route.getName()); } return ArrayUtil.toStringArray(routeNames); }
Example 3
Source File: TaggedExtendsInterfaceClassInspection.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@NotNull @Override 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 visitFile(PsiFile psiFile) { if(psiFile instanceof YAMLFile) { psiFile.acceptChildren(new YmlClassElementWalkingVisitor(holder, new ContainerCollectionResolver.LazyServiceCollector(holder.getProject()))); } else if(psiFile instanceof XmlFile) { psiFile.acceptChildren(new XmlClassElementWalkingVisitor(holder, new ContainerCollectionResolver.LazyServiceCollector(holder.getProject()))); } } }; }
Example 4
Source File: PhpGotoRelatedProvider.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@NotNull @Override public List<? extends GotoRelatedItem> getItems(@NotNull PsiElement psiElement) { if(!Symfony2ProjectComponent.isEnabled(psiElement)) { return Collections.emptyList(); } if(psiElement.getLanguage() != PhpLanguage.INSTANCE) { return Collections.emptyList(); } Method method = PsiTreeUtil.getParentOfType(psiElement, Method.class); if(method == null || !method.getName().endsWith("Action")) { return Collections.emptyList(); } return ControllerMethodLineMarkerProvider.getGotoRelatedItems(method); }
Example 5
Source File: ContainerSettingDeprecatedInspection.java From idea-php-symfony2-plugin with MIT License | 6 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 element) { if(element instanceof XmlAttribute) { registerXmlAttributeProblem(holder, (XmlAttribute) element); } else if(element instanceof YAMLKeyValue) { registerYmlRoutePatternProblem(holder, (YAMLKeyValue) element); } super.visitElement(element); } }; }
Example 6
Source File: TwigRouteMissingInspection.java From idea-php-symfony2-plugin with MIT License | 6 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 element) { if(TwigPattern.getAutocompletableRoutePattern().accepts(element) && TwigUtil.isValidStringWithoutInterpolatedOrConcat(element)) { invoke(element, holder); } super.visitElement(element); } }; }
Example 7
Source File: YamlCompletionContributor.java From idea-php-symfony2-plugin with MIT License | 5 votes |
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { if(!Symfony2ProjectComponent.isEnabled(completionParameters.getPosition())) { return; } PsiElement psiElement = completionParameters.getPosition(); YAMLCompoundValue yamlCompoundValue = PsiTreeUtil.getParentOfType(psiElement, YAMLCompoundValue.class); if(yamlCompoundValue == null) { return; } addYamlClassMethods(yamlCompoundValue, completionResultSet, this.yamlArrayKeyName); }
Example 8
Source File: XmlDuplicateParameterKeyInspection.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@NotNull @Override 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 visitFile(PsiFile file) { visitRoot(file, holder, "parameters", "parameter", "key"); } }; }
Example 9
Source File: PhpTranslationKeyInspection.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@NotNull @Override public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) { if(!Symfony2ProjectComponent.isEnabled(holder.getProject())) { return super.buildVisitor(holder, isOnTheFly); } return new PsiElementVisitor() { @Override public void visitElement(PsiElement element) { invoke(holder, element); super.visitElement(element); } }; }
Example 10
Source File: FormTypeConstantMigrationAction.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Override protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { if(!(file instanceof PhpFile) || !Symfony2ProjectComponent.isEnabled(project)) { return false; } PhpClass classAtCaret = PhpCodeEditUtil.findClassAtCaret(editor, file); return classAtCaret != null && PhpElementsUtil.isInstanceOf(classAtCaret, "Symfony\\Component\\Form\\FormTypeInterface") ; }
Example 11
Source File: RoutesToolboxProvider.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@NotNull @Override public Collection<LookupElement> getLookupElements(@NotNull PhpToolboxCompletionContributorParameter parameter) { if(!Symfony2ProjectComponent.isEnabled(parameter.getProject())) { return Collections.emptyList(); } return RouteHelper.getRoutesLookupElements(parameter.getProject()); }
Example 12
Source File: TranslationDomainToolboxProvider.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@NotNull @Override public Collection<PsiElement> getPsiTargets(@NotNull PhpToolboxDeclarationHandlerParameter parameter) { if(!Symfony2ProjectComponent.isEnabled(parameter.getProject())) { return Collections.emptyList(); } return new HashSet<>(TranslationUtil.getDomainPsiFiles(parameter.getProject(), parameter.getContents())); }
Example 13
Source File: MethodMatcher.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Nullable public MethodMatchParameter match() { if (!Symfony2ProjectComponent.isEnabled(psiElement)) { return null; } MethodReferenceBag bag = PhpElementsUtil.getMethodParameterReferenceBag(psiElement); if(bag == null) { return null; } // try on current method MethodMatcher.MethodMatchParameter methodMatchParameter = new StringParameterMatcher(psiElement, parameterIndex) .withSignature(this.signatures) .match(); if(methodMatchParameter != null) { return methodMatchParameter; } // walk down next method MethodReference methodReference = bag.getMethodReference(); for (Method method : PhpElementsUtil.getMultiResolvedMethod(methodReference)) { for(PsiElement var: PhpElementsUtil.getMethodParameterReferences(method, bag.getParameterBag().getIndex())) { MethodMatcher.MethodMatchParameter methodMatchParameterRef = new MethodMatcher.StringParameterMatcher(var, parameterIndex) .withSignature(this.signatures) .match(); if(methodMatchParameterRef != null) { return methodMatchParameterRef; } } } return null; }
Example 14
Source File: YamlCompletionContributor.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Override protected void addCompletions(@NotNull CompletionParameters completionParameters, final ProcessingContext processingContext, @NotNull final CompletionResultSet completionResultSet) { PsiFile originalFile = completionParameters.getOriginalFile(); if(!Symfony2ProjectComponent.isEnabled(originalFile)) { return; } final PsiDirectory containingDirectory = originalFile.getContainingDirectory(); if (containingDirectory == null) { return; } final VirtualFile containingDirectoryFiles = containingDirectory.getVirtualFile(); VfsUtil.visitChildrenRecursively(containingDirectoryFiles, new VirtualFileVisitor() { @Override public boolean visitFile(@NotNull VirtualFile file) { String relativePath = VfsUtil.getRelativePath(file, containingDirectoryFiles, '/'); if (relativePath == null) { return super.visitFile(file); } completionResultSet.addElement(LookupElementBuilder.create(relativePath).withIcon(file.getFileType().getIcon())); return super.visitFile(file); } }); }
Example 15
Source File: TagNameCompletionProvider.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Override protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { if(!Symfony2ProjectComponent.isEnabled(completionParameters.getPosition())) { return; } completionResultSet.addAllElements(getTagLookupElements(completionParameters.getPosition().getProject())); }
Example 16
Source File: PhpTemplateMissingInspection.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@NotNull @Override public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) { if(!Symfony2ProjectComponent.isEnabled(holder.getProject())) { return super.buildVisitor(holder, isOnTheFly); } return new PsiElementVisitor() { @Override public void visitElement(PsiElement element) { invoke(holder, element); super.visitElement(element); } }; }
Example 17
Source File: TwigTemplateCompletionContributor.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext processingContext, @NotNull CompletionResultSet resultSet) { PsiElement psiElement = parameters.getOriginalPosition(); if(psiElement == null || !Symfony2ProjectComponent.isEnabled(psiElement)) { return; } // "foobar".<caret> Collection<String> possibleTypes = TwigTypeResolveUtil.formatPsiTypeName(psiElement); if(possibleTypes.size() != 1) { return; } String rootElement = possibleTypes.iterator().next(); resultSet.addAllElements( TwigUtil.getImportedMacrosNamespaces(psiElement.getContainingFile()).stream() .filter(twigMacro -> twigMacro.getName().startsWith(rootElement + ".") ) .map((Function<TwigMacro, LookupElement>) twigMacro -> LookupElementBuilder.create(twigMacro.getName().substring(rootElement.length() + 1)) .withTypeText(twigMacro.getTemplate(), true) .withTailText(twigMacro.getParameter(), true) .withIcon(TwigIcons.TwigFileIcon).withInsertHandler(FunctionInsertHandler.getInstance()) ).collect(Collectors.toList()) ); }
Example 18
Source File: AbstractProjectDumbAwareAction.java From idea-php-symfony2-plugin with MIT License | 4 votes |
public void update(AnActionEvent event) { Project project = event.getData(PlatformDataKeys.PROJECT); if (project == null || !Symfony2ProjectComponent.isEnabled(project)) { setStatus(event, false); } }
Example 19
Source File: TwigExtractLanguageAction.java From idea-php-symfony2-plugin with MIT License | 4 votes |
public void update(AnActionEvent event) { Project project = event.getData(PlatformDataKeys.PROJECT); if (project == null || !Symfony2ProjectComponent.isEnabled(project)) { this.setStatus(event, false); return; } PsiFile psiFile = event.getData(PlatformDataKeys.PSI_FILE); if(!(psiFile instanceof TwigFile)) { this.setStatus(event, false); return; } Editor editor = event.getData(PlatformDataKeys.EDITOR); if(editor == null) { this.setStatus(event, false); return; } // find valid PsiElement context, because only html text is a valid extractor action PsiElement psiElement; if(editor.getSelectionModel().hasSelection()) { psiElement = psiFile.findElementAt(editor.getSelectionModel().getSelectionStart()); } else { psiElement = psiFile.findElementAt(editor.getCaretModel().getOffset()); } if(psiElement == null) { this.setStatus(event, false); return; } // <a title="TEXT">TEXT</a> IElementType elementType = psiElement.getNode().getElementType(); if(elementType == XmlTokenType.XML_DATA_CHARACTERS || elementType == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN) { this.setStatus(event, true); } else { this.setStatus(event, false); } }
Example 20
Source File: TwigLineMarkerProvider.java From idea-php-symfony2-plugin with MIT License | 4 votes |
@Override public void collectSlowLineMarkers(@NotNull List<PsiElement> psiElements, @NotNull Collection<LineMarkerInfo> results) { if(psiElements.size() == 0 || !Symfony2ProjectComponent.isEnabled(psiElements.get(0))) { return; } Map<VirtualFile, FileImplementsLazyLoader> implementsMap = new HashMap<>(); FileOverwritesLazyLoader fileOverwritesLazyLoader = null; for(PsiElement psiElement: psiElements) { // controller if(psiElement instanceof TwigFile) { attachController((TwigFile) psiElement, results); // find foreign file references tags like: // include, embed, source, from, import, ... LineMarkerInfo lineIncludes = attachIncludes((TwigFile) psiElement); if(lineIncludes != null) { results.add(lineIncludes); } LineMarkerInfo extending = attachExtends((TwigFile) psiElement); if(extending != null) { results.add(extending); } // eg bundle overwrites LineMarkerInfo overwrites = attachOverwrites((TwigFile) psiElement); if(overwrites != null) { results.add(overwrites); } } else if (TwigPattern.getBlockTagPattern().accepts(psiElement) || TwigPattern.getPrintBlockOrTagFunctionPattern("block").accepts(psiElement)) { // blocks: {% block 'foobar' %}, {{ block('foobar') }} VirtualFile virtualFile = psiElement.getContainingFile().getVirtualFile(); if(!implementsMap.containsKey(virtualFile)) { implementsMap.put(virtualFile, new FileImplementsLazyLoader(psiElement.getProject(), virtualFile)); } LineMarkerInfo lineImpl = attachBlockImplements(psiElement, implementsMap.get(virtualFile)); if(lineImpl != null) { results.add(lineImpl); } if(fileOverwritesLazyLoader == null) { fileOverwritesLazyLoader = new FileOverwritesLazyLoader(psiElements.get(0).getProject()); } LineMarkerInfo lineOverwrites = attachBlockOverwrites(psiElement, fileOverwritesLazyLoader); if(lineOverwrites != null) { results.add(lineOverwrites); } } } }