Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .changeset/effect-fn-opportunity-inferred-layer-v4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
"@effect/language-service": minor
---

Improve `effectFnOpportunity` inferred span naming for service-layer methods and align examples for Effect v4.

The inferred span can now include service + method names (for example `MyService.log`) when the convertible function is a method inside a layer service object for strict supported patterns like:

- `Layer.succeed(Service)(...)`
- `Layer.sync(Service)(...)`
- `Layer.effect(Service)(Effect.gen(...))`
- `Layer.effect(Service, Effect.gen(...))`

Also add Effect v4 diagnostics fixtures for:

- `effectFnOpportunity_inferred.ts`
- `effectFnOpportunity_inferredLayer.ts`

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Few options can be provided alongside the initialization of the Language Service
"importAliases": { "Array": "Arr" }, // allows to chose some different names for import name aliases (only when not chosing to import the whole module) (default: {})
"noExternal": false, // disables features that provides links to external websites (such as links to mermaidchart.com) (default: false)
"keyPatterns": [{ "target": "service", "pattern": "default", "skipLeadingPath": ["src/"] }], // configure the key patterns; recommended reading more on the section "Configuring Key Patterns"
"effectFn": ["span"], // what types of Effect.fn you want to get suggested, zero or multiple between "untraced" for fnUntraced, "span" for Effect.fn with span, "inferred-span" for Effect.fn with the inferred span name, "no-span" for Effect.fn with no span (default: ["span"])
"effectFn": ["span"], // what types of Effect.fn you want to get suggested, zero or multiple between "untraced" for fnUntraced, "span" for Effect.fn with explicit withSpan span, "suggested-span" for Effect.fn with a broadly suggested name from local context, "inferred-span" for Effect.fn with inferred exported declaration names, "no-span" for Effect.fn with no span (default: ["span"])
"layerGraphFollowDepth": 0, // controls the depth level that the layer graph will follow when resolving layer dependencies, depth is counted only when exiting the currently hovered/analyzed layer definition (default: 0)
"mermaidProvider": "mermaid.live" // which provider to use for mermaid, can also be a uri like http://localhost:8080 if running mermaid-live-editor locally.
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
effectFnOpportunity_toEffectFnUntraced from 762 to 784
effectFnOpportunity_toEffectFnNoSpan from 762 to 784
effectFnOpportunity_toEffectFnSpanInferred from 762 to 784
effectFnOpportunity_skipNextLine from 762 to 784
effectFnOpportunity_skipFile from 762 to 784
effectFnOpportunity_toEffectFnUntraced from 386 to 399
effectFnOpportunity_toEffectFnNoSpan from 386 to 399
effectFnOpportunity_toEffectFnSpanInferred from 386 to 399
effectFnOpportunity_skipNextLine from 386 to 399
effectFnOpportunity_skipFile from 386 to 399
effectFnOpportunity_toEffectFnUntraced from 508 to 526
effectFnOpportunity_toEffectFnNoSpan from 508 to 526
effectFnOpportunity_toEffectFnSpanInferred from 508 to 526
effectFnOpportunity_skipNextLine from 508 to 526
effectFnOpportunity_skipFile from 508 to 526
effectFnOpportunity_toEffectFnUntraced from 624 to 645
effectFnOpportunity_toEffectFnNoSpan from 624 to 645
effectFnOpportunity_toEffectFnSpanInferred from 624 to 645
effectFnOpportunity_skipNextLine from 624 to 645
effectFnOpportunity_skipFile from 624 to 645
effectFnOpportunity_toEffectFnUntraced from 780 to 802
effectFnOpportunity_toEffectFnNoSpan from 780 to 802
effectFnOpportunity_toEffectFnSpanInferred from 780 to 802
effectFnOpportunity_skipNextLine from 780 to 802
effectFnOpportunity_skipFile from 780 to 802
effectFnOpportunity_toEffectFnUntraced from 404 to 417
effectFnOpportunity_toEffectFnNoSpan from 404 to 417
effectFnOpportunity_toEffectFnSpanInferred from 404 to 417
effectFnOpportunity_skipNextLine from 404 to 417
effectFnOpportunity_skipFile from 404 to 417
effectFnOpportunity_toEffectFnUntraced from 526 to 544
effectFnOpportunity_toEffectFnNoSpan from 526 to 544
effectFnOpportunity_toEffectFnSpanInferred from 526 to 544
effectFnOpportunity_skipNextLine from 526 to 544
effectFnOpportunity_skipFile from 526 to 544
effectFnOpportunity_toEffectFnUntraced from 642 to 663
effectFnOpportunity_toEffectFnNoSpan from 642 to 663
effectFnOpportunity_toEffectFnSpanInferred from 642 to 663
effectFnOpportunity_skipNextLine from 642 to 663
effectFnOpportunity_skipFile from 642 to 663
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// code fix effectFnOpportunity_toEffectFnNoSpan output for range 404 - 417
// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] }
import * as Effect from "effect/Effect"

