Skip to content

Comments

Syntax Highlighter to Janino Scripts#249

Open
KAMKEEL wants to merge 363 commits intodevfrom
syntax-highlighter-unified
Open

Syntax Highlighter to Janino Scripts#249
KAMKEEL wants to merge 363 commits intodevfrom
syntax-highlighter-unified

Conversation

@KAMKEEL
Copy link
Owner

@KAMKEEL KAMKEEL commented Jan 9, 2026

No description provided.

bigguy345 and others added 30 commits February 3, 2026 22:12
…to ExpressionParser

Problem:
- function(act){...} expressions not reaching ExpressionParser
- resolveExpressionType only checked containsOperators() or startsWith("(")
- Function expressions went through simple resolver and returned null type

Solution:
- Added looksLikeFunctionOrLambda helper (lines 4766-4773) to detect:
  * JS functions: function(...)
  * Arrow functions: =>
  * Java lambdas: ->
- Updated gate condition at line 4144 to route these into ExpressionParser
- Function expressions now reach ExpressionTypeResolver.resolveJSFunctionType

Impact:
- SAM typing now works in pass-2 when expected type is known
- Fixes schedule("TpGainAction", function(act){...}) argument typing
- Enables proper overload resolution for function/lambda parameters
…gorithm

Problem:
- schedule("TpGainAction", function(act){...}) resolved to wrong overload
- TypeInfo.getBestMethodOverload rejected candidates when argType == null
- Fell back to arbitrary overloads.get(0) based on reflection order
- Result: selected 1-arg varargs overload instead of 2-arg fixed-arity

Solution:
- Created OverloadSelector helper class implementing scoring algorithm
- Scoring tiers (lower is better):
  * Arity mismatch: +10000 + distance penalty (hard disqualifier)
  * Varargs: +1000 penalty (fixed-arity strongly preferred)
  * Unknown arg type (null): +10 (penalty but doesn't disqualify)
  * Compatible type: +5 (modest preference for matching)
  * Exact match: +0 (best case)
- Closest arity fallback when no arity-applicable overload exists
- TypeInfo.getBestMethodOverload now delegates (4 lines vs 220)

Impact:
- Deterministic overload selection (no reflection-order dependence)
- schedule("TpGainAction", function(act){...}) now resolves correctly
- Unknown arg types no longer cause fallback to unrelated overloads
- Fixed-arity methods preferred over varargs when both viable
- Removed 220 lines of complex nested logic from TypeInfo

Testing:
- OverloadResolutionTest with 6 test cases (all passing)
- Verifies fixed-arity preference, unknown arg handling, arity fallback
# Conflicts:
#	gradle-plugins~dev
Matches dev branch's submodule reference so branch switching works seamlessly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- add full parser/type-resolver support for Java method and constructor references

- infer SAM callback types for named JS script methods with conflict reporting

- surface argument-level SAM/type mismatch errors in method validation
- trigger completion after :: and detect method-reference receiver chains

- restrict suggestions to methods (plus constructor refs) in method-reference mode

- insert method names without parentheses when completing method references
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants