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

Add cross tests for pattern only case completions, fix for typed case completions #4356

Merged
merged 12 commits into from Sep 15, 2022

Conversation

jkciesluk
Copy link
Member

@jkciesluk jkciesluk commented Sep 7, 2022

Adds a cross tests suite to check if we cover all cases like case _: @@, case xxx @ So@@ etc.
Also fixes sorting completions when CaseKeywordCompletions are not exclusive.

Edit: I moved all extractors to one place

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 adding the test cases! That highlighted some issues we might have

),
true,
false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you use named arguments for all the booleans?

| }
|}""".stripMargin,
"""|None scala
|Some[_] scala
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
|Some[_] scala
|Some[?] scala

_ might get deprecated at some point

| case _: N@@ =>
| }
|}""".stripMargin,
"""|None scala
Copy link
Contributor

Choose a reason for hiding this comment

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

None is an object, so ideally we shouldn't suggest it

@jkciesluk jkciesluk changed the title Add cross tests for pattern only case completions Add cross tests for pattern only case completions, fix for typed case completions Sep 7, 2022
case (sel @ Select(qualifier, name)) :: _
if "match".startsWith(name.toString()) && text.charAt(
completionPos.start - 1
) == ' ' =>
Copy link
Member

Choose a reason for hiding this comment

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

it also might be a .

I found this usage recently at https://dotty.epfl.ch/docs/reference/other-new-features/indentation.html

one
  + two.match
      case 1 => b
      case 2 => c
  + three

Copy link
Member Author

Choose a reason for hiding this comment

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

In the first, main PR about match case completions for scala3 we came to conclusion to show match completions after two.match but not two.m, two.ma etc. because I think most users aren't using this syntax and having match completion there might be confusing (also, match completions are exclusive, maybe we should change that?)

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can make match completions not exclusive, to enable things like xxx.match@@ and completion xxx.matches(), but it's better to not show match completions in xxx.mat@@ (only for xxx.match@@)

Copy link
Member

Choose a reason for hiding this comment

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

Ok, thx for clarifying!

case Some(query) => CompletionFuzzy.matches(query, name)

def toCompletionValue(
sym: Symbol,
name: String,
autoImports: List[l.TextEdit],
)(using Context): CompletionValue.CaseKeyword =
)(using Context): Option[CompletionValue.CaseKeyword] =
sym.info
Copy link
Member

Choose a reason for hiding this comment

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

this line is unused

Comment on lines +412 to +413
"""|head :: next scala.collection.immutable
|Nil scala.collection.immutable""".stripMargin
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't these result be filtered out by fuzzy-match?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is a problem, because new is not seen on path (the tree looks the same as for case@@. I'm looking into it, if I won't find a solution soon I will create an issue

Copy link
Member Author

Choose a reason for hiding this comment

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

fuzzy-match isn't working, because compiler doesn't see the Ident("new")

Copy link
Member Author

Choose a reason for hiding this comment

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

I've created an issue #4367

@tgodzik tgodzik merged commit 7a915ad into scalameta:main Sep 15, 2022
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

3 participants