1
0
Fork 0
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:
Andrew Ferguson 2008-03-13 11:32:53 +00:00
parent 2ee490ecf3
commit 83b3470a9e
3 changed files with 52 additions and 23 deletions

View file

@ -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
@ -523,6 +523,19 @@ public class DefaultCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
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
// MM {}

View file

@ -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();

View file

@ -189,11 +189,8 @@ 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();
@ -207,7 +204,6 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
stopWhenLeaving= declaration;
}
}
}
return PROCESS_CONTINUE;
}
public int leave(IASTDeclaration declaration) {