how to define outline style in c++ CLR ?

SyntaxEditor for Windows Forms Forum

Posted 8 years ago by dani
Version: 4.0.0287
Avatar
Product Version: SyntaxEditor v4.0.0287 .NET Controls

hi,
Thanks for your great SyntaxEditor Component


how to Perform automatic outlining style in C++ CLR.NET Language ?

i'm not used VB.NET Or C#.NET language
i'm using C++.NET CLR but how we can define a Class like "CSharpDynamicSyntaxLanguage.cs" to use DynamicLanguage ?


for example we use
"ActiproSoftware.CSharp.xml"
[And]
"CSharpDynamicSyntaxLanguage.cs"
in C#.net language to doing automatic outlining

but
how to do it in c++[CLR]Visual Studio .NET language?
ActiproSoftware.CSharp.xml
[And]
???


i need few code to make
a class like "CSharpDynamicSyntaxLanguage.cs" but not in c#.net Language
in c++(CLR).NET Language


Thank You Very Much.

Comments (13)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Dani,

I'm sorry but we don't really do C++.NET here so I'm not sure of how you would define it in C++. Basically in the .xml file you'll note the root tag has a:
SyntaxLanguageTypeName="TestApplication.CSharpDynamicSyntaxLanguage, TestApplication"

Which means look for a CSharpDynamicSyntaxLanguage class in the TestApplication namespace and within a .NET assembly named TestApplication that is loaded.

You'll have to consult Microsoft's documentation or their forums to determine how to make .NET-compatible assemblies and classes that can be used from C# code. Once you do that, change your SyntaxLanguageTypeName attribute in the .xml file to point to the appropriate assembly/type combination you make.


Actipro Software Support

Posted 8 years ago by dani
Avatar
hi Actipro
Thank you for reply

i research on it and i do it !
this is my code and show how to i'm connect my c++ class to your DynamicSyntaxLanguage c# class !
to doing automaticOutlinig


namespace MyEditor {

enum string_code {
OpenCurlyBraceToken,
CloseCurlyBraceToken,
MultiLineCommentStartToken,
MultiLineCommentEndToken,
XMLCommentStartToken,
XMLCommentEndToken,
RegionPreProcessorDirectiveStartToken,
EndRegionPreProcessorDirectiveEndToken
};

public ref class CppDynamicSyntaxLanguage :DynamicSyntaxLanguage {

public:
CppDynamicSyntaxLanguage() {}

public:
CppDynamicSyntaxLanguage(String ^key, bool secure) {}

public:

void GetTokenOutliningAction (TokenStream tokenStream, String ^outliningKey, OutliningNodeAction tokenAction)
{

string_code i;

IToken ^ token = tokenStream.Peek();
switch (i )
{
case 1:
outliningKey = "CodeBlock";
tokenAction = OutliningNodeAction::Start;
break;
case 2:
outliningKey = "CodeBlock";
tokenAction = OutliningNodeAction::End;
break;
case 3:
outliningKey = "MultiLineComment";
tokenAction = OutliningNodeAction::Start;
break;
case 4:
outliningKey = "MultiLineComment";
tokenAction = OutliningNodeAction::End;
break;
case 5:
outliningKey = "XMLComment";
tokenAction = OutliningNodeAction::Start;
break;
case 6:
outliningKey = "XMLComment";
tokenAction = OutliningNodeAction::End;
break;
case 7:
outliningKey = "RegionPreProcessorDirective";
tokenAction = OutliningNodeAction::Start;
break;
case 8:
outliningKey = "RegionPreProcessorDirective";
tokenAction = OutliningNodeAction::End;
break;
}

};//void
};//class
}//name space


this code's worked and not return any error
i used:
<SyntaxLanguage Key="C++" LanguageDefinitionVersion="4.0" Secure="False"
SyntaxLanguageTypeName="MyEditor.CppDynamicSyntaxLanguage, MyEditor"

it's work and when run application

public :
CppDynamicSyntaxLanguage(){}

Called
But

void GetTokenOutliningAction (TokenStream tokenStream, String ^outliningKey, OutliningNodeAction tokenAction)

Not Called !

i want to buy a Enterprise License for our company product but first i must fix this problem.

Thank You Very Much.
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Dani,

