public void VisitColumnReference(OracleColumnReference columnReference) { if (TryBuildSchemaTooltip(columnReference)) { return; } if (columnReference.ObjectNode == _terminal) { columnReference.ValidObjectReference?.Accept(this); return; } if (columnReference.ColumnDescription == null) { return; } var validObjectReference = columnReference.ValidObjectReference; var isSchemaObject = validObjectReference.Type == ReferenceType.SchemaObject; var targetSchemaObject = isSchemaObject ? validObjectReference.SchemaObject.GetTargetSchemaObject() : null; var databaseModel = columnReference.Container.SemanticModel.DatabaseModel; if (isSchemaObject) { ColumnDetailsModel dataModel; switch (targetSchemaObject.Type) { case OracleObjectType.Table: case OracleObjectType.MaterializedView: dataModel = BuildColumnDetailsModel(databaseModel, columnReference); ToolTip = columnReference.ColumnDescription.IsPseudocolumn ? (IToolTip)new ToolTipViewColumn(dataModel) : new ToolTipColumn(dataModel); return; case OracleObjectType.View: dataModel = BuildColumnDetailsModel(databaseModel, columnReference); ToolTip = new ToolTipViewColumn(dataModel); return; } } var objectPrefix = columnReference.ObjectNode == null && !String.IsNullOrEmpty(validObjectReference.FullyQualifiedObjectName.Name) ? $"{validObjectReference.FullyQualifiedObjectName.ToLabel()}." : null; var qualifiedColumnName = isSchemaObject && String.Equals(targetSchemaObject.Type, OracleObjectType.Sequence) ? null : $"{objectPrefix}{columnReference.NormalizedName.ToSimpleIdentifier()}"; var labelBuilder = new ToolTipLabelBuilder(); labelBuilder.AddElement(qualifiedColumnName); labelBuilder.AddElement(columnReference.ColumnDescription.FullTypeName); labelBuilder.AddElement($"{(columnReference.ColumnDescription.Nullable ? null : "NOT ")}NULL"); ToolTip = new ToolTipObject { DataContext = labelBuilder.ToString() }; }
public void VisitPlSqlVariableReference(OraclePlSqlVariableReference variableReference) { if (variableReference.Variables.Count != 1) { return; } var element = variableReference.Variables.First(); var labelBuilder = new ToolTipLabelBuilder(); var elementTypeName = element.GetType().Name; var elementName = $"{element.Name.ToSimpleIdentifier()}:"; switch (elementTypeName) { case nameof(OraclePlSqlParameter): var parameter = (OraclePlSqlParameter)element; labelBuilder.AddElement("Parameter"); labelBuilder.AddElement(elementName); labelBuilder.AddElement(GetDataTypeFromNode(parameter)); labelBuilder.AddElement("NULL"); labelBuilder.AddElement(GetDefaultExpression(variableReference.PlSqlProgram, parameter), "= "); break; case nameof(OraclePlSqlVariable): var variable = (OraclePlSqlVariable)element; labelBuilder.AddElement(variable.IsConstant ? "Constant" : "Variable"); labelBuilder.AddElement(elementName); var dataTypeName = variable.DataType == null ? GetDataTypeFromNode(variable) : OracleDataType.ResolveFullTypeName(variable.DataType); labelBuilder.AddElement(dataTypeName); labelBuilder.AddElement(variable.Nullable ? "NULL" : "NOT NULL"); labelBuilder.AddElement(GetDefaultExpression(variableReference.PlSqlProgram, variable), "= "); break; case nameof(OraclePlSqlType): labelBuilder.AddElement("Type"); labelBuilder.AddElement(elementName); break; case nameof(OraclePlSqlCursorVariable): var cursor = (OraclePlSqlCursorVariable)element; if (variableReference.ObjectNode != null && variableReference.IdentifierNode == _terminal) { labelBuilder.AddElement("Cursor column"); var columns = cursor.SemanticModel?.MainQueryBlock?.NamedColumns[variableReference.NormalizedName].ToArray(); var columnName = variableReference.NormalizedName.ToSimpleIdentifier(); var columnNameAndType = columns != null && columns.Length == 1 && !String.IsNullOrEmpty(columns[0].ColumnDescription.FullTypeName) ? $"{columnName}: {columns[0].ColumnDescription.FullTypeName}" : columnName; labelBuilder.AddElement($"{cursor.Name.ToSimpleIdentifier()}.{columnNameAndType}"); } else { labelBuilder.AddElement(cursor.IsImplicit ? "Implicit cursor" : "Cursor"); labelBuilder.AddElement(elementName); if (cursor.SemanticModel != null) { var queryText = cursor.SemanticModel.Statement.RootNode.GetText(variableReference.Container.SemanticModel.StatementText); labelBuilder.AddElement(queryText); } } break; } ToolTip = new ToolTipObject { DataContext = labelBuilder.ToString() }; }
public void VisitPlSqlVariableReference(OraclePlSqlVariableReference variableReference) { if (variableReference.Variables.Count != 1) { return; } var element = variableReference.Variables.First(); var labelBuilder = new ToolTipLabelBuilder(); var elementTypeName = element.GetType().Name; var elementName = $"{element.Name.ToSimpleIdentifier()}:"; switch (elementTypeName) { case nameof(OraclePlSqlParameter): var parameter = (OraclePlSqlParameter)element; labelBuilder.AddElement("Parameter"); labelBuilder.AddElement(elementName); labelBuilder.AddElement(GetDataTypeFromNode(parameter)); labelBuilder.AddElement("NULL"); labelBuilder.AddElement(GetDefaultExpression(variableReference.PlSqlProgram, parameter), "= "); break; case nameof(OraclePlSqlVariable): var variable = (OraclePlSqlVariable)element; labelBuilder.AddElement(variable.IsConstant ? "Constant" : "Variable"); labelBuilder.AddElement(elementName); var dataTypeName = variable.DataType == null?GetDataTypeFromNode(variable) : OracleDataType.ResolveFullTypeName(variable.DataType); labelBuilder.AddElement(dataTypeName); labelBuilder.AddElement(variable.Nullable ? "NULL" : "NOT NULL"); labelBuilder.AddElement(GetDefaultExpression(variableReference.PlSqlProgram, variable), "= "); break; case nameof(OraclePlSqlType): labelBuilder.AddElement("Type"); labelBuilder.AddElement(elementName); break; case nameof(OraclePlSqlCursorVariable): var cursor = (OraclePlSqlCursorVariable)element; if (variableReference.ObjectNode != null && variableReference.IdentifierNode == _terminal) { labelBuilder.AddElement("Cursor column"); var columns = cursor.SemanticModel?.MainQueryBlock?.NamedColumns[variableReference.NormalizedName].ToArray(); var columnName = variableReference.NormalizedName.ToSimpleIdentifier(); var columnNameAndType = columns != null && columns.Length == 1 && !String.IsNullOrEmpty(columns[0].ColumnDescription.FullTypeName) ? $"{columnName}: {columns[0].ColumnDescription.FullTypeName}" : columnName; labelBuilder.AddElement($"{cursor.Name.ToSimpleIdentifier()}.{columnNameAndType}"); } else { labelBuilder.AddElement(cursor.IsImplicit ? "Implicit cursor" : "Cursor"); labelBuilder.AddElement(elementName); if (cursor.SemanticModel != null) { var queryText = cursor.SemanticModel.Statement.RootNode.GetText(variableReference.Container.SemanticModel.StatementText); labelBuilder.AddElement(queryText); } } break; } ToolTip = new ToolTipObject { DataContext = labelBuilder.ToString() }; }
public void VisitColumnReference(OracleColumnReference columnReference) { if (TryBuildSchemaTooltip(columnReference)) { return; } if (columnReference.ObjectNode == _terminal) { columnReference.ValidObjectReference?.Accept(this); return; } if (columnReference.ColumnDescription == null) { return; } var validObjectReference = columnReference.ValidObjectReference; var isSchemaObject = validObjectReference.Type == ReferenceType.SchemaObject; var targetSchemaObject = isSchemaObject ? validObjectReference.SchemaObject.GetTargetSchemaObject() : null; var databaseModel = columnReference.Container.SemanticModel.DatabaseModel; if (isSchemaObject) { ColumnDetailsModel dataModel; switch (targetSchemaObject.Type) { case OracleObjectType.Table: case OracleObjectType.MaterializedView: dataModel = BuildColumnDetailsModel(databaseModel, columnReference); ToolTip = columnReference.ColumnDescription.IsPseudocolumn ? (IToolTip) new ToolTipViewColumn(dataModel) : new ToolTipColumn(dataModel); return; case OracleObjectType.View: dataModel = BuildColumnDetailsModel(databaseModel, columnReference); ToolTip = new ToolTipViewColumn(dataModel); return; } } var objectPrefix = columnReference.ObjectNode == null && !String.IsNullOrEmpty(validObjectReference.FullyQualifiedObjectName.Name) ? $"{validObjectReference.FullyQualifiedObjectName.ToLabel()}." : null; var qualifiedColumnName = isSchemaObject && String.Equals(targetSchemaObject.Type, OracleObjectType.Sequence) ? null : $"{objectPrefix}{columnReference.NormalizedName.ToSimpleIdentifier()}"; var labelBuilder = new ToolTipLabelBuilder(); labelBuilder.AddElement(qualifiedColumnName); labelBuilder.AddElement(columnReference.ColumnDescription.FullTypeName); labelBuilder.AddElement($"{(columnReference.ColumnDescription.Nullable ? null : "NOT ")}NULL"); ToolTip = new ToolTipObject { DataContext = labelBuilder.ToString() }; }