Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove methods marked with "override" from public API #810

Merged
merged 1 commit into from
Mar 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ abstract protected void onPublicApi(AstNode node, String id,
private static final String UNNAMED_CLASSIFIER_ID = "<unnamed class>";
private static final String UNNAMED_ENUM_ID = "<unnamed enumeration>";

private static final String TOKEN_OVERRIDE = "override";

public interface PublicApiHandler {

void onPublicApi(AstNode node, String id, List<Token> comments);
Expand Down Expand Up @@ -418,6 +420,20 @@ private boolean isDefaultOrDeleteFunctionBody(AstNode functionBodyNode) {
return defaultOrDelete;
}

private boolean isOverriddenMethod(AstNode memberDeclarator) {
List<AstNode> modifiers = memberDeclarator.getDescendants(CxxGrammarImpl.cliFunctionModifier);

for (AstNode modifier : modifiers) {
AstNode modifierId = modifier.getFirstChild();

if (TOKEN_OVERRIDE.equals(modifierId.getTokenValue())) {
return true;
}
}

return false;
}

/**
* Find documentation node, associated documentation, identifier of a
* <em>public</em> member declarator and visit it as a public API.
Expand All @@ -430,6 +446,12 @@ private void visitMemberDeclarator(AstNode node) {
CxxGrammarImpl.templateDeclaration,
CxxGrammarImpl.classSpecifier);

if (isOverriddenMethod(node)) {
// assume that ancestor method is documented
// and do not count as public API
return;
}

AstNode docNode;

if (container == null
Expand Down
4 changes: 3 additions & 1 deletion cxx-squid/src/test/resources/metrics/public_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ class testClass
protectedMethod doc
*/
virtual void protectedMethod();


virtual void overriddenMethod() override; // no doc is OK, it could come from ancestor

/**
protectedStruct doc
*/
Expand Down