Examples of DocumentTemplateContext


Examples of org.eclipse.jface.text.templates.DocumentTemplateContext

    public void resolve(final TemplateVariable variable, final TemplateContext theContext) {
        if (reentry) {
            return;
        }
        reentry = true;
        final DocumentTemplateContext context = new DocumentTemplateContext(
                ErlangSourceContextTypeModule.getDefault(), new Document(
                        fTemplate.getPattern()), 0, fTemplate.getPattern().length());
        TemplateBuffer tb;
        try {
            tb = context.evaluate(fTemplate);
            variable.setValue(tb.getString());
        } catch (final BadLocationException e) {
        } catch (final TemplateException e) {
        }
        reentry = false;
View Full Code Here

Examples of org.eclipse.jface.text.templates.DocumentTemplateContext

            final Template commentTemplate = ErlangSourceContextTypeComment.getDefault()
                    .getTemplateStore()
                    .getTemplateData("org.erlide.ui.erlangsource.functioncomment")
                    .getTemplate();

            DocumentTemplateContext commentContext = new DocumentTemplateContext(
                    ErlangSourceContextTypeLayout.getDefault(), new Document(
                            commentTemplate.getPattern()), 0, commentTemplate
                            .getPattern().length());
            TemplateBuffer tb = null;
            try {
                tb = commentContext.evaluate(commentTemplate);
            } catch (final BadLocationException e) {
                ErlLogger.warn(e);
                buff.append("Error: " + e.getMessage());
            } catch (final TemplateException e) {
                ErlLogger.warn(e);
                buff.append("Error: " + commentTemplate.getName()
                        + " could not be validated!");
            }

            if (tb != null) {
                buff.append(tb.getString() + "\n");
            }

            final Template template = ErlangSourceContextTypeComment.getDefault()
                    .getTemplateStore()
                    .getTemplateData("org.erlide.ui.erlangsource.functionlayout")
                    .getTemplate();

            commentContext = new DocumentTemplateContext(
                    ErlangSourceContextTypeLayout.getDefault(), new Document(
                            template.getPattern()), 0, template.getPattern().length());
            try {
                tb = commentContext.evaluate(template);
            } catch (final BadLocationException e) {
                ErlLogger.warn(e);
                buff.append("Error: " + e.getMessage());
            } catch (final TemplateException e) {
                ErlLogger.warn(e);
View Full Code Here

Examples of org.eclipse.jface.text.templates.DocumentTemplateContext

        }

        TemplateBuffer tb = null;

        try {
            final DocumentTemplateContext context = new DocumentTemplateContext(
                    contextType, new Document(template.getPattern()), 0, template
                            .getPattern().length());
            tb = context.evaluate(template);
        } catch (final BadLocationException e) {
            ErlLogger.warn(e);
        } catch (final TemplateException e) {
            ErlLogger.warn(e);
        }
View Full Code Here

Examples of org.eclipse.jface.text.templates.DocumentTemplateContext

    Template template = getSelectedTemplate();
    if (template != null) {
      TemplateContextType contextType = JSPUIPlugin.getDefault().getTemplateContextRegistry().getContextType(TemplateContextTypeIdsJSP.NEW_TAG);
      IDocument document = new Document();
      TemplateContext context = new DocumentTemplateContext(contextType, document, 0, 0);
      try {
        TemplateBuffer buffer = context.evaluate(template);
        templateString = buffer.getString();
      }
      catch (Exception e) {
        Logger.log(Logger.WARNING_DEBUG, "Could not create template for new jsp tag", e); //$NON-NLS-1$
      }
View Full Code Here

Examples of org.eclipse.jface.text.templates.DocumentTemplateContext

    Template template = getSelectedTemplate();
    if (template != null) {
      TemplateContextType contextType = JSPUIPlugin.getDefault().getTemplateContextRegistry().getContextType(TemplateContextTypeIdsJSP.NEW);
      IDocument document = new Document();
      TemplateContext context = new DocumentTemplateContext(contextType, document, 0, 0);
      try {
        TemplateBuffer buffer = context.evaluate(template);
        templateString = buffer.getString();
      }
      catch (Exception e) {
        Logger.log(Logger.WARNING_DEBUG, "Could not create template for new jsp", e); //$NON-NLS-1$
      }
View Full Code Here

Examples of org.eclipse.jface.text.templates.DocumentTemplateContext

    Template template = getSelectedTemplate();
    if (template != null) {
      TemplateContextType contextType = XMLUIPlugin.getDefault().getTemplateContextRegistry().getContextType(TemplateContextTypeIdsXML.NEW);
      IDocument document = new Document();
      TemplateContext context = new DocumentTemplateContext(contextType, document, 0, 0);
      try {
        TemplateBuffer buffer = context.evaluate(template);
        templateString = buffer.getString();
      }
      catch (Exception e) {
        Logger.log(Logger.WARNING_DEBUG, "Could not create template for new xml", e); //$NON-NLS-1$
      }
View Full Code Here

Examples of org.eclipse.jface.text.templates.DocumentTemplateContext

  public HdlTemplateProposal createProposal() {
    Region region = null;
    Image image;
    int relevance = 0;
    TemplateWithIndent templateX = null;
    DocumentTemplateContext context = null;
    Template template = null;

    image = VerilogPlugin.getPlugin().getImage(m_Element.GetImageName());
    context = new DocumentTemplateContext(new VhdlGlobalContext(), m_Doc,
        m_Offset, m_Length);
    //set the region to cover the text begin replaced
    region = new Region(m_Offset, m_Length);

    template = new Template(
View Full Code Here

Examples of org.eclipse.jface.text.templates.DocumentTemplateContext

      }
      //get a list of templates
      String contextString=getTemplateContextString(context);
      TemplateContextType contextType=VerilogPlugin.getPlugin().getContextTypeRegistry().getContextType(contextString);
      Template[] templates= VerilogPlugin.getPlugin().getTemplateStore().getTemplates(contextType.getId());
      DocumentTemplateContext documnetTemplateContext= new DocumentTemplateContext(contextType, doc, region.getOffset(), region.getLength());
      //find a matching template
      for (int i= 0; i < templates.length; i++) {
        Template template= templates[i];
        String pattern = template.getPattern();
        pattern = pattern.replace("\t", indentationstring);
View Full Code Here

Examples of org.eclipse.jface.text.templates.DocumentTemplateContext

     * @return a template context that can handle template insertion at the given location, or <code>null</code>
     */
    protected TemplateContext createContext(ITextViewer viewer, IRegion region, IDocument document) {
        TemplateContextType contextType = getContextType(viewer, region);
        if (contextType != null) {
            return new DocumentTemplateContext(contextType, document, region.getOffset(), region.getLength());
        }
        return null;
    }
View Full Code Here

Examples of org.eclipse.jface.text.templates.DocumentTemplateContext

   
    String string = null;
    int offset = 0;
    if (template != null) {
      IDocument document = new Document();
      DocumentTemplateContext context = getContext(contextTypeRegistry, template, containerName, fileName, document, varHolder);
      TemplateBuffer buffer = null;
      try {
        buffer = context.evaluate(template);
      } catch (BadLocationException e) {
        PHPUiPlugin.log(e);
      } catch (TemplateException e) {
        PHPUiPlugin.log(e);
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.