/** * Returns a database-specific SQL statement service class. * * @param profileName * @param dbType * @return */ public static SQLService getSQLService(DatabaseIdentifier databaseIdentifier, String dbType) { SQLDevToolsConfiguration f = getConfiguration(dbType, databaseIdentifier); return f.getSQLService(); }
/** * Return all the GenericSQLContextType objects which identify the context type of templates used in SQL editor. * * @return */ public static Collection getSQLContextTypes() { Collection c = getRegistry().getConfigurations(); int size = c.size(); SQLDevToolsConfiguration[] fs = (SQLDevToolsConfiguration[]) c.toArray(new SQLDevToolsConfiguration[size]); Collection ctxTypes = new ArrayList(); for (int i = 0; i < size; i++) { ctxTypes.add(fs[i].getSQLService().getSQLContextType()); } return ctxTypes; }
/** * Returns this plug-in's context type registry. * * @return the context type registry for this plug-in instance */ public ContextTypeRegistry getTemplateContextTypeRegistry() { if (_registry == null) { // create an configure the contexts available in the template editor _registry = new ContributionContextTypeRegistry(); _registry.addContextType(GenericSQLContextType.SQL_CONTEXT_TYPE); Collection c = SQLToolsFacade.getConfigurations(); Collection ctxTypes = new ArrayList(); for (Iterator iter = c.iterator(); iter.hasNext();) { SQLDevToolsConfiguration config = (SQLDevToolsConfiguration) iter.next(); ctxTypes.add(config.getSQLService().getSQLContextType()); } for (Iterator i = ctxTypes.iterator(); i.hasNext();) { //getId() will return null before calling addContextType _registry.addContextType(((GenericSQLContextType) i.next()).getSQLContextId()); } } return _registry; }
private void createPortabilityCheckCombo(Composite parent) { Collection dbnames = SQLToolsFacade.getSupportedDBDefinitionNames(); String[] names = (String[])dbnames.toArray(new String[dbnames.size()]); String[] nameValues = new String[names.length + 1]; nameValues[0] = PreferenceMessages.GeneralPreferencePage_portable_target; // FOR CR:403675-1 remove the portability checks option that has no parser in preference page int j = 0; for (int i = 0; i < names.length; i++) { SQLDevToolsConfiguration config = SQLToolsFacade.getConfigurationByDBDefName(names[i]); SQLParser pp = config.getSQLService().getSQLParser(); //For CR:list all supported database definitions if (pp != null && pp.isComplete()) { nameValues[j + 1] = names[i]; j++; } } String[] portNameValues = new String[j + 1]; for (int i = 0; i < j + 1; i++) { portNameValues[i] = nameValues[i]; } _portabilityCheckLabel = new Label(parent, SWT.NONE); _portabilityCheckLabel.setText(PreferenceMessages.GeneralPreferencePage_portable_check); _portabilityCheckCombo = new Combo(parent, SWT.READ_ONLY); _portabilityCheckCombo.setItems(portNameValues); }
/** * Generally this method is not encouraged to overide * * @param value * @param databaseIdentifier * @return */ protected ValidatorMessage checkReservedwords(String value, DatabaseIdentifier databaseIdentifier) { SQLDevToolsConfiguration conf = SQLToolsFacade.getConfiguration(null, databaseIdentifier); String[] reserved = conf.getSQLService().getSQLSyntax().getReservedwords(); String[] types = conf.getSQLService().getSQLSyntax().getTypes(); for (int i = 0; i < reserved.length; i++) { if (value.equalsIgnoreCase(reserved[i])) { return new ValidatorMessage(ValidatorMessage.ERROR, Messages.IdentifierValidator_invalid_reservedword); } } for (int i = 0; i < types.length; i++) { if (value.equalsIgnoreCase(types[i])) { return new ValidatorMessage(ValidatorMessage.ERROR, Messages.IdentifierValidator_invalid_reservedword); } } return null; }
/** * Checks the validity of the unquoted identifier and unquotes content if necessary. * * @param id original identifier * @return */ public static String unquoteWhenNecessary(String id, DatabaseIdentifier databaseIdentifier) { if (id == null || id.equals("") || databaseIdentifier == null) { return id; } String newId = SQLUtil.unquote(id); SQLDevToolsConfiguration conf = SQLToolsFacade.getConfigurationByProfileName(databaseIdentifier.getProfileName()); IIdentifierValidator validator = conf.getSQLService().getIdentifierValidator(); if (validator != null) { ValidatorMessage msg = validator.isValid(newId, IIdentifierValidator.IDENTIFIER_TYPE_UNKNOW, databaseIdentifier); if (msg == null || !ValidatorMessage.hasError(msg, ValidatorMessage.ERROR)) { return newId; } } return id; }
public ProceduralObjectSourceUpdater(SQLObject _object, DatabaseDefinition dbDefinition) { this._routine = _object; _dbDefinition = dbDefinition; _dbDefinitionId = new DatabaseVendorDefinitionId(_dbDefinition.getProduct(), _dbDefinition.getVersion()); SQLDevToolsConfiguration f = SQLToolsFacade.getConfigurationByVendorIdentifier(_dbDefinitionId); _parser = f.getSQLService().getSQLParser(); _parserParameters = new ParserParameters(false); _parserParameters.setProperty(ParserParameters.PARAM_HEADER_MODE, Boolean.TRUE); }
IIdentifierValidator validator = conf.getSQLService().getIdentifierValidator(); if (validator != null)
_config = SQLToolsFacade .getConfigurationByVendorIdentifier(_databaseVendorDefinitionId); SQLParser _parser = _config.getSQLService().getSQLParser(); result.getRootNode().setDocument(doc); ParserProposalAdvisor parserAdvisor = _config.getSQLService() .getParserProposalAdvisor(); return getProposals(result, parserAdvisor);
/** * Creates, configures, and returns the ContentFormatter to use. * * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getContentFormatter(ISourceViewer) */ public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) { ContentFormatter formatter = new ContentFormatter(); formatter.setDocumentPartitioning( SQLPartitionScanner.SQL_PARTITIONING ); SQLDevToolsConfiguration factory = SQLToolsFacade.getConfigurationByVendorIdentifier(getSQLEditor().getConnectionInfo().getDatabaseVendorDefinitionId()); IFormattingStrategy formattingStrategy = new SQLWordStrategy(factory.getSQLService().getSQLSyntax()); formatter.setFormattingStrategy( formattingStrategy, IDocument.DEFAULT_CONTENT_TYPE ); return formatter; }
if (_fWord.startsWith(globalVariablePrefix)) //$NON-NLS-1$ ISQLSyntax syntax = _config.getSQLService().getSQLSyntax(); resultCollector.setVariableList(new ArrayList(Arrays .asList(createVarProposals(syntax
.getDatabaseVendorDefinitionId()); if (config != null) { contextType = config.getSQLService().getSQLContextType(); } else { contextType = SQLEditorPlugin.getDefault()
/** * Sets up the document partitioner. Since we support multiple dialects, each time when the database vendor definition for this SQL editor * is changed, this method should be called to update the document partitioner. */ protected void setupDocumentPartitioner() { IDocument document = getDocumentProvider().getDocument(getEditorInput()); DatabaseVendorDefinitionId vendorId = getConnectionInfo().getDatabaseVendorDefinitionId(); SQLDevToolsConfiguration factory = SQLToolsFacade.getConfigurationByVendorIdentifier(vendorId); SQLPartitionScanner _sqlPartitionSanner = new SQLPartitionScanner(factory.getSQLService().getSQLSyntax()); if (document instanceof IDocumentExtension3) { IDocumentExtension3 extension3 = (IDocumentExtension3) document; IDocumentPartitioner partitioner = new FastPartitioner( _sqlPartitionSanner, new String[] { SQLPartitionScanner.SQL_COMMENT, SQLPartitionScanner.SQL_MULTILINE_COMMENT, SQLPartitionScanner.SQL_STRING, SQLPartitionScanner.SQL_DOUBLE_QUOTES_IDENTIFIER }); partitioner.connect(document); extension3.setDocumentPartitioner(SQLPartitionScanner.SQL_PARTITIONING, partitioner); } }
SQLService sqlService = f.getSQLService(); if (sqlService != null)
SQLParser p = f.getSQLService().getSQLParser(); ISourceViewer viewer = _editor.getSV(); if (viewer == null) pp = pf.getSQLService().getSQLParser(); if (pp != null && !(pp.getClass().equals(p.getClass())))
SQLParser p = conf.getSQLService().getSQLParser(); if (p == null || !p.isComplete())
SQLParser parser = conf.getSQLService().getSQLParser(); if (parser == null)
public void run() { Template template = new Template(); template.setPattern(_sqlEditor.getSelectedText()); SQLDevToolsConfiguration config = SQLToolsFacade.getConfigurationByVendorIdentifier(_sqlEditor.getConnectionInfo().getDatabaseVendorDefinitionId()); SQLService sqlService = config.getSQLService(); template.setContextTypeId(sqlService.getSQLContextType().getSQLContextId()); Dialog dialog = new EditTemplateDialog(null, template, false, true, SQLEditorPlugin.getDefault().getTemplateContextTypeRegistry()); if (dialog.open() == Window.OK) { TemplatePersistenceData data = new TemplatePersistenceData(template, true); SQLEditorPlugin.getDefault().getTemplateStore().add(data); try { SQLEditorPlugin.getDefault().getTemplateStore().save(); } catch (IOException e) { openWriteErrorDialog(e); } } }
if (factory != null) sqlCodeScanner.setSQLSyntax(factory.getSQLService().getSQLSyntax());