Merge remote-tracking branch 'origin/master' into BETA_JAVA9
diff --git a/org.eclipse.jdt.astview/META-INF/MANIFEST.MF b/org.eclipse.jdt.astview/META-INF/MANIFEST.MF
index 76fcee6..d9167be 100644
--- a/org.eclipse.jdt.astview/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.astview/META-INF/MANIFEST.MF
@@ -10,8 +10,8 @@
Export-Package: org.eclipse.jdt.astview;x-internal:=true,
org.eclipse.jdt.astview.views;x-internal:=true
Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.jdt.core;bundle-version="[3.12.0,4.0.0)",
- org.eclipse.jdt.ui;bundle-version="[3.12.0,4.0.0)",
+ org.eclipse.jdt.core;bundle-version="[3.13.0,4.0.0)",
+ org.eclipse.jdt.ui;bundle-version="[3.13.0,4.0.0)",
org.eclipse.ui.ide,
org.eclipse.ui.views,
org.eclipse.jface.text,
diff --git a/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTView.java b/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTView.java
index 6acc8db..375b250 100644
--- a/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTView.java
+++ b/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTView.java
@@ -122,8 +122,14 @@
public class ASTView extends ViewPart implements IShowInSource {
- static final int JLS_LATEST= AST.JLS8;
+ static final int JLS_LATEST= AST.JLS9;
+ private static final int JLS9= AST.JLS9;
+
+ /**
+ * @deprecated to get rid of deprecation warnings in code
+ */
+ @Deprecated
private static final int JLS8= AST.JLS8;
/**
@@ -442,6 +448,7 @@
case JLS3:
case JLS4:
case JLS8:
+ case JLS9:
fCurrentASTLevel= level;
}
} catch (NumberFormatException e) {
@@ -1051,6 +1058,7 @@
new ASTLevelToggle("AST Level &3 (1.5)", JLS3), //$NON-NLS-1$
new ASTLevelToggle("AST Level &4 (1.7)", JLS4), //$NON-NLS-1$
new ASTLevelToggle("AST Level &8 (1.8)", JLS8), //$NON-NLS-1$
+ new ASTLevelToggle("AST Level &9 (9)", JLS9), //$NON-NLS-1$
};
fAddToTrayAction= new Action() {
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java
index 70b3842..af48e31 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
* Matt Chapman, mpchapman@gmail.com - 89977 Make JDT .java agnostic
@@ -61,7 +65,7 @@
*/
public static final String VERSION_LATEST;
static {
- VERSION_LATEST= JavaCore.VERSION_1_8; // make sure it is not inlined
+ VERSION_LATEST= JavaCore.VERSION_9; // make sure it is not inlined
}
/**
@@ -98,6 +102,12 @@
public static final String PACKAGE_HTML= "package.html"; //$NON-NLS-1$
/**
+ * The name of the module-info.java file.
+ * @since 3.13 BETA_JAVA9
+ */
+ public static final String MODULE_INFO_JAVA= "module-info.java"; //$NON-NLS-1$
+
+ /**
* Finds a type container by container name. The returned element will be of type
* <code>IType</code> or a <code>IPackageFragment</code>. <code>null</code> is returned if the
* type container could not be found.
@@ -219,7 +229,7 @@
* Returns whether the two names match. They match if they
* are equal, or if they are the same name but one is missing a dot-separated qualifier.
*
- * @param nameA a potentially qualified name
+ * @param nameA a potentially qualified name
* @param nameB a potentially qualified name
* @return <code>true</code> iff the given names match
* @since 3.8
@@ -761,6 +771,10 @@
return !isVersionLessThan(compliance, JavaCore.VERSION_1_8);
}
+ public static boolean is9OrHigher(String compliance) {
+ return !isVersionLessThan(compliance, JavaCore.VERSION_9);
+ }
+
/**
* Checks if the given project or workspace has source compliance 1.5 or greater.
*
@@ -792,6 +806,17 @@
return is18OrHigher(getSourceCompliance(project));
}
+ /**
+ * Checks if the given project or workspace has source compliance 9 or greater.
+ *
+ * @param project the project to test or <code>null</code> to test the workspace settings
+ * @return <code>true</code> if the given project or workspace has source compliance 9 or
+ * greater.
+ */
+ public static boolean is9OrHigher(IJavaProject project) {
+ return is9OrHigher(getSourceCompliance(project));
+ }
+
private static String getSourceCompliance(IJavaProject project) {
return project != null ? project.getOption(JavaCore.COMPILER_SOURCE, true) : JavaCore.getOption(JavaCore.COMPILER_SOURCE);
}
@@ -825,6 +850,8 @@
String version= vMInstall.getJavaVersion();
if (version == null) {
return defaultCompliance;
+ } else if (version.startsWith(JavaCore.VERSION_9)) {
+ return JavaCore.VERSION_9;
} else if (version.startsWith(JavaCore.VERSION_1_8)) {
return JavaCore.VERSION_1_8;
} else if (version.startsWith(JavaCore.VERSION_1_7)) {
@@ -855,7 +882,9 @@
// fallback:
String desc= executionEnvironment.getId();
- if (desc.indexOf(JavaCore.VERSION_1_8) != -1) {
+ if (desc.indexOf(JavaCore.VERSION_9) != -1) {
+ return JavaCore.VERSION_9;
+ } else if (desc.indexOf(JavaCore.VERSION_1_8) != -1) {
return JavaCore.VERSION_1_8;
} else if (desc.indexOf(JavaCore.VERSION_1_7) != -1) {
return JavaCore.VERSION_1_7;
@@ -919,6 +948,17 @@
return PACKAGE_INFO_JAVA.equals(cu.getElementName());
}
+ /**
+ * Tells whether the given CU is the module-info.java.
+ *
+ * @param cu the compilation unit to test
+ * @return <code>true</code> if the given CU is the module-info.java
+ * @since 3.13 BETA_JAVA9
+ */
+ public static boolean isModuleInfo(ICompilationUnit cu) {
+ return MODULE_INFO_JAVA.equals(cu.getElementName());
+ }
+
public static boolean isPolymorphicSignature(IMethod method) {
return method.getAnnotation("java.lang.invoke.MethodHandle$PolymorphicSignature").exists(); //$NON-NLS-1$
}
diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationDelegate.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationDelegate.java
index 911b3bd..c39939c 100644
--- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationDelegate.java
+++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationDelegate.java
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
* David Saff (saff@mit.edu) - bug 102632: [JUnit] Support for JUnit 4.
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitCompletion.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitCompletion.java
index 4eb1c8c..51f587b 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitCompletion.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitCompletion.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
* Lukas Hanke <hanke@yatta.de> - [templates][content assist] Content assist for 'for' loop should suggest member variables - https://bugs.eclipse.org/117215
@@ -734,6 +738,7 @@
setIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, true);
setIgnored(CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER, true);
setIgnored(CompletionProposal.PACKAGE_REF, true);
+ setIgnored(CompletionProposal.MODULE_REF, true);
setIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION, true);
setIgnored(CompletionProposal.VARIABLE_DECLARATION, true);
setIgnored(CompletionProposal.TYPE_REF, true);
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
new file mode 100644
index 0000000..d314c35
--- /dev/null
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/InfoFilesUtil.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * 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
+ *******************************************************************************/
+package org.eclipse.jdt.internal.corext.util;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+
+import org.eclipse.jdt.core.IBuffer;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.ISourceRange;
+import org.eclipse.jdt.core.formatter.CodeFormatter;
+
+import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility;
+
+import org.eclipse.jdt.ui.CodeGeneration;
+
+public class InfoFilesUtil {
+
+ /**
+ * Creates a compilation unit in the given package fragment with the specified file name. The
+ * compilation unit is formatted and contains the given contents with file and type comments
+ * prepended to it.
+ *
+ * @param fileName the name of the compilation unit
+ * @param fileContent the contents of the compilation unit
+ * @param pack the package fragment to create the compilation unit in
+ * @param monitor the progress monitor
+ * @throws CoreException when there is a problem while creating the compilation unit
+ */
+ 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);
+
+ if (fileComment != null) {
+ content.append(fileComment);
+ content.append(lineDelimiter);
+ }
+
+ if (typeComment != null) {
+ content.append(typeComment);
+ content.append(lineDelimiter);
+ } else if (fileComment != null) {
+ // insert an empty file comment to avoid that the file comment becomes the type comment
+ content.append("/**"); //$NON-NLS-1$
+ content.append(lineDelimiter);
+ content.append(" *"); //$NON-NLS-1$
+ content.append(lineDelimiter);
+ content.append(" */"); //$NON-NLS-1$
+ content.append(lineDelimiter);
+ }
+
+ content.append(fileContent);
+
+ ICompilationUnit compilationUnit= pack.createCompilationUnit(fileName, content.toString(), true, monitor);
+
+ JavaModelUtil.reconcile(compilationUnit);
+
+ compilationUnit.becomeWorkingCopy(monitor);
+ try {
+ IBuffer buffer= compilationUnit.getBuffer();
+ ISourceRange sourceRange= compilationUnit.getSourceRange();
+ String originalContent= buffer.getText(sourceRange.getOffset(), sourceRange.getLength());
+
+ String formattedContent= CodeFormatterUtil.format(CodeFormatter.K_COMPILATION_UNIT, originalContent, 0, lineDelimiter, pack.getJavaProject());
+ formattedContent= Strings.trimLeadingTabsAndSpaces(formattedContent);
+ buffer.replace(sourceRange.getOffset(), sourceRange.getLength(), formattedContent);
+ compilationUnit.commitWorkingCopy(true, new SubProgressMonitor(monitor, 1));
+ } finally {
+ compilationUnit.discardWorkingCopy();
+ }
+ }
+
+ public static String getFileComment(String fileName, IPackageFragment pack, String lineDelimiterUsed) throws CoreException {
+ ICompilationUnit cu= pack.getCompilationUnit(fileName);
+ return CodeGeneration.getFileComment(cu, lineDelimiterUsed);
+ }
+
+ public static String getTypeComment(String fileName, IPackageFragment pack, String lineDelimiterUsed) throws CoreException {
+ ICompilationUnit cu= pack.getCompilationUnit(fileName);
+ String typeName= fileName.substring(0, fileName.length() - JavaModelUtil.DEFAULT_CU_SUFFIX.length());
+ return CodeGeneration.getTypeComment(cu, typeName, lineDelimiterUsed);
+ }
+
+}
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/JavaElementUtil.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/JavaElementUtil.java
index 632fd04..d2f3592 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/JavaElementUtil.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/JavaElementUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -44,6 +44,7 @@
import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.core.SourceRange;
+import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels;
import org.eclipse.jdt.internal.corext.CorextMessages;
import org.eclipse.jdt.internal.corext.ValidateEditException;
import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages;
@@ -51,8 +52,6 @@
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.corext.util.Resources;
-import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels;
-
/**
* Utility methods for the Java Model.
@@ -268,9 +267,10 @@
}
/**
- * Applies an text edit to a compilation unit. Filed bug 117694 against jdt.core.
- * @param cu the compilation unit to apply the edit to
- * @param edit the edit to apply
+ * Applies a text edit to a compilation unit.
+ *
+ * @param cu the compilation unit to apply the edit to
+ * @param edit the edit to apply
* @param save is set, save the CU after the edit has been applied
* @param monitor the progress monitor to use
* @throws CoreException Thrown when the access to the CU failed
diff --git a/org.eclipse.jdt.ui/icons/full/obj16/module_obj.png b/org.eclipse.jdt.ui/icons/full/obj16/module_obj.png
new file mode 100644
index 0000000..300adac
--- /dev/null
+++ b/org.eclipse.jdt.ui/icons/full/obj16/module_obj.png
Binary files differ
diff --git a/org.eclipse.jdt.ui/plugin.properties b/org.eclipse.jdt.ui/plugin.properties
index 964ecb7..9fef5b7 100644
--- a/org.eclipse.jdt.ui/plugin.properties
+++ b/org.eclipse.jdt.ui/plugin.properties
@@ -5,6 +5,10 @@
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
+# 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
# Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 83258 [jar exporter] Deploy java application as executable jar
@@ -213,6 +217,7 @@
JavaElementCreationActionSet.description= Java Element Creation Action Set
CompilationUnitEditorName= Java Editor
+ModuleInfoEditorName= Module-Info Editor
OpenTypeAction.label=Open &Type...
OpenTypeAction.tooltip=Open Type
diff --git a/org.eclipse.jdt.ui/plugin.xml b/org.eclipse.jdt.ui/plugin.xml
index 4da9b92..3ee9a1f 100644
--- a/org.eclipse.jdt.ui/plugin.xml
+++ b/org.eclipse.jdt.ui/plugin.xml
@@ -7,6 +7,11 @@
<!-- which accompanies this distribution, and is available at -->
<!-- http://www.eclipse.org/legal/epl-v10.html -->
<!-- -->
+<!-- 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 -->
<!-- Francis Upton IV, Oakland Software <francisu@ieee.org> - Add support for Go Into with the ProjectExplorer - https://bugs.eclipse.org/bugs/show_bug.cgi?id=262091 -->
@@ -1018,6 +1023,16 @@
launcher="org.eclipse.jdt.internal.ui.jarpackager.OpenJarExportWizardEditorLauncher"
name="%jarDescEditorName">
</editor>
+ <editor
+ name="%ModuleInfoEditorName"
+ icon="$nl$/icons/full/obj16/jcu_obj.png"
+ filenames="module-info.java"
+ class="org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor"
+ contributorClass="org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditorActionContributor"
+ id="org.eclipse.jdt.ui.ModuleInfoEditor"
+ default="true"
+ symbolicFontName="org.eclipse.jdt.ui.editors.textfont">
+ </editor>
</extension>
<extension
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java
index cb5222c..7727e33 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java
@@ -132,6 +132,7 @@
public static final String IMG_OBJS_ENV_VAR= NAME_PREFIX + "envvar_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_JAVA_MODEL= NAME_PREFIX + "java_model_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_MODULE= NAME_PREFIX + "module_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_ERROR_ALT= NAME_PREFIX + "error_alt_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_WARNING_ALT= NAME_PREFIX + "warning_alt_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INFO_ALT= NAME_PREFIX + "info_alt_obj.gif"; //$NON-NLS-1$
@@ -231,6 +232,7 @@
public static final ImageDescriptor DESC_OBJS_PROJECT_SETTINGS= createManagedFromKey(T_OBJ, IMG_OBJS_PROJECT_SETTINGS);
public static final ImageDescriptor DESC_OBJS_JAVA_MODEL= createManagedFromKey(T_OBJ, IMG_OBJS_JAVA_MODEL);
+ public static final ImageDescriptor DESC_OBJS_MODULE= createManagedFromKey(T_OBJ, IMG_OBJS_MODULE);
public static final ImageDescriptor DESC_OBJS_CLASS= createManagedFromKey(T_OBJ, IMG_OBJS_CLASS);
public static final ImageDescriptor DESC_OBJS_CLASS_DEFAULT= createManagedFromKey(T_OBJ, IMG_OBJS_CLASS_DEFAULT);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaOutlinePage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaOutlinePage.java
index faa8cae..5bedf68 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaOutlinePage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaOutlinePage.java
@@ -100,6 +100,7 @@
import org.eclipse.jdt.core.IElementChangedListener;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaElementDelta;
+import org.eclipse.jdt.core.IModuleDescription;
import org.eclipse.jdt.core.IParent;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.ISourceReference;
@@ -296,7 +297,7 @@
@Override
public Object[] getChildren(Object parent) {
- if (parent instanceof IParent) {
+ if (parent instanceof IParent && !(parent instanceof IModuleDescription)) {
IParent c= (IParent) parent;
try {
return filter(c.getChildren());
@@ -338,7 +339,7 @@
@Override
public boolean hasChildren(Object parent) {
- if (parent instanceof IParent) {
+ if (parent instanceof IParent && !(parent instanceof IModuleDescription)) {
IParent c= (IParent) parent;
try {
IJavaElement[] children= filter(c.getChildren());
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java
index bb98d04..775af22 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
*******************************************************************************/
@@ -121,6 +125,7 @@
private static final String VERSION_1_6= JavaCore.VERSION_1_6;
private static final String VERSION_1_7= JavaCore.VERSION_1_7;
private static final String VERSION_1_8= JavaCore.VERSION_1_8;
+ private static final String VERSION_9= JavaCore.VERSION_9;
private static final String VERSION_JSR14= "jsr14"; //$NON-NLS-1$
private static final String ERROR= JavaCore.ERROR;
@@ -259,16 +264,49 @@
private Composite createComplianceTabContent(Composite folder) {
- String[] values3456= new String[] { VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8 };
- String[] values3456Labels= new String[] {
+ final String[] complianceVersions= new String[] { VERSION_1_3, VERSION_1_4,
+ VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9 };
+ final String[] complianceLabels= new String[] {
PreferencesMessages.ComplianceConfigurationBlock_version13,
PreferencesMessages.ComplianceConfigurationBlock_version14,
PreferencesMessages.ComplianceConfigurationBlock_version15,
PreferencesMessages.ComplianceConfigurationBlock_version16,
PreferencesMessages.ComplianceConfigurationBlock_version17,
PreferencesMessages.ComplianceConfigurationBlock_version18,
+ PreferencesMessages.ComplianceConfigurationBlock_version9,
};
-
+
+ String[] targetVersions= new String[] { VERSION_CLDC_1_1, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4,
+ VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9 };
+ String[] targetLabels= new String[] {
+ PreferencesMessages.ComplianceConfigurationBlock_versionCLDC11,
+ PreferencesMessages.ComplianceConfigurationBlock_version11,
+ PreferencesMessages.ComplianceConfigurationBlock_version12,
+ PreferencesMessages.ComplianceConfigurationBlock_version13,
+ PreferencesMessages.ComplianceConfigurationBlock_version14,
+ PreferencesMessages.ComplianceConfigurationBlock_version15,
+ PreferencesMessages.ComplianceConfigurationBlock_version16,
+ PreferencesMessages.ComplianceConfigurationBlock_version17,
+ PreferencesMessages.ComplianceConfigurationBlock_version18,
+ PreferencesMessages.ComplianceConfigurationBlock_version9,
+ };
+ if (ComplianceConfigurationBlock.VERSION_JSR14.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM))) {
+ targetVersions= append(targetVersions, ComplianceConfigurationBlock.VERSION_JSR14);
+ targetLabels= append(targetLabels, ComplianceConfigurationBlock.VERSION_JSR14);
+ }
+
+ String[] sourceVersions= new String[] { VERSION_1_3, VERSION_1_4,
+ VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9 };
+ String[] sourceLabels= new String[] {
+ PreferencesMessages.ComplianceConfigurationBlock_version13,
+ PreferencesMessages.ComplianceConfigurationBlock_version14,
+ PreferencesMessages.ComplianceConfigurationBlock_version15,
+ PreferencesMessages.ComplianceConfigurationBlock_version16,
+ PreferencesMessages.ComplianceConfigurationBlock_version17,
+ PreferencesMessages.ComplianceConfigurationBlock_version18,
+ PreferencesMessages.ComplianceConfigurationBlock_version9,
+ };
+
final ScrolledPageContent sc1 = new ScrolledPageContent(folder);
Composite composite= sc1.getBody();
GridLayout layout= new GridLayout();
@@ -318,7 +356,7 @@
String label= PreferencesMessages.ComplianceConfigurationBlock_compiler_compliance_label;
- addComboBox(group, label, PREF_COMPLIANCE, values3456, values3456Labels, 0);
+ addComboBox(group, label, PREF_COMPLIANCE, complianceVersions, complianceLabels, 0);
label= PreferencesMessages.ComplianceConfigurationBlock_default_settings_label;
addCheckBox(group, label, INTR_DEFAULT_COMPLIANCE, defaultUserValues, 0);
@@ -331,30 +369,11 @@
int indent= LayoutUtil.getIndent();
- String[] versions= new String[] { VERSION_CLDC_1_1, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8 };
- String[] versionsLabels= new String[] {
- PreferencesMessages.ComplianceConfigurationBlock_versionCLDC11,
- PreferencesMessages.ComplianceConfigurationBlock_version11,
- PreferencesMessages.ComplianceConfigurationBlock_version12,
- PreferencesMessages.ComplianceConfigurationBlock_version13,
- PreferencesMessages.ComplianceConfigurationBlock_version14,
- PreferencesMessages.ComplianceConfigurationBlock_version15,
- PreferencesMessages.ComplianceConfigurationBlock_version16,
- PreferencesMessages.ComplianceConfigurationBlock_version17,
- PreferencesMessages.ComplianceConfigurationBlock_version18
- };
-
- boolean showJsr14= ComplianceConfigurationBlock.VERSION_JSR14.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM));
- if (showJsr14) {
- versions= append(versions, ComplianceConfigurationBlock.VERSION_JSR14);
- versionsLabels= append(versionsLabels, ComplianceConfigurationBlock.VERSION_JSR14);
- }
-
label= PreferencesMessages.ComplianceConfigurationBlock_codegen_targetplatform_label;
- addComboBox(group, label, PREF_CODEGEN_TARGET_PLATFORM, versions, versionsLabels, indent);
+ addComboBox(group, label, PREF_CODEGEN_TARGET_PLATFORM, targetVersions, targetLabels, indent);
label= PreferencesMessages.ComplianceConfigurationBlock_source_compatibility_label;
- addComboBox(group, label, PREF_SOURCE_COMPATIBILITY, values3456, values3456Labels, indent);
+ addComboBox(group, label, PREF_SOURCE_COMPATIBILITY, sourceVersions, sourceLabels, indent);
String[] errorWarningInfoIgnore= new String[] { ERROR, WARNING, INFO, IGNORE };
@@ -607,11 +626,12 @@
}
}
-// String source= getValue(PREF_SOURCE_COMPATIBILITY);
-// if (VERSION_1_8.equals(source)) {
-// fJRE50InfoText.setText("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."); //$NON-NLS-1$
-// isVisible= true;
-// }
+ //TODO: Remove once Java SE 9 has been shipped:
+ String selectedCompliance= getValue(PREF_COMPLIANCE);
+ if (VERSION_9.equals(selectedCompliance)) {
+ fJRE50InfoText.setText("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."); //$NON-NLS-1$
+ isVisible= true;
+ }
fJRE50InfoText.setVisible(isVisible);
fJRE50InfoImage.setImage(isVisible ? JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING) : null);
@@ -846,32 +866,13 @@
}
} else {
- //TODO: use JavaModelUtil.setComplianceOptions(new HashMap(), complianceLevel);
- if (VERSION_1_4.equals(complianceLevel)) {
- assertAsId= WARNING;
- enumAsId= WARNING;
- source= VERSION_1_3;
- target= VERSION_1_2;
- } else if (VERSION_1_5.equals(complianceLevel)) {
- assertAsId= ERROR;
- enumAsId= ERROR;
- source= VERSION_1_5;
- target= VERSION_1_5;
- } else if (VERSION_1_6.equals(complianceLevel)) {
- assertAsId= ERROR;
- enumAsId= ERROR;
- source= VERSION_1_6;
- target= VERSION_1_6;
- } else if (VERSION_1_7.equals(complianceLevel)) {
- assertAsId= ERROR;
- enumAsId= ERROR;
- source= VERSION_1_7;
- target= VERSION_1_7;
- } else if (VERSION_1_8.equals(complianceLevel)) {
- assertAsId= ERROR;
- enumAsId= ERROR;
- source= VERSION_1_8;
- target= VERSION_1_8;
+ HashMap<String, String> options= new HashMap<String, String>();
+ JavaModelUtil.setComplianceOptions(options, complianceLevel);
+ if (complianceLevel.equals(options.get(JavaCore.COMPILER_COMPLIANCE))) {
+ source= options.get(JavaCore.COMPILER_SOURCE);
+ target= options.get(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM);
+ assertAsId= options.get(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER);
+ enumAsId= options.get(JavaCore.COMPILER_PB_ENUM_IDENTIFIER);
} else {
assertAsId= IGNORE;
enumAsId= IGNORE;
@@ -908,38 +909,16 @@
* @return {@link #DEFAULT_CONF} or {@link #USER_CONF}
*/
private String getCurrentCompliance() {
- Object complianceLevel= getValue(PREF_COMPLIANCE);
- //TODO: use JavaModelUtil.setComplianceOptions(new HashMap(), complianceLevel);
- if ((VERSION_1_3.equals(complianceLevel)
- && IGNORE.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER))
- && IGNORE.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER))
- && VERSION_1_3.equals(getValue(PREF_SOURCE_COMPATIBILITY))
- && VERSION_1_1.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)))
- || (VERSION_1_4.equals(complianceLevel)
- && WARNING.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER))
- && WARNING.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER))
- && VERSION_1_3.equals(getValue(PREF_SOURCE_COMPATIBILITY))
- && VERSION_1_2.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)))
- || (VERSION_1_5.equals(complianceLevel)
- && ERROR.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER))
- && ERROR.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER))
- && VERSION_1_5.equals(getValue(PREF_SOURCE_COMPATIBILITY))
- && VERSION_1_5.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)))
- || (VERSION_1_6.equals(complianceLevel)
- && ERROR.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER))
- && ERROR.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER))
- && VERSION_1_6.equals(getValue(PREF_SOURCE_COMPATIBILITY))
- && VERSION_1_6.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)))
- || (VERSION_1_7.equals(complianceLevel)
- && ERROR.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER))
- && ERROR.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER))
- && VERSION_1_7.equals(getValue(PREF_SOURCE_COMPATIBILITY))
- && VERSION_1_7.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)))
- || (VERSION_1_8.equals(complianceLevel)
- && ERROR.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER))
- && ERROR.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER))
- && VERSION_1_8.equals(getValue(PREF_SOURCE_COMPATIBILITY))
- && VERSION_1_8.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)))) {
+ String complianceLevel= getValue(PREF_COMPLIANCE);
+
+ HashMap<String, String> defaultOptions= new HashMap<String, String>();
+ JavaModelUtil.setComplianceOptions(defaultOptions, complianceLevel);
+
+ if (complianceLevel.equals(defaultOptions.get(JavaCore.COMPILER_COMPLIANCE))
+ && getValue(PREF_SOURCE_COMPATIBILITY).equals(defaultOptions.get(JavaCore.COMPILER_SOURCE))
+ && getValue(PREF_CODEGEN_TARGET_PLATFORM).equals(defaultOptions.get(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM))
+ && getValue(PREF_PB_ASSERT_AS_IDENTIFIER).equals(defaultOptions.get(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER))
+ && getValue(PREF_PB_ENUM_AS_IDENTIFIER).equals(defaultOptions.get(JavaCore.COMPILER_PB_ENUM_IDENTIFIER))) {
return DEFAULT_CONF;
}
return USER_CONF;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java
index deec7d9..f1adb32 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
* John Kaplan, johnkaplantech@gmail.com - 108071 [code templates] template for body of newly created class
@@ -804,6 +808,7 @@
public static String ComplianceConfigurationBlock_version16;
public static String ComplianceConfigurationBlock_version17;
public static String ComplianceConfigurationBlock_version18;
+ public static String ComplianceConfigurationBlock_version9;
public static String ComplianceConfigurationBlock_versionCLDC11;
public static String ComplianceConfigurationBlock_src_greater_compliance;
public static String ComplianceConfigurationBlock_classfile_greater_compliance;
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 573e2a3..7bcf34b 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
@@ -566,6 +566,7 @@
ComplianceConfigurationBlock_version16=1.6
ComplianceConfigurationBlock_version17=1.7
ComplianceConfigurationBlock_version18=1.8
+ComplianceConfigurationBlock_version9=9 (BETA)
ComplianceConfigurationBlock_versionCLDC11=CLDC 1.1
ComplianceConfigurationBlock_needsbuild_title=Compiler Settings Changed
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SimilarElementsRequestor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SimilarElementsRequestor.java
index b489950..5946dbb 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SimilarElementsRequestor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SimilarElementsRequestor.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
*******************************************************************************/
@@ -76,6 +80,7 @@
requestor.setIgnored(CompletionProposal.LABEL_REF, true);
requestor.setIgnored(CompletionProposal.METHOD_DECLARATION, true);
requestor.setIgnored(CompletionProposal.PACKAGE_REF, true);
+ requestor.setIgnored(CompletionProposal.MODULE_REF, true);
requestor.setIgnored(CompletionProposal.VARIABLE_DECLARATION, true);
requestor.setIgnored(CompletionProposal.METHOD_REF, true);
requestor.setIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, true);
@@ -220,7 +225,7 @@
if (packName.length() > 0) {
dummyCU.append("package ").append(packName).append(';'); //$NON-NLS-1$
- }
+ }
dummyCU.append("public class ").append(type.getElementName()).append("{\n static {\n").append(elementName); // static initializer //$NON-NLS-1$//$NON-NLS-2$
int offset= dummyCU.length();
dummyCU.append("\n}\n }"); //$NON-NLS-1$
@@ -262,8 +267,8 @@
} finally {
if (newCU != null) {
newCU.discardWorkingCopy();
- }
- }
+ }
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAllCompletionProposalComputer.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAllCompletionProposalComputer.java
index 3284bba..ac18277 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAllCompletionProposalComputer.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAllCompletionProposalComputer.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
*******************************************************************************/
@@ -39,6 +43,7 @@
collector.setIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, false);
collector.setIgnored(CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER, false);
collector.setIgnored(CompletionProposal.PACKAGE_REF, false);
+ collector.setIgnored(CompletionProposal.MODULE_REF, false);
collector.setIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION, false);
collector.setIgnored(CompletionProposal.VARIABLE_DECLARATION, false);
collector.setIgnored(CompletionProposal.TYPE_REF, false);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaCodeScanner.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaCodeScanner.java
index 39e13d1..40948a3 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaCodeScanner.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaCodeScanner.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
* Philippe Ombredanne <pombredanne@nexb.com> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=150989
@@ -13,6 +17,7 @@
package org.eclipse.jdt.internal.ui.text.java;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
@@ -394,6 +399,7 @@
private static final String RETURN= "return"; //$NON-NLS-1$
private static String[] fgJava14Keywords= { "assert" }; //$NON-NLS-1$
private static String[] fgJava15Keywords= { "enum" }; //$NON-NLS-1$
+ private static String[] fgJava9ModuleInfoKeywords= { "module", "requires", "exports", "to", "provides", "with", "uses", "open", "opens", "transitive" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
private static String[] fgTypes= { "void", "boolean", "char", "byte", "short", "strictfp", "int", "long", "float", "double" }; //$NON-NLS-1$ //$NON-NLS-5$ //$NON-NLS-7$ //$NON-NLS-6$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-2$
@@ -414,6 +420,8 @@
private List<ISourceVersionDependent> fVersionDependentRules= new ArrayList<>(3);
+ private boolean fIsModuleInfoEditor;
+
/**
* Creates a Java code scanner
*
@@ -421,7 +429,19 @@
* @param store the preference store
*/
public JavaCodeScanner(IColorManager manager, IPreferenceStore store) {
+ this(manager, store, false);
+ }
+
+ /**
+ * Creates a Java code scanner
+ *
+ * @param manager the color manager
+ * @param store the preference store
+ * @param isModuleInfoEditor <code>true</code> if used for module-info.java editor
+ */
+ public JavaCodeScanner(IColorManager manager, IPreferenceStore store, boolean isModuleInfoEditor) {
super(manager, store);
+ fIsModuleInfoEditor= isModuleInfoEditor;
initialize();
}
@@ -441,18 +461,22 @@
List<IRule> rules= new ArrayList<>();
+ Token defaultToken= getToken(IJavaColorConstants.JAVA_DEFAULT);
+
+ String version= getPreferenceStore().getString(SOURCE_VERSION);
+
+ // Create rules for JLS9 module-info.java editor
+ if (fIsModuleInfoEditor) {
+ return create9ModuleInfoRules(defaultToken, version);
+ }
+
// Add rule for character constants.
Token token= getToken(IJavaColorConstants.JAVA_STRING);
rules.add(new SingleLineRule("'", "'", token, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
-
- Token defaultToken= getToken(IJavaColorConstants.JAVA_DEFAULT);
-
// Add generic whitespace rule.
rules.add(new WhitespaceRule(new JavaWhitespaceDetector(), defaultToken));
- String version= getPreferenceStore().getString(SOURCE_VERSION);
-
// Add JLS3 rule for /@\s*interface/ and /@\s*\w+/
token= getToken(ANNOTATION_COLOR_KEY);
AnnotationRule atInterfaceRule= new AnnotationRule(getToken(IJavaColorConstants.JAVA_KEYWORD), token, JavaCore.VERSION_1_5, version);
@@ -513,6 +537,22 @@
return rules;
}
+ private List<IRule> create9ModuleInfoRules(Token defaultToken, String version) {
+ // Add word rule for new keywords
+ VersionedWordMatcher j9ModuleInfoMatcher= new VersionedWordMatcher(defaultToken, JavaCore.VERSION_9, version);
+ Token token= getToken(IJavaColorConstants.JAVA_KEYWORD);
+ for (int i= 0; i < fgJava9ModuleInfoKeywords.length; i++)
+ j9ModuleInfoMatcher.addWord(fgJava9ModuleInfoKeywords[i], token);
+
+ CombinedWordRule combinedWordRule= new CombinedWordRule(new JavaWordDetector(), defaultToken);
+ combinedWordRule.addWordMatcher(j9ModuleInfoMatcher);
+
+ fVersionDependentRules.add(j9ModuleInfoMatcher);
+
+ setDefaultReturnToken(defaultToken);
+ return new ArrayList<>(Arrays.asList(combinedWordRule));
+ }
+
/*
* @see org.eclipse.jdt.internal.ui.text.AbstractJavaScanner#getBoldKey(java.lang.String)
*/
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaNoTypeCompletionProposalComputer.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaNoTypeCompletionProposalComputer.java
index a2d5a03..4d9f213 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaNoTypeCompletionProposalComputer.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaNoTypeCompletionProposalComputer.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
*******************************************************************************/
@@ -41,6 +45,7 @@
collector.setIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, false);
collector.setIgnored(CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER, false);
collector.setIgnored(CompletionProposal.PACKAGE_REF, false);
+ collector.setIgnored(CompletionProposal.MODULE_REF, false);
collector.setIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION, false);
collector.setIgnored(CompletionProposal.VARIABLE_DECLARATION, false);
return collector;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/LazyJavaTypeCompletionProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/LazyJavaTypeCompletionProposal.java
index 9c44673..520417d 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/LazyJavaTypeCompletionProposal.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/LazyJavaTypeCompletionProposal.java
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
*******************************************************************************/
@@ -100,8 +104,8 @@
String qualifiedTypeName= getQualifiedTypeName();
- // Type in package info must be fully qualified.
- if (fCompilationUnit != null && JavaModelUtil.isPackageInfo(fCompilationUnit))
+ // Type in package info and module info must be fully qualified.
+ if (fCompilationUnit != null && (JavaModelUtil.isPackageInfo(fCompilationUnit) || JavaModelUtil.isModuleInfo(fCompilationUnit)))
return qualifiedTypeName;
if (qualifiedTypeName.indexOf('.') == -1 && replacement.length() > 0)
@@ -163,7 +167,7 @@
}
private ImportRewrite createImportRewrite() {
- if (fCompilationUnit != null && allowAddingImports() && !JavaModelUtil.isPackageInfo(fCompilationUnit)) {
+ if (fCompilationUnit != null && allowAddingImports() && !JavaModelUtil.isPackageInfo(fCompilationUnit) && !JavaModelUtil.isModuleInfo(fCompilationUnit)) {
try {
CompilationUnit cu= getASTRoot(fCompilationUnit);
if (cu == null) {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/LazyModuleCompletionProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/LazyModuleCompletionProposal.java
new file mode 100644
index 0000000..f64952f
--- /dev/null
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/LazyModuleCompletionProposal.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.jdt.internal.ui.text.java;
+
+import org.eclipse.jdt.core.CompletionProposal;
+
+import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext;
+
+public class LazyModuleCompletionProposal extends LazyJavaCompletionProposal {
+
+ public LazyModuleCompletionProposal(CompletionProposal proposal, JavaContentAssistInvocationContext context) {
+ super(proposal, context);
+ }
+
+ @Override
+ protected ProposalInfo computeProposalInfo() {
+ return super.computeProposalInfo();
+ }
+}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementImageProvider.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementImageProvider.java
index a3b6247..688f407 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementImageProvider.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementImageProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -308,6 +308,9 @@
case IJavaElement.ANNOTATION:
return JavaPluginImages.DESC_OBJS_ANNOTATION;
+
+ case IJavaElement.JAVA_MODULE:
+ return JavaPluginImages.DESC_OBJS_MODULE;
default:
// ignore. Must be a new, yet unknown Java element
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementLabelComposer.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementLabelComposer.java
index e8052cc..a35fb4f 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementLabelComposer.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementLabelComposer.java
@@ -1387,13 +1387,17 @@
path= root.getPath();
}
if (getFlag(flags, JavaElementLabels.REFERENCED_ROOT_POST_QUALIFIED)) {
- int segements= path.segmentCount();
- if (segements > 0) {
- fBuffer.append(path.segment(segements - 1));
+ int segmentCount= path.segmentCount();
+ if (segmentCount > 0) {
+ String elementName= root.getElementName();
+ fBuffer.append(elementName);
int offset= fBuffer.length();
- if (segements > 1 || path.getDevice() != null) {
+
+ boolean skipLastSegment= elementName.equals(path.lastSegment());
+ if (segmentCount > 1 || path.getDevice() != null || !skipLastSegment) {
fBuffer.append(JavaElementLabels.CONCAT_STRING);
- fBuffer.append(path.removeLastSegments(1).toOSString());
+ IPath postQualifier= skipLastSegment ? path.removeLastSegments(1) : path;
+ fBuffer.append(postQualifier.toOSString());
}
if (classpathEntry != null) {
IClasspathEntry referencingEntry= classpathEntry.getReferencingEntry();
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewSourceFolderCreationWizard.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewSourceFolderCreationWizard.java
index 0a3f204..3370b26 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewSourceFolderCreationWizard.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewSourceFolderCreationWizard.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
*******************************************************************************/
@@ -13,8 +17,13 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
+
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
@@ -50,7 +59,11 @@
public boolean performFinish() {
boolean res= super.performFinish();
if (res) {
- selectAndReveal(fPage.getCorrespondingResource());
+ IResource resource= fPage.getCorrespondingResource();
+ selectAndReveal(resource);
+ if (resource instanceof IFile && resource.getName().equals(JavaModelUtil.MODULE_INFO_JAVA)) {
+ openResource((IFile) resource);
+ }
}
return res;
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewSourceFolderWizardPage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewSourceFolderWizardPage.java
index ad34ec6..26af690 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewSourceFolderWizardPage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewSourceFolderWizardPage.java
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
*******************************************************************************/
@@ -40,6 +44,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.util.BidiUtils;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -60,11 +65,13 @@
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaModelStatus;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaConventions;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.corext.util.InfoFilesUtil;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.corext.util.Messages;
@@ -100,6 +107,10 @@
private SelectionButtonDialogField fExcludeInOthersFields;
private SelectionButtonDialogField fIgnoreOptionalProblemsField;
+ private SelectionButtonDialogField fCreateModuleInfoJavaField;
+
+ private static final String MODULE_INFO_JAVA_FILENAME= JavaModelUtil.MODULE_INFO_JAVA;
+ private static final String SETTINGS_CREATE_MODULE_INFO_JAVA= "create_module_info_java"; //$NON-NLS-1$
private IWorkspaceRoot fWorkspaceRoot;
@@ -144,6 +155,11 @@
fIgnoreOptionalProblemsField.setLabelText(NewWizardMessages.NewSourceFolderWizardPage_ignore_optional_problems_label);
fIgnoreOptionalProblemsField.setSelection(false);
+ fCreateModuleInfoJavaField= new SelectionButtonDialogField(SWT.CHECK);
+ fCreateModuleInfoJavaField.setDialogFieldListener(adapter);
+ fCreateModuleInfoJavaField.setLabelText(NewWizardMessages.NewSourceFolderWizardPage_create_module_info_java);
+ fCreateModuleInfoJavaField.setSelection(false);
+
fRootStatus= new StatusInfo();
fProjectStatus= new StatusInfo();
}
@@ -154,6 +170,14 @@
String projPath= getProjectPath(selection);
fProjectField.setText(projPath != null ? projPath : ""); //$NON-NLS-1$
fRootDialogField.setText(""); //$NON-NLS-1$
+
+ IDialogSettings dialogSettings= getDialogSettings();
+ if (dialogSettings != null) {
+ IDialogSettings section= dialogSettings.getSection(PAGE_NAME);
+ if (section != null) {
+ fCreateModuleInfoJavaField.setSelection(section.getBoolean(SETTINGS_CREATE_MODULE_INFO_JAVA));
+ }
+ }
}
private String getProjectPath(IStructuredSelection selection) {
@@ -198,6 +222,7 @@
fRootDialogField.doFillIntoGrid(composite, 3);
fExcludeInOthersFields.doFillIntoGrid(composite, 3);
fIgnoreOptionalProblemsField.doFillIntoGrid(composite, 3);
+ fCreateModuleInfoJavaField.doFillIntoGrid(composite, 3);
int maxFieldWidth= convertWidthInCharsToPixels(40);
LayoutUtil.setWidthHint(fProjectField.getTextControl(null), maxFieldWidth);
@@ -267,6 +292,8 @@
updateRootStatus();
} else if (field == fIgnoreOptionalProblemsField) {
updateRootStatus();
+ } else if (field == fCreateModuleInfoJavaField) {
+ updateRootStatus();
}
updateStatus(new IStatus[] { fProjectStatus, fRootStatus });
}
@@ -365,7 +392,10 @@
IClasspathEntry curr= fEntries[i];
if (curr.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
if (path.equals(curr.getPath())) {
- fRootStatus.setError(NewWizardMessages.NewSourceFolderWizardPage_error_AlreadyExisting);
+ boolean createModuleInfoJava= isCreateModuleInfoJava() && !moduleInfoJavaAlreadyExists(fCurrJProject.getPackageFragmentRoot(res));
+ if (!createModuleInfoJava) {
+ fRootStatus.setError(NewWizardMessages.NewSourceFolderWizardPage_error_AlreadyExisting);
+ }
return;
}
if (projPath.equals(curr.getPath())) {
@@ -431,6 +461,27 @@
}
}
+ /**
+ * Checks if the module-info.java file already exists in any package in the given package
+ * fragment root.
+ *
+ * @param root the package fragment root
+ * @return <code>true</code> if module-info.java exists in any package in the given
+ * <code>root</code>, <code>false</code> otherwise
+ */
+ private boolean moduleInfoJavaAlreadyExists(IPackageFragmentRoot root) {
+ try {
+ for (IJavaElement pkgFragment : root.getChildren()) {
+ if (((IPackageFragment) pkgFragment).getCompilationUnit(MODULE_INFO_JAVA_FILENAME).exists()) {
+ return true;
+ }
+ }
+ } catch (JavaModelException e) {
+ // pretend that the file does not exist
+ }
+ return false;
+ }
+
private void insertAtEndOfCategory(IClasspathEntry entry, List<IClasspathEntry> entries) {
int length= entries.size();
IClasspathEntry[] elements= entries.toArray(new IClasspathEntry[length]);
@@ -488,40 +539,70 @@
return fCreatedRoot;
}
+ /**
+ * @return <code>true</code> if module-info.java should be created, <code>false</code> otherwise
+ */
+ private boolean isCreateModuleInfoJava() {
+ return JavaModelUtil.is9OrHigher(fCurrJProject) && fCreateModuleInfoJavaField.isSelected();
+ }
+
public IResource getCorrespondingResource() {
- return fCurrJProject.getProject().getFolder(fRootDialogField.getText());
+ IFolder folder= fCurrJProject.getProject().getFolder(fRootDialogField.getText());
+ if (isCreateModuleInfoJava()) {
+ return folder.getFile(MODULE_INFO_JAVA_FILENAME);
+ }
+ return folder;
}
public void createPackageFragmentRoot(IProgressMonitor monitor) throws CoreException, InterruptedException {
if (monitor == null) {
monitor= new NullProgressMonitor();
}
- monitor.beginTask(NewWizardMessages.NewSourceFolderWizardPage_operation, 3);
- try {
- IPath projPath= fCurrJProject.getProject().getFullPath();
- if (fOutputLocation.equals(projPath) && !fNewOutputLocation.equals(projPath)) {
- if (BuildPathsBlock.hasClassfiles(fCurrJProject.getProject())) {
- if (BuildPathsBlock.getRemoveOldBinariesQuery(getShell()).doQuery(false, projPath)) {
- BuildPathsBlock.removeOldClassfiles(fCurrJProject.getProject());
+ String relPath= fRootDialogField.getText();
+ IFolder folder= fCurrJProject.getProject().getFolder(relPath);
+ fCreatedRoot= fCurrJProject.getPackageFragmentRoot(folder);
+
+ if (!fCreatedRoot.exists()) {
+ monitor.beginTask(NewWizardMessages.NewSourceFolderWizardPage_operation, 3);
+ try {
+ IPath projPath= fCurrJProject.getProject().getFullPath();
+ if (fOutputLocation.equals(projPath) && !fNewOutputLocation.equals(projPath)) {
+ if (BuildPathsBlock.hasClassfiles(fCurrJProject.getProject())) {
+ if (BuildPathsBlock.getRemoveOldBinariesQuery(getShell()).doQuery(false, projPath)) {
+ BuildPathsBlock.removeOldClassfiles(fCurrJProject.getProject());
+ }
}
}
+
+ if (!folder.exists()) {
+ CoreUtility.createFolder(folder, true, true, new SubProgressMonitor(monitor, 1));
+ }
+ if (monitor.isCanceled()) {
+ throw new InterruptedException();
+ }
+
+ fCurrJProject.setRawClasspath(fNewEntries, fNewOutputLocation, new SubProgressMonitor(monitor, 2));
+
+ } finally {
+ monitor.done();
}
+ }
- String relPath= fRootDialogField.getText();
+ if (isCreateModuleInfoJava()) {
+ // default package always exists
+ IPackageFragment pack= fCreatedRoot.getPackageFragment(""); //$NON-NLS-1$
+ String fileContent= JavaCore.createModuleFromPackageRoot(null, fCreatedRoot);
+ InfoFilesUtil.createInfoJavaFile(MODULE_INFO_JAVA_FILENAME, fileContent, pack, monitor);
+ }
- IFolder folder= fCurrJProject.getProject().getFolder(relPath);
- if (!folder.exists()) {
- CoreUtility.createFolder(folder, true, true, new SubProgressMonitor(monitor, 1));
+ // save dialog settings for create_module_info_java
+ IDialogSettings dialogSettings= getDialogSettings();
+ if (dialogSettings != null) {
+ IDialogSettings section= dialogSettings.getSection(PAGE_NAME);
+ if (section == null) {
+ section= dialogSettings.addNewSection(PAGE_NAME);
}
- if (monitor.isCanceled()) {
- throw new InterruptedException();
- }
-
- fCurrJProject.setRawClasspath(fNewEntries, fNewOutputLocation, new SubProgressMonitor(monitor, 2));
-
- fCreatedRoot= fCurrJProject.getPackageFragmentRoot(folder);
- } finally {
- monitor.done();
+ section.put(SETTINGS_CREATE_MODULE_INFO_JAVA, fCreateModuleInfoJavaField.isSelected());
}
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java
index 1c1ceef..458d5aa 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
* Philippe Marschall <philippe.marschall@netcetera.ch> - [type wizards] Allow the creation of a compilation unit called package-info.java - https://bugs.eclipse.org/86168
@@ -264,6 +268,7 @@
public static String NewSourceFolderWizardPage_operation;
public static String NewSourceFolderWizardPage_exclude_label;
public static String NewSourceFolderWizardPage_ignore_optional_problems_label;
+ public static String NewSourceFolderWizardPage_create_module_info_java;
public static String NewSourceFolderWizardPage_ChooseExistingRootDialog_title;
public static String NewSourceFolderWizardPage_ChooseExistingRootDialog_description;
public static String NewSourceFolderWizardPage_ChooseProjectDialog_title;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties
index 857b9fd..fd92433 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties
@@ -5,6 +5,10 @@
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
+# 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
# Philippe Marschall <philippe.marschall@netcetera.ch> - [type wizards] Allow the creation of a compilation unit called package-info.java - https://bugs.eclipse.org/86168
@@ -239,6 +243,7 @@
NewSourceFolderWizardPage_exclude_label=&Update exclusion filters in other source folders to solve nesting
NewSourceFolderWizardPage_ignore_optional_problems_label=&Ignore optional compile problems
+NewSourceFolderWizardPage_create_module_info_java=&Create module-info.java (9 or higher)
NewSourceFolderWizardPage_ChooseExistingRootDialog_title=Existing Folder Selection
NewSourceFolderWizardPage_ChooseExistingRootDialog_description=&Choose folder as source folder:
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaUI.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaUI.java
index e3f125e..9fddb0c 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaUI.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaUI.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
*******************************************************************************/
@@ -158,6 +162,14 @@
public static final String ID_SNIPPET_EDITOR= "org.eclipse.jdt.ui.SnippetEditor"; //$NON-NLS-1$
/**
+ * The editor part id of the module-info.java editor (value
+ * <code>"org.eclipse.jdt.ui.ModuleInfoEditor"</code>).
+ *
+ * @since 3.13 BETA_JAVA9
+ */
+ public static final String ID_MODULE_INFO_EDITOR= "org.eclipse.jdt.ui.ModuleInfoEditor"; //$NON-NLS-1$
+
+ /**
* The view part id of the Packages view
* (value <code>"org.eclipse.jdt.ui.PackageExplorer"</code>).
* <p>
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/StandardJavaElementContentProvider.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/StandardJavaElementContentProvider.java
index 40047a7..746e670 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/StandardJavaElementContentProvider.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/StandardJavaElementContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -29,6 +29,7 @@
import org.eclipse.jdt.core.IJavaElementDelta;
import org.eclipse.jdt.core.IJavaModel;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IModuleDescription;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IParent;
@@ -188,7 +189,8 @@
return ((IJarEntryResource) element).getChildren();
}
- if (getProvideMembers() && element instanceof ISourceReference && element instanceof IParent) {
+ if (getProvideMembers() && element instanceof ISourceReference && element instanceof IParent
+ && !(element instanceof IModuleDescription)) {
return ((IParent)element).getChildren();
}
} catch (CoreException e) {
@@ -220,7 +222,7 @@
}
}
- if (element instanceof IParent) {
+ if (element instanceof IParent && !(element instanceof IModuleDescription)) {
try {
// when we have Java children return true, else we fetch all the children
if (((IParent)element).hasChildren())
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java
index 1ecf02c..dcf83fc 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
* Tom Eicher (Avaloq Evolution AG) - block selection mode
@@ -343,7 +347,12 @@
*/
private void initializeScanners() {
Assert.isTrue(isNewSetup());
- fCodeScanner= new JavaCodeScanner(getColorManager(), fPreferenceStore);
+ boolean isModuleInfoEditor= false;
+ if (fTextEditor != null && fTextEditor.getEditorSite() != null
+ && JavaUI.ID_MODULE_INFO_EDITOR.equals(fTextEditor.getEditorSite().getId())) {
+ isModuleInfoEditor= true;
+ }
+ fCodeScanner= new JavaCodeScanner(getColorManager(), fPreferenceStore, isModuleInfoEditor);
fMultilineCommentScanner= new JavaCommentScanner(getColorManager(), fPreferenceStore, IJavaColorConstants.JAVA_MULTI_LINE_COMMENT);
fSinglelineCommentScanner= new JavaCommentScanner(getColorManager(), fPreferenceStore, IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT);
fStringScanner= new SingleTokenJavaScanner(getColorManager(), fPreferenceStore, IJavaColorConstants.JAVA_STRING);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalCollector.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalCollector.java
index 5917ea0..6794657 100755
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalCollector.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalCollector.java
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
*******************************************************************************/
@@ -54,6 +58,7 @@
import org.eclipse.jdt.internal.ui.text.java.JavaMethodCompletionProposal;
import org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal;
import org.eclipse.jdt.internal.ui.text.java.LazyJavaTypeCompletionProposal;
+import org.eclipse.jdt.internal.ui.text.java.LazyModuleCompletionProposal;
import org.eclipse.jdt.internal.ui.text.java.LazyPackageCompletionProposal;
import org.eclipse.jdt.internal.ui.text.java.MethodDeclarationCompletionProposal;
import org.eclipse.jdt.internal.ui.text.java.MethodProposalInfo;
@@ -403,6 +408,8 @@
return createKeywordProposal(proposal);
case CompletionProposal.PACKAGE_REF:
return createPackageProposal(proposal);
+ case CompletionProposal.MODULE_REF:
+ return createModuleProposal(proposal);
case CompletionProposal.TYPE_REF:
return createTypeProposal(proposal);
case CompletionProposal.JAVADOC_TYPE_REF:
@@ -589,6 +596,7 @@
return "java.lang.Object".toCharArray(); //$NON-NLS-1$
return Signature.toCharArray(declaration);
case CompletionProposal.PACKAGE_REF:
+ case CompletionProposal.MODULE_REF:
return proposal.getDeclarationSignature();
case CompletionProposal.JAVADOC_TYPE_REF:
case CompletionProposal.TYPE_REF:
@@ -809,6 +817,10 @@
}
}
+ private IJavaCompletionProposal createModuleProposal(CompletionProposal proposal) {
+ return new LazyModuleCompletionProposal(proposal, getInvocationContext());
+ }
+
private IJavaCompletionProposal createPackageProposal(CompletionProposal proposal) {
return new LazyPackageCompletionProposal(proposal, getInvocationContext());
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalLabelProvider.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalLabelProvider.java
index 9d64dad..e48bf4c 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalLabelProvider.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalLabelProvider.java
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
*******************************************************************************/
@@ -15,6 +19,8 @@
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.ui.ide.IDE;
+
import org.eclipse.jdt.core.CompletionContext;
import org.eclipse.jdt.core.CompletionProposal;
import org.eclipse.jdt.core.Flags;
@@ -27,6 +33,7 @@
import org.eclipse.jdt.ui.JavaElementImageDescriptor;
import org.eclipse.jdt.ui.JavaElementLabels;
+import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider;
@@ -508,6 +515,11 @@
return Strings.markJavaElementLabelLTR(buf);
}
+ StyledString createModuleProposalLabel(CompletionProposal proposal) {
+ Assert.isTrue(proposal.getKind() == CompletionProposal.MODULE_REF);
+ return Strings.markJavaElementLabelLTR(new StyledString(String.valueOf(proposal.getDeclarationSignature())));
+ }
+
StyledString createPackageProposalLabel(CompletionProposal proposal) {
Assert.isTrue(proposal.getKind() == CompletionProposal.PACKAGE_REF);
return Strings.markJavaElementLabelLTR(new StyledString(String.valueOf(proposal.getDeclarationSignature())));
@@ -587,6 +599,8 @@
return createJavadocMethodProposalLabel(proposal);
case CompletionProposal.PACKAGE_REF:
return createPackageProposalLabel(proposal);
+ case CompletionProposal.MODULE_REF:
+ return createModuleProposalLabel(proposal);
case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
case CompletionProposal.FIELD_REF:
case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER:
@@ -648,6 +662,9 @@
case CompletionProposal.PACKAGE_REF:
descriptor= JavaPluginImages.DESC_OBJS_PACKAGE;
break;
+ case CompletionProposal.MODULE_REF:
+ descriptor= JavaPlugin.getDefault().getWorkbench().getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT);
+ break;
case CompletionProposal.KEYWORD:
case CompletionProposal.LABEL_REF:
descriptor= null;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewPackageWizardPage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewPackageWizardPage.java
index fbf048e..52d4ea4 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewPackageWizardPage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewPackageWizardPage.java
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
* Philippe Marschall <philippe.marschall@netcetera.ch> - [type wizards] Allow the creation of a compilation unit called package-info.java - https://bugs.eclipse.org/86168
@@ -37,7 +41,6 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -53,27 +56,22 @@
import org.eclipse.ui.PlatformUI;
-import org.eclipse.jdt.core.IBuffer;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.JavaConventions;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.formatter.CodeFormatter;
import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility;
import org.eclipse.jdt.internal.corext.javadoc.JavaDocCommentReader;
-import org.eclipse.jdt.internal.corext.util.CodeFormatterUtil;
+import org.eclipse.jdt.internal.corext.util.InfoFilesUtil;
import org.eclipse.jdt.internal.corext.util.JavaConventionsUtil;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.corext.util.Messages;
-import org.eclipse.jdt.internal.core.manipulation.util.Strings;
-import org.eclipse.jdt.ui.CodeGeneration;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
@@ -525,61 +523,12 @@
}
private void createPackageInfoJava(IProgressMonitor monitor) throws CoreException {
- String lineDelimiter= StubUtility.getLineDelimiterUsed(fCreatedPackageFragment.getJavaProject());
- StringBuilder content = new StringBuilder();
- String fileComment= getFileComment(lineDelimiter);
- String typeComment= getTypeComment(lineDelimiter);
-
- if (fileComment != null) {
- content.append(fileComment);
- content.append(lineDelimiter);
- }
+ StringBuilder fileContent= new StringBuilder();
+ fileContent.append("package "); //$NON-NLS-1$
+ fileContent.append(fCreatedPackageFragment.getElementName());
+ fileContent.append(";"); //$NON-NLS-1$
- if (typeComment != null) {
- content.append(typeComment);
- content.append(lineDelimiter);
- } else if (fileComment != null) {
- // insert an empty file comment to avoid that the file comment becomes the type comment
- content.append("/**"); //$NON-NLS-1$
- content.append(lineDelimiter);
- content.append(" *"); //$NON-NLS-1$
- content.append(lineDelimiter);
- content.append(" */"); //$NON-NLS-1$
- content.append(lineDelimiter);
- }
-
- content.append("package "); //$NON-NLS-1$
- content.append(fCreatedPackageFragment.getElementName());
- content.append(";"); //$NON-NLS-1$
-
- ICompilationUnit compilationUnit= fCreatedPackageFragment.createCompilationUnit(PACKAGE_INFO_JAVA_FILENAME, content.toString(), true, monitor);
-
- JavaModelUtil.reconcile(compilationUnit);
-
- compilationUnit.becomeWorkingCopy(monitor);
- try {
- IBuffer buffer= compilationUnit.getBuffer();
- ISourceRange sourceRange= compilationUnit.getSourceRange();
- String originalContent= buffer.getText(sourceRange.getOffset(), sourceRange.getLength());
-
- String formattedContent= CodeFormatterUtil.format(CodeFormatter.K_COMPILATION_UNIT, originalContent, 0, lineDelimiter, fCreatedPackageFragment.getJavaProject());
- formattedContent= Strings.trimLeadingTabsAndSpaces(formattedContent);
- buffer.replace(sourceRange.getOffset(), sourceRange.getLength(), formattedContent);
- compilationUnit.commitWorkingCopy(true, new SubProgressMonitor(monitor, 1));
- } finally {
- compilationUnit.discardWorkingCopy();
- }
- }
-
- private String getFileComment(String lineDelimiterUsed) throws CoreException {
- ICompilationUnit cu= fCreatedPackageFragment.getCompilationUnit(PACKAGE_INFO_JAVA_FILENAME);
- return CodeGeneration.getFileComment(cu, lineDelimiterUsed);
- }
-
- private String getTypeComment(String lineDelimiterUsed) throws CoreException {
- ICompilationUnit cu= fCreatedPackageFragment.getCompilationUnit(PACKAGE_INFO_JAVA_FILENAME);
- String typeName= PACKAGE_INFO_JAVA_FILENAME.substring(0, PACKAGE_INFO_JAVA_FILENAME.length() - JavaModelUtil.DEFAULT_CU_SUFFIX.length());
- return CodeGeneration.getTypeComment(cu, typeName, lineDelimiterUsed);
+ InfoFilesUtil.createInfoJavaFile(PACKAGE_INFO_JAVA_FILENAME, fileContent.toString(), fCreatedPackageFragment, monitor);
}
private void createPackageHtml(IPackageFragmentRoot root, IProgressMonitor monitor) throws CoreException {
@@ -599,8 +548,8 @@
private String buildPackageHtmlContent(IPackageFragmentRoot root, String charset) throws CoreException {
String lineDelimiter= StubUtility.getLineDelimiterUsed(root.getJavaProject());
StringBuilder content = new StringBuilder();
- String fileComment= getFileComment(lineDelimiter);
- String typeComment= getTypeComment(lineDelimiter);
+ String fileComment= InfoFilesUtil.getFileComment(PACKAGE_INFO_JAVA_FILENAME, fCreatedPackageFragment, lineDelimiter);
+ String typeComment= InfoFilesUtil.getTypeComment(PACKAGE_INFO_JAVA_FILENAME, fCreatedPackageFragment, lineDelimiter);
content.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">"); //$NON-NLS-1$
content.append(lineDelimiter);