fr.adrienbrault.idea.symfony2plugin.Symfony2Icons Java Examples

The following examples show how to use fr.adrienbrault.idea.symfony2plugin.Symfony2Icons. 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: DoctrineDbalQbGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 7 votes vote down vote up
@NotNull
@Override
public Collection<LookupElement> getLookupElements() {

    DoctrineMetadataModel model = DoctrineMetadataUtil.getMetadataByTable(getProject(), this.stringValue);
    if(model == null) {
        return Collections.emptyList();
    }

    Collection<LookupElement> elements = new ArrayList<>();
    for (DoctrineModelField field : model.getFields()) {
        String column = field.getColumn();

        // use "column" else fallback to field name
        if(column != null && StringUtils.isNotBlank(column)) {
            elements.add(LookupElementBuilder.create(column).withIcon(Symfony2Icons.DOCTRINE));
        } else {
            String name = field.getName();
            if(StringUtils.isNotBlank(name)) {
                elements.add(LookupElementBuilder.create(name).withIcon(Symfony2Icons.DOCTRINE));
            }
        }
    }

    return elements;
}
 
Example #2
Source File: ConfigCompletionProvider.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
private LookupElementBuilder getNodeAttributeLookupElement(Node node, Map<String, String> nodeVars, boolean isShortcut) {

        String nodeName = getNodeName(node);
        LookupElementBuilder lookupElementBuilder = LookupElementBuilder.create(nodeName).withIcon(Symfony2Icons.CONFIG_VALUE);

        String textContent = node.getTextContent();
        if(StringUtils.isNotBlank(textContent)) {
            lookupElementBuilder = lookupElementBuilder.withTailText("(" + textContent + ")", true);
        }

        if(nodeVars.containsKey(nodeName)) {
            lookupElementBuilder = lookupElementBuilder.withTypeText(StringUtil.shortenTextWithEllipsis(nodeVars.get(nodeName), 100, 0), true);
        }

        if(isShortcut) {
            lookupElementBuilder = lookupElementBuilder.withIcon(Symfony2Icons.CONFIG_VALUE_SHORTCUT);
        }

        return lookupElementBuilder;
    }
 
Example #3
Source File: DoctrineModelFieldLookupElement.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Override
public void renderElement(LookupElementPresentation presentation) {
    super.renderElement(presentation);

    presentation.setItemTextBold(withBoldness);
    presentation.setIcon(Symfony2Icons.DOCTRINE);
    presentation.setTypeGrayed(true);

    if(this.doctrineModelField.getTypeName() != null) {
        presentation.setTypeText(this.doctrineModelField.getTypeName());
    }

    if(this.doctrineModelField.getRelationType() != null) {
        presentation.setTailText(String.format("(%s)", this.doctrineModelField.getRelationType()), true);
    }

    if(this.doctrineModelField.getRelation() != null) {
        presentation.setTypeText(this.doctrineModelField.getRelation());
        presentation.setIcon(PhpIcons.CLASS_ICON);
    }

}
 
Example #4
Source File: ParameterLookupElement.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
public void renderElement(LookupElementPresentation presentation) {
    presentation.setItemText(containerParameter.getName());

    String value = containerParameter.getValue();
    if(value != null && StringUtils.isNotBlank(value)) {
        presentation.setTypeText(value);
    }

    presentation.setTypeGrayed(true);
    presentation.setIcon(Symfony2Icons.PARAMETER);

    if(this.containerParameter.isWeak()) {
        presentation.setIcon(Symfony2Icons.PARAMETER_OPACITY);
    }

}
 
Example #5
Source File: FormOptionLookupVisitor.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Override
public void visit(@NotNull PsiElement psiElement, @NotNull String option, @NotNull FormClass formClass, @NotNull FormOptionEnum optionEnum) {

    String typeText = formClass.getPhpClass().getPresentableFQN();
    if(typeText.lastIndexOf("\\") != -1) {
        typeText = typeText.substring(typeText.lastIndexOf("\\") + 1);
    }

    if(typeText.endsWith("Type")) {
        typeText = typeText.substring(0, typeText.length() - 4);
    }

    lookupElements.add(LookupElementBuilder.create(option)
            .withTypeText(typeText, true)
            .withIcon(Symfony2Icons.FORM_OPTION)
    );

}
 
Example #6
Source File: DoctrineEntityLookupElement.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Nullable
private Icon getIcon() {
    if(manager == null) {
        return null;
    }

    if(manager == DoctrineTypes.Manager.ORM) {
        return Symfony2Icons.DOCTRINE;
    }

    if(manager == DoctrineTypes.Manager.MONGO_DB || manager == DoctrineTypes.Manager.COUCH_DB) {
        return Symfony2Icons.NO_SQL;
    }

    return null;
}
 
Example #7
Source File: DoctrineEntityLookupElement.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Nullable
private Icon getWeakIcon() {
    if(manager == null) {
        return null;
    }

    if(manager == DoctrineTypes.Manager.ORM) {
        return Symfony2Icons.DOCTRINE_WEAK;
    }

    if(manager == DoctrineTypes.Manager.MONGO_DB || manager == DoctrineTypes.Manager.COUCH_DB) {
        return Symfony2Icons.NO_SQL;
    }

    return null;
}
 
Example #8
Source File: FormFieldNameReference.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
public static LookupElement[] getFormLookups(Method method) {

        MethodReference[] formBuilderTypes = FormUtil.getFormBuilderTypes(method);
        List<LookupElement> lookupElements = new ArrayList<>();

        for(MethodReference methodReference: formBuilderTypes) {
            String fieldName = PsiElementUtils.getMethodParameterAt(methodReference, 0);
            if(fieldName != null) {

                LookupElementBuilder lookup = LookupElementBuilder.create(fieldName).withIcon(Symfony2Icons.FORM_TYPE);
                String fieldType = PsiElementUtils.getMethodParameterAt(methodReference, 1);
                if(fieldType != null) {
                    lookup = lookup.withTypeText(fieldType, true);
                }

                lookupElements.add(lookup);
            }
        }

        return lookupElements.toArray(new LookupElement[lookupElements.size()]);
    }
 
Example #9
Source File: DoctrineMetadataLineMarkerProvider.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
private void attachXmlRelationMarker(@NotNull PsiElement target, @NotNull XmlAttributeValue psiElement, @NotNull Collection<LineMarkerInfo> results) {
    String value = psiElement.getValue();
    if(StringUtils.isBlank(value)) {
        return;
    }

    Collection<PhpClass> classesInterface = DoctrineMetadataUtil.getClassInsideScope(psiElement, value);
    if(classesInterface.size() == 0) {
        return;
    }

    NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.DOCTRINE_LINE_MARKER).
        setTargets(classesInterface).
        setTooltipText("Navigate to class");

    results.add(builder.createLineMarkerInfo(target));
}
 
Example #10
Source File: ConfigLineMarkerProvider.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
private void visitRootElements(@NotNull Collection<LineMarkerInfo> result, @NotNull PsiElement psiElement, @NotNull LazyConfigTreeSignatures function) {
    PsiElement parent = psiElement.getParent();
    if(!(parent instanceof YAMLKeyValue)) {
        return;
    }

    String keyText = ((YAMLKeyValue) parent).getKeyText();
    Map<String, Collection<String>> treeSignatures = function.value();
    if(!treeSignatures.containsKey(keyText)) {
        return;
    }

    NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.SYMFONY_LINE_MARKER)
        .setTargets(new MyClassIdLazyValue(psiElement.getProject(), treeSignatures.get(keyText), keyText))
        .setTooltipText("Navigate to configuration");

    result.add(builder.createLineMarkerInfo(psiElement));
}
 
Example #11
Source File: ServiceLineMarkerProvider.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * Constraints in same namespace and validateBy service name
 */
