1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 01:45:33 +02:00

238852: suppress @param for f(void) parameter

This commit is contained in:
Andrew Ferguson 2008-07-02 09:55:53 +00:00
parent 29eafddce0
commit d4573870a7
2 changed files with 70 additions and 8 deletions

View file

@ -441,7 +441,43 @@ public class DoxygenCCommentAutoEditStrategyTest extends DefaultCCommentAutoEdit
// * X
// */
// void foo(void) {}
public void testAutoDocCommentContent21_238852() throws CoreException {
public void testAutoDocCommentContent21_238852_a() throws CoreException {
assertAutoEditBehaviour();
}
// /**X
// void foo(void* x) {}
// /**
// * X
// * @param x
// */
// void foo(void* x) {}
public void testAutoDocCommentContent21_238852_b() throws CoreException {
assertAutoEditBehaviour();
}
// /**X
// void foo(void (*fp)()) {}
// /**
// * X
// * @param fp
// */
// void foo(void (*fp)()) {}
public void testAutoDocCommentContent21_238852_c() throws CoreException {
assertAutoEditBehaviour();
}
// /**X
// void foo(void vs[]) {}
// /**
// * X
// * @param vs
// */
// void foo(void vs[]) {}
public void testAutoDocCommentContent21_238852_d() throws CoreException {
assertAutoEditBehaviour();
}

View file

@ -18,6 +18,7 @@ import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@ -33,7 +34,6 @@ import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.ui.text.doctools.DefaultMultilineCommentAutoEditStrategy;
@ -87,16 +87,42 @@ public class DoxygenMultilineAutoEditStrategy extends DefaultMultilineCommentAut
protected StringBuilder documentFunctionParameters(IASTParameterDeclaration[] decls) {
StringBuilder result= new StringBuilder();
for(int i=0; i<decls.length; i++) {
IASTDeclarator dtor= decls[i].getDeclarator();
if(decls[i].getDeclSpecifier() instanceof IASTSimpleDeclSpecifier) {
if(((IASTSimpleDeclSpecifier)decls[i].getDeclSpecifier()).getType() == IASTSimpleDeclSpecifier.t_void) {
continue;
}
if(!isVoidParameter(decls[i])) {
result.append(PARAM+getParameterName(decls[i])+"\n"); //$NON-NLS-1$
}
result.append(PARAM+dtor.getName()+"\n"); //$NON-NLS-1$
}
return result;
}
/**
* @param decl
* @return the name of the parameter
*/
protected String getParameterName(IASTParameterDeclaration decl) {
IASTDeclarator dtor= decl.getDeclarator();
for(int i=0; i<8 && dtor.getName().getRawSignature().length()==0 && dtor.getNestedDeclarator() != null; i++) {
dtor= dtor.getNestedDeclarator();
}
return dtor.getName().getRawSignature();
}
/**
* @param decl
* @return true if the specified parameter declaration is of void type
*/
protected boolean isVoidParameter(IASTParameterDeclaration decl) {
if(decl.getDeclSpecifier() instanceof IASTSimpleDeclSpecifier) {
if(((IASTSimpleDeclSpecifier)decl.getDeclSpecifier()).getType() == IASTSimpleDeclSpecifier.t_void) {
IASTDeclarator dtor= decl.getDeclarator();
if(dtor.getPointerOperators().length == 0) {
if(!(dtor instanceof IASTFunctionDeclarator) && !(dtor instanceof IASTArrayDeclarator)) {
return true;
}
}
}
}
return false;
}
/**
* @return the comment content to describe the return