From 512b73075f7f33be51a9fb016a5221662e14f7ce Mon Sep 17 00:00:00 2001 From: Thomas Corbat Date: Wed, 20 Jun 2018 15:45:09 +0200 Subject: [PATCH] Bug 535274 Follow up cosmetics Change-Id: I562bc0925e53a461bd9e6362dc14f2e1cd924582 Signed-off-by: Thomas Corbat --- .../internal/formatter/CodeFormatterVisitor.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java index 6afe726bd4f..b084a2db1bd 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java @@ -18,7 +18,6 @@ import java.util.Collections; import java.util.EmptyStackException; import java.util.List; import java.util.Stack; -import java.util.function.Predicate; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.ASTVisitor; @@ -158,6 +157,8 @@ import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator; import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.cdt.core.formatter.DefaultCodeFormatterOptions; import org.eclipse.cdt.core.parser.IToken; +import org.eclipse.cdt.core.parser.util.IUnaryPredicate; +import org.eclipse.cdt.core.parser.util.InstanceOfPredicate; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.formatter.align.Alignment; @@ -1108,13 +1109,13 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, // namespace scribe.printNextToken(Token.t_namespace, false); scribe.space(); - formatLeadingAttributes(node, ICPPASTAttributeList.class::isInstance); + formatLeadingAttributes(node, ICPPASTAttributeList.TYPE_FILTER); boolean isNamedNamespace = !CPPVisitor.isAnonymousNamespace(node); if (isNamedNamespace) { IASTName name = node.getName(); name.accept(this); } - formatAttributes(node, isNamedNamespace, false, IGCCASTAttributeList.class::isInstance); + formatAttributes(node, isNamedNamespace, false, IGCCASTAttributeList.TYPE_FILTER); // member declarations IASTDeclaration[] memberDecls= node.getDeclarations(); @@ -1558,7 +1559,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, * @param owner Node containing attributes * @param filter Filter predicate for specifying which attributes to print */ - private void formatLeadingAttributes(IASTAttributeOwner owner, Predicate predicate) { + private void formatLeadingAttributes(IASTAttributeOwner owner, InstanceOfPredicate predicate) { formatAttributes(owner, false, true, predicate); } @@ -1575,7 +1576,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, * @param filter Filter predicate for specifying which attributes to print */ private void formatAttributes(IASTAttributeOwner owner, boolean printLeadingSpace, - boolean printTrailingSpace, Predicate filter) { + boolean printTrailingSpace, IUnaryPredicate filter) { if (owner == null) { return; } @@ -1585,7 +1586,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, scribe.space(); } for (IASTAttributeSpecifier attributeSpecifier : attributeSpecifiers) { - if (filter.test(attributeSpecifier)) { + if (filter.apply(attributeSpecifier)) { formatRaw(attributeSpecifier); } }