private void validatorClassMarker(PsiElement psiElement, Collection<LineMarkerInfo> results) {
    PsiElement phpClassContext = psiElement.getContext();
    if(!(phpClassContext instanceof PhpClass) || !PhpElementsUtil.isInstanceOf((PhpClass) phpClassContext, "\\Symfony\\Component\\Validator\\Constraint")) {
        return;
    }

    // class in same namespace
    String className = ((PhpClass) phpClassContext).getFQN() + "Validator";
    Collection<PhpClass> phpClasses = new ArrayList<>(PhpElementsUtil.getClassesInterface(psiElement.getProject(), className));

    // @TODO: validateBy alias

    if(phpClasses.size() == 0) {
        return;
    }

    NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.SYMFONY_LINE_MARKER).
        setTargets(phpClasses).
        setTooltipText("Navigate to validator");

    results.add(builder.createLineMarkerInfo(psiElement));
}
 
Example #12
Source File: ServiceLineMarkerProvider.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * "FooValidator" back to "Foo" constraint
 */
private void constraintValidatorClassMarker(PsiElement psiElement, Collection<LineMarkerInfo> results) {
    PsiElement phpClass = psiElement.getContext();
    if(!(phpClass instanceof PhpClass) || !PhpElementsUtil.isInstanceOf((PhpClass) phpClass, "Symfony\\Component\\Validator\\ConstraintValidatorInterface")) {
        return;
    }

    String fqn = ((PhpClass) phpClass).getFQN();
    if(!fqn.endsWith("Validator")) {
        return;
    }

    Collection<PhpClass> phpClasses = new ArrayList<>(
        PhpElementsUtil.getClassesInterface(psiElement.getProject(), fqn.substring(0, fqn.length() - "Validator".length()))
    );

    if(phpClasses.size() == 0) {
        return;
    }

    NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.SYMFONY_LINE_MARKER).
        setTargets(phpClasses).
        setTooltipText("Navigate to constraint");

    results.add(builder.createLineMarkerInfo(psiElement));
}
 
Example #13
Source File: DoctrineTypeGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@NotNull
@Override
public Collection<LookupElement> getLookupElements() {
    final Collection<LookupElement> lookupElements = new ArrayList<>();

    Collection<String> typeClassesByScopeWithAllFallback = DoctrineMetadataTypeUtil.getTypeClassesByScopeWithAllFallback(getElement());
    DoctrineMetadataTypeUtil.visitType(getProject(), typeClassesByScopeWithAllFallback, pair -> {
        lookupElements.add(
            LookupElementBuilder.create(pair.getSecond())
                .withIcon(Symfony2Icons.DOCTRINE)
                .withTypeText(pair.getSecond(), true)
        );
        return true;
    });

    if(typeClassesByScopeWithAllFallback.contains(DoctrineMetadataTypeUtil.DBAL_TYPE)) {
        DoctrineStaticTypeLookupBuilder.fillOrmLookupElementsWithStatic(lookupElements);
    }

    return lookupElements;
}
 
Example #14
Source File: YamlCompletionProvider.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) {
    if(!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) {
        return;
    }

    if(this.lookupList != null) {
        resultSet.addAllElements(this.lookupList);
    } else if(lookupMap != null) {
        for (Map.Entry<String, String> lookup : lookupMap.entrySet()) {
            LookupElementBuilder lookupElement = LookupElementBuilder.create(lookup.getKey()).withTypeText(lookup.getValue(), true).withIcon(Symfony2Icons.SYMFONY);
            if(lookup.getValue() != null && lookup.getValue().contains("deprecated")) {
                lookupElement = lookupElement.withStrikeoutness(true);
            }

            resultSet.addElement(lookupElement);
        }
    }
}
 
Example #15
Source File: ConfigCompletionProvider.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
private void attachRootConfig(CompletionResultSet completionResultSet, PsiElement element) {

        Document document = getConfigTemplate(ProjectUtil.getProjectDir(element));
        if(document == null) {
            return;
        }

        try {

            // attach config aliases
            NodeList nodeList  = (NodeList) XPathFactory.newInstance().newXPath().compile("//config/*").evaluate(document, XPathConstants.NODESET);
            for (int i = 0; i < nodeList.getLength(); i++) {
                completionResultSet.addElement(LookupElementBuilder.create(getNodeName(nodeList.item(i))).withIcon(Symfony2Icons.CONFIG_VALUE));
            }

        } catch (XPathExpressionException ignored) {
        }

    }
 
