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:
parent
c9dbba10e8
commit
12348ba297
2 changed files with 36 additions and 12 deletions
|
@ -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 {
|
public void testSingleLineComment_Hash() throws BadLocationException {
|
||||||
// to get single line comment partitions for # lines,
|
// to get single line comment partitions for # lines,
|
||||||
// we need to configure the partitioner
|
// we need to configure the partitioner
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.eclipse.cdt.internal.ui.text.BufferedDocumentScanner;
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>C multi line comments</li>
|
* <li>C multi line comments</li>
|
||||||
* <li>Assembly line comments</li>
|
* <li>Assembly line comments</li>
|
||||||
|
* <li>C++ line comments</li>
|
||||||
* <li>C string literals</li>
|
* <li>C string literals</li>
|
||||||
* <li>Assembly character literals</li>
|
* <li>Assembly character literals</li>
|
||||||
* <li>C preprocessor directives</li>
|
* <li>C preprocessor directives</li>
|
||||||
|
@ -364,21 +365,21 @@ public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPart
|
||||||
|
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case '/':
|
case '/':
|
||||||
// unsupported: C++ line comment
|
// supported by gnu preprocessor
|
||||||
// if (fLast == SLASH) {
|
if (fLast == SLASH) {
|
||||||
// if (fTokenLength - getLastLength(fLast) > 0) {
|
if (fTokenLength - getLastLength(fLast) > 0) {
|
||||||
// return preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 2);
|
return preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 2);
|
||||||
// } else {
|
} else {
|
||||||
// preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 2);
|
preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 2);
|
||||||
// fTokenOffset += fTokenLength;
|
fTokenOffset += fTokenLength;
|
||||||
// fTokenLength= fPrefixLength;
|
fTokenLength= fPrefixLength;
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
// } else {
|
} else {
|
||||||
fTokenLength++;
|
fTokenLength++;
|
||||||
fLast= SLASH;
|
fLast= SLASH;
|
||||||
break;
|
break;
|
||||||
// }
|
}
|
||||||
|
|
||||||
case '*':
|
case '*':
|
||||||
if (fLast == SLASH) {
|
if (fLast == SLASH) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue