Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSasikanth Bharadwaj2016-09-25 17:06:25 +0000
committerSasikanth Bharadwaj2016-09-25 17:07:05 +0000
commit9bf78cba47059f0c2c8da2c64445ec00ed642f86 (patch)
tree8533086dc5f8dc80bf67238da5d9b5dfa87c2421
parent96cc7d1f2b16a1d266e02faa2b0051283ab6588c (diff)
downloadeclipse.jdt.core-9bf78cba47059f0c2c8da2c64445ec00ed642f86.tar.gz
eclipse.jdt.core-9bf78cba47059f0c2c8da2c64445ec00ed642f86.tar.xz
eclipse.jdt.core-9bf78cba47059f0c2c8da2c64445ec00ed642f86.zip
Final part, passes all java8 tests, compiler is back to where it wassasikanth/BETA_JAVA9_Experiment
before all this, only cleanup remains
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java17
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JrtPackageFragmentRoot.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Module.java51
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModuleSourcePathManager.java12
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java39
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java22
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ProjectEntry.java18
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java1
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java1
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrt.java1
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathMultiDirectory.java1
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/Module.java46
12 files changed, 148 insertions, 65 deletions
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
index b40d869d89..b1dc3a04d6 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
@@ -76,6 +76,9 @@ import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.eval.IEvaluationContext;
import org.eclipse.jdt.internal.compiler.env.IModule;
+import org.eclipse.jdt.internal.compiler.env.IModuleEnvironment;
+import org.eclipse.jdt.internal.compiler.env.PackageLookup;
+import org.eclipse.jdt.internal.compiler.env.TypeLookup;
import org.eclipse.jdt.internal.compiler.util.JRTUtil;
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
@@ -116,7 +119,7 @@ import org.xml.sax.SAXException;
@SuppressWarnings({ "rawtypes", "unchecked" })
public class JavaProject
extends Openable
- implements IJavaProject, IProjectNature, SuffixConstants {
+ implements IJavaProject, IProjectNature, IModuleEnvironment, SuffixConstants {
/**
* Name of file containing project classpath
@@ -3351,4 +3354,16 @@ public class JavaProject
return module;
}
+
+ @Override
+ public TypeLookup typeLookup() {
+ // No direct way to lookup, use the java model APIs instead
+ return TypeLookup.Dummy;
+ }
+
+ @Override
+ public PackageLookup packageLookup() {
+ // No direct way to lookup, use the java model APIs instead
+ return PackageLookup.Dummy;
+ }
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JrtPackageFragmentRoot.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JrtPackageFragmentRoot.java
index 90dd19d2cd..f8486b7155 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JrtPackageFragmentRoot.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JrtPackageFragmentRoot.java
@@ -137,13 +137,13 @@ public class JrtPackageFragmentRoot extends JarPackageFragmentRoot implements IM
@Override
public TypeLookup typeLookup() {
- //
+ // No direct way to lookup, use the java model APIs instead
return TypeLookup.Dummy;
}
@Override
public PackageLookup packageLookup() {
- //
+ // No direct way to lookup, use the java model APIs instead
return PackageLookup.Dummy;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Module.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Module.java
index 2ae23c7db5..baaffc7889 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Module.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Module.java
@@ -14,33 +14,64 @@
*******************************************************************************/
package org.eclipse.jdt.internal.core;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.env.IModuleDeclaration;
import org.eclipse.jdt.internal.compiler.env.IModuleEnvironment;
-import org.eclipse.jdt.internal.compiler.env.IModulePathEntry;
public class Module implements org.eclipse.jdt.internal.compiler.env.IModule {
- public IModulePathEntry entry;
- public IModuleDeclaration declaration;
+ public ClassFile binaryDecl;
+ public IModuleDeclaration declaration = null;
+ public boolean isBinary = false;
+ public SourceType sourceDecl;
- public Module(IModulePathEntry entry, IModuleDeclaration declaration) {
- this.entry = entry;
- this.declaration = declaration;
+ public Module(SourceType sourceDecl) {
+ this.sourceDecl = sourceDecl;
+ }
+ public Module(ClassFile binaryDecl) {
+ this.binaryDecl = binaryDecl;
+ this.isBinary = true;
}
@Override
public char[] name() {
//
- return this.declaration.name();
+ IModuleDeclaration decl = getDeclaration();
+ return decl == null ? CharOperation.NO_CHAR : decl.name();
}
@Override
public IModuleDeclaration getDeclaration() {
//
+ if (this.declaration == null) {
+ try {
+ if (this.isBinary) {
+ IType type = this.binaryDecl.getType();
+ this.declaration = ((ClassFileReader) (((BinaryType)type).getElementInfo())).getModuleDeclaration();
+ } else {
+ this.declaration = (ModuleInfo) this.sourceDecl.getElementInfo();
+ }
+ }catch (JavaModelException e) {
+ // do nothing
+ }
+ }
return this.declaration;
}
@Override
public IModuleEnvironment getLookupEnvironment() {
- //
- return this.entry == null ? null : this.entry.getLookupEnvironment();
- }
+ // TODO: this should refer to the ModuleSourcePathManager to map this module to
+ // an IModuelePathEntry
+ if (this.isBinary) {
+ PackageFragmentRoot root = (PackageFragmentRoot) this.binaryDecl
+ .getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
+ if (root instanceof JrtPackageFragmentRoot)
+ return (JrtPackageFragmentRoot) root;
+ } else {
+ return (JavaProject) this.sourceDecl.getAncestor(IJavaElement.JAVA_PROJECT);
+ }
+ return null;
+ }
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModuleSourcePathManager.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModuleSourcePathManager.java
index 6c5b7b21a9..7d84c730bc 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModuleSourcePathManager.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModuleSourcePathManager.java
@@ -45,7 +45,15 @@ public class ModuleSourcePathManager {
root = this.knownModules.get(name);
return root;
}
-
+ public void addEntry(IModule module, JavaProject project) throws JavaModelException {
+ String moduleName = new String(module.name());
+ IModulePathEntry entry = getModuleRoot0(moduleName);
+ if (entry != null) {
+ // TODO : Should we signal error via JavaModelException
+ return;
+ }
+ this.knownModules.put(moduleName, new ProjectEntry(project));
+ }
public void seekModule(char[] name, boolean partialMatch, IJavaElementRequestor requestor) throws JavaModelException {
if (name == null)
return;
@@ -59,8 +67,8 @@ public class ModuleSourcePathManager {
IModule module = ((JavaProject) project).getModule();
if (module != null) {
char[] moduleName = module.name();
- this.knownModules.put(CharOperation.charToString(name), ((Module)module).entry);
if (CharOperation.equals(name, moduleName)) {
+ addEntry(module, (JavaProject) project);
requestor.acceptModule(module);
break;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java
index 97e4ae2493..ee2f9c51f6 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java
@@ -13,8 +13,6 @@ package org.eclipse.jdt.internal.core;
import java.io.File;
import java.util.*;
-import java.util.stream.Stream;
-
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -1018,32 +1016,13 @@ public class NameLookup implements SuffixConstants {
Object value = this.packageFragments.valueTable[pkgIndex];
// reuse existing String[]
String[] pkgName = (String[]) this.packageFragments.keyTable[pkgIndex];
- context.getEnvironment().<PackageFragmentRoot>flatMap(e -> {
- if (e instanceof ProjectEntry) {
- JavaProject prj = ((ProjectEntry) e).project;
- List<IPackageFragmentRoot> children;
- try {
- children = prj.getChildrenOfType(IJavaElement.PACKAGE_FRAGMENT_ROOT);
- return children.stream().filter(r -> {
- try {
- return r.getKind() == IPackageFragmentRoot.K_SOURCE;
- } catch (JavaModelException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- return false;
- }).map(r -> (PackageFragmentRoot)r);
- } catch (JavaModelException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- return Stream.empty();
- } else {
- return Stream.of((JrtPackageFragmentRoot)e);
- }
- }).forEach(r -> {
+ context.getEnvironment().forEach(r -> {
if (value instanceof PackageFragmentRoot) {
- if (value.equals(r)) {
+ Object toCompare = value;
+ if (r instanceof JavaProject) {
+ toCompare = ((PackageFragmentRoot)value).getJavaProject();
+ }
+ if (value.equals(toCompare)) {
PackageFragmentRoot root = (PackageFragmentRoot) value;
requestor.acceptPackageFragment(root.getPackageFragment(pkgName));
}
@@ -1054,7 +1033,11 @@ public class NameLookup implements SuffixConstants {
if (requestor.isCanceled())
return;
PackageFragmentRoot root = (PackageFragmentRoot) roots[i];
- if (root.equals(r))
+ Object toCompare = root;
+ if (r instanceof JavaProject) {
+ toCompare = root.getJavaProject();
+ }
+ if (root.equals(toCompare))
requestor.acceptPackageFragment(root.getPackageFragment(pkgName));
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java
index 257a1dee62..af16c47aba 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java
@@ -22,7 +22,6 @@ import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
import org.eclipse.jdt.core.*;
import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
import org.eclipse.jdt.internal.core.util.MementoTokenizer;
import org.eclipse.jdt.internal.core.util.Messages;
@@ -882,33 +881,20 @@ public org.eclipse.jdt.internal.compiler.env.IModule getModule() {
.getCompilationUnit(TypeConstants.MODULE_INFO_FILE_NAME_STRING);
if (unit instanceof CompilationUnit && unit.exists()) {
IType type = unit.getType(new String(TypeConstants.MODULE_INFO_NAME));
- ModuleInfo decl = (ModuleInfo)((SourceType)type).getElementInfo();
- if (decl != null) {
- JavaProject prj = (JavaProject) this.getAncestor(IJavaElement.JAVA_PROJECT);
- module = new Module(new ProjectEntry(prj), decl);
- rootInfo.setModule(module);
- return module;
+ if (type != null) {
+ rootInfo.setModule(module = new Module((SourceType)type));
}
-// info = (CompilationUnitElementInfo) ((CompilationUnit) unit)
-// .getElementInfo();
-// if (info != null)
-// return info.getModule();
}
} else {
IClassFile classFile = ((IPackageFragment)pkgs[j]).getClassFile(TypeConstants.MODULE_INFO_CLASS_NAME_STRING);
if (classFile instanceof ClassFile && classFile.exists()) {
- IType type = classFile.getType();
- org.eclipse.jdt.internal.compiler.env.IModuleDeclaration decl = ((ClassFileReader)(((BinaryType)type).getElementInfo())).getModuleDeclaration();
- if (decl != null) {
- org.eclipse.jdt.internal.compiler.env.IModule mod = new Module((JrtPackageFragmentRoot)this, decl);
- rootInfo.setModule(mod);
- return mod;
- }
+ rootInfo.setModule(module = new Module((ClassFile)classFile));
}
}
break;
}
}
+ return module;
} catch (JavaModelException e) {
//
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ProjectEntry.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ProjectEntry.java
index 54679bfddf..eb03bc31bc 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ProjectEntry.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ProjectEntry.java
@@ -1,3 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corporation.
+ * 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.core;
import org.eclipse.jdt.core.JavaModelException;
@@ -7,6 +21,10 @@ import org.eclipse.jdt.internal.compiler.env.IModulePathEntry;
import org.eclipse.jdt.internal.compiler.env.PackageLookup;
import org.eclipse.jdt.internal.compiler.env.TypeLookup;
+/**
+ * Represents a project
+ *
+ */
public class ProjectEntry implements IModulePathEntry, IModuleEnvironment {
JavaProject project;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java
index 8815af2eca..03ccf748fb 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java
@@ -35,7 +35,6 @@ import org.eclipse.jdt.internal.compiler.env.TypeLookup;
import org.eclipse.jdt.internal.compiler.lookup.ModuleEnvironment;
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
-import org.eclipse.jdt.internal.core.Module;
import org.eclipse.jdt.internal.core.util.Util;
public class ClasspathDirectory extends ClasspathLocation implements IModuleEnvironment {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java
index aba726771b..d09dda6e31 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java
@@ -32,7 +32,6 @@ import org.eclipse.jdt.internal.compiler.env.TypeLookup;
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
-import org.eclipse.jdt.internal.core.Module;
import org.eclipse.jdt.internal.core.util.Util;
import java.io.*;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrt.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrt.java
index 0fbb63212f..83add014b6 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrt.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrt.java
@@ -45,7 +45,6 @@ import org.eclipse.jdt.internal.compiler.env.TypeLookup;
import org.eclipse.jdt.internal.compiler.util.JRTUtil;
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
-import org.eclipse.jdt.internal.core.Module;
public class ClasspathJrt extends ClasspathLocation implements IMultiModuleEntry, IModuleEnvironment {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathMultiDirectory.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathMultiDirectory.java
index 63e6ecf453..b43f4a2427 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathMultiDirectory.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathMultiDirectory.java
@@ -23,7 +23,6 @@ import org.eclipse.jdt.internal.compiler.env.IModule;
import org.eclipse.jdt.internal.compiler.env.IModuleDeclaration;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
import org.eclipse.jdt.internal.compiler.parser.Parser;
-import org.eclipse.jdt.internal.core.Module;
import org.eclipse.jdt.internal.core.ModuleInfo;
import org.eclipse.jdt.internal.core.util.Util;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/Module.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/Module.java
new file mode 100644
index 0000000000..8333df19d4
--- /dev/null
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/Module.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.core.builder;
+
+import org.eclipse.jdt.internal.compiler.env.IModule;
+import org.eclipse.jdt.internal.compiler.env.IModuleDeclaration;
+import org.eclipse.jdt.internal.compiler.env.IModuleEnvironment;
+import org.eclipse.jdt.internal.compiler.env.IModulePathEntry;
+
+public class Module implements IModule {
+ public IModulePathEntry entry;
+ public IModuleDeclaration declaration;
+
+ public Module(IModulePathEntry entry, IModuleDeclaration declaration) {
+ this.entry = entry;
+ this.declaration = declaration;
+ }
+
+ @Override
+ public char[] name() {
+ //
+ return this.declaration.name();
+ }
+ @Override
+ public IModuleDeclaration getDeclaration() {
+ //
+ return this.declaration;
+ }
+ @Override
+ public IModuleEnvironment getLookupEnvironment() {
+ //
+ return this.entry == null ? null : this.entry.getLookupEnvironment();
+ }
+}

Back to the top