Bug 568707: [16] Switch AST to JLS16

Update flattener

Change-Id: Ie892745e870ef964da7476852005c9dcf82b7eb7
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/util/ASTHelper.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/util/ASTHelper.java
index b1b187f..7d8c7b2 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/util/ASTHelper.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/util/ASTHelper.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2019, 2020 IBM Corporation and others.
+ * Copyright (c) 2019, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -7,6 +7,10 @@
  * https://www.eclipse.org/legal/epl-2.0/
  *
  * SPDX-License-Identifier: EPL-2.0
+ * 
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
@@ -90,4 +94,8 @@
 		return isModifierSupportedInAST(ast, Modifier.SEALED);
 	}
 
+	public static boolean isInstanceofExpressionPatternSupported(AST ast) {
+		return isNodeTypeSupportedInAST(ast, ASTNode.INSTANCEOF_EXPRESSION);
+	}
+
 }
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.java
index bb05217..22fbfe8 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -7,6 +7,10 @@
  * https://www.eclipse.org/legal/epl-2.0/
  *
  * SPDX-License-Identifier: EPL-2.0
+ * 
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
@@ -806,6 +810,10 @@
 		node.getLeftOperand().accept(this);
 		this.fBuffer.append(" instanceof ");//$NON-NLS-1$
 		node.getRightOperand().accept(this);
+		if (ASTHelper.isInstanceofExpressionPatternSupported(node.getAST()) && node.getPatternVariable()!= null) {
+			this.fBuffer.append(" "); //$NON-NLS-1$
+			node.getPatternVariable().accept(this);
+		}
 		return false;
 	}