SYNTAX EDITOR AS EXPRESSION EDITOR

I am adding c# expressions to my app. The expression will winding up being incorporated in to a larger class as a method body later on via code generation. I would like the syntax editor to behave as if it is sees the entire class with regard to code complete, intellisence and syntax errors. Do you have a technique for this? Short of an establish technique, is there a way to sit in between the editor and the parser and add the complete class on the fly? Does that sounds ridiculous? An ideas?
Thanks so much
Jim
Hello Jim,
Yes, this should be possible. You can make code editor to only display part of the code, or use Class-less C# script mode (with last one C# parser accepts global code, without class or method definition).
Please refer to SnippetParser QuickStart project to see how it works.
regards,
Andrew
Great!
Where do I find the Snippets quick start? I looked in my install but did not see anything that looks like sample code.
Thanks for your help Andrew
Jim
Hi Jim,
you find the sample here (if you don't have version 5.x installed, change the path):
C:\Users\Public\Documents\AlterNET Software\Extensibility Studio v.5\Demo\Editor\QuickStarts\Parsers\SnippetsParsers
If you have questions, feel free to ask - the sample was created by AlterNET because I had the same requirement as you have ;-).
The sample is probably not easy to use. It is easier if you have only one type of snippet, so that the class code has a fixed number of lines.

Best regards
Wolfgang
Hey Wolfgang
Thanks for replying!!!!
I saw your posts and realized that what you wanted was probably what I wanted as well. I just didn't know where the samples were located.
This should be easy for me as I am not actually building the class at the time of entry. I will only have this one method in my virtual class. I will save the snippet and generate the class later will all the snippets if any.
If I get into a jam I will reach out to you.
Thanks again and have a nice weekend.
Jim
I am using Syntax Editor to edit Rosyln Scripts. Everything works great. Intellisense and code completion work. The only issue I have is that the editor does not know about the global variables introduced when the script is evaluated. Research has yielded that there is a HostObjectType parameter on ProjectInfo.Create method. Do you have a way to set that value so the editor will see the global variables?
As always tanks for your help.
Jim
Hello Jim,
If I understand your question correctly, you need code completion to show global objects passed to the script.
We create a separate class on a fly which contains definitions of global objects, this code needs to be passed to the parser engine.
You can register Global Code in the Roslyn Solution like this:
RoslynParser parser = edit.Lexer as RoslynParser;
if (parser != null)
{
var solution = parser.Repository.Solution;
if (solution != null)
solution.ReplaceDocument(null, "global.cs", scriptRun.ScriptHost.GlobalCode);
}
or call RegisterScriptCodeForEditor like it done in the QuiskStart ObjectReference method for IScriptEdit.
regards,
Andrew
I apologize for the poor quality of my post! (and for double posting). It was the end of a long day slogging through all this. ;)
Your response contained enough info for me to figure out the solution on my own. It now works great.
In case anyone else needs:
var source = SourceText.From("using My.Stuff; MyClass InputClass; string InputString;"); CsParser.Repository.Solution.AddDocument("global.cs", source);
Now editor knows about globals passed into CSharpScript at Evaluation time;
I'm not using your ScriptRunner. I'm using the Roslyn Script (CSharpScript).
Now on to snippets.
Thanks so much for your patience!!
Jim