Example #16
Source File: ConfigCompletionProvider.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Nullable
private LookupElementBuilder getNodeTagLookupElement(Node node, boolean isShortcut) {

    String nodeName = getNodeName(node);
    boolean prototype = isPrototype(node);

    // prototype "connection" must be "connections" so pluralize
    if(prototype) {
        nodeName = StringUtil.pluralize(nodeName);
    }

    LookupElementBuilder lookupElementBuilder = LookupElementBuilder.create(nodeName).withIcon(Symfony2Icons.CONFIG_PROTOTYPE);

    if(prototype) {
        lookupElementBuilder = lookupElementBuilder.withTypeText("Prototype", true);
    }

    if(isShortcut) {
        lookupElementBuilder = lookupElementBuilder.withIcon(Symfony2Icons.CONFIG_VALUE_SHORTCUT);
    }

    return lookupElementBuilder;
}
 
Example #17
Source File: ConstraintPropertyReference.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@NotNull
@Override
public Object[] getVariants() {

    List<LookupElement> lookupElements = new ArrayList<>();

    for(Field field: constraintPhpClass.getFields()) {
        if(!field.isConstant() && field.getModifier().isPublic()) {

            LookupElementBuilder lookupElement = LookupElementBuilder.create(field.getName()).withIcon(Symfony2Icons.SYMFONY);

            String defaultValue = PhpElementsUtil.getStringValue(field.getDefaultValue());
            if(defaultValue != null) {
                lookupElement = lookupElement.withTypeText(defaultValue, true);
            }

            lookupElements.add(lookupElement);
        }
    }

    return lookupElements.toArray();
}
 
Example #18
Source File: XmlLineMarkerProvider.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
private void attachRouteActions(@NotNull PsiElement psiElement, @NotNull Collection<LineMarkerInfo> lineMarkerInfos) {
    PsiElement xmlTag = psiElement.getParent();
    if(!(xmlTag instanceof XmlTag) || !Pattern.getRouteTag().accepts(xmlTag)) {
        return;
    }

    String controller = RouteHelper.getXmlController((XmlTag) xmlTag);
    if(controller != null) {
        PsiElement[] methods = RouteHelper.getMethodsOnControllerShortcut(xmlTag.getProject(), controller);
        if(methods.length > 0) {
            NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.TWIG_CONTROLLER_LINE_MARKER).
                setTargets(methods).
                setTooltipText("Navigate to action");

            lineMarkerInfos.add(builder.createLineMarkerInfo(psiElement));
        }
    }
}
 
Example #19
Source File: ServiceToolboxProvider.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Nullable
@Override
public ProviderPresentation getPresentation() {
    return new ProviderPresentation() {
        @Nullable
        @Override
        public Icon getIcon() {
            return Symfony2Icons.SERVICE;
        }

        @Nullable
        @Override
        public String getDescription() {
            return "Public services";
        }

        @Nullable
        public ProviderParameter[] getParameter() {
            return new ProviderParameter[] {
                new ProviderParameter("private", ProviderParameter.TYPE.BOOLEAN),
                new ProviderParameter("public", ProviderParameter.TYPE.BOOLEAN),
            };
        }
    };
}
 
Example #20
Source File: RoutesToolboxProvider.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Nullable
@Override
public ProviderPresentation getPresentation() {
    return new ProviderPresentation() {
        @Nullable
        @Override
        public Icon getIcon() {
            return Symfony2Icons.ROUTE;
        }

        @Nullable
        @Override
        public String getDescription() {
            return "Symfony routes";
        }
    };
}
 
Example #21
Source File: YamlLineMarkerProvider.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * Find controller definition in yaml structor
 *
 * foo:
 *   defaults: { _controller: "Bundle:Foo:Bar" }
 *   controller: "Bundle:Foo:Bar"
 */
