Skip to content

Commit 9a654c3

Browse files
author
Corneliu Tusnea
committed
lots of improvements for the plugin
1 parent 1e30363 commit 9a654c3

20 files changed

+3054
-946
lines changed

docs/img/favicon.svg

Lines changed: 3 additions & 3 deletions
Loading

isl-transform/src/jmh/resources/shopify-transform.isl

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@ fun convertAddress( $addr ) {
88
$state = $addr.province_code | trim | upperCase;
99
$zip = $addr.zip | trim;
1010
$country = $addr.country_code | trim | upperCase;
11-
$formatted = `${$street}, ${$city}, ${$state} ${$zip}` | trim;
12-
13-
return { street: $street, city: $city, state: $state, zipCode: $zip, country: $country, formatted: $formatted };
11+
$formatted = `$street, ${$city}, ${$state} ${$zip}` | trim;
12+
13+
return {
14+
street: $street,
15+
city: $city,
16+
state: $state,
17+
zipCode: $zip,
18+
country: $country,
19+
formatted: $formatted
20+
};
1421
}
1522

1623
// Helper function: Convert customer with loyalty tier calculation
@@ -19,23 +26,22 @@ fun convertCustomer( $cust ) {
1926
$lastName = $cust.last_name | trim | upperCase;
2027
$email = $cust.email | trim | lowerCase;
2128
$orders = $cust.orders_count | to.number;
22-
$spent = $cust.total_spent | to.decimal | precision(2);
29+
$spent = $cust.total_spent | to.decimal | precision( 2 );
2330
$addr = @.This.convertAddress( $cust.default_address );
2431

2532
return { id: $cust.id | to.string, fullName: `$firstName ${$lastName}` | trim, firstName: $firstName, lastName: $lastName, email: $email, phone: $cust.phone | trim, totalOrders: $orders, lifetimeValue: $spent, address: $addr };
2633
}
2734

