lukebuehler / NRefactory-Completion-Sample

A small but full featured prototype how to do code completion with NRefactory
93 stars 39 forks source link

How do you Change Between AvalonEdit TextDocument and NRefactory TextDocument #4

Open Camuvingian opened 10 years ago

Camuvingian commented 10 years ago

Hi Luke,

In OverrideCompletionData.cs you use var syntaxTree = new CSharpParser().Parse(document); (as one of a handful of examples) where document here is of type ICSharpCode.AvalonEdit.Document.TextDocument. The Parse(...) method expects a type of ICSharpCode.NRefactory.Editor.ITextSource and it is getting ICSharpCode.AvalonEdit.Document.ITextSource. So I am getting a compiler fail, but in your solution you do not. My question is what am I missing here?

Thanks for your time.

lukebuehler commented 10 years ago

I changed the avalon edit version in the completion sample to use the NRefactory IDocument, normally it has it's own (the plan was for avalon edit to eventually have a version that shares IDocument with NRefactory, I read this somewhere on the Nrefactory forums). This is why it works so seamlessly in my example. However if you add NRefactory and AvalonEdit from NuGet some additional work is required.

See the current CShell code for more details: https://github.com/lukebuehler/CShell/tree/dev/Src/CShell.Completion

The completion result is returned here: https://github.com/lukebuehler/CShell/blob/dev/Src/CShell.Completion/CSharpCompletion.cs#L95 and then used here: https://github.com/lukebuehler/CShell/blob/dev/Src/CShell.Completion/CodeTextEditor.cs#L112

Essentially, the returned completions are already created for AvalonEdit and not for nrefactory.

Camuvingian commented 10 years ago

Thanks for your reply, it is most appreciated. I will look at what you have done in CShell. Just to clarify, have you used the NuGet Versions of AvalonEdit and NRefactory in CShell?

lukebuehler commented 10 years ago

In CShell I'm using the Nuget version of AvalonEdit and the Nrefactory from here (https://github.com/lukebuehler/NRefactory) because there was a small rare bug that they havent fixed yet. I think you should be fine with using Nuget Nrefactory though.

On Tue, Nov 11, 2014 at 12:38 PM, Nicholas Camus notifications@github.com wrote:

Thanks for your reply, it is most appreciated. I will look at what you have done in CShell. Just to clarify, have you used the NuGet Versions of AvalonEdit and NRefactory in CShell?

— Reply to this email directly or view it on GitHub https://github.com/lukebuehler/NRefactory-Completion-Sample/issues/4#issuecomment-62585150 .

Camuvingian commented 10 years ago

I have implemented both the latest NuGet packges for NRefactory and AvalonEdit following your work with CShell. I am well impressed! Some fantastic code in there. How long did it take you to cobble together?

I would like to add the ability to add in namespaces via using System.* at run-time and have the namespace included dynamically. Is this something you have thought about or looked at?

Thanks again.

lukebuehler commented 10 years ago

Thanks!

Yes, I'm actually working on this right now, but in my case there's a whole another layer of complexity as we are trying to support ScriptCS as well...

I dont have a clear idea yet though.

On Tue, Nov 11, 2014 at 5:42 PM, Nicholas Camus notifications@github.com wrote:

I have implemented both the latest NuGet packges for NRefactory and AvalonEdit following your work with CShell. I am well impressed! Some fantastic code in there. How long did it take you to cobble together?

I would like to add the ability to add in namespaces via using System.* at run-time and have the namespace included dynamically. Is this something you have thought about or looked at?

Thanks again.

— Reply to this email directly or view it on GitHub https://github.com/lukebuehler/NRefactory-Completion-Sample/issues/4#issuecomment-62635592 .

Camuvingian commented 10 years ago

I will take a look at the basic case as i go forward with what I am attempting to do. If i have anything I think will be of use I will let you know.

All the best.