Try having your CppDynamicSyntaxLanguage class inherit DynamicOutliningSyntaxLanguage instead of DynamicSyntaxLanguage, since DynamicOutliningSyntaxLanguage that has outlining support you can customize.

Let us know if that fixes it.


Actipro Software Support

Posted 8 years ago by dani
Avatar
hi Actipro
i try to use
public ref class CppDynamicSyntaxLanguage :DynamicOutliningSyntaxLanguage

but i recive this message :

Additional information: An error occurred while loading the DynamicSyntaxLanguage '{Unknown}':
An instance of the syntax language type 'MyEditor.CppDynamicSyntaxLanguage, MyEditor' could not be created. Please ensure that a public constructor exists with the same parameters as the base 'DynamicSyntaxLanguage' class. The problem that occurred was:
Cannot create an abstract class.
The problem occurred near line 1, position 2
in Unknown Stream.
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
We're getting closer... That seems to indicate your CppDynamicSyntaxLanguage class is abstract or there isn't a public constructor found that it likes.

Make sure your class is not abstract and that it has a public constructor that takes a string key parameter, as well as a bool secure parameter, and passes both to the base class' constructor.

In C# that sort of code would be written like:
public CppDynamicSyntaxLanguage(string key, bool secure) : base(key, secure) {}


Actipro Software Support

Posted 8 years ago by dani
Avatar
Hi Actipro,

now i added this code's to my CppDynamicSyntaxLanguage class to fix it:


public:
CppDynamicSyntaxLanguage ():DynamicOutliningSyntaxLanguage () {}

public:
CppDynamicSyntaxLanguage (String ^ key, bool secure):DynamicOutliningSyntaxLanguage (key, secure) {}


it's true code and compiled...

but when i run application i recive this message again:

Additional information: An error occurred while loading the DynamicSyntaxLanguage '{Unknown}':
An instance of the syntax language type 'MyEditor.CppDynamicSyntaxLanguage, MyEditor' could not be created. Please ensure that a public constructor exists with the same parameters as the base 'DynamicSyntaxLanguage' class. The problem that occurred was:
Cannot create an abstract class.
The problem occurred near line 1, position 2
in Unknown Stream.
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Dani,

That "Cannot create an abstract class." is still in your error message, which means that .NET probably thinks CppDynamicSyntaxLanguage is abstract. If you open your .dll in Reflector and go browse to the CppDynamicSyntaxLanguage class, perhaps you can tell from that if it is marked abstract or not. Let us know. If so, you need to make sure it is not abstract and can be created by our code.


Actipro Software Support

Posted 8 years ago by dani
Avatar
Hi Actipro,

oh
you'r right ! it's abstract and i don't know!

please see this..

http://stark.persiangig.com/abstract%20show.JPG

but how to make it a non abstract?
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
That is your problem then. Unfortunately we don't know C++ syntax so I'm not sure how to create a non-abstract class there. I'm sure it's possible. Perhaps a post in the Microsoft forums or some web searches can help you with that.


Actipro Software Support

Posted 8 years ago by dani
Avatar
but when i define

public ref class CppDynamicSyntaxLanguage :public DynamicSyntaxLanguage

my class is not abstract
please see this:

http://stark.persiangig.com/pic2.JPG
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Our DynamicOutliningSyntaxLanguage is abstract but in C# at least, when you create a new class that inherits an abstract class, it doesn't make the inheriting class abstract unless you explicitly say it is per the 'abstract' keyword. That is different behavior than what you are describing in C++.

The DynamicOutliningSyntaxLanguage class has a single abstract method called GetTokenOutliningAction. Make sure you implement that. If you aren't, perhaps C++ is keeping your class abstract too?


Actipro Software Support

Posted 8 years ago by dani
Avatar
i'm not used 'abstract' keyword in all of my project code's;
and
i implement GetTokenOutliningAction and not implement it both ! but have no action
my class is abstract allways.

unless i define:
public ref class CppDynamicSyntaxLanguage :public DynamicSyntaxLanguage
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I'm sorry but again we don't know C++ and don't know why that is happening to you. It's different than how C# works.

I'd recommend you post in Microsoft forums or in StackOverflow asking why when you inherit an abstract C# class defined in a .dll, your C++ class is forced abstract. If you can figure that out then you'll probably have everything working.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.