private void attachRouteActions(@NotNull Collection<LineMarkerInfo> lineMarkerInfos, @NotNull PsiElement psiElement) {
    if(psiElement.getNode().getElementType() != YAMLTokenTypes.SCALAR_KEY) {
        return;
    }

    PsiElement yamlKeyValue = psiElement.getParent();
    if(!(yamlKeyValue instanceof YAMLKeyValue)) {
        return;
    }

    String yamlController = RouteHelper.getYamlController((YAMLKeyValue) yamlKeyValue);
    if(yamlController != null) {
        PsiElement[] methods = RouteHelper.getMethodsOnControllerShortcut(psiElement.getProject(), yamlController);
        if(methods.length > 0) {
            NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.TWIG_CONTROLLER_LINE_MARKER).
                setTargets(methods).
                setTooltipText("Navigate to action");

            lineMarkerInfos.add(builder.createLineMarkerInfo(psiElement));
        }
    }
}
 
Example #22
Source File: TranslationDomainToolboxProvider.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Nullable
@Override
public ProviderPresentation getPresentation() {
    return new ProviderPresentation() {
        @Nullable
        @Override
        public Icon getIcon() {
            return Symfony2Icons.TRANSLATION;
        }

        @Nullable
        @Override
        public String getDescription() {
            return "Symfony translation domains";
        }
    };
}
 
Example #23
Source File: SymfonyCreateService.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
private static SymfonyCreateService prepare(@Nullable Component component, @NotNull SymfonyCreateService service) {
    service.init();
    service.setTitle("Symfony: Service Generator");
    service.setIconImage(Symfony2Icons.getImage(Symfony2Icons.SYMFONY));
    service.pack();

    service.setMinimumSize(new Dimension(550, 250));

    if(component != null) {
        service.setLocationRelativeTo(component);
    }

    service.setVisible(true);

    return service;
}
 
Example #24
Source File: DoctrineModelProvider.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Nullable
@Override
public ProviderPresentation getPresentation() {
    return new ProviderPresentation() {
        @Nullable
        @Override
        public Icon getIcon() {
            return Symfony2Icons.DOCTRINE;
        }

        @Nullable
        @Override
        public String getDescription() {
            return "Doctrine entities, documents, ...";
        }
    };
}
 
Example #25
Source File: TwigControllerUsageControllerRelatedGotoCollector.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Override
public void collectGotoRelatedItems(ControllerActionGotoRelatedCollectorParameter parameter) {
    Method method = parameter.getMethod();
    PhpClass containingClass = method.getContainingClass();

    if (containingClass == null) {
        return;
    }

    String controllerAction = StringUtils.stripStart(containingClass.getPresentableFQN(), "\\") + "::" + method.getName();

    Collection<VirtualFile> targets = new HashSet<>();
    FileBasedIndex.getInstance().getFilesWithKey(TwigControllerStubIndex.KEY, new HashSet<>(Collections.singletonList(controllerAction)), virtualFile -> {
        targets.add(virtualFile);
        return true;
    }, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(parameter.getProject()), TwigFileType.INSTANCE));

    for (PsiFile psiFile: PsiElementUtils.convertVirtualFilesToPsiFiles(parameter.getProject(), targets)) {
        TwigUtil.visitControllerFunctions(psiFile, pair -> {
            if (pair.getFirst().equalsIgnoreCase(controllerAction)) {
                parameter.add(new RelatedPopupGotoLineMarker.PopupGotoRelatedItem(pair.getSecond()).withIcon(TwigIcons.TwigFileIcon, Symfony2Icons.TWIG_LINE_MARKER));
            }
        });
    }
}
 
Example #26
Source File: SymfonyCommandSymbolContributor.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@NotNull
@Override
public NavigationItem[] getItemsByName(String name, String s2, Project project, boolean b) {
    if(!Symfony2ProjectComponent.isEnabled(project)) {
        return new NavigationItem[0];
    }

    List<NavigationItem> navigationItems = new ArrayList<>();

    for (SymfonyCommand symfonyCommand : SymfonyCommandUtil.getCommands(project)) {
        if(symfonyCommand.getName().equals(name)) {
            navigationItems.add(new NavigationItemEx(symfonyCommand.getPsiElement(), name, Symfony2Icons.SYMFONY, "Command"));
        }
    }

    return navigationItems.toArray(new NavigationItem[navigationItems.size()]);
}
 
