Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract project names #12106

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open

Abstract project names #12106

wants to merge 7 commits into from

Conversation

kazcw
Copy link
Contributor

@kazcw kazcw commented Jan 22, 2025

Pull Request Description

Use abstract project references in retained state.

Fixes #11815.

Important Notes

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    TypeScript,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • Unit tests have been written where possible.
  • If meaningful changes were made to logic or tests affecting Enso Cloud integration in the libraries,
    or the Snowflake database integration, a run of the Extra Tests has been scheduled.
    • If applicable, it is suggested to paste a link to a successful run of the Extra Tests.

Copy link

github-actions bot commented Jan 22, 2025

🧪 Storybook is successfully deployed!

📊 Dashboard:


normalized(): ProjectPath {
if (!this.path) return this
const normalized = this.path.match(/^Main(\\..+)?$/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gratuitous \ - it matches Main\ab but not Main.ab

Add test/case for this method

Comment on lines +32 to +33
/** `undefined` identifies the current project; otherwise, this will be a two-segment path. */
readonly project: QualifiedName | undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a guard in this class to be more explicit what undefined means.

For example

  notCurrentProject(): this is AbsoluteProjectPath {
    return this.project != null
  }

(I would like to reverse it to isCurrentProject, but I don't know how to keep the type guard).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the meaning of undefined is not self-evident here, but I think it's better not to have a predicate for AbsoluteProjectPath. Really the only reason AbsoluteProjectPath exists is so that when a (non current-project) ProjectPath constant is defined, the corresponding QualifiedName can be obtained without needing a ProjectNameStore instance. Testing whether a path is absolute at runtime would not be useful because if it isn't, a projectNames instance will be needed anyway, and so it's best just to handle the values uniformly using the general functions from projectNames.

app/gui/src/project-view/util/ast/abstract.ts Outdated Show resolved Hide resolved
Comment on lines +37 to +39
private readonly pathToId = new ReactiveIndex(this, (id, entry) => [
[pathKey(entry.definitionPath), id],
])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is private necessary here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not useful without pathKey, which is an implementation detail

app/gui/src/project-view/stores/projectNames.ts Outdated Show resolved Hide resolved
Comment on lines 32 to 46
function parseProjectPath(path: QualifiedName): ProjectPath {
const parsed = parseAbsoluteProjectPath(path)
return parsed.project === inboundProject.value ?
ProjectPath.create(undefined, parsed.path)
: parsed
}

function printProjectPath(path: ProjectPath): QualifiedName {
return normalizeQualifiedName(printProjectPathDenormalized(path))
}

function printProjectPathDenormalized(path: ProjectPath): QualifiedName {
const project = path.project ?? outboundProject.value
return path.path ? qnJoin(project, path.path) : project
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have tests for those functions.

app/gui/src/project-view/stores/projectNames.ts Outdated Show resolved Hide resolved
app/gui/src/project-view/stores/project/index.ts Outdated Show resolved Hide resolved
imported: ImportedNames
}

export type RawImport = Import<QualifiedName>
export type AbstractImport = Import<ProjectPath>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this called Abstract? Neither it misses some information, nor I see any specializations

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProjectPath abstracts the name of the current project

@kazcw kazcw self-assigned this Jan 22, 2025
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.

Renaming a project causes collapsed function added by Component Browser to stop working
2 participants