private void CheckPrettySignature() { if (_prettySignature == null) { var pcs = new ProbeClassifiedStringBuilder(); var spaceRequired = false; if (_privacy != FunctionPrivacy.Public) { pcs.AddKeyword(_privacy.ToString().ToLower()); spaceRequired = true; } if (_extern) { if (spaceRequired) { pcs.AddSpace(); } pcs.AddKeyword("extern"); spaceRequired = true; } if (_returnDataType != null) { if (spaceRequired) { pcs.AddSpace(); } pcs.AddClassifiedString(_returnDataType.Source); spaceRequired = true; } if (spaceRequired) { pcs.AddSpace(); } pcs.AddFunction(_funcName); pcs.AddOperator("("); spaceRequired = false; var firstArg = true; foreach (var arg in _args) { if (firstArg) { firstArg = false; } else { pcs.AddDelimiter(", "); } var argStartPos = pcs.Length; var argSource = arg.ClassifiedString; pcs.AddClassifiedString(argSource); arg.SignatureSpan = new Span(argStartPos, argStartPos + argSource.Length); } pcs.AddOperator(")"); _prettySignature = pcs.ToClassifiedString(); } }
private void CreateDefinition() { /* * create [unique] [primary | NOPICK] index IndexName on TableName [description "Line1" ... "LineN"] (ColumnName [,...] ) * * create relationship RelationshipName SchemaNumber [updates] [prompt "TablePrompt"] [comment "RelationshipComment"] [image "FileName"] [description "Line1" ... "LineN"] * <one TableNameA to one TableNameB | one TableNameA to many TableNameB | many TableNameA to many TableNameB[2] > [order by [unique] ColumnName [...]] ( [ColumnDefinitions] ) * * create time relationship RelationshipName SchemaNumber [prompt "ChildTablePrompt"] [comment "RelationshipComment"] [description "Line1" ... "LineN"] * MasterTableName to HistoryTableName * [order by effective ColumnName [...]] ( ) */ var pcs = new ProbeClassifiedStringBuilder(); if (Unique) { pcs.AddKeyword("unique"); pcs.AddSpace(); } if (Primary) { pcs.AddKeyword("primary"); pcs.AddSpace(); } if (NoPick) { pcs.AddKeyword("nopick"); pcs.AddSpace(); } switch (_type) { case RelIndType.Index: pcs.AddKeyword("index"); break; case RelIndType.Relationship: pcs.AddKeyword("relationship"); break; case RelIndType.TimeRelationship: pcs.AddKeyword("time"); pcs.AddSpace(); pcs.AddKeyword("relationship"); break; } pcs.AddSpace(); pcs.AddTableName(Name); if (_type == RelIndType.Index) { pcs.AddSpace(); pcs.AddKeyword("on"); pcs.AddSpace(); pcs.AddTableName(TableName); } if (Number != 0) { pcs.AddSpace(); pcs.AddNumber(Number.ToString()); } if (LinkDesc != null && !LinkDesc.IsEmpty) { pcs.AddSpace(); pcs.AddClassifiedString(LinkDesc); } if (_sortCols != null) { switch (_type) { case RelIndType.Index: { pcs.AddSpace(); pcs.AddOperator("("); var first = true; foreach (var col in _sortCols) { if (first) { first = false; } else { pcs.AddDelimiter(","); pcs.AddSpace(); } pcs.AddTableField(col); } pcs.AddOperator(")"); } break; case RelIndType.Relationship: case RelIndType.TimeRelationship: pcs.AddSpace(); pcs.AddKeyword("order"); pcs.AddSpace(); pcs.AddKeyword("by"); if (Unique) { pcs.AddSpace(); pcs.AddKeyword("unique"); } foreach (var col in _sortCols) { pcs.AddSpace(); pcs.AddTableField(col); } pcs.AddSpace(); pcs.AddOperator("("); pcs.AddSpace(); if (Columns.Any()) { pcs.AddComment("... "); } pcs.AddOperator(")"); break; } } _def = new RelIndDefinition(this, TableName, pcs.ToClassifiedString(), Description, FilePosition); }