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

Outline compiler #6114

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Conversation

kasiaMarek
Copy link
Contributor

@kasiaMarek kasiaMarek commented Feb 13, 2024

connected to: #917

Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!

Let's also add a user setting to enable the new logic.

@@ -0,0 +1,6 @@
package scala.meta.pc;

public interface CompilerFiles {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add some docs why it's needed.

The alternative is to not add new method, but send changedFiles for every file if the project doesn't compile

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 moved the files to outline logic outside of pc. I think it increases readability of that logic.

val richCompilationCache: TrieMap[String, RichCompilationUnit] =
TrieMap.empty[String, RichCompilationUnit]

// for those paths units were
Copy link
Contributor

Choose a reason for hiding this comment

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

We should add a bit more to the comment here


def successfulCompilation(): Unit = {
wasSuccessfullyCompiled.set(true)
changedDocuments.clear()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: that this doesn't account for possible changes before compilation end is reported, it may not 100% reflect the state of files that was during compilation.

.asJava
Some(
OutlineFiles(
allFiles,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We may want to cap the number of files for initial compilation, so it won't take too long.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can do a high number like 300 or something

@kasiaMarek kasiaMarek force-pushed the outline-compiler branch 2 times, most recently from 6675382 to d1060a8 Compare March 20, 2024 08:03
@kasiaMarek
Copy link
Contributor Author

Failing Scala3 NIGHTLY test is a test-only problem, so it shouldn't block this PR.

@kasiaMarek kasiaMarek requested a review from tgodzik March 26, 2024 16:15
else false
}

// TODO the same in autoimports TEST
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we check auto imports? Is the TODO still relevant?

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 added tests, this seems to be already handled

@kasiaMarek kasiaMarek marked this pull request as ready for review April 19, 2024 11:39
@kasiaMarek kasiaMarek requested a review from tgodzik April 19, 2024 11:52
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

Some minor comments, but I also tested it on Metals codebase this workflow seems to break:

  1. Add non compiling method to the MD5 object in mtagsShared
  2. Change the name of MD5 to MD55
  3. Try to auto import MD55 in another package.
  4. We get completions for MD5 aside from MD55 and something like MD55.<local>

Could you take a look if you can reproduce it?

@@ -101,6 +104,10 @@ class Compilers(

import compilerConfiguration._

val plugins = new CompilerPlugins()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
val plugins = new CompilerPlugins()

I don't think it's used here now.

s"no build target found for $path. Using presentation compiler with project's scala-library version: ${scalaVersion}"
)
Some(fallbackCompiler)
case None => Some(fallbackCompiler)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove this?

} provider.didChange(path)
}

def getOutlineFiles(id: String): Optional[JOutlineFiles] =
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this id? Should we use BuildTargetIdentifier here? Or at least add an alias.

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 BuildTargetIdentifier, I'm constructing it here.

  def getOutlineFiles(id: String): Optional[JOutlineFiles] =
    getOutlineFiles(buildTargetId(id))

  def getOutlineFiles(
      buildTargetId: Option[BuildTargetIdentifier]
  )

It's just that it comes as a string from pc (can't be BuildTargetIdentifier, because pc interface doesn't depend on bsp4j) and it's less boilerplate to map it here instead of each place in Compilers.

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.

None yet

2 participants