Package com.dubture.twig.core.codeassist.context

Examples of com.dubture.twig.core.codeassist.context.BlocknameContext


     */
    @Override
    public void apply(ICompletionReporter reporter) throws Exception
    {
       
        BlocknameContext context = (BlocknameContext) getContext();
       
        TwigModuleDeclaration module = context.getModule();
        BlockStatement extendsBlock = module.getExtends();
       
        if (extendsBlock == null) {
            return;
        }
       
        StringLiteral literal = (StringLiteral) extendsBlock.getFirstChild();
       
        if (literal == null) {
            return;
        }
       
        String path = literal.getValue();
        List<ITemplateResolver> providers = ExtensionManager.getInstance().getTemplateProviders();
       
        String prefix = context.getPrefix();
        SourceRange range = getReplacementRange(context);
       
        for (ITemplateResolver resolver : providers) {
           
            SourceModule sourceModule = resolver.revolePath(path, context.getSourceModule().getScriptProject());
            TwigModuleDeclaration parent = (TwigModuleDeclaration) SourceParserUtil.parseSourceModule(sourceModule);
           
            if (parent != null) {
                for (BlockStatement block : parent.getBlocks()) {
                    BlockName name = block.getName();
                    if (name != null && "block".equals(name.getValue())) {
                        Variable child = (Variable) block.getFirstChild();
                        String value = child.getValue();
                       
                        if (CodeAssistUtils.startsWithIgnoreCase(value, prefix)) {
                            FakeField field = new FakeField((ModelElement) context.getSourceModule(), value, 0);
                            reporter.reportField(field, "", range, false);
                        }
                    }
                }
            }
View Full Code Here


        contexts.add(new TemplateVariablesContext());
        contexts.add(new QuotesContext());
        contexts.add(new FunctionContext());
        contexts.add(new TagContext());
        contexts.add(new TestContext());
        contexts.add(new BlocknameContext());

        IConfigurationElement[] config = Platform.getExtensionRegistry()
                .getConfigurationElementsFor(CONTEXTYFACTORY_ID);

        try {
View Full Code Here

TOP

Related Classes of com.dubture.twig.core.codeassist.context.BlocknameContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.