public void validate(String pattern) throws TemplateException { super.validate(pattern); if (fIsComment) { if (!isValidComment(pattern)) { throw new TemplateException(JavaTemplateMessages.CodeTemplateContextType_validate_invalidcomment); } } }
@Override public void validate(String pattern) throws TemplateException { super.validate(pattern); if (fIsComment) { if (!isValidComment(pattern)) { throw new TemplateException(JavaTemplateMessages.CodeTemplateContextType_validate_invalidcomment); } } }
protected boolean validate(Template template, TemplateContext context) { try { context.getContextType().validate(template.getPattern()); } catch(TemplateException e) { return false; } return true; }
@Override public void validate(String pattern) throws TemplateException { super.validate(pattern); if (fIsComment) { if (!isValidComment(pattern)) { throw new TemplateException(JavaManipulationMessages.CodeTemplateContextType_validate_invalidcomment); } } }
protected String validateTemplate(Template template) { TemplateContextType type= fRegistry.getContextType(template.getContextTypeId()); if (type == null) { return "Unknown context type: " + template.getContextTypeId(); //$NON-NLS-1$ } try { type.validate(template.getPattern()); return null; } catch (TemplateException e) { return e.getMessage(); } }
protected String validateTemplate(Template template) { TemplateContextType type= fRegistry.getContextType(template.getContextTypeId()); if (type == null) { return "Unknown context type: " + template.getContextTypeId(); //$NON-NLS-1$ } try { type.validate(template.getPattern()); return null; } catch (TemplateException e) { return e.getMessage(); } }
protected String validateTemplate(Template template) { TemplateContextType type= fRegistry.getContextType(template.getContextTypeId()); if (type == null) { return "Unknown context type: " + template.getContextTypeId(); //$NON-NLS-1$ } try { type.validate(template.getPattern()); return null; } catch (TemplateException e) { return e.getMessage(); } }
/** * Validates a template against the context type registered in the context * type registry. Returns always <code>true</code> if no registry is * present. * * @param template the template to validate * @return <code>true</code> if validation is successful or no context * type registry is specified, <code>false</code> if validation * fails */ private boolean validateTemplate(Template template) { String contextTypeId= template.getContextTypeId(); if (contextExists(contextTypeId)) { if (fRegistry != null) try { fRegistry.getContextType(contextTypeId).validate(template.getPattern()); } catch (TemplateException e) { return false; } return true; } return false; }
/** * Validates a template against the context type registered in the context * type registry. Returns always <code>true</code> if no registry is * present. * * @param template the template to validate * @return <code>true</code> if validation is successful or no context * type registry is specified, <code>false</code> if validation * fails */ private boolean validateTemplate(Template template) { String contextTypeId= template.getContextTypeId(); if (contextExists(contextTypeId)) { if (fRegistry != null) try { fRegistry.getContextType(contextTypeId).validate(template.getPattern()); } catch (TemplateException e) { return false; } return true; } return false; }
@Override public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { ITextSelection selection= (ITextSelection) viewer.getSelectionProvider().getSelection(); // adjust offset to end of normalized selection if (selection.getOffset() == offset) offset= selection.getOffset() + selection.getLength(); String prefix= extractPrefix(viewer, offset); Region region= new Region(offset - prefix.length(), prefix.length()); TemplateContext context= createContext(viewer, region); if (context == null) return new ICompletionProposal[0]; context.setVariable("selection", selection.getText()); // name of the selection variables {line, word}_selection //$NON-NLS-1$ Template[] templates= getTemplates(context.getContextType().getId()); List<ICompletionProposal> matches= new ArrayList<>(); for (Template template : templates) { try { context.getContextType().validate(template.getPattern()); } catch (TemplateException e) { continue; } if (template.matches(prefix, context.getContextType().getId())) matches.add(createProposal(template, context, (IRegion) region, getRelevance(template, prefix))); } Collections.sort(matches, fgProposalComparator); return matches.toArray(new ICompletionProposal[matches.size()]); }
/** * Validates a template against the context type registered in the context * type registry. Returns always <code>true</code> if no registry is * present. * * @param template the template to validate * @return <code>true</code> if validation is successful or no context * type registry is specified, <code>false</code> if validation * fails */ private boolean validateTemplate(Template template) { String contextTypeId= template.getContextTypeId(); if (!contextExists(contextTypeId)) return false; if (getRegistry() != null) { try { getRegistry().getContextType(contextTypeId).validate(template.getPattern()); } catch (TemplateException e) { return false; } } return true; }
private void doSourceChanged(IDocument document) { String text= document.get(); fValidationStatus.setOK(); TemplateContextType contextType= fContextTypeRegistry.getContextType(getContextId()); if (contextType != null) { try { contextType.validate(text); } catch (TemplateException e) { fValidationStatus.setError(e.getLocalizedMessage()); } } updateAction(ITextEditorActionConstants.UNDO); updateButtons(); }
protected void doSourceChanged(IDocument document) { String text= document.get(); fValidationStatus.setOK(); TemplateContextType contextType= fContextTypeRegistry.getContextType(getContextId()); if (contextType != null) { try { contextType.validate(text); } catch (TemplateException e) { fValidationStatus.setError(e.getLocalizedMessage()); } } updateAction(ITextEditorActionConstants.UNDO); updateStatusAndButtons(); }
/** * Validates a template against the context type registered in the context type registry. Returns always * <code>true</code> if no registry is present. * * @param template the template to validate * @return <code>true</code> if validation is successful or no context type registry is specified, * <code>false</code> if validation fails */ private boolean validateTemplate(Template template) { String contextTypeId = template.getContextTypeId(); if (!contextExists(contextTypeId)) { return false; } if (getRegistry() != null) { try { getRegistry().getContextType(contextTypeId).validate(template.getPattern()); } catch (TemplateException e) { return false; } } return true; }
private void doSourceChanged(IDocument document) { String text= document.get(); fValidationStatus.setOK(); TemplateContextType contextType= fContextTypeRegistry.getContextType(getContextId()); if (contextType != null) { try { contextType.validate(text); } catch (TemplateException e) { fValidationStatus.setError(e.getLocalizedMessage()); } } updateUndoAction(); updateButtons(); }
protected void doSourceChanged(IDocument document) { String text= document.get(); fValidationStatus.setOK(); TemplateContextType contextType= fContextTypeRegistry.getContextType(getContextId()); if (contextType != null) { try { contextType.validate(text); } catch (TemplateException e) { fValidationStatus.setError(e.getLocalizedMessage()); } } updateUndoAction(); updateStatusAndButtons(); }
private void doSourceChanged(IDocument document) { String text= document.get(); fValidationStatus.setOK(); TemplateContextType contextType= fContextTypeRegistry.getContextType(getContextId()); if (contextType != null) { try { contextType.validate(text); } catch (TemplateException e) { fValidationStatus.setError(e.getLocalizedMessage()); } } updateAction(ITextEditorActionConstants.UNDO); updateButtons(); }
protected void doSourceChanged(IDocument document) { String text= document.get(); fValidationStatus.setOK(); TemplateContextType contextType= fContextTypeRegistry.getContextType(getContextId()); if (contextType != null) { try { contextType.validate(text); } catch (TemplateException e) { fValidationStatus.setError(e.getLocalizedMessage()); } } updateAction(ITextEditorActionConstants.UNDO); updateStatusAndButtons(); }
private void doSourceChanged(IDocument document) { String text = document.get(); _fTemplate.setPattern(text); _fValidationStatus.setOK(); TemplateContextType contextType = _fContextTypeRegistry.getContextType(_fTemplate.getContextTypeId()); if (contextType != null) { try { contextType.validate(text); } catch (TemplateException e) { _fValidationStatus.setError(e.getLocalizedMessage()); } } updateUndoAction(); updateButtons(); }
/** * Validates a template against the context type registered in the context * type registry. Returns always <code>true</code> if no registry is * present. * * @param template the template to validate * @return <code>true</code> if validation is successful or no context * type registry is specified, <code>false</code> if validation * fails */ private boolean validateTemplate(Template template) { String contextTypeId= template.getContextTypeId(); if (!contextExists(contextTypeId)) return false; if (getRegistry() != null) { try { getRegistry().getContextType(contextTypeId).validate(template.getPattern()); } catch (TemplateException e) { EditorsPlugin.log(NLSUtility.format(ContributionTemplateMessages.ContributionTemplateStore_ignore_validation_failed, template.getName()), e); return false; } } return true; }