mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
fix behaviour when commenting methods preceded by a macro
This commit is contained in:
parent
2ee490ecf3
commit
83b3470a9e
3 changed files with 52 additions and 23 deletions
|
@ -41,7 +41,7 @@ import org.eclipse.cdt.internal.ui.text.CTextTools;
|
|||
* Testing the auto indent strategies.
|
||||
*/
|
||||
public class DefaultCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
|
||||
private HashMap fOptions;
|
||||
private HashMap<String,String> fOptions;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
|
@ -522,6 +522,19 @@ public class DefaultCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
|
|||
public void testFollowingDeclaration9() {
|
||||
assertDeclarationFollowingX("void baz(int x) {}");
|
||||
}
|
||||
|
||||
// #define STATIC static
|
||||
//
|
||||
// class D {
|
||||
// public:
|
||||
// X
|
||||
// STATIC void D::foo(int x) {
|
||||
//
|
||||
// }
|
||||
// };
|
||||
public void testFollowingDeclaration13() throws CoreException {
|
||||
assertDeclarationFollowingX("STATIC void D::foo(int x) {\n \n }");
|
||||
}
|
||||
|
||||
// #define MM void foo()
|
||||
// X
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
|
||||
package org.eclipse.cdt.ui.tests.text.doctools.doxygen;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
|
@ -23,7 +21,6 @@ import org.eclipse.jface.text.BadLocationException;
|
|||
import org.eclipse.jface.text.Document;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
|
@ -45,7 +42,6 @@ import org.eclipse.cdt.internal.ui.text.CTextTools;
|
|||
* Testing the auto indent strategies.
|
||||
*/
|
||||
public class DoxygenCCommentAutoEditStrategyTest extends DefaultCCommentAutoEditStrategyTest {
|
||||
private HashMap fOptions;
|
||||
protected ICProject fCProject;
|
||||
|
||||
/**
|
||||
|
@ -62,7 +58,6 @@ public class DoxygenCCommentAutoEditStrategyTest extends DefaultCCommentAutoEdit
|
|||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
fCProject= CProjectHelper.createCCProject("test"+System.currentTimeMillis(), null);
|
||||
fOptions= CCorePlugin.getOptions();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -70,7 +65,6 @@ public class DoxygenCCommentAutoEditStrategyTest extends DefaultCCommentAutoEdit
|
|||
*/
|
||||
protected void tearDown() throws Exception {
|
||||
CProjectHelper.delete(fCProject);
|
||||
CCorePlugin.setOptions(fOptions);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
@ -332,6 +326,32 @@ public class DoxygenCCommentAutoEditStrategyTest extends DefaultCCommentAutoEdit
|
|||
assertAutoEditBehaviour();
|
||||
}
|
||||
|
||||
// #define STATIC static
|
||||
//
|
||||
// class D {
|
||||
// public:
|
||||
// /**X
|
||||
// STATIC void D::foo(int x) {
|
||||
//
|
||||
// }
|
||||
// };
|
||||
|
||||
// #define STATIC static
|
||||
//
|
||||
// class D {
|
||||
// public:
|
||||
// /**
|
||||
// * X
|
||||
// * @param x
|
||||
// */
|
||||
// STATIC void D::foo(int x) {
|
||||
//
|
||||
// }
|
||||
// };
|
||||
public void testAutoDocCommentContent17() throws CoreException {
|
||||
assertAutoEditBehaviour();
|
||||
}
|
||||
|
||||
protected void assertAutoEditBehaviour() throws CoreException {
|
||||
CTextTools textTools = CUIPlugin.getDefault().getTextTools();
|
||||
final IDocument doc = new Document();
|
||||
|
|
|
@ -189,23 +189,19 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
|
|||
IASTDeclaration stopWhenLeaving;
|
||||
|
||||
public int visit(IASTDeclaration declaration) {
|
||||
IASTNodeLocation[] locs= declaration.getNodeLocations();
|
||||
if(locs.length>0) {
|
||||
for(int i=0; i<locs.length; i++) {
|
||||
IASTNodeLocation loc= locs[i];
|
||||
IASTNodeLocation loc= declaration.getFileLocation();
|
||||
if(loc != null) {
|
||||
int candidateOffset= loc.getNodeOffset();
|
||||
int candidateEndOffset= candidateOffset+loc.getNodeLength();
|
||||
|
||||
int candidateOffset= loc.getNodeOffset();
|
||||
int candidateEndOffset= candidateOffset+loc.getNodeLength();
|
||||
|
||||
if(offset <= candidateOffset) {
|
||||
dec[0]= declaration;
|
||||
return PROCESS_ABORT;
|
||||
}
|
||||
|
||||
boolean candidateEnclosesOffset= (offset >= candidateOffset) && (offset < candidateEndOffset);
|
||||
if(candidateEnclosesOffset) {
|
||||
stopWhenLeaving= declaration;
|
||||
}
|
||||
if(offset <= candidateOffset) {
|
||||
dec[0]= declaration;
|
||||
return PROCESS_ABORT;
|
||||
}
|
||||
|
||||
boolean candidateEnclosesOffset= (offset >= candidateOffset) && (offset < candidateEndOffset);
|
||||
if(candidateEnclosesOffset) {
|
||||
stopWhenLeaving= declaration;
|
||||
}
|
||||
}
|
||||
return PROCESS_CONTINUE;
|
||||
|
|
Loading…
Add table
Reference in a new issue