2835
// Helper function: Process and enrich line item
2936
fun processLineItem( $item ) {
30-
$sku = $item.sku | trim | upperCase;
31-
$name = $item.name | trim | truncate(100, "...");
32-
$vendor = $item.vendor | trim | titleCase;
33-
$qty = $item.quantity | to.number;
34-
$price = $item.price | to.decimal;
35-
$weight = $item.grams | to.number;
36-
$lineTotal = {{ $price * $qty }} | Math.clamp(0, 999999) | precision(2);
37-
$weightKg = {{ $weight / 1000 }} | precision(3);
38-
$productCode = `${$sku}-${$item.product_id | to.string}` | upperCase;
37+
38+
$items = if( $item.result ) true else false;
39+
40+
$o = {
41+
items: foreach $item in $array
42+
// loop body
43+
endfor
44+
}
3945

4046
return $item | to.string;
4147

@@ -46,7 +52,7 @@ fun processLineItem( $item ) {
4652
fun run( $input ) {
4753
// Order header
4854
$orderId = $input.id | to.string;
49-
$orderNum = $input.order_number | to.string | padStart(8, "0");
55+
$orderNum = $input.order_number | to.string | padStart( 8, "0" );
5056
$orderName = $input.name | trim;
5157

5258
// Convert customer with enrichment
@@ -66,21 +72,21 @@ fun run( $input ) {
6672
// Calculate order statistics using map/reduce with implicit $ iterator
6773
$totalItems = $input.line_items | length | to.number;
6874
$quantities = $input.line_items | map( $.quantity | to.number );
69-
$totalQty = $quantities | Math.sum(0);
75+
$totalQty = $quantities | Math.sum( 0 );
7076
$weights = $input.line_items | map( $.grams | to.number );
71-
$totalWeight = $weights | Math.sum(0);
72-
$totalWeightKg = {{ $totalWeight / 1000 }} | precision(3);
77+
$totalWeight = $weights | Math.sum( 0 );
78+
$totalWeightKg = {{ $totalWeight / 1000 }} | precision( 3 );
7379
$premiumCount = $input.line_items | filter( $.price | to.decimal >= 100 ) | length | to.number;
7480
$vendors = $input.line_items | map( $.vendor | trim | titleCase ) | unique | sort;
7581
$vendorCount = $vendors | length | to.number;
7682

7783
// Financial calculations
78-
$subtotal = $input.subtotal_price | to.decimal | precision(2);
79-
$shippingCost = $input.total_shipping_price_set.shop_money.amount | to.decimal | precision(2);
80-
$tax = $input.total_tax | to.decimal | precision(2);
81-
$discounts = $input.total_discounts | to.decimal | precision(2);
82-
$total = $input.total_price | to.decimal | precision(2);
83-
$finalTotal = {{ $total - $discounts }} | Math.clamp(0, 999999) | precision(2);
84+
$subtotal = $input.subtotal_price | to.decimal | precision( 2 );
85+
$shippingCost = $input.total_shipping_price_set.shop_money.amount | to.decimal | precision( 2 );
86+
$tax = $input.total_tax | to.decimal | precision( 2 );
87+
$discounts = $input.total_discounts | to.decimal | precision( 2 );
88+
$total = $input.total_price | to.decimal | precision( 2 );
89+
$finalTotal = {{ $total - $discounts }} | Math.clamp( 0, 999999 ) | precision( 2 );
8490

8591
// Determine shipping method and status with conditionals
8692
$fulfillmentStatus = $input.fulfillment_status | trim | upperCase;
@@ -95,7 +101,7 @@ fun run( $input ) {
95101
$noteValues = $input.note_attributes | map( $.value | trim );
96102

97103
// Extract and process tags using map
98-
$tags = $input.tags | split(",") | map( $ | trim | upperCase );
104+
$tags = $input.tags | split( "," ) | map( $ | trim | upperCase );
99105

100106
// Status flags with conditionals
101107
$isPaid = if( $input.financial_status | trim | lowerCase == "paid" ) true else false;
@@ -138,7 +144,7 @@ fun run( $input ) {
138144
tags: $tags;
139145
notes: $input.note | trim;
140146
noteKeys: $noteKeys;
141-
processedAt: $input.processed_at | date.parse("yyyy-MM-dd'T'HH:mm:ssXXX") | to.string("yyyy-MM-dd HH:mm:ss");
147+
processedAt: $input.processed_at | date.parse( "yyyy-MM-dd'T'HH:mm:ssXXX" ) | to.string( "yyyy-MM-dd HH:mm:ss" );
142148
isConfirmed: $input.confirmed | to.boolean;
143149
isTest: $input.test | to.boolean;
144150
isPaid: $isPaid;
@@ -147,3 +153,10 @@ fun run( $input ) {
147153
}
148154

149155

156+
157+
158+
159+
160+
161+
162+

plugin/CHANGELOG.md

Lines changed: 96 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,102 @@
22

33
All notable changes to the ISL Language Support extension will be documented in this file.
44

5-
## [1.0.0] - 2024-11-21
5+
## [1.0.0] - 2025-11-26
6+
7+
### Added
8+
- **Signature Help**: Parameter hints for functions and modifiers
9+
- **Inlay Hints**: Type annotations displayed inline for variables
10+
- **Code Actions & Quick Fixes**:
11+
- Simplify unnecessary string interpolation braces (`${$var}``$var`)
12+
- Convert `default()` modifier to null coalescing operator (`??`)
13+
- Format long single-line objects onto multiple lines
14+
- Change colon (`:`) to equals (`=`) for variable assignments
15+
- "Fix all in file" option for colon-to-equals conversions
16+
- **Enhanced Snippets**: 20+ new snippets for common ISL patterns including:
17+
- Safe navigation and error handling
18+
- Array and object transformations
19+
- Conditional field patterns
20+
- Date operations
21+
- Batch processing patterns
22+
- **CodeLens Enhancements**:
23+
- "Test Function" action for quick testing
24+
- "Find Usages" for tracking function references
25+
- **Status Bar Enhancements**: Active file indicator and quick actions
26+
27+
### Improved
28+
29+
#### Syntax Highlighting
30+
- Fixed division operator (`/`) being incorrectly highlighted as regex
31+
- Removed regex literal pattern (ISL uses regex as string arguments)
32+
- Improved modifier highlighting with consistent coloring for namespaced modifiers
33+
- Enhanced pipe operator (`|`) visibility with distinct color
34+
- Better number literal highlighting
35+
36+
#### Code Completion
37+
- Fixed variable autocompletion preserving `$` prefix when completing
38+
- Improved context-aware suggestions
39+
40+
#### Formatter
41+
- **Pipe Spacing**: Automatically adds space after pipe operator (`|trim``| trim`)
42+
- **Function/Modifier Parameters**: Consistent spacing in declarations
43+
- With parameters: `fun name( $param1, $param2 )`
44+
- Without parameters: `fun name()`
45+
- **Control Flow Parameters**: Consistent spacing for `if`, `switch`, `while`, `foreach`
46+
- Example: `if ( $condition )`, `switch ( $value )`
47+
- **Nested Control Flow**: Proper indentation for nested structures, including:
48+
- Nested switch statements in switch cases (`"A" -> switch($x) ... endswitch;`)
49+
- Control flow after arrow operator (`->`)
50+
- **Switch Statement Objects**: Fixed indentation for object values in switch cases
51+
- Properly handles `};` in case values without closing the switch
52+
- **Modifier Chain Indentation**: Multi-line modifier chains are now indented
53+
- **Multi-line String Preservation**: Backtick strings preserve original formatting and indentation
54+
- Removed automatic splitting of long modifier chains (user controls line breaks)
55+
56+
#### Validator
57+
- **Semantic Validation**:
58+
- Undefined function detection
59+
- Undefined modifier detection (including `push`, `getProperty`, `setProperty`)
60+
- Undeclared variable usage detection
61+
- Smart variable declaration tracking (supports both `=` and `:` operators)
62+
- **Improved Control Flow Balance**:
63+
- Fixed `endfor`/`foreach` matching in expression contexts
64+
- Fixed `endswitch`/`switch` matching for nested switches
65+
- Fixed `endif`/`if` detection in complex conditions
66+
- Recognizes control flow after arrow operator (`->`) in switch cases
67+
- Better handling of inline vs. block control flow statements
68+
- **Return Statement Validation**: Completely rewritten to accurately track function scope with proper brace depth tracking
69+
- **Comment Handling**: All validations now correctly ignore code in comments
70+
- **Assignment Operators**: Recognizes both `=` and `:` for variable declarations
71+
- **Information-Level Diagnostics** (blue squiggly):
72+
- Long object declarations suggesting formatting
73+
- Colon usage suggesting equals for consistency
74+
- Unnecessary string interpolation braces
75+
76+
#### Spell Checking
77+
- Added ISL-specific keywords to cSpell dictionary:
78+
- Control flow: `endfor`, `endswitch`, `endif`, `endwhile`
79+
- Modifiers: `upperCase`, `toLowerCase`, `pushItems`, `getProperty`, `setProperty`
80+
- VSCode extension terms: `inlayhints`, `codelens`, `quickfix`
81+
- Common concatenated forms
82+
83+
### Fixed
84+
- Division operator no longer highlighted as regex in expressions
85+
- Variable completion maintains `$` prefix
86+
- Object formatting no longer cuts string interpolations
87+
- Math expressions no longer misidentified as objects in type hints
88+
- Variables in comments no longer trigger "undeclared variable" warnings
89+
- Control flow balance correctly handles all nesting scenarios
90+
- Return statement validation accurate in complex nested functions
91+
- Function/modifier parameter spacing consistent after formatting
92+
- Nested switch statement indentation correct
93+
- Switch case object values maintain proper indentation
94+
- Multi-line backtick strings preserve internal formatting
95+
96+
### Configuration
97+
- Removed `isl.formatting.formatModifierChains` (automatic chain splitting removed)
98+
- Kept `isl.formatting.alignProperties` for object property alignment
99+
100+
## [1.0.0-Beta]
6101

7102
### Added
8103
- Initial release
@@ -86,15 +181,11 @@ All notable changes to the ISL Language Support extension will be documented in
86181
- Symbol provider for outline view
87182
- Reference finder
88183
- Rename symbol support
89-
- Code actions and quick fixes
90-
- Refactoring support
91184
- Debug adapter protocol support
92185
- Test runner integration
93186
- Performance optimizations
94187
- Multi-file validation
95188
- Import resolution and auto-import
96189
- Type checking based on type declarations
97-
- More sophisticated code formatting
98190
- Bracket pair colorization
99-
- Inlay hints for inferred types
100191

0 commit comments

Comments
 (0)