Auto edit for multi line comments [message #694615] |
Sat, 09 July 2011 01:37 |
Dénes Harmath Messages: 157 Registered: July 2009 |
Senior Member |
|
|
Hi all,
unfortunately my grammar's comment terminal rules look like this:
terminal SL_COMMENT: "%" !("\n" | "\r")* ("\r"? "\n")?;
terminal ML_COMMENT: "%{" -> "%}";
so they have a common prefix. I think this causes the following problem:
Here's my auto edit strategy provider:
private static void accept(IEditStrategyAcceptor acceptor, IAutoEditStrategy strategy) {
acceptor.accept(strategy, IDocument.DEFAULT_CONTENT_TYPE);
acceptor.accept(strategy, TerminalsTokenTypeToPartitionMapper.COMMENT_PARTITION);
acceptor.accept(strategy, TerminalsTokenTypeToPartitionMapper.SL_COMMENT_PARTITION);
}
public static final String[][] BLOCK_KEYWORD_PAIRS = { { "{", "}" }, //$NON-NLS-1$ //$NON-NLS-2$
{ "%{", "%}" }, //$NON-NLS-1$ //$NON-NLS-2$
{ "<<", ">>" } }; //$NON-NLS-1$ //$NON-NLS-2$
@Override
protected void configure(IEditStrategyAcceptor acceptor) {
accept(acceptor, defaultIndentLineAutoEditStrategy.get());
for (String[] blockKeywordPair : BLOCK_KEYWORD_PAIRS) {
accept(acceptor, singleLineTerminals.newInstance(blockKeywordPair[0], blockKeywordPair[1]));
accept(acceptor, multiLineTerminals.newInstance(blockKeywordPair[0], null, blockKeywordPair[1]));
}
final String[][] brackets = new String[][] { { "[", "]" }, //$NON-NLS-1$ //$NON-NLS-2$
{ "\\(", "\\)" }, //$NON-NLS-1$ //$NON-NLS-2$
{ "(", ")" } }; //$NON-NLS-1$ //$NON-NLS-2$
for (String[] blockKeywordPair : brackets) {
accept(acceptor, singleLineTerminals.newInstance(blockKeywordPair[0], blockKeywordPair[1]));
}
accept(acceptor, partitionInsert.newInstance("\"", "\"")); //$NON-NLS-1$ //$NON-NLS-2$
}
Unfortunately, when I type %{, only } is inserted, not %}. How can I circumvent this?
Thanks in advance,
thSoft
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01745 seconds