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.
|
* Testing the auto indent strategies.
|
||||||
*/
|
*/
|
||||||
public class DefaultCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
|
public class DefaultCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
|
||||||
private HashMap fOptions;
|
private HashMap<String,String> fOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name
|
||||||
|
@ -523,6 +523,19 @@ public class DefaultCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
|
||||||
assertDeclarationFollowingX("void baz(int x) {}");
|
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()
|
// #define MM void foo()
|
||||||
// X
|
// X
|
||||||
// MM {}
|
// MM {}
|
||||||
|
|
|
@ -13,8 +13,6 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.tests.text.doctools.doxygen;
|
package org.eclipse.cdt.ui.tests.text.doctools.doxygen;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
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.Document;
|
||||||
import org.eclipse.jface.text.IDocument;
|
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.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
@ -45,7 +42,6 @@ import org.eclipse.cdt.internal.ui.text.CTextTools;
|
||||||
* Testing the auto indent strategies.
|
* Testing the auto indent strategies.
|
||||||
*/
|
*/
|
||||||
public class DoxygenCCommentAutoEditStrategyTest extends DefaultCCommentAutoEditStrategyTest {
|
public class DoxygenCCommentAutoEditStrategyTest extends DefaultCCommentAutoEditStrategyTest {
|
||||||
private HashMap fOptions;
|
|
||||||
protected ICProject fCProject;
|
protected ICProject fCProject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,7 +58,6 @@ public class DoxygenCCommentAutoEditStrategyTest extends DefaultCCommentAutoEdit
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
fCProject= CProjectHelper.createCCProject("test"+System.currentTimeMillis(), null);
|
fCProject= CProjectHelper.createCCProject("test"+System.currentTimeMillis(), null);
|
||||||
fOptions= CCorePlugin.getOptions();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -70,7 +65,6 @@ public class DoxygenCCommentAutoEditStrategyTest extends DefaultCCommentAutoEdit
|
||||||
*/
|
*/
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
CProjectHelper.delete(fCProject);
|
CProjectHelper.delete(fCProject);
|
||||||
CCorePlugin.setOptions(fOptions);
|
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,6 +326,32 @@ public class DoxygenCCommentAutoEditStrategyTest extends DefaultCCommentAutoEdit
|
||||||
assertAutoEditBehaviour();
|
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 {
|
protected void assertAutoEditBehaviour() throws CoreException {
|
||||||
CTextTools textTools = CUIPlugin.getDefault().getTextTools();
|
CTextTools textTools = CUIPlugin.getDefault().getTextTools();
|
||||||
final IDocument doc = new Document();
|
final IDocument doc = new Document();
|
||||||
|
|
|
@ -189,11 +189,8 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
|
||||||
IASTDeclaration stopWhenLeaving;
|
IASTDeclaration stopWhenLeaving;
|
||||||
|
|
||||||
public int visit(IASTDeclaration declaration) {
|
public int visit(IASTDeclaration declaration) {
|
||||||
IASTNodeLocation[] locs= declaration.getNodeLocations();
|
IASTNodeLocation loc= declaration.getFileLocation();
|
||||||
if(locs.length>0) {
|
if(loc != null) {
|
||||||
for(int i=0; i<locs.length; i++) {
|
|
||||||
IASTNodeLocation loc= locs[i];
|
|
||||||
|
|
||||||
int candidateOffset= loc.getNodeOffset();
|
int candidateOffset= loc.getNodeOffset();
|
||||||
int candidateEndOffset= candidateOffset+loc.getNodeLength();
|
int candidateEndOffset= candidateOffset+loc.getNodeLength();
|
||||||
|
|
||||||
|
@ -207,7 +204,6 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
|
||||||
stopWhenLeaving= declaration;
|
stopWhenLeaving= declaration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
public int leave(IASTDeclaration declaration) {
|
public int leave(IASTDeclaration declaration) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue