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

Symbol uses #34

Merged
merged 7 commits into from
Jun 30, 2015
Merged

Symbol uses #34

merged 7 commits into from
Jun 30, 2015

Conversation

rojepp
Copy link
Contributor

@rojepp rojepp commented Jun 28, 2015

Implements #31.

I botched the previous PR by rebasing, so git wouldn't let me push (when will I ever learn).
I added a few fields from SymbolUse, including IsFromDefinition which should address @7sharp9's concern. Anything else that should be included?

@7sharp9
Copy link
Contributor

7sharp9 commented Jun 29, 2015

I want to click the Merge Pull Request but Ill leave that to @rneatherway :-)

yield { StartLine = su.RangeAlternate.StartLine
StartColumn = su.RangeAlternate.StartColumn + 1
EndLine = su.RangeAlternate.EndLine
EndColumn = su.RangeAlternate.EndColumn + 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding 1 here doesn't seem right, they should already be 1-based from the Alternate syntax. Looking at the results I also think they should end one earlier e.g. with:

let testval = FileTwo.NewObjectType()

The results have a range with columns start=5 and end=12. t is definitely at 5, and l is 6 further on, so 11. This is an inclusive range and I think we should leave it alone, documenting it as such (if we ever get around to adding documentation for this project!). If editors prefer to work with an exclusive range they can make the adjustement locally.

Copy link
Contributor

Choose a reason for hiding this comment

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

XS columns are 1 based we do something like:

        let start, finish = Symbols.trimSymbolRegion symbolUse lastIdentAtLoc
        let filename = doc.FileName.ToString()  
        let offset = doc.LocationToOffset(start.Line, start.Column+1)
        let domRegion = DomRegion(filename, start.Line, start.Column+1, finish.Line, finish.Column+1)

        let symbol = createSymbol(doc, context, symbolUse.Symbol, lastIdentAtLoc, domRegion)
        let memberRef = MemberReference(symbol, filename, offset, lastIdentAtLoc.Length)

        //if the current range is a symbol range and the fileNameOfRefs match change the ReferenceUsageType
        if symbolUse.IsFromDefinition then
            memberRef.ReferenceUsageType <- ReferenceUsageType.Write

        memberRef

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'm not sure how to fix this. FCS seems to report 0-based columns (lines are 1-based). Do you want me to only add 1 to StartColumn? That doesn't seem right to me. That would leave testva highlighted.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I misread. It seems that FCS accepts 1-based column numbers but returns 0-based. Why would this possibly be a good idea?

I've looked at the output we give and I think only declarations, finddecl and this new command return positions. I think they should all return 0-based or all return 1-based columns, for consistency. However, I think that if FCS is outputting 0-based columns it should probably be accepting 0-based as well.

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 all very confusing. Adding 1 to StartColumn and EndColumn seems to be the right thing to do, so we normalize to consistently being 1-based . Do the other commands return 0-based?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Find Declaration seems to return 0-based.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I guess you posted at the same time as me ;-)

I would be happy if everything returned 1-based so at least FSAC is consistent even if FCS isn't.

@7sharp9 do you adjust the results you get from GetNavigationItems for the pathed document support as well to be 1-based?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's do it. :)

Separate PR or this one?

Copy link
Contributor

Choose a reason for hiding this comment

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

Here is fine by me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@rneatherway
Copy link
Contributor

Otherwise looks great. Thanks so much for the contribution, things are really coming on!

@@ -461,7 +485,7 @@ module internal Main =
let sb = new System.Text.StringBuilder()
sb.AppendLine("DATA: errors") |> ignore
for e in errs do
sb.AppendLine(sprintf "[%d:%d-%d:%d] %s %s" e.StartLineAlternate e.StartColumn e.EndLineAlternate e.EndColumn
sb.AppendLine(sprintf "[%d:%d-%d:%d] %s %s" e.StartLineAlternate (e.StartColumn + 1) e.EndLineAlternate (e.EndColumn + 1)
(if e.Severity = FSharpErrorSeverity.Error then "ERROR" else "WARNING") e.Message)
|> ignore
sb.Append("<<EOF>>") |> ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

The JSON printing just below Data =errs is also affected

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I'll fix it shortly.

@rneatherway
Copy link
Contributor

Having to also correct the errors makes it less enjoyable :-(

@rojepp
Copy link
Contributor Author

rojepp commented Jun 29, 2015

Argh, FSharpErrorInfo has no public constructor. I guess the only option is to make a record type with the same fields.

@rojepp
Copy link
Contributor Author

rojepp commented Jun 29, 2015

In doing a record type, should I keep StartLineAlternate/EndLineAlternate? Maybe a good time to expose fewer fields?

rojepp added 2 commits June 29, 2015 20:31
In doing so, I also removed FSharpErrorInfo.StartLineAlternate and FSharpErrorInfo.EndLineAlternate. Now there is only StartLine/EndLine, and they're 1-based.
@rojepp
Copy link
Contributor Author

rojepp commented Jun 29, 2015

With that, I think I'm done. :)

rneatherway added a commit that referenced this pull request Jun 30, 2015
@rneatherway rneatherway merged commit 4621181 into ionide:master Jun 30, 2015
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