use of org.eclipse.jface.text.templates.ContextTypeRegistry in project xtext-eclipse by eclipse.
the class TemplateValidator method checkParameters.
@Check
public void checkParameters(Variable variable) {
Codetemplate template = EcoreUtil2.getContainerOfType(variable, Codetemplate.class);
Codetemplates templates = EcoreUtil2.getContainerOfType(template, Codetemplates.class);
if (templates != null && template != null) {
Grammar language = templates.getLanguage();
AbstractRule rule = template.getContext();
ContextTypeIdHelper helper = languageRegistry.getContextTypeIdHelper(language);
if (helper != null && rule != null && !rule.eIsProxy() && rule instanceof ParserRule) {
String contextTypeId = helper.getId(rule);
ContextTypeRegistry contextTypeRegistry = languageRegistry.getContextTypeRegistry(language);
TemplateContextType contextType = contextTypeRegistry.getContextType(contextTypeId);
if (contextType != null) {
Iterator<TemplateVariableResolver> resolvers = Iterators.filter(contextType.resolvers(), TemplateVariableResolver.class);
String type = variable.getType();
if (type == null)
type = variable.getName();
while (resolvers.hasNext()) {
final TemplateVariableResolver resolver = resolvers.next();
if (resolver.getType().equals(type)) {
IInspectableTemplateVariableResolver inspectableResolver = registry.toInspectableResolver(resolver);
if (inspectableResolver != null) {
inspectableResolver.validateParameters(variable, this);
}
}
}
}
}
}
}
use of org.eclipse.jface.text.templates.ContextTypeRegistry in project liferay-ide by liferay.
the class NewLayoutTplWizard method getDefaultProvider.
@Override
protected IDataModelProvider getDefaultProvider() {
LayoutTplUI defaultUI = LayoutTplUI.getDefault();
TemplateStore templateStore = defaultUI.getTemplateStore();
ContextTypeRegistry contextTypeRegistry = defaultUI.getTemplateContextRegistry();
TemplateContextType contextType = contextTypeRegistry.getContextType(LayoutTplTemplateContextTypeIds.NEW);
return new NewLayoutTplDataModelProvider() {
@Override
public IDataModelOperation getDefaultOperation() {
return new AddLayoutTplOperation(getDataModel(), templateStore, contextType);
}
};
}
use of org.eclipse.jface.text.templates.ContextTypeRegistry in project liferay-ide by liferay.
the class LiferayUIPlugin method _registerResolvers.
private void _registerResolvers() {
ContextTypeRegistry templateContextRegistry = JavaPlugin.getDefault().getTemplateContextRegistry();
Iterator<?> ctIter = templateContextRegistry.contextTypes();
while (ctIter.hasNext()) {
Object next = ctIter.next();
if (next instanceof TemplateContextType) {
TemplateContextType contextType = (TemplateContextType) next;
if (contextType.getId().equals("java")) {
contextType.addResolver(new ServiceClassNameResolver());
}
}
}
}
use of org.eclipse.jface.text.templates.ContextTypeRegistry in project liferay-ide by liferay.
the class ServiceXmlTemplateCompletinoProcessor method getContextType.
@Override
protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) {
TemplateContextType type = null;
ContextTypeRegistry registry = getTemplateContextRegistry();
if (registry != null) {
type = registry.getContextType(ServiceXmlContextType.ID_SERVICE_XML_TAG);
}
return type;
}
use of org.eclipse.jface.text.templates.ContextTypeRegistry in project mylyn.docs by eclipse.
the class WikiTextTemplateAccess method getContextTypeRegistry.
public ContextTypeRegistry getContextTypeRegistry() {
if (registry == null) {
if (WikiTextUiPlugin.getDefault() != null) {
ContributionContextTypeRegistry contributionRegistry = new ContributionContextTypeRegistry();
contributionRegistry.addContextType(SourceTemplateContextType.ID);
registry = contributionRegistry;
} else {
ContextTypeRegistry contextTypeRegistry = new ContextTypeRegistry();
contextTypeRegistry.addContextType(new SourceTemplateContextType());
registry = contextTypeRegistry;
}
}
return registry;
}
Aggregations