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

Large refactor of processing structure #43

Merged
merged 5 commits into from
Jul 28, 2015

Conversation

rneatherway
Copy link
Contributor

Backwards-incompatible changes:

* Update helptext command to return { Name = ""; Text = "" }. Fixes #35.
* `project` command response now has 'null' for OutputFile and
  TargetFramework if a value cannot be determined.

Other changes:

* FSharp.CompilerBinding removed, and used parts absorbed. Fixes #17.
* ScriptCheckerOptions fetched with no timeout, and also stores them.
  Fixes #18, #28.
* If a .fs file is not in a loaded project, produce an incomplete
  typecheck environment for it to give basic results.
* Update parsing of project options to include ProjectReferences. Fixes #39.
* Separate parsing of commands, main command loop, and formatting of
  response message into separate modules.
if str = "<<EOF>>" then List.rev input
else readInput (str::input)

// Parse 'parse "<filename>" [full]' command
Copy link
Member

Choose a reason for hiding this comment

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

The [full] here should be [sync], I guess?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

@tpetricek
Copy link
Member

The changes look good to me. I don't know the full source code anymore, but I had a look through the new version and did not find anything that looked problematic.

I still added a bunch of comments here and there - mostly either small things or things that are OK for now, but could be improved in the future.

Thanks for doing all the work on this! It's so cool to see this helping Atom too!

open Microsoft.FSharp.Compiler
open Microsoft.FSharp.Compiler.SourceCodeServices

type ParseAndCheckResults(parse: FSharpParseFileResults,
Copy link
Member

Choose a reason for hiding this comment

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

Most of the methods in this type are calling Async.RunSynchronously - so it makes me wonder if they should be themselves asynchronous and the caller should take care of blocking?

(I guess it does not matter now - but it could be useful for cancellation and it might make this file actually reusable for other projects. I think I could have a use for this in some of the web-based F# editors like the one on www.fun3d.net!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're probably right. These are just some simple wrappers around FCS methods to handle the ident cracking etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And what I meant to say is that perhaps if there is a canonical implementation of ident cracking etc in FCS, something like this file could also be pushed into FCS.

@tpetricek
Copy link
Member

That's all from me :-).

The failing AppVeyor build seems to be just that something gets called before the compiler gets all information - which is pretty silly issue. Not sure what to do about it.

@rneatherway
Copy link
Contributor Author

Thanks a lot for taking a look, it's very useful to have extra eyes on this code. More editors using this are one of the main motivations for working more on this too!

The AppVeyor build failure is due to #22, and some of the older tests have massive waits inserted to work around this. After converting the rest to JSON those new ones now intermittently fail :-( It's a choice between allowing editors to specify a timeout by using DescriptionTextAsync and just setting the dataTipSpinWaitTime environment variable really high in appveyor.yml.

rneatherway added a commit that referenced this pull request Jul 28, 2015
Large refactor of processing structure
@rneatherway rneatherway merged commit 12a64f7 into ionide:master Jul 28, 2015
@7sharp9
Copy link
Contributor

7sharp9 commented Jul 28, 2015

How did you get on with removing the language service, any issues?

@rneatherway
Copy link
Contributor Author

No it was all smooth sailing as far as removing the background agent is concerned. I still use a similar wrapper to what you have to handle the ident cracking, as Tomas and I were saying higher up that should really be in FCS.

@rneatherway rneatherway deleted the big-refactor branch July 28, 2015 15:23
@7sharp9
Copy link
Contributor

7sharp9 commented Jul 28, 2015

You can backtrack easy enough if you have already dome the tokenisation I created a prototype of this a few years ago that went up 10 lines, seems to work ok, its the up front processing which take the longest.

@rneatherway
Copy link
Contributor Author

if you have already dome the tokenisation

The problem is that in the FsAutoComplete setting we haven't, and we can't easily because we don't get deltas for file source text, just the whole file each time. Tokenizing on each parse seems like it might be too expensive.

@7sharp9
Copy link
Contributor

7sharp9 commented Jul 28, 2015

Thats how we do it for semantic highlighting, after a parse is complete we tokenise the file and extract any additional keywords that might be defined via CE's

@7sharp9
Copy link
Contributor

7sharp9 commented Jul 28, 2015

I could do partial tokenisation as the lower section from the changed file is known, but I don't currently.

@rneatherway
Copy link
Contributor Author

I take it the tokenisation pass is done asynchronously? And then any extra highlighting info can be applied when it is done? Using the tokenisation information for ident cracking would mean waiting for a parse to be complete and then also for the tokenisation pass before any cracking can be done. It also needs to be completely up to date to get the right tokens, whereas a stale ParseResults is normally good enough.

@7sharp9
Copy link
Contributor

7sharp9 commented Jul 28, 2015

Yep, additional highlighting is applied asynchronously when it completes. I was just talking about the tokenisation in general in XSF#. You don't need to parse to run the tokeniser, in this instance I do because I require the symbol info to do semantic highlighting. The tokenisation could be yielded at the same time as the parse so that it can be reused later. i.e. semantic highlighting when parsing is finished.

@rneatherway
Copy link
Contributor Author

Right, yes I see. It will be too slow to use for the ident cracking still if we tokenise the whole file each time though won't it?

@7sharp9
Copy link
Contributor

7sharp9 commented Jul 28, 2015

I found it was faster than the parser combinator unless you start looking at large files.

@7sharp9
Copy link
Contributor

7sharp9 commented Jul 28, 2015

For cracking caret±10 lines should suffice

@rneatherway
Copy link
Contributor Author

I found it was faster than the parser combinator unless you start looking at large files.

So that means you would tokenize the whole file?

For cracking caret±10 lines should suffice

Or just go back 10 lines? That is problematic because you might end up in the middle of a string or comment.

@7sharp9
Copy link
Contributor

7sharp9 commented Jul 28, 2015

Regarding the combinators, whats the purpose of the empty lists like this?
https://github.com/fsharp/FsAutoComplete/blob/master/FsAutoComplete/Parser.fs#L115
Theres also some unnecessary recs in there too.

@rneatherway
Copy link
Contributor Author

That empty list is because many can be empty, like * in a regex (whereas some is like +).

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