Comment and Uncomment fail on one document

SyntaxEditor Python Language Add-on for WPF Forum

Posted 4 years ago by Bob Puckett
Version: 15.1.0622
Avatar

I have multiple tabbed docs.  I have most things working (cut, paste, etc.).  Indent and Outdent work.

But, I have a problem with comment and uncomment in the first doc tab, but it works fine in all others.  

my Editor control has this code:

 

public void EditorAction(IEditAction action)
{
    bool result = mySyntaxEditor.ActiveView.ExecuteEditAction(action);
}

 

my application form has this code:

 

private void myCodeCommentBlockButton_ItemClick(object sender, ItemClickEventArgs e)
{
    activePythonEditor.EditorAction(new CommentLinesAction());
}

private void myCodeUncommentBlockButton_ItemClick(object sender, ItemClickEventArgs e)
{
    activePythonEditor.EditorAction(new UncommentLinesAction());
}

 

When I try this on the first doc (which is created slightly differently), the result comes back as false.  But all other commands work fine.  And, this works fine on other created tabs.  All highlighting and intellisense is working.

Any ideas why this might fail?

Comments (4)

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

Hi Bob,

The ExecuteEditAction returns false if the related action's CanExecute method returns false.  The CommentLinesAction.CanExecute method returns false when the document is read-only, doesn't have a language, or the language doesn't have an ILineCommenter service.  Check all those conditions to see where the problem is in your case.


Actipro Software Support

Posted 4 years ago by Bob Puckett
Avatar

Thanks.  I solved the problem.

Posted 3 years ago by Nate Wiegman
Avatar

Hi,

I'm taking over where Bob left off. This issue of adding comments still persists for our "Simple Script" language. I've modified to source that comments lines to check 'CanExecute', and 'CanExecute' always returns false. The language definition I have created includes comments (they begin with '* '). Any ideas what else I can check?

        private void CodeCommentBlockButton_ItemClick(object sender, ItemClickEventArgs e)
        {
            CommentLinesAction action = new CommentLinesAction();

            IEditorView view = activeSyntaxEditor.m_SyntaxEditor.ActiveView;

            if (action.CanExecute(view))
                activeSyntaxEditor.EditorAction(new CommentLinesAction());
        }

 

Thanks,
Nate

Language definition:

<?xml version="1.0" encoding="utf-8"?>
<!--

Actipro Syntax Language Definition (.langdef)
  For use with Actipro SyntaxEditor and related products.
  http://www.actiprosoftware.com

'Prober Bench Simple Script' language created by Nate Wiegman.
  2016 Cascade Microtech

-->
<LanguageDefinition LanguageKey="VeloxSimpleScript" LanguageDescription="Prober Bench Simple Script" Creator="Nate Wiegman" Copyright="2016 Cascade Microtech" xmlns="http://schemas.actiprosoftware.com/langdef/1.0">
	<!-- Classification types -->
	<LanguageDefinition.ClassificationTypes>
		<ClassificationType Key="Comment" DefaultStyle="#FF008000" />
		<ClassificationType Key="Identifier" />
		<ClassificationType Key="Keyword" DefaultStyle="#FF0000FF" />
		<ClassificationType Key="Number" />
		<ClassificationType Key="String" DefaultStyle="#FF800000" />
	</LanguageDefinition.ClassificationTypes>
	<!-- Lexer -->
	<LanguageDefinition.Lexer>
		<DynamicLexer>
			<!-- Default state -->
			<State Id="1" Key="Default">
				<State.ChildStates>
					<StateRef Key="PrimaryString" />
					<StateRef Key="SingleLineComment" />
				</State.ChildStates>
				<RegexPatternGroup TokenId="1" TokenKey="Whitespace" Pattern="{LineTerminatorWhitespace}+" />
				<ExplicitPatternGroup TokenId="2" TokenKey="Keyword" ClassificationTypeKey="Keyword" LookAheadPattern="{NonWord}|\z">
					<ExplicitPatterns><![CDATA[
						*Delay *GPIB *RS232 *SCI
					]]></ExplicitPatterns>
				</ExplicitPatternGroup>
				<RegexPatternGroup TokenId="3" TokenKey="Identifier" ClassificationTypeKey="Identifier" Pattern="(_ | {Alpha})({Word})*" />
				<RegexPatternGroup TokenId="4" TokenKey="RealNumber" ClassificationTypeKey="Number" LookAheadPattern="{NonWord}|\z">
					<RegexPattern Value="{Digit}* \. {Digit}+ ([Ee] [\+\-]? {Digit}+)?" />
					<RegexPattern Value="{Digit}+ [Ee] [\+\-]? {Digit}+" />
				</RegexPatternGroup>
				<RegexPatternGroup TokenId="5" TokenKey="IntegerNumber" ClassificationTypeKey="Number" Pattern="{Digit}+" LookAheadPattern="{NonWord}|\z" />
				<RegexPatternGroup TokenId="6" TokenKey="HexNumber" ClassificationTypeKey="Number" Pattern="0x {HexDigit}+" LookAheadPattern="{NonWord}|\z" CaseSensitivity="Insensitive" />
			</State>
			<!-- PrimaryString state -->
			<State Id="2" Key="PrimaryString" DefaultTokenId="7" DefaultTokenKey="PrimaryStringText" DefaultClassificationTypeKey="String">
				<State.Scopes>
					<Scope>
						<Scope.StartPatternGroup>
							<ExplicitPatternGroup TokenId="8" TokenKey="PrimaryStringStartDelimiter" Pattern="&quot;" />
						</Scope.StartPatternGroup>
						<Scope.EndPatternGroup>
							<RegexPatternGroup TokenId="9" TokenKey="PrimaryStringEndDelimiter" Pattern="[\&quot;\n]" />
						</Scope.EndPatternGroup>
					</Scope>
				</State.Scopes>
				<RegexPatternGroup TokenId="7" TokenKey="PrimaryStringText" Pattern="[^\&quot;\n]+" />
			</State>
			<!-- SingleLineComment state -->
			<State Id="3" Key="SingleLineComment" DefaultTokenId="10" DefaultTokenKey="SingleLineCommentText" DefaultClassificationTypeKey="Comment">
				<State.Scopes>
					<Scope>
						<Scope.StartPatternGroup>
							<ExplicitPatternGroup TokenId="11" TokenKey="SingleLineCommentStartDelimiter" Pattern="*" />
						</Scope.StartPatternGroup>
						<Scope.EndPatternGroup>
							<RegexPatternGroup TokenId="12" TokenKey="SingleLineCommentEndDelimiter" Pattern="\n" />
						</Scope.EndPatternGroup>
					</Scope>
				</State.Scopes>
				<RegexPatternGroup TokenId="10" TokenKey="SingleLineCommentText" Pattern="[^\n]+" />
			</State>
		</DynamicLexer>
	</LanguageDefinition.Lexer>
	<!-- Example text -->
	<LanguageDefinition.ExampleText><![CDATA[ReportKernelVersion K
ReadProberStatus
EchoData "Hello World"]]></LanguageDefinition.ExampleText>
</LanguageDefinition>
Posted 3 years ago by Nate Wiegman
Avatar

Hi,

One of our engineers here kindly pointed me to this post which solved my issue!

http://www.actiprosoftware.com/community/thread/4402/comment-uncomment-commands-disabled

Thanks,
Nate

The latest build of this product (v2019.1 build 0681) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.