Posted 6 years ago by David Rutten - Robert McNeel & Associates
Version: 12.1.0303
Avatar

Dear all,

getting started switching out our old code editor with the Actipro one, but it's taking me a long time to get anywhere. What I need is 4 fairly simple things (I would have thought):

  1. Set up an editor control and load it up with either a VB.NET or a C# language (this I think is working, highligting is correct though automatic indenting and formatting and autocompletion isn't working).
  2. Add a bunch of assemblies that contain all the types that I need autocompletion and intellisense for.
  3. Populate the document with an array of lines, where each line has a readonly boolean associated with it. I think I've figured out how to get whether a line is readonly, but I can't find where to set that property. From what I gather though Actipro prefers to assign Readonly properties to TextRanges, not line indices, so maybe I'm better off aggregating all lines into a single block first?
  4. Extract all the lines from the editor control into an array of strings with associated readonly booleans. I.e. the opposite of item 3. I think I have this working using DocumentLine.Text and checking whether DocumentLine.TextRange happens to be readonly, but I don't know whether my code works as I'm stuck on step [3].

I think I have the .NET languages add-on as I was informed I needed this for proper autocompletion, however it doesn't appear as a separate listing in the Windows Control Panel. How can I check whether it is installed and whether I'm actually using it?

 

Any help greatly appreciated,

David

--

David Rutten

david@mcneel.com

Poprad, Slovakia

[Modified 6 years ago]

Comments (3)

Posted 6 years ago by David Rutten - Robert McNeel & Associates
Avatar

I think I figured out the Readonly bit (3) and (4). Not sure if I'm doing it right, but it seems to work. I was very confused by the layer/layers singular/plural mismatch:

Dim layer As SpanIndicatorLayer = Document.SpanIndicatorLayers(SpanIndicatorLayer.ReadOnlyKey)

SpanIndicatorLayers returns a SpanIndicatorLayerCollection yet it is assigned to a single SpanIndicatorLayer. I don't know why it works, but it works.

Basically I'm left trying to figure out why it's crashing when I call 

CodeEditor.Document.Language.FormatDocument(CodeEditor.Document)

with a NotImplementedException:

System::Windows::Forms::Application::ThreadException event occured
SENDER: System.Threading.Thread
EXCEPTION: System.NotImplementedException
MESSAGE: The language 'VB' needs to implement the 'FormatTextRange' method so that it can support code formatting.
SOURCE: ActiproSoftware.SyntaxEditor.WinForms
CALL STACK
at ActiproSoftware.SyntaxEditor.SyntaxLanguage.FormatTextRange(Document document, TextRange textRange)
at ActiproSoftware.SyntaxEditor.SyntaxLanguage.FormatDocument(Document document)
at Grasshopper.GUI.Script.GH_ScriptEditor.SetSourceCode(GH_EditorCodeLines lines) in C:\dev\Grasshopper\1.0\root\src\GH_ScriptEditor.vb:line 357
at ScriptComponents.Component_GenericScript.ShowScriptEditor() in C:\dev\Grasshopper\1.0\root\src\Components\ScriptComponents\Component_GenericScript2.vb:line 784
at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 

Does that mean I'm not using the .NET languages add-on correctly?

--

David

Answer - Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi David,

1/2)  For these, make sure you read through the "Key Steps for Getting Started" items in the .NET Languages Add-on's "Overview" documentation topic.  That tells you how to get up and running with it and have automated IntelliPrompt working.  If you miss any of those steps, then it won't work properly.  You also can look at the source of our DotNetReflection demo since that shows an example of everything, including adding references to assemblies.  The .NET Languages Add-on language classes are CSharpSyntaxLanguage and VBSyntaxLanguage.  If you are using those then you are using the add-on.

3)  As you saw, our editor only tracks read-only ranges, not read-only lines.  You'd need to somehow convert your line data to the proper offset data so that you can make read-only ranges.  And be sure that you combine the adjacent ranges wherever possible to make things most efficient.  Also note that our offsets track line terminators with a single \n character.  So account for that when calculating offsets.

4) You could do it that way.  Or get the entire text once and split it by line terminator.

As for the SpanIndicatorLayers, you are calling an indexer there, which returns a single SpanIndicatorLayer item from a collection.

For the formatter, the exception message indicates that the VB language in the add-on doesn't implement a text formatter.  Languages can optionally implement one but that particular one doesn't at this time, thus the exception when you call that method.  You can add one on if you wish though as described in the "Code Formatting" documentation topic if you have your own logic for formatting (or find one on the web) that you'd like to apply.


Actipro Software Support

Posted 6 years ago by David Rutten - Robert McNeel & Associates
Avatar

For the formatter, the exception message indicates that the VB language in the add-on doesn't implement a text formatter.

Ok, appearently a Text Formatter isn't what I think it is then. If I can get away without one that's fine.

I'm running into more problems as the old ones get solved, but I'll put those on a different thread.

Thanks,

David

The latest build of this product (v2018.1 build 0341) was released 6 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.