Class member declaration expected warning

SyntaxEditor for Windows Forms Forum

Posted 11 years ago by Alex
Version: 4.0.0259
Platform: Services
Environment: Windows XP (32-bit)
Avatar
Hello, guys.

First of all I want to say thnx for your work. Your control is very useful. I'm using SE in my application and have just found an issue. I think it can be a bug. Recently I have downloaded the latest release (build 274), but the problem still exists. Truly say it is not reproducing in your sample project. I tried to duplicate initialization strings from your sample to mine, but it also didn't solve my problems. So, I have dialog box with two tabs on it. First tab is making available to edit body code segment (Document.Text) and second one is created as read only and shows all code segments (headertext, text, footertext), please see attached pictures (1,2).
Tab 1
Tab 2
As you can see the warning pop up is presented on Tab 1 - Class member declaration expected. An warning occurs only when I select C sharp language.
Here is my initialization steps:

   private StatusTextEditor CreateNewSyntaxEditor(ICodeSegment codeSegment, Boolean isFullText)
   {
            StatusTextEditor editor = new StatusTextEditor();
            editor.SyntaxEditor.Tag = codeSegment;
            editor.SyntaxEditor.Document.LanguageData = dotNetProjectResolver;
            editor.SyntaxEditor.AllowDrag = true;
            editor.SyntaxEditor.AllowDrop = true;
            editor.SyntaxEditor.LineNumberMarginVisible = true;
            editor.SyntaxEditor.WordWrap = WordWrapType.None;
            editor.SyntaxEditor.ScrollBarType = ScrollBarType.Both;
            editor.SyntaxEditor.LostFocus += SyntaxEditor_LostFocus;
            editor.SyntaxEditor.GotFocus += SyntaxEditor_GotFocus;
            editor.SyntaxEditor.CutCopyDragWithRtf = true;
            editor.SyntaxEditor.UnicodeEnabled = true;
            editor.SyntaxEditor.Font = new Font(editor.SyntaxEditor.Font.FontFamily, 8);

            editor.Dock = DockStyle.Fill;
            switch (Language)
            {
                case Language.CSharp:
                    editor.SyntaxEditor.Document.Language = new CSharpSyntaxLanguage();
                    break;
                case Language.VB:
                    editor.SyntaxEditor.Document.Language = new VBSyntaxLanguage();
                    break;

            }

            editor.SyntaxEditor.Document.ReadOnly = isFullEditor;
            editor.SyntaxEditor.CurrentLineHighlightingVisible = true;
            editor.SyntaxEditor.DefaultContextMenuEnabled = false;

            if (!((ICodeSegment)editor.SyntaxEditor.Tag).EditableByUser))
            {
                editor.SyntaxEditor.UseDisabledRenderingForReadOnlyMode = true;
            }
            else
            {
                editor.SyntaxEditor.ContextMenuStrip = contextMenuStrip1;
            }

            return editor;
   }
When I insert multi lined code without any conditions everything works fine. Suggestions?

[Modified at 07/16/2008 10:14 AM]

[Modified at 07/16/2008 10:15 AM]

Comments (5)

Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
It's hard to say without a repro project that we can debug. However here are a couple suggestions:

1) We just released a new build a couple days ago that did have a couple tweaks for header/footer text. Not sure if that will help here though.

2) Make sure you put a line feed at the end of the text you have in your header text. Otherwise, it may be parsing your first like in your body as a continuation of the single line comment above it in your full text. This would more likely be the problem or something similar.


Actipro Software Support

Posted 11 years ago by Alex
Avatar
I reproduced this issue in your repro project (in v.4.0.0274 package). You can see the code snippet on the attached picture below.

CodeFragmentEditing

[Modified at 07/17/2008 05:15 AM]
Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
When I insert that code in the latest build here I don't see the error. Can you verify whether it happens with build 275?


Actipro Software Support

Posted 11 years ago by Alex
Avatar
I tested it with 275 build. The warning still occurs. Please see screenshot for details.

CodeFragmentEditing v275 'Class method declaration expected' error

The steps to reproduce this error are following:
1) Open Code Fragment sample
2) Press Toggle Editing Mode to move focus to header part of code
3) Insert any single comment line after method declaration
Something like this:

public void MyMethod(int level) {
// lalala
4) Press Toggle Editing Mode to move back focus to body text
5) Remove all code
6) Insert following code snippet:

if (true) {
   return;
}
return;
The error message 'Class method declaration expected' pops up. I understand that this piece of code is absolutely superfluous. But in my project the SyntaxEditor is used to insert code snippets that are executed in the runtime and initial data is unknown. So, the similarly conditions are widely used.


[Modified at 07/18/2008 03:27 AM]
Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Ok I can dupe it now however it goes back to the #2 I said in a previous message. You must have a line feed in your header to end the comment line. Otherwise when it combines things for parsing, the "if (true) {" line is considered part of the comment.

Just put a line feed at the end of the // lallaa and it works.


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.