// These cases can be converted to Effect.fnUntraced because:
// - There are no pipe arguments
// - There is no withSpan for tracing
// Converting to Effect.fnUntraced improves performance by not
// reallocating the generator function on every call.

export const arrowBlockGen = Effect.fn(function*() {
yield* Effect.succeed(1)
return 42
})

export const arrowExpressionGen = () =>
Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})

export const functionExpressionGen = function() {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}

export function functionDeclarationGen() {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// code fix effectFnOpportunity_toEffectFnNoSpan output for range 526 - 544
// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] }
import * as Effect from "effect/Effect"

// These cases can be converted to Effect.fnUntraced because:
// - There are no pipe arguments
// - There is no withSpan for tracing
// Converting to Effect.fnUntraced improves performance by not
// reallocating the generator function on every call.

export const arrowBlockGen = () => {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}

export const arrowExpressionGen = Effect.fn(function*() {
yield* Effect.succeed(1)
return 42
})

export const functionExpressionGen = function() {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}

export function functionDeclarationGen() {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// code fix effectFnOpportunity_toEffectFnNoSpan output for range 642 - 663
// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] }
import * as Effect from "effect/Effect"

// These cases can be converted to Effect.fnUntraced because:
// - There are no pipe arguments
// - There is no withSpan for tracing
// Converting to Effect.fnUntraced improves performance by not
// reallocating the generator function on every call.

export const arrowBlockGen = () => {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}

export const arrowExpressionGen = () =>
Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})

export const functionExpressionGen = Effect.fn(function*() {
yield* Effect.succeed(1)
return 42
})

export function functionDeclarationGen() {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// code fix effectFnOpportunity_toEffectFnNoSpan output for range 780 - 802
// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] }
import * as Effect from "effect/Effect"

// These cases can be converted to Effect.fnUntraced because:
// - There are no pipe arguments
// - There is no withSpan for tracing
// Converting to Effect.fnUntraced improves performance by not
// reallocating the generator function on every call.

export const arrowBlockGen = () => {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}

export const arrowExpressionGen = () =>
Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})

export const functionExpressionGen = function() {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}

export const functionDeclarationGen = Effect.fn(function*() {
yield* Effect.succeed(1)
return 42
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 404 - 417
// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] }
import * as Effect from "effect/Effect"

// These cases can be converted to Effect.fnUntraced because:
// - There are no pipe arguments
// - There is no withSpan for tracing
// Converting to Effect.fnUntraced improves performance by not
// reallocating the generator function on every call.

export const arrowBlockGen = Effect.fn("arrowBlockGen")(function*() {
yield* Effect.succeed(1)
return 42
})

export const arrowExpressionGen = () =>
Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})

export const functionExpressionGen = function() {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}

export function functionDeclarationGen() {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 526 - 544
// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] }
import * as Effect from "effect/Effect"

// These cases can be converted to Effect.fnUntraced because:
// - There are no pipe arguments
// - There is no withSpan for tracing
// Converting to Effect.fnUntraced improves performance by not
// reallocating the generator function on every call.

export const arrowBlockGen = () => {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}

export const arrowExpressionGen = Effect.fn("arrowExpressionGen")(function*() {
yield* Effect.succeed(1)
return 42
})

export const functionExpressionGen = function() {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}

export function functionDeclarationGen() {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 642 - 663
// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] }
import * as Effect from "effect/Effect"

// These cases can be converted to Effect.fnUntraced because:
// - There are no pipe arguments
// - There is no withSpan for tracing
// Converting to Effect.fnUntraced improves performance by not
// reallocating the generator function on every call.

export const arrowBlockGen = () => {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}

export const arrowExpressionGen = () =>
Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})

export const functionExpressionGen = Effect.fn("functionExpressionGen")(function*() {
yield* Effect.succeed(1)
return 42
})

export function functionDeclarationGen() {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 780 - 802
// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] }
import * as Effect from "effect/Effect"

// These cases can be converted to Effect.fnUntraced because:
// - There are no pipe arguments
// - There is no withSpan for tracing
// Converting to Effect.fnUntraced improves performance by not
// reallocating the generator function on every call.

export const arrowBlockGen = () => {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}

export const arrowExpressionGen = () =>
Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})

export const functionExpressionGen = function() {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}

export const functionDeclarationGen = Effect.fn("functionDeclarationGen")(function*() {
yield* Effect.succeed(1)
return 42
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// code fix effectFnOpportunity_toEffectFnUntraced output for range 404 - 417
// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] }
import * as Effect from "effect/Effect"

// These cases can be converted to Effect.fnUntraced because:
// - There are no pipe arguments
// - There is no withSpan for tracing
// Converting to Effect.fnUntraced improves performance by not
// reallocating the generator function on every call.

export const arrowBlockGen = Effect.fnUntraced(function*() {
yield* Effect.succeed(1)
return 42
})

export const arrowExpressionGen = () =>
Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})

export const functionExpressionGen = function() {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}

export function functionDeclarationGen() {
return Effect.gen(function*() {
yield* Effect.succeed(1)
return 42
})
}
Loading
Loading