private void Init() { InsertText = DeclarationTitle; Label = DeclarationTitle; DelimitedIdentifier delimitedIdentifier = GetDelimitedIdentifier(TokenText); // If we're not already going to quote this then handle special cases for various // DeclarationTypes if (delimitedIdentifier == null && !string.IsNullOrEmpty(DeclarationTitle)) { switch (this.DeclarationType) { case DeclarationType.Server: case DeclarationType.Database: case DeclarationType.Table: case DeclarationType.Column: case DeclarationType.View: case DeclarationType.Schema: // Only quote if we need to - i.e. if this isn't a valid name (has characters that need escaping such as [) // or if it's a reserved word if (!ValidSqlNameRegex.IsMatch(DeclarationTitle) || AutoCompleteHelper.IsReservedWord(InsertText)) { InsertText = WithDelimitedIdentifier(BracketedIdentifiers, DeclarationTitle); } break; case DeclarationType.BuiltInFunction: case DeclarationType.ScalarValuedFunction: case DeclarationType.TableValuedFunction: // Add ()'s for all functions except global variable system functions (which all start with @@) if (!DeclarationTitle.StartsWith("@@")) { InsertText = WithDelimitedIdentifier(FunctionPostfix, DeclarationTitle); } break; } } // If the user typed a token that starts with a delimiter then always quote both // the display label and text to be inserted if (delimitedIdentifier != null) { Label = WithDelimitedIdentifier(delimitedIdentifier, Label); InsertText = WithDelimitedIdentifier(delimitedIdentifier, InsertText); } Detail = Label; Kind = CreateCompletionItemKind(); }
private void Init() { InsertText = DeclarationTitle; DelimitedIdentifier delimitedIdentifier = GetDelimitedIdentifier(TokenText); Label = DeclarationTitle; if (delimitedIdentifier == null && !string.IsNullOrEmpty(DeclarationTitle) && (!ValidSqlNameRegex.IsMatch(DeclarationTitle) || AutoCompleteHelper.IsReservedWord(InsertText))) { InsertText = WithDelimitedIdentifier(BracketedIdentifiers, DeclarationTitle); } if (delimitedIdentifier != null) { Label = WithDelimitedIdentifier(delimitedIdentifier, Label); InsertText = WithDelimitedIdentifier(delimitedIdentifier, InsertText); } Detail = Label; Kind = CreateCompletionItemKind(); }