Commit e50fbf58 authored by Miklos Magyari's avatar Miklos Magyari
Browse files

Comment scanner improvements for better highlighting


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent 35785331
......@@ -14,9 +14,11 @@ import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.PatternRule;
import org.eclipse.jface.text.rules.RuleBasedScanner;
import org.eclipse.jface.text.rules.WhitespaceRule;
import org.eclipse.jface.text.rules.WordRule;
import org.eclipse.titan.designer.AST.TTCN3.definitions.ICommentable;
import org.eclipse.titan.designer.editors.ColorManager;
import org.eclipse.titan.designer.editors.WhiteSpaceDetector;
import org.eclipse.titan.designer.preferences.PreferenceConstants;
/**
......@@ -38,6 +40,9 @@ public final class CommentScanner extends RuleBasedScanner {
}
rules.add(wordRule);
rules.add(new PatternRule("<", ">", htmltag, '\0', false));
rules.add(new WhitespaceRule(new WhiteSpaceDetector()));
final WordRule commentTextRule = new WordRule(new CommentTextDetector(), comment);
rules.add(commentTextRule);
setRules(rules.toArray(new IRule[rules.size()]));
}
}
/******************************************************************************
* Copyright (c) 2000-2022 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
******************************************************************************/
package org.eclipse.titan.designer.editors.ttcn3editor;
import org.eclipse.jface.text.rules.IWordDetector;
public class CommentTextDetector implements IWordDetector {
@Override
public boolean isWordStart(char c) {
return true;
}
@Override
public boolean isWordPart(char c) {
switch(c) {
case ' ':
case '\t':
case '\n':
case '<':
case '@':
return false;
default:
return true;
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment