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

Document symbol provider #27

Merged
merged 6 commits into from
Jul 1, 2017
Merged

Document symbol provider #27

merged 6 commits into from
Jul 1, 2017

Conversation

jonas
Copy link
Collaborator

@jonas jonas commented Jun 30, 2017

Refs #21

screen shot 2017-06-29 at 9 41 35 pm


Will need some help on how to extract the symbol info from Scalameta's Symbol and Denotation.

Copy link
Member

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

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

This is super cool, I'm impressed how much monaco provides out of the box. I pushed some changes to your branch, including adding a more interesting corpus.

val pos = Position("???", symPos.start.offset, symPos.end.offset)
new SymbolInformation(
name = denotation.name,
containerName = "???",
Copy link
Member

Choose a reason for hiding this comment

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

Try denotation.info

Copy link
Member

Choose a reason for hiding this comment

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

screen shot 2017-07-01 at 16 29 31

Copy link
Member

Choose a reason for hiding this comment

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

We can probably implement a utility to shorten those fully qualified names org.typelevel.paiges.Doc into Doc

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The fully qualified names make sense to me especially for cross project metadoc sites.

val denotations = attrs.denotations.map { case (s, d) => s -> d }.toMap
val symbols = for {
(symPos, sym) <- attrs.names
denotation <- denotations.get(sym)
Copy link
Member

Choose a reason for hiding this comment

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

We should probably filter out parameters, a symbol is any definition, including def parameters/class fields and bound names in pattern matching.

This seems to do an OK job

        (!isPARAM && !isTypeParam) && {
          isClass ||
          isTrait ||
          isObject ||
          isDef ||
          isVal
        }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Glad you pitched in on getting this working!

else if (denotation.isClass)
Some(SymbolKind.Class)
else if (denotation.isObject)
Some(SymbolKind.Module)
Copy link
Member

Choose a reason for hiding this comment

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

.Object

) = {
val denotations = attrs.denotations.map { case (s, d) => s -> d }.toMap
val symbols = for {
(symPos, sym) <- attrs.names
Copy link
Member

Choose a reason for hiding this comment

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

It seems we currently don't have the model's filename, model.uri is inmemory://model/1. Once we solve #19 then we can filter out the symbols by filename.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Depending on your progress we can also start by creating the model separately which allows to define the URI.

Copy link
Member

Choose a reason for hiding this comment

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

I've been digging into the vscode api, and learning how to use desktop vscode at the same time 😅

Seems the ITextModelService is what we need to provide.

@olafurpg olafurpg changed the title [WIP] Document symbol provider Document symbol provider Jul 1, 2017
@olafurpg
Copy link
Member

olafurpg commented Jul 1, 2017

Here is how it looks now

screen shot 2017-07-01 at 16 41 08

- Add more interesting corpus.
- Use Index instead of Attributes.names.
- Filter out parameters.
index.files
.find(_.endsWith("Doc.scala"))
.get
.replace(".scala", ".semanticdb")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We should probably add an entrypoint setting to the CLI and store it in metadoc.index for use here, unless we show some kind of directory browser on start.

Copy link
Member

Choose a reason for hiding this comment

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

I think it makes sense to start with an empty page + instructions on opening files

screen shot 2017-07-01 at 18 27 46

Copy link
Member

Choose a reason for hiding this comment

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

I propose we fix that once we nail #19

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍

@olafurpg
Copy link
Member

olafurpg commented Jul 1, 2017

Are we good to merge this?

isVal
}
}
kind <- symbolKind(denotation)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We are filtering twice here, since anything we cannot map to a SymbolKind won't be shown. I suggest we change the above filter to only remove parameters and type parameters.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Although I think there's a SymbolKind for parameters.

Copy link
Member

Choose a reason for hiding this comment

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

Nice catch, I will update.

@jonas
Copy link
Collaborator Author

jonas commented Jul 1, 2017

Definitely, let's merge. It looks great.

@olafurpg olafurpg merged commit a8f9d52 into master Jul 1, 2017
@olafurpg olafurpg deleted the document-symbol-provider branch July 1, 2017 16:50
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.

2 participants