Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipe Mulet2001-08-03 10:36:01 +0000
committerPhilipe Mulet2001-08-03 10:36:01 +0000
commit8fe276c9a253deb1dc49b8bec89bbeb9117f7d7f (patch)
tree0f926dd99051f88029489955834291fb5e65c1de
parent37b80d5b6322474683b56f9759227ede3c0e16b7 (diff)
downloadeclipse.jdt.core-8fe276c9a253deb1dc49b8bec89bbeb9117f7d7f.tar.gz
eclipse.jdt.core-8fe276c9a253deb1dc49b8bec89bbeb9117f7d7f.tar.xz
eclipse.jdt.core-8fe276c9a253deb1dc49b8bec89bbeb9117f7d7f.zip
*** empty log message ***
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java25
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java18
2 files changed, 39 insertions, 4 deletions
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java
index b38372f52a..fdeba0d826 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java
@@ -96,6 +96,12 @@ public class SourceMapper extends ReferenceInfoAdapter implements ISourceElement
protected IJavaElement searchedElement;
/**
+ * imports references
+ */
+ private char[][] imports;
+ private int importsCounter;
+
+ /**
* Enclosing type information
*/
IType[] types;
@@ -119,7 +125,14 @@ public SourceMapper(IPath zipPath, String rootPath, JavaModel model) {
* @see ISourceElementRequestor
*/
public void acceptImport(int declarationStart, int declarationEnd, char[] name, boolean onDemand) {
- //do nothing
+ if (this.imports == null) {
+ this.imports = new char[5][];
+ this.importsCounter = 0;
+ }
+ if (this.imports.length == this.importsCounter) {
+ System.arraycopy(this.imports, 0, (this.imports = new char[this.importsCounter * 2][]), 0, this.importsCounter);
+ }
+ this.imports[this.importsCounter++] = name;
}
/**
* @see ISourceElementRequestor
@@ -436,6 +449,7 @@ public void mapSource(IType type, char[] contents) {
public ISourceRange mapSource(IType type, char[] contents, IJavaElement searchedElement) {
fType= (BinaryType)type;
+ this.imports = null;
this.searchedElement = searchedElement;
this.types = new IType[1];
this.typeDeclarationStarts = new int[1];
@@ -505,4 +519,13 @@ protected byte[] readEntry(ZipFile zip, ZipEntry entry) {
protected void setSourceRange(IJavaElement element, SourceRange sourceRange, SourceRange nameRange) {
fSourceRanges.put(element, new SourceRange[] {sourceRange, nameRange});
}
+
+/**
+ * Return a char[][] array containing the imports of the attached source for an IType
+ */
+public char[][] getImports() {
+ if (this.imports != null && this.imports.length != this.importsCounter) {
+ System.arraycopy(this.imports, 0, (this.imports = new char[this.importsCounter][]), 0, this.importsCounter);
+ }
+ return this.imports;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java
index 2e7995f41a..82df64f3ce 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java
@@ -7,12 +7,14 @@ package org.eclipse.jdt.internal.core.eval;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.eval.*;
import org.eclipse.jdt.internal.codeassist.ISelectionRequestor;
import org.eclipse.jdt.internal.codeassist.ICompletionRequestor;
-import org.eclipse.jdt.internal.compiler.*;
+import org.eclipse.jdt.internal.compiler.ConfigurableOption;
+import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
+import org.eclipse.jdt.internal.compiler.IProblemFactory;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
-import org.eclipse.jdt.core.*;
-import org.eclipse.jdt.core.eval.*;
import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.*;
import org.eclipse.jdt.internal.core.builder.impl.JavaBuilder;
@@ -137,6 +139,16 @@ public void evaluateCodeSnippet(
}
this.context.setImports(importsNames);
}
+ } else {
+ // try to retrieve imports from the source
+ SourceMapper sourceMapper = ((ClassFile) declaringType.getClassFile()).getSourceMapper();
+ if (sourceMapper != null) {
+ declaringType.getSource(); // do the mapping and initialize the imports
+ char[][] imports = sourceMapper.getImports();
+ if (imports != null) {
+ this.context.setImports(sourceMapper.getImports());
+ }
+ }
}
}
try {

Back to the top