Skip to content

Conversation

liufengyun
Copy link
Contributor

Skip caret when source is missing in initialization checker

@liufengyun liufengyun marked this pull request as ready for review September 15, 2025 12:50
* The method SourceFile#exists always return true thus cannot be used.
*/
def fileExists(source: SourceFile): Boolean =
source.content().nonEmpty
Copy link
Contributor

Choose a reason for hiding this comment

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

FileContentNonEmpty?

* The method SourceFile#exists always return true thus cannot be used.
*/
def fileExists(source: SourceFile): Boolean =
source.content().nonEmpty
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just headOption,does the nonEmpty read the content?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SourceFile#content is a special method with cache. If it is not empty, we will need to read lines from it (thus force loading the content).

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean maybe just need to check the first char or line

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 see what you mean. If you check the overall design for code caching and SourceFile#content, you will see there is no need/opportunity for optimization here.

Copy link
Contributor

@olhotak olhotak left a comment

Choose a reason for hiding this comment

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

LGTM

In CompilationTests.scala, we are accumulating quite a few ad hoc cases where we compile some files somehow, and later compile some other files together with the output of the first compilation. As a future issue/PR, we should think about ways to factor out any commonality to clean this up.

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.

3 participants