1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix 221853: Assembly editor does not parse comments correctly

This commit is contained in:
Anton Leherbauer 2008-03-10 08:56:51 +00:00
parent c9dbba10e8
commit 12348ba297
2 changed files with 36 additions and 12 deletions

View file

@ -1073,6 +1073,29 @@ public class AsmPartitionerTest extends TestCase {
}
}
public void testSingleLineComment_CppStyle() throws BadLocationException {
fDocument.set("// single line comment");
int p1= fDocument.getLength();
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
TypedRegion[] expectation= {
new TypedRegion(0, p1, ICPartitions.C_SINGLE_LINE_COMMENT)
};
checkPartitioning(expectation, result);
fDocument.replace(p1++, 0, "\nlabel: opcode arg1,arg2 ");
int p2= fDocument.getLength();
fDocument.replace(p2, 0, "// end-of-line comment");
int p3= fDocument.getLength();
result= fDocument.computePartitioning(0, fDocument.getLength());
expectation= new TypedRegion[] {
new TypedRegion(0, p1, ICPartitions.C_SINGLE_LINE_COMMENT),
new TypedRegion(p1, p2-p1, IDocument.DEFAULT_CONTENT_TYPE),
new TypedRegion(p2, p3-p2, ICPartitions.C_SINGLE_LINE_COMMENT)
};
checkPartitioning(expectation, result);
}
public void testSingleLineComment_Hash() throws BadLocationException {
// to get single line comment partitions for # lines,
// we need to configure the partitioner

View file

@ -30,6 +30,7 @@ import org.eclipse.cdt.internal.ui.text.BufferedDocumentScanner;
* <ul>
* <li>C multi line comments</li>
* <li>Assembly line comments</li>
* <li>C++ line comments</li>
* <li>C string literals</li>
* <li>Assembly character literals</li>
* <li>C preprocessor directives</li>
@ -364,21 +365,21 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
switch (ch) {
case '/':
// unsupported: C++ line comment
// if (fLast == SLASH) {
// if (fTokenLength - getLastLength(fLast) > 0) {
// return preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 2);
// } else {
// preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 2);
// fTokenOffset += fTokenLength;
// fTokenLength= fPrefixLength;
// break;
// }
// } else {
// supported by gnu preprocessor
if (fLast == SLASH) {
if (fTokenLength - getLastLength(fLast) > 0) {
return preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 2);
} else {
preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 2);
fTokenOffset += fTokenLength;
fTokenLength= fPrefixLength;
break;
}
} else {
fTokenLength++;
fLast= SLASH;
break;
// }
}
case '*':
if (fLast == SLASH) {