Skip to content

Commit 183ca7a

Browse files
Merge remote-tracking branch 'origin/develop' into wip/jtulach/StartupWithImport
2 parents f4a29a1 + 27f7d14 commit 183ca7a

File tree

38 files changed

+651
-215
lines changed

38 files changed

+651
-215
lines changed

app/gui2/e2e/collapsingAndEntering.spec.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { expect } from './customExpect'
44
import { mockCollapsedFunctionInfo } from './expressionUpdates'
55
import { CONTROL_KEY } from './keyboard'
66
import * as locate from './locate'
7+
import { mockSuggestion } from './suggestionUpdates'
78

89
const MAIN_FILE_NODES = 12
910

@@ -81,9 +82,24 @@ test('Collapsing nodes', async ({ page }) => {
8182

8283
await page.getByLabel('Group Selected Components').click()
8384
await expect(locate.graphNode(page)).toHaveCount(initialNodesCount - 2)
84-
const collapsedNode = locate.graphNodeByBinding(page, 'prod')
85-
await expect(collapsedNode.locator('.WidgetToken')).toHaveText(['Main', '.', 'collapsed', 'five'])
8685
await mockCollapsedFunctionInfo(page, 'prod', 'collapsed')
86+
await mockSuggestion(page, {
87+
type: 'method',
88+
module: 'local.Mock_Project',
89+
name: 'collapsed',
90+
isStatic: true,
91+
aliases: [],
92+
arguments: [{ name: 'five', reprType: 'Any', isSuspended: false, hasDefault: false }],
93+
selfType: 'local.Mock_Project',
94+
returnType: 'Standard.Base.Any.Any',
95+
documentation: [],
96+
annotations: [],
97+
})
98+
const collapsedNode = locate.graphNodeByBinding(page, 'prod')
99+
await expect(collapsedNode.locator('.WidgetFunctionName')).toExist()
100+
await expect(collapsedNode.locator('.WidgetFunctionName .WidgetToken')).toHaveText(['Main', '.'])
101+
await expect(collapsedNode.locator('.WidgetFunctionName input')).toHaveValue('collapsed')
102+
await expect(collapsedNode.locator('.WidgetTopLevelArgument')).toHaveText('five')
87103

88104
await locate.graphNodeIcon(collapsedNode).dblclick()
89105
await actions.ensureNoCircularMenusVisibleDueToHovering(page)

app/gui2/e2e/suggestionUpdates.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { Page } from '@playwright/test'
2+
import * as lsTypes from 'ydoc-shared/languageServerTypes/suggestions'
3+
4+
/** Add an entry to the suggestion database. */
5+
export async function mockSuggestion(page: Page, update: lsTypes.SuggestionEntry) {
6+
await page.evaluate(({ update }) => (window as any)._mockSuggestion(update), { update })
7+
}

app/gui2/src/components/GraphEditor.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import type { RequiredImport } from '@/stores/graph/imports'
4747
import { useProjectStore } from '@/stores/project'
4848
import { provideSuggestionDbStore } from '@/stores/suggestionDatabase'
4949
import { suggestionDocumentationUrl, type Typename } from '@/stores/suggestionDatabase/entry'
50+
import { applyUpdates } from '@/stores/suggestionDatabase/lsUpdate'
5051
import { provideVisualizationStore } from '@/stores/visualization'
5152
import { bail } from '@/util/assert'
5253
import type { AstId } from '@/util/ast/abstract'
@@ -71,6 +72,7 @@ import {
7172
type ComponentInstance,
7273
} from 'vue'
7374
import { encodeMethodPointer } from 'ydoc-shared/languageServerTypes'
75+
import * as lsTypes from 'ydoc-shared/languageServerTypes/suggestions'
7476
import * as iterable from 'ydoc-shared/util/data/iterable'
7577
import { isDevMode } from 'ydoc-shared/util/detect'
7678
@@ -84,6 +86,7 @@ const widgetRegistry = provideWidgetRegistry(graphStore.db)
8486
const _visualizationStore = provideVisualizationStore(projectStore)
8587
const visible = injectVisibility()
8688
provideFullscreenContext(rootNode)
89+
;(window as any)._mockSuggestion = suggestionDb.mockSuggestion
8790
8891
onMounted(() => {
8992
widgetRegistry.loadWidgets(Object.entries(builtinWidgets))

app/gui2/src/components/GraphEditor/widgets/WidgetApplication.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ const targetMaybePort = computed(() => {
2525
if (!ptr) return input
2626
const definition = graph.getMethodAst(ptr)
2727
if (!definition.ok) return input
28-
input[FunctionName] = {
29-
editableName: definition.value.name.externalId,
28+
if (input.value instanceof Ast.PropertyAccess || input.value instanceof Ast.Ident) {
29+
input[FunctionName] = {
30+
editableName: definition.value.name.externalId,
31+
}
3032
}
3133
return input
3234
} else {

app/gui2/src/components/GraphEditor/widgets/WidgetFunction.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ const innerInput = computed(() => {
6767
const callInfo = methodCallInfo.value
6868
if (callInfo) {
6969
input[CallInfo] = callInfo
70-
const definition = graph.getMethodAst(callInfo.methodCall.methodPointer)
71-
if (definition.ok) input[FunctionName] = { editableName: definition.value.name.externalId }
70+
if (input.value instanceof Ast.PropertyAccess || input.value instanceof Ast.Ident) {
71+
const definition = graph.getMethodAst(callInfo.methodCall.methodPointer)
72+
if (definition.ok) input[FunctionName] = { editableName: definition.value.name.externalId }
73+
}
7274
}
7375
return input
7476
})

app/gui2/src/components/GraphEditor/widgets/WidgetFunctionName.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const FunctionName: unique symbol = Symbol.for('WidgetInput:FunctionName'
5252
declare module '@/providers/widgetRegistry' {
5353
export interface WidgetInput {
5454
[FunctionName]?: {
55-
/** Id of expression which is accepted by Lanugage Server's
55+
/** Id of expression which is accepted by Language Server's
5656
* [`refactoring/renameSymbol` method](https://github.com/enso-org/enso/blob/develop/docs/language-server/protocol-language-server.md#refactoringrenamesymbol)
5757
*/
5858
editableName: ExpressionId
@@ -63,7 +63,7 @@ declare module '@/providers/widgetRegistry' {
6363
function isFunctionName(
6464
input: WidgetInput,
6565
): input is WidgetInput & { value: Ast.Ast; [FunctionName]: { editableName: ExpressionId } } {
66-
return WidgetInput.isToken(input) && FunctionName in input
66+
return WidgetInput.isAst(input) && FunctionName in input
6767
}
6868
6969
export const widgetDefinition = defineWidget(
@@ -82,7 +82,7 @@ export const widgetDefinition = defineWidget(
8282
<NodeWidget v-if="operator" :input="WidgetInput.FromAst(operator)" />
8383
<AutoSizedInput
8484
v-model="displayedName"
85-
class="FunctionName"
85+
class="FunctionName widgetApplyPadding"
8686
@change="newNameAccepted"
8787
@pointerdown.stop
8888
@click.stop

app/gui2/src/stores/suggestionDatabase/index.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
import { markRaw, proxyRefs, ref, type Ref } from 'vue'
1515
import { LanguageServer } from 'ydoc-shared/languageServer'
1616
import type { MethodPointer } from 'ydoc-shared/languageServerTypes'
17+
import * as lsTypes from 'ydoc-shared/languageServerTypes/suggestions'
1718
import { exponentialBackoff } from 'ydoc-shared/util/net'
1819

1920
export class SuggestionDb extends ReactiveDb<SuggestionId, SuggestionEntry> {
@@ -154,6 +155,22 @@ export const { provideFn: provideSuggestionDbStore, injectFn: useSuggestionDbSto
154155
const entries = new SuggestionDb()
155156
const groups = ref<Group[]>([])
156157

158+
/** Add an entry to the suggestion database. */
159+
function mockSuggestion(entry: lsTypes.SuggestionEntry) {
160+
const id = Math.max(...entries.nameToId.reverse.keys()) + 1
161+
applyUpdates(
162+
entries,
163+
[
164+
{
165+
type: 'Add',
166+
id,
167+
suggestion: entry,
168+
},
169+
],
170+
groups.value,
171+
)
172+
}
173+
157174
const _synchronizer = new Synchronizer(projectStore, entries, groups)
158-
return proxyRefs({ entries: markRaw(entries), groups, _synchronizer })
175+
return proxyRefs({ entries: markRaw(entries), groups, _synchronizer, mockSuggestion })
159176
})

app/gui2/src/util/ast/node.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ export function primaryApplicationSubject(
5858
// Require at least one property access.
5959
if (accessChain.length === 0) return
6060
// The leftmost element must be an identifier or a placeholder.
61-
if (!(subject instanceof Ast.Ident || subject instanceof Ast.Wildcard)) return
61+
if (
62+
!(
63+
(subject instanceof Ast.Ident && !subject.isTypeOrConstructor()) ||
64+
subject instanceof Ast.Wildcard
65+
)
66+
)
67+
return
6268
return { subject: subject.id, accessChain: accessChain.map((ast) => ast.id) }
6369
}

app/ydoc-shared/src/ast/tree.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,6 +2224,10 @@ export class Ident extends Ast {
22242224
return this.module.getToken(this.fields.get('token').node) as IdentifierToken
22252225
}
22262226

2227+
isTypeOrConstructor(): boolean {
2228+
return /^[A-Z]/.test(this.token.code())
2229+
}
2230+
22272231
static concrete(module: MutableModule, token: NodeChild<Token>) {
22282232
const base = module.baseObject('Ident')
22292233
const fields = composeFieldData(base, { token })

build.sbt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2872,7 +2872,7 @@ lazy val `std-benchmarks` = (project in file("std-bits/benchmarks"))
28722872
.settings(
28732873
frgaalJavaCompilerSetting,
28742874
annotationProcSetting,
2875-
libraryDependencies ++= GraalVM.modules ++ GraalVM.langsPkgs ++ Seq(
2875+
libraryDependencies ++= GraalVM.modules ++ GraalVM.langsPkgs ++ GraalVM.toolsPkgs ++ Seq(
28762876
"org.openjdk.jmh" % "jmh-core" % jmhVersion,
28772877
"org.openjdk.jmh" % "jmh-generator-annprocess" % jmhVersion,
28782878
"org.graalvm.polyglot" % "polyglot" % graalMavenPackagesVersion,
@@ -2895,14 +2895,23 @@ lazy val `std-benchmarks` = (project in file("std-bits/benchmarks"))
28952895
"-J-Dpolyglotimpl.DisableClassPathIsolation=true",
28962896
"-J-Dpolyglot.engine.WarnInterpreterOnly=false"
28972897
),
2898-
moduleDependencies := {
2899-
componentModulesIds.value ++ Seq(
2898+
modulePath := {
2899+
val allRuntimeMods = componentModulesPaths.value
2900+
val otherModIds = Seq(
29002901
"org.slf4j" % "slf4j-nop" % slf4jVersion
29012902
)
2903+
val requiredMods = JPMSUtils.filterModulesFromUpdate(
2904+
(Compile / update).value,
2905+
otherModIds,
2906+
streams.value.log,
2907+
shouldContainAll = true
2908+
)
2909+
allRuntimeMods ++ requiredMods
29022910
},
29032911
addModules := {
29042912
val runtimeModuleName = (`runtime-fat-jar` / javaModuleName).value
2905-
Seq(runtimeModuleName)
2913+
val arrowModName = (`runtime-language-arrow` / javaModuleName).value
2914+
Seq(runtimeModuleName, arrowModName)
29062915
},
29072916
addExports := {
29082917
Map("org.slf4j.nop/org.slf4j.nop" -> Seq("org.slf4j"))
@@ -2937,6 +2946,10 @@ lazy val `std-benchmarks` = (project in file("std-bits/benchmarks"))
29372946
)
29382947
.dependsOn(`bench-processor`)
29392948
.dependsOn(`runtime-fat-jar`)
2949+
.dependsOn(`ydoc-server`)
2950+
.dependsOn(`runtime-language-arrow`)
2951+
.dependsOn(`syntax-rust-definition`)
2952+
.dependsOn(`profiling-utils`)
29402953
.dependsOn(`std-table` % "provided")
29412954
.dependsOn(`std-base` % "provided")
29422955
.dependsOn(`benchmark-java-helpers` % "provided")

0 commit comments

Comments
 (0)