Example #27
Source File: Symfony2WebProfilerForm.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
private void renderRequestDetails(@NotNull ProfilerRequestInterface profilerRequest) {
    DefaultListModel<RequestDetails> listModel = (DefaultListModel<RequestDetails>) listRequestDetails.getModel();
    listModel.removeAllElements();

    DefaultDataCollectorInterface defaultDataCollector = profilerRequest.getCollector(DefaultDataCollectorInterface.class);
    if(defaultDataCollector != null) {
        if(defaultDataCollector.getRoute() != null) {
            listModel.addElement(new RequestDetails(defaultDataCollector.getRoute(), Symfony2Icons.ROUTE));
        }

        if(defaultDataCollector.getController() != null) {
            listModel.addElement(new RequestDetails(defaultDataCollector.getController(), PhpIcons.METHOD_ICON));
        }

        if(defaultDataCollector.getTemplate() != null) {
            listModel.addElement(new RequestDetails(defaultDataCollector.getTemplate(), TwigIcons.TwigFileIcon));
        }
    }
}
 
Example #28
Source File: FormCompletionContributorTest.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
public void testClassConstantsCompletionWithNamespaceShouldInsertUseAndStripNamespace() {
    assertCompletionResultEquals(PhpFileType.INSTANCE,
        "<?php\n" +
            "namespace Foo {\n" +
            "  /** @var $foo \\Symfony\\Component\\Form\\FormBuilderInterface */\n" +
            "  $foo->add('', HiddenType<caret>);\n" +
            "};",
        "<?php\n" +
            "namespace Foo {\n\n" +
            "    use Symfony\\Component\\Form\\Extension\\Core\\Type\\HiddenType;\n\n" +
            "    /** @var $foo \\Symfony\\Component\\Form\\FormBuilderInterface */\n" +
            "  $foo->add('', HiddenType::class);\n" +
            "};",
        new LookupElementInsert.Icon(Symfony2Icons.FORM_TYPE)
    );
}
 
Example #29
Source File: TwigTemplateCompletionContributor.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext processingContext, @NotNull CompletionResultSet resultSet) {
    PsiElement position = parameters.getPosition();
    if(!Symfony2ProjectComponent.isEnabled(position)) {
        return;
    }

    TwigUtil.visitTokenParsers(position.getProject(), pair ->
        resultSet.addElement(LookupElementBuilder.create(pair.getFirst()).withIcon(Symfony2Icons.SYMFONY))
    );

    // add special tag ending, provide a static list. there no suitable safe way to extract them
    // search able via: "return $token->test(array('end"
    for (String s : new String[]{"endtranschoice", "endtrans"}) {
        resultSet.addElement(LookupElementBuilder.create(s).withIcon(Symfony2Icons.SYMFONY));
    }
}
 
Example #30
Source File: TwigLineMarkerProvider.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Nullable
private LineMarkerInfo attachOverwrites(@NotNull TwigFile twigFile) {
    Collection<PsiFile> targets = new ArrayList<>();

    for (String templateName: TwigUtil.getTemplateNamesForFile(twigFile)) {
        for (PsiFile psiFile : TwigUtil.getTemplatePsiElements(twigFile.getProject(), templateName)) {
            if(!psiFile.getVirtualFile().equals(twigFile.getVirtualFile()) && !targets.contains(psiFile)) {
                targets.add(psiFile);
            }
        }
    }

    if(targets.size() == 0) {
        return null;
    }

    List<GotoRelatedItem> gotoRelatedItems = new ArrayList<>();
    for(PsiElement blockTag: targets) {
        gotoRelatedItems.add(new RelatedPopupGotoLineMarker.PopupGotoRelatedItem(
            blockTag,
            TwigUtil.getPresentableTemplateName(blockTag, true)
        ).withIcon(TwigIcons.TwigFileIcon, Symfony2Icons.TWIG_LINE_OVERWRITE));
    }

    return getRelatedPopover("Overwrites", "Overwrite", twigFile, gotoRelatedItems, Symfony2Icons.TWIG_LINE_OVERWRITE);
}