refactor(ast): rename value types to Number/Decimal/Text/Boolean
Renamed AST value types for v0.3 naming convention: - Value::Int -> Value::Number - Value::Float -> Value::Decimal - Value::String -> Value::Text - Value::Bool -> Value::Boolean - Expr::IntLit -> Expr::NumberLit - Expr::FloatLit -> Expr::DecimalLit - Expr::StringLit -> Expr::TextLit - Expr::BoolLit -> Expr::BooleanLit Updated all references across parser, resolver, validator, LSP, query engine, tests, and editor.
This commit is contained in:
@@ -2389,10 +2389,10 @@ fn get_default_value_for_type(field_type: &crate::syntax::ast::Value) -> String
|
||||
}
|
||||
},
|
||||
| Value::List(_) => String::from("[]"),
|
||||
| Value::String(_) => String::from("\"\""),
|
||||
| Value::Int(_) => String::from("0"),
|
||||
| Value::Float(_) => String::from("0.0"),
|
||||
| Value::Bool(_) => String::from("false"),
|
||||
| Value::Text(_) => String::from("\"\""),
|
||||
| Value::Number(_) => String::from("0"),
|
||||
| Value::Decimal(_) => String::from("0.0"),
|
||||
| Value::Boolean(_) => String::from("false"),
|
||||
| Value::Object(_) => String::from("{}"),
|
||||
| Value::Range(_, _) => String::from("0..10"),
|
||||
| Value::Time(_) => String::from("00:00"),
|
||||
@@ -2408,10 +2408,10 @@ fn format_value(value: &crate::syntax::ast::Value) -> String {
|
||||
use crate::syntax::ast::Value;
|
||||
|
||||
match value {
|
||||
| Value::String(s) => format!("\"{}\"", s),
|
||||
| Value::Int(n) => n.to_string(),
|
||||
| Value::Float(f) => f.to_string(),
|
||||
| Value::Bool(b) => b.to_string(),
|
||||
| Value::Text(s) => format!("\"{}\"", s),
|
||||
| Value::Number(n) => n.to_string(),
|
||||
| Value::Decimal(f) => f.to_string(),
|
||||
| Value::Boolean(b) => b.to_string(),
|
||||
| Value::Identifier(path) => path.join("."),
|
||||
| Value::List(items) => {
|
||||
let formatted: Vec<String> = items.iter().map(format_value).collect();
|
||||
@@ -2443,10 +2443,10 @@ fn infer_type_from_value(value: &crate::syntax::ast::Value) -> String {
|
||||
use crate::syntax::ast::Value;
|
||||
|
||||
match value {
|
||||
| Value::String(_) => String::from("String"),
|
||||
| Value::Int(_) => String::from("Int"),
|
||||
| Value::Float(_) => String::from("Float"),
|
||||
| Value::Bool(_) => String::from("Bool"),
|
||||
| Value::Text(_) => String::from("Text"),
|
||||
| Value::Number(_) => String::from("Number"),
|
||||
| Value::Decimal(_) => String::from("Decimal"),
|
||||
| Value::Boolean(_) => String::from("Boolean"),
|
||||
| Value::Identifier(path) => path.join("."), // Reference type
|
||||
| Value::List(items) => {
|
||||
if items.is_empty() {
|
||||
|
||||
@@ -209,10 +209,10 @@ fn is_typing_declaration_name(text: &str, offset: usize) -> bool {
|
||||
fn format_value_type(value: &Value) -> String {
|
||||
match value {
|
||||
| Value::Identifier(path) => path.join("."),
|
||||
| Value::String(_) => "String".to_string(),
|
||||
| Value::Int(_) => "Int".to_string(),
|
||||
| Value::Float(_) => "Float".to_string(),
|
||||
| Value::Bool(_) => "Bool".to_string(),
|
||||
| Value::Text(_) => "Text".to_string(),
|
||||
| Value::Number(_) => "Number".to_string(),
|
||||
| Value::Decimal(_) => "Decimal".to_string(),
|
||||
| Value::Boolean(_) => "Boolean".to_string(),
|
||||
| Value::List(items) => {
|
||||
if items.is_empty() {
|
||||
"List".to_string()
|
||||
|
||||
@@ -526,10 +526,10 @@ fn format_behavior_node_preview(node: &crate::syntax::ast::BehaviorNode, depth:
|
||||
fn format_value_as_type(value: &Value) -> String {
|
||||
match value {
|
||||
| Value::Identifier(path) => path.join("."),
|
||||
| Value::String(_) => "String".to_string(),
|
||||
| Value::Int(_) => "Int".to_string(),
|
||||
| Value::Float(_) => "Float".to_string(),
|
||||
| Value::Bool(_) => "Bool".to_string(),
|
||||
| Value::Text(_) => "Text".to_string(),
|
||||
| Value::Number(_) => "Number".to_string(),
|
||||
| Value::Decimal(_) => "Decimal".to_string(),
|
||||
| Value::Boolean(_) => "Boolean".to_string(),
|
||||
| Value::List(items) => {
|
||||
if items.is_empty() {
|
||||
"List".to_string()
|
||||
@@ -557,10 +557,10 @@ fn format_value_as_type(value: &Value) -> String {
|
||||
fn format_value_preview(value: &Value) -> String {
|
||||
match value {
|
||||
| Value::Identifier(path) => format!("`{}`", path.join(".")),
|
||||
| Value::String(s) => format!("\"{}\"", truncate(s, 50)),
|
||||
| Value::Int(n) => n.to_string(),
|
||||
| Value::Float(f) => f.to_string(),
|
||||
| Value::Bool(b) => b.to_string(),
|
||||
| Value::Text(s) => format!("\"{}\"", truncate(s, 50)),
|
||||
| Value::Number(n) => n.to_string(),
|
||||
| Value::Decimal(f) => f.to_string(),
|
||||
| Value::Boolean(b) => b.to_string(),
|
||||
| Value::List(items) => {
|
||||
if items.is_empty() {
|
||||
"[]".to_string()
|
||||
|
||||
@@ -145,7 +145,7 @@ fn add_type_hint(
|
||||
// Only add hints for non-obvious types
|
||||
// Skip if the type is clear from the literal (e.g., "string", 123, true)
|
||||
let should_hint = match &field.value {
|
||||
| Value::String(_) | Value::Int(_) | Value::Float(_) | Value::Bool(_) => false,
|
||||
| Value::Text(_) | Value::Number(_) | Value::Decimal(_) | Value::Boolean(_) => false,
|
||||
| Value::Identifier(_) => true, // Show type for identifier references
|
||||
| Value::List(_) => true, // Show list element type
|
||||
| Value::Object(_) => false, // Object structure is visible
|
||||
@@ -183,10 +183,10 @@ fn add_type_hint(
|
||||
fn infer_value_type(value: &Value) -> String {
|
||||
match value {
|
||||
| Value::Identifier(path) => path.join("."),
|
||||
| Value::String(_) => "String".to_string(),
|
||||
| Value::Int(_) => "Int".to_string(),
|
||||
| Value::Float(_) => "Float".to_string(),
|
||||
| Value::Bool(_) => "Bool".to_string(),
|
||||
| Value::Text(_) => "Text".to_string(),
|
||||
| Value::Number(_) => "Number".to_string(),
|
||||
| Value::Decimal(_) => "Decimal".to_string(),
|
||||
| Value::Boolean(_) => "Boolean".to_string(),
|
||||
| Value::List(items) => {
|
||||
if items.is_empty() {
|
||||
"[]".to_string()
|
||||
|
||||
@@ -411,14 +411,14 @@ fn highlight_field(builder: &mut SemanticTokensBuilder, field: &Field) {
|
||||
/// Helper to highlight a value
|
||||
fn highlight_value(builder: &mut SemanticTokensBuilder, value: &Value) {
|
||||
match value {
|
||||
| Value::String(_s) => {
|
||||
// String literals are already highlighted by the grammar
|
||||
| Value::Text(_s) => {
|
||||
// Text literals are already highlighted by the grammar
|
||||
// but we could add semantic highlighting here if needed
|
||||
},
|
||||
| Value::Int(_) | Value::Float(_) => {
|
||||
| Value::Number(_) | Value::Decimal(_) => {
|
||||
// Number literals are already highlighted by the grammar
|
||||
},
|
||||
| Value::Bool(_) => {
|
||||
| Value::Boolean(_) => {
|
||||
// Boolean literals are already highlighted by the grammar
|
||||
},
|
||||
| Value::Identifier(_path) => {
|
||||
|
||||
Reference in New Issue
Block a user