Bug 519491 - [9][templates] module-info.java is created with both file
and type comments

Change-Id: Icadeadd726a90548367c878153f0a63be2afd069
Signed-off-by: Vikas Chandra <Vikas.Chandra@in.ibm.com>
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/InfoFilesUtil.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/InfoFilesUtil.java
index 02500a8..82a2782 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/InfoFilesUtil.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/InfoFilesUtil.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2016, 2018 IBM Corporation and others.
+ * Copyright (c) 2016, 2019 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -26,6 +26,8 @@
 
 import org.eclipse.jdt.internal.core.manipulation.StubUtility;
 
+import org.eclipse.jdt.ui.PreferenceConstants;
+
 import org.eclipse.jdt.internal.ui.preferences.formatter.FormatterProfileManager;
 
 public class InfoFilesUtil {
@@ -44,9 +46,9 @@
 	public static void createInfoJavaFile(String fileName, String fileContent, IPackageFragment pack, IProgressMonitor monitor) throws CoreException {
 		String lineDelimiter= StubUtility.getLineDelimiterUsed(pack.getJavaProject());
 		StringBuilder content= new StringBuilder();
-		String fileComment= getFileComment(fileName, pack, lineDelimiter);
-		String typeComment= getTypeComment(fileName, pack, lineDelimiter);
-
+		boolean addComments= Boolean.valueOf(PreferenceConstants.getPreference(PreferenceConstants.CODEGEN_ADD_COMMENTS, pack.getJavaProject())).booleanValue();
+		String fileComment= addComments ? getFileComment(fileName, pack, lineDelimiter) : null;
+		String typeComment= addComments ? getTypeComment(fileName, pack, lineDelimiter) : null;
 		if (fileComment != null) {
 			content.append(fileComment);
 			content.append(lineDelimiter);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties
index 2f4a900..4e751ea 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2000, 2018 IBM Corporation and others.
+# Copyright (c) 2000, 2019 IBM Corporation and others.
 #
 # This program and the accompanying materials
 # are made available under the terms of the Eclipse Public License 2.0
@@ -711,7 +711,7 @@
 CodeTemplateBlock_templates_export_button=E&xport...
 CodeTemplateBlock_templates_exportall_button=Ex&port All...
 
-CodeTemplateBlock_createcomment_label=Automatically add comments &for new methods and types
+CodeTemplateBlock_createcomment_label=Automatically add comments &for new methods, types, modules, packages and files
 CodeTemplateBlock_templates_label=&Configure generated code and comments:
 CodeTemplateBlock_preview=Pa&ttern: