private static String evaluateTemplate(CodeTemplateContext context, Template template) throws CoreException { TemplateBuffer buffer; try { buffer= context.evaluate(template); } catch (BadLocationException e) { throw new CoreException(Status.CANCEL_STATUS); } catch (TemplateException e) { throw new CoreException(Status.CANCEL_STATUS); } if (buffer == null) return null; String str= buffer.getString(); if (Strings.containsOnlyWhitespaces(str)) { return null; } return str; }
private int getCaretOffset(TemplateBuffer buffer) { TemplateVariable[] variables= buffer.getVariables(); for (int i= 0; i != variables.length; i++) { TemplateVariable variable= variables[i]; if (variable.getType().equals(GlobalTemplateVariables.Cursor.NAME)) return variable.getOffsets()[0]; } return buffer.getString().length(); }
private int getCaretOffset(TemplateBuffer buffer) { TemplateVariable[] variables= buffer.getVariables(); for (int i= 0; i != variables.length; i++) { TemplateVariable variable= variables[i]; if (variable.getType().equals(GlobalTemplateVariables.Cursor.NAME)) return variable.getOffsets()[0]; } return buffer.getString().length(); }
private int getCaretOffset(TemplateBuffer buffer) { TemplateVariable[] variables= buffer.getVariables(); for (int i= 0; i != variables.length; i++) { TemplateVariable variable= variables[i]; if (variable.getType().equals(GlobalTemplateVariables.Cursor.NAME)) return variable.getOffsets()[0]; } return buffer.getString().length(); }
private static String evaluateTemplate(CodeTemplateContext context, Template template) throws CoreException { TemplateBuffer buffer; try { buffer= context.evaluate(template); } catch (BadLocationException e) { throw new CoreException(Status.CANCEL_STATUS); } catch (TemplateException e) { throw new CoreException(Status.CANCEL_STATUS); } if (buffer == null) return null; String str= buffer.getString(); if (Strings.containsOnlyWhitespaces(str)) { return null; } return str; }
private static String evaluateTemplate(CodeTemplateContext context, Template template) throws CoreException { TemplateBuffer buffer; try { buffer= context.evaluate(template); } catch (BadLocationException e) { throw new CoreException(Status.CANCEL_STATUS); } catch (TemplateException e) { throw new CoreException(Status.CANCEL_STATUS); } if (buffer == null) return null; String str= buffer.getString(); if (Strings.containsOnlyWhitespaces(str)) { return null; } return str; }
private int getCaretOffset(TemplateBuffer buffer) { TemplateVariable[] variables= buffer.getVariables(); for (int i= 0; i != variables.length; i++) { TemplateVariable variable= variables[i]; if (variable.getType().equals(GlobalTemplateVariables.Cursor.NAME)) return variable.getOffsets()[0]; } return buffer.getString().length(); }
private int getCaretOffset(TemplateBuffer buffer) { TemplateVariable[] variables= buffer.getVariables(); for (int i= 0; i != variables.length; i++) { TemplateVariable variable= variables[i]; if (variable.getType().equals(GlobalTemplateVariables.Cursor.NAME)) return variable.getOffsets()[0]; } return buffer.getString().length(); }
private int getCaretOffset(TemplateBuffer buffer) { TemplateVariable[] variables = buffer.getVariables(); for (int i = 0; i != variables.length; i++) { TemplateVariable variable = variables[i]; if (variable.getType().equals(GlobalTemplateVariables.Cursor.NAME)) { return variable.getOffsets()[0]; } } return buffer.getString().length(); }
@Override public String getAdditionalProposalInfo() { try { fContext.setReadOnly(true); TemplateBuffer templateBuffer; try { templateBuffer= fContext.evaluate(fTemplate); } catch (TemplateException e) { return null; } return templateBuffer.getString(); } catch (BadLocationException e) { return null; } }
@Override public String getAdditionalProposalInfo() { try { fContext.setReadOnly(true); TemplateBuffer templateBuffer; try { templateBuffer= fContext.evaluate(fTemplate); } catch (TemplateException e) { return null; } return templateBuffer.getString(); } catch (BadLocationException e) { return null; } }
private String evaluateTemplate(Template template, CodeTemplateContext context) { TemplateBuffer buffer; try { buffer= context.evaluate(template); } catch (BadLocationException e) { JavaPlugin.log(e); return ""; //$NON-NLS-1$ } catch (TemplateException e) { JavaPlugin.log(e); return ""; //$NON-NLS-1$ } if (buffer == null) return ""; //$NON-NLS-1$ return buffer.getString(); }
private String evaluateTemplate(Template template, CodeTemplateContext context) { TemplateBuffer buffer; try { buffer= context.evaluate(template); } catch (BadLocationException e) { JavaPlugin.log(e); return ""; //$NON-NLS-1$ } catch (TemplateException e) { JavaPlugin.log(e); return ""; //$NON-NLS-1$ } if (buffer == null) return ""; //$NON-NLS-1$ return buffer.getString(); }
public String getAdditionalProposalInfo() { try { fContext.setReadOnly(true); TemplateBuffer templateBuffer; try { templateBuffer= fContext.evaluate(fTemplate); } catch (TemplateException e1) { return null; } IDocument document= new Document(templateBuffer.getString()); IndentUtil.indentLines(document, new LineRange(0, document.getNumberOfLines()), null, null); return document.get(); } catch (BadLocationException e) { handleException(JavaPlugin.getActiveWorkbenchShell(), new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, "", e))); //$NON-NLS-1$ return null; } }
@Override public String getAdditionalProposalInfo() { try { fContext.setReadOnly(true); TemplateBuffer templateBuffer; try { templateBuffer= fContext.evaluate(fTemplate); } catch (TemplateException e) { return null; } IDocument document= new Document(templateBuffer.getString()); IndentUtil.indentLines(document, new LineRange(0, document.getNumberOfLines()), null, null); return document.get(); } catch (BadLocationException e) { handleException(JavaPlugin.getActiveWorkbenchShell(), new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, "", e))); //$NON-NLS-1$ return null; } }
@Override public String getAdditionalProposalInfo() { try { fContext.setReadOnly(true); TemplateBuffer templateBuffer; try { templateBuffer= fContext.evaluate(fTemplate); } catch (TemplateException e) { return null; } IDocument document= new Document(templateBuffer.getString()); IndentUtil.indentLines(document, new LineRange(0, document.getNumberOfLines()), null, null); return document.get(); } catch (BadLocationException e) { handleException(JavaPlugin.getActiveWorkbenchShell(), new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, "", e))); //$NON-NLS-1$ return null; } }
public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException { TemplateBuffer buffer = super.evaluate(template); if (buffer != null) { if ((fInsertOffset > -1) && (fInsertOffset > getStart())) { String prefix = getDocument().get(getStart(), fInsertOffset - getStart()); if (!template.getName().startsWith(prefix)) { // generate a new buffer that actually contains the // text that was going to be overwritten buffer = new TemplateBuffer(prefix + buffer.getString(), buffer.getVariables()); } } } return buffer; } }
/** * Creates a new tracker. * * @param buffer the buffer to track * @throws MalformedTreeException * @throws BadLocationException */ public VariableTracker(TemplateBuffer buffer) throws MalformedTreeException, BadLocationException { Assert.isLegal(buffer != null); fBuffer= buffer; fDocument= new Document(fBuffer.getString()); installJavaStuff(fDocument); fDocument.addPositionCategory(CATEGORY); fDocument.addPositionUpdater(new ExclusivePositionUpdater(CATEGORY)); fPositions= createRangeMarkers(fBuffer.getVariables(), fDocument); }
/** * Creates a new tracker. * * @param buffer the buffer to track * @throws MalformedTreeException * @throws BadLocationException */ public VariableTracker(TemplateBuffer buffer) throws MalformedTreeException, BadLocationException { Assert.isLegal(buffer != null); fBuffer= buffer; fDocument= new Document(fBuffer.getString()); installJavaStuff(fDocument); fDocument.addPositionCategory(CATEGORY); fDocument.addPositionUpdater(new ExclusivePositionUpdater(CATEGORY)); fPositions= createRangeMarkers(fBuffer.getVariables(), fDocument); }
/** * Creates a new tracker. * * @param buffer the buffer to track * @throws MalformedTreeException * @throws BadLocationException */ public VariableTracker(TemplateBuffer buffer) throws MalformedTreeException, BadLocationException { Assert.isLegal(buffer != null); fBuffer= buffer; fDocument= new Document(fBuffer.getString()); installJavaStuff(fDocument); fDocument.addPositionCategory(CATEGORY); fDocument.addPositionUpdater(new ExclusivePositionUpdater(CATEGORY)); fPositions= createRangeMarkers(fBuffer.getVariables(), fDocument); }