View | Details | Raw Unified | Return to bug 125504 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/SourceRefElement.java (+6 lines)
Lines 151-156 Link Here
151
	String token = memento.nextToken();
151
	String token = memento.nextToken();
152
	return getHandleFromMemento(token, memento, owner);
152
	return getHandleFromMemento(token, memento, owner);
153
}
153
}
154
/**
155
 * @see IMember
156
 */
157
public IJavaFile getJavaFile() {
158
	return ((JavaElement)getParent()).getJavaFile();
159
}
154
/*
160
/*
155
 * @see IMember#getOccurrenceCount()
161
 * @see IMember#getOccurrenceCount()
156
 */
162
 */
(-)model/org/eclipse/jdt/internal/core/CompilationUnit.java (+6 lines)
Lines 586-591 Link Here
586
	return this;
586
	return this;
587
}
587
}
588
/**
588
/**
589
 * @see IMember#getJavaFile()
590
 */
591
public IJavaFile getJavaFile() {
592
	return this;
593
}
594
/**
589
 * @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getContents()
595
 * @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getContents()
590
 */
596
 */
591
public char[] getContents() {
597
public char[] getContents() {
(-)model/org/eclipse/jdt/internal/core/ClassFile.java (+16 lines)
Lines 55-60 Link Here
55
 * @see IClassFile#becomeWorkingCopy(IProblemRequestor, WorkingCopyOwner, IProgressMonitor)
55
 * @see IClassFile#becomeWorkingCopy(IProblemRequestor, WorkingCopyOwner, IProgressMonitor)
56
 */
56
 */
57
public ICompilationUnit becomeWorkingCopy(IProblemRequestor problemRequestor, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException {
57
public ICompilationUnit becomeWorkingCopy(IProblemRequestor problemRequestor, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException {
58
	return getWorkingCopy(owner, problemRequestor, monitor);
59
}
60
61
/*
62
 * @see IClassFile#getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor)
63
 */
64
public ICompilationUnit getWorkingCopy(WorkingCopyOwner owner, IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException {
58
	JavaModelManager manager = JavaModelManager.getJavaModelManager();
65
	JavaModelManager manager = JavaModelManager.getJavaModelManager();
59
	CompilationUnit workingCopy = new ClassFileWorkingCopy(this, owner == null ? DefaultWorkingCopyOwner.PRIMARY : owner);
66
	CompilationUnit workingCopy = new ClassFileWorkingCopy(this, owner == null ? DefaultWorkingCopyOwner.PRIMARY : owner);
60
	JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = manager.getPerWorkingCopyInfo(workingCopy, false/*don't create*/, true /*record usage*/, null/*no problem requestor needed*/);
67
	JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = manager.getPerWorkingCopyInfo(workingCopy, false/*don't create*/, true /*record usage*/, null/*no problem requestor needed*/);
Lines 239-244 Link Here
239
	}
246
	}
240
	return elt;
247
	return elt;
241
}
248
}
249
public IType findPrimaryType() {
250
	return getType();
251
}
242
public String getAttachedJavadoc(IProgressMonitor monitor) throws JavaModelException {
252
public String getAttachedJavadoc(IProgressMonitor monitor) throws JavaModelException {
243
	return this.getType().getAttachedJavadoc(monitor);
253
	return this.getType().getAttachedJavadoc(monitor);
244
}
254
}
Lines 327-332 Link Here
327
	return this;
337
	return this;
328
}
338
}
329
/**
339
/**
340
 * @see IMember
341
 */
342
public IJavaFile getJavaFile() {
343
	return this;
344
}
345
/**
330
 * A class file has a corresponding resource unless it is contained
346
 * A class file has a corresponding resource unless it is contained
331
 * in a jar.
347
 * in a jar.
332
 *
348
 *
(-)model/org/eclipse/jdt/internal/core/JavaElement.java (+6 lines)
Lines 294-299 Link Here
294
	 */
294
	 */
295
	protected abstract char getHandleMementoDelimiter();
295
	protected abstract char getHandleMementoDelimiter();
296
	/**
296
	/**
297
	 * @see IMember
298
	 */
299
	public IJavaFile getJavaFile() {
300
		return null;
301
	}
302
	/**
297
	 * @see IJavaElement
303
	 * @see IJavaElement
298
	 */
304
	 */
299
	public IJavaModel getJavaModel() {
305
	public IJavaModel getJavaModel() {
(-)dom/org/eclipse/jdt/core/dom/ASTParser.java (-39 / +38 lines)
Lines 17-22 Link Here
17
import org.eclipse.jdt.core.IClassFile;
17
import org.eclipse.jdt.core.IClassFile;
18
import org.eclipse.jdt.core.ICompilationUnit;
18
import org.eclipse.jdt.core.ICompilationUnit;
19
import org.eclipse.jdt.core.IJavaElement;
19
import org.eclipse.jdt.core.IJavaElement;
20
import org.eclipse.jdt.core.IJavaFile;
20
import org.eclipse.jdt.core.IJavaProject;
21
import org.eclipse.jdt.core.IJavaProject;
21
import org.eclipse.jdt.core.JavaCore;
22
import org.eclipse.jdt.core.JavaCore;
22
import org.eclipse.jdt.core.JavaModelException;
23
import org.eclipse.jdt.core.JavaModelException;
Lines 154-167 Link Here
154
    private char[] rawSource = null;
155
    private char[] rawSource = null;
155
    
156
    
156
    /**
157
    /**
157
     * Java mode compilation unit supplying the source.
158
     * Java model class file or compilation unit supplying the source.
158
     */
159
     */
159
    private ICompilationUnit compilationUnitSource = null;
160
    private IJavaFile javaFileSource = null;
160
    
161
    /**
162
     * Java model class file supplying the source.
163
     */
164
    private IClassFile classFileSource = null;
165
    
161
    
166
    /**
162
    /**
167
     * Character-based offset into the source string where parsing is to
163
     * Character-based offset into the source string where parsing is to
Lines 218-225 Link Here
218
	private void initializeDefaults() {
214
	private void initializeDefaults() {
219
		this.astKind = K_COMPILATION_UNIT;
215
		this.astKind = K_COMPILATION_UNIT;
220
		this.rawSource = null;
216
		this.rawSource = null;
221
		this.classFileSource = null;
217
		this.javaFileSource = null;
222
		this.compilationUnitSource = null;
223
		this.resolveBindings = false;
218
		this.resolveBindings = false;
224
		this.sourceLength = -1;
219
		this.sourceLength = -1;
225
		this.sourceOffset = 0;
220
		this.sourceOffset = 0;
Lines 452-460 Link Here
452
     */
447
     */
453
	public void setSource(char[] source) {
448
	public void setSource(char[] source) {
454
		this.rawSource = source;
449
		this.rawSource = source;
455
		// clear the others
450
		// clear the other
456
		this.compilationUnitSource = null;
451
		this.javaFileSource = null;
457
		this.classFileSource = null;
458
	}
452
	}
459
453
460
	/**
454
	/**
Lines 467-482 Link Here
467
     * is to be parsed, or <code>null</code> if none
461
     * is to be parsed, or <code>null</code> if none
468
      */
462
      */
469
	public void setSource(ICompilationUnit source) {
463
	public void setSource(ICompilationUnit source) {
470
		this.compilationUnitSource = source;
464
		setSource((IJavaFile) source);
471
		// clear the others
472
		this.rawSource = null;
473
		this.classFileSource = null;
474
		if (source != null) {
475
			this.project = source.getJavaProject();
476
			Map options = this.project.getOptions(true);
477
			options.remove(JavaCore.COMPILER_TASK_TAGS); // no need to parse task tags
478
			this.compilerOptions = options;
479
		}
480
	}
465
	}
481
	
466
	
482
	/**
467
	/**
Lines 491-500 Link Here
491
     * is to be parsed, or <code>null</code> if none
476
     * is to be parsed, or <code>null</code> if none
492
     */
477
     */
493
	public void setSource(IClassFile source) {
478
	public void setSource(IClassFile source) {
494
		this.classFileSource = source;
479
		setSource((IJavaFile) source);
495
		// clear the others
480
	}
481
	
482
	/**
483
	 * Sets the source code to be parsed.
484
	 * <p>This method automatically sets the project (and compiler
485
	 * options) based on the given compilation unit of class file, in a manner
486
	 * equivalent to <code>setProject(source.getJavaProject())</code>.</p>
487
	 * <p>If source is a class file has without source attachment, the creation of the 
488
	 * ast will fail with an IllegalStateException.</p>
489
	 *
490
	 * @param source the Java model compilation unit or class file whose corresponding source code
491
	 * is to be parsed, or <code>null</code> if none
492
	 * @since 3.3
493
	 */
494
	public void setSource(IJavaFile source) {
495
		this.javaFileSource = source;
496
		// clear the other
496
		this.rawSource = null;
497
		this.rawSource = null;
497
		this.compilationUnitSource = null;
498
		if (source != null) {
498
		if (source != null) {
499
			this.project = source.getJavaProject();
499
			this.project = source.getJavaProject();
500
			Map options = this.project.getOptions(true);
500
			Map options = this.project.getOptions(true);
Lines 623-630 Link Here
623
	   if (monitor != null) monitor.beginTask("", 1); //$NON-NLS-1$
623
	   if (monitor != null) monitor.beginTask("", 1); //$NON-NLS-1$
624
		try {
624
		try {
625
			if ((this.rawSource == null)
625
			if ((this.rawSource == null)
626
		   	  && (this.compilationUnitSource == null)
626
		   	  && (this.javaFileSource == null)) {
627
		   	  && (this.classFileSource == null)) {
628
		   	  throw new IllegalStateException("source not specified"); //$NON-NLS-1$
627
		   	  throw new IllegalStateException("source not specified"); //$NON-NLS-1$
629
		   }
628
		   }
630
	   		result = internalCreateAST(monitor);
629
	   		result = internalCreateAST(monitor);
Lines 782-803 Link Here
782
				try {
781
				try {
783
					NodeSearcher searcher = null;
782
					NodeSearcher searcher = null;
784
					org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = null;
783
					org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = null;
785
					IJavaElement element = null;
784
					IJavaFile javaFile = null;
786
					if (this.compilationUnitSource != null) {
785
					if (this.javaFileSource instanceof ICompilationUnit) {
787
						sourceUnit = (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) this.compilationUnitSource;
786
						sourceUnit = (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) this.javaFileSource;
788
						// use a BasicCompilation that caches the source instead of using the compilationUnitSource directly 
787
						// use a BasicCompilation that caches the source instead of using the javaFileSource directly 
789
						// (if it is a working copy, the source can change between the parse and the AST convertion)
788
						// (if it is a working copy, the source can change between the parse and the AST convertion)
790
						// (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=75632)
789
						// (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=75632)
791
						sourceUnit = new BasicCompilationUnit(sourceUnit.getContents(), sourceUnit.getPackageName(), new String(sourceUnit.getFileName()), this.project);
790
						sourceUnit = new BasicCompilationUnit(sourceUnit.getContents(), sourceUnit.getPackageName(), new String(sourceUnit.getFileName()), this.project);
792
						element = this.compilationUnitSource;
791
						javaFile = this.javaFileSource;
793
					} else if (this.classFileSource != null) {
792
					} else if (this.javaFileSource instanceof IClassFile) {
794
						try {
793
						try {
795
							String sourceString = this.classFileSource.getSource();
794
							String sourceString = this.javaFileSource.getSource();
796
							if (sourceString == null) {
795
							if (sourceString == null) {
797
								throw new IllegalStateException();
796
								throw new IllegalStateException();
798
							}
797
							}
799
							PackageFragment packageFragment = (PackageFragment) this.classFileSource.getParent();
798
							PackageFragment packageFragment = (PackageFragment) this.javaFileSource.getParent();
800
							BinaryType type = (BinaryType) this.classFileSource.getType();
799
							BinaryType type = (BinaryType) this.javaFileSource.findPrimaryType();
801
							IBinaryType binaryType = (IBinaryType) type.getElementInfo();
800
							IBinaryType binaryType = (IBinaryType) type.getElementInfo();
802
							// file name is used to recreate the Java element, so it has to be the toplevel .class file name
801
							// file name is used to recreate the Java element, so it has to be the toplevel .class file name
803
							char[] fileName = binaryType.getFileName();
802
							char[] fileName = binaryType.getFileName();
Lines 811-817 Link Here
811
								fileName = newFileName;
810
								fileName = newFileName;
812
							}
811
							}
813
							sourceUnit = new BasicCompilationUnit(sourceString.toCharArray(), Util.toCharArrays(packageFragment.names), new String(fileName), this.project);
812
							sourceUnit = new BasicCompilationUnit(sourceString.toCharArray(), Util.toCharArrays(packageFragment.names), new String(fileName), this.project);
814
							element = this.classFileSource;
813
							javaFile = this.javaFileSource;
815
						} catch(JavaModelException e) {
814
						} catch(JavaModelException e) {
816
							// an error occured accessing the java element
815
							// an error occured accessing the java element
817
							throw new IllegalStateException();
816
							throw new IllegalStateException();
Lines 859-868 Link Here
859
						this.apiLevel, 
858
						this.apiLevel, 
860
						this.compilerOptions,
859
						this.compilerOptions,
861
						needToResolveBindings,
860
						needToResolveBindings,
862
						this.compilationUnitSource == null ? this.workingCopyOwner : this.compilationUnitSource.getOwner(),
861
						! (this.javaFileSource instanceof ICompilationUnit) ? this.workingCopyOwner : ((ICompilationUnit) this.javaFileSource).getOwner(),
863
						needToResolveBindings ? new DefaultBindingResolver.BindingTables() : null, 
862
						needToResolveBindings ? new DefaultBindingResolver.BindingTables() : null, 
864
						monitor);
863
						monitor);
865
					result.setJavaElement(element);
864
					result.setJavaElement(javaFile);
866
					return result;
865
					return result;
867
				} finally {
866
				} finally {
868
					if (compilationUnitDeclaration != null && this.resolveBindings) {
867
					if (compilationUnitDeclaration != null && this.resolveBindings) {
(-)dom/org/eclipse/jdt/core/dom/CompilationUnit.java (-7 / +20 lines)
Lines 18-23 Link Here
18
import java.util.Map;
18
import java.util.Map;
19
19
20
import org.eclipse.jdt.core.IJavaElement;
20
import org.eclipse.jdt.core.IJavaElement;
21
import org.eclipse.jdt.core.IJavaFile;
21
import org.eclipse.jdt.core.compiler.IProblem;
22
import org.eclipse.jdt.core.compiler.IProblem;
22
import org.eclipse.jdt.internal.compiler.parser.Scanner;
23
import org.eclipse.jdt.internal.compiler.parser.Scanner;
23
import org.eclipse.jface.text.IDocument;
24
import org.eclipse.jface.text.IDocument;
Lines 123-133 Link Here
123
	private DefaultCommentMapper commentMapper = null;
124
	private DefaultCommentMapper commentMapper = null;
124
	
125
	
125
	/**
126
	/**
126
	 * The Java element (an <code>org.eclipse.jdt.core.ICompilationUnit</code> or an <code>org.eclipse.jdt.core.IClassFile</code>) 
127
	 * The Java file (an <code>org.eclipse.jdt.core.ICompilationUnit</code> or an <code>org.eclipse.jdt.core.IClassFile</code>) 
127
	 * this compilation unit was created from, or <code>null</code> if it was not created from a Java element.
128
	 * this compilation unit was created from, or <code>null</code> if it was not created from a Java file.
128
	 * @since 3.1
129
	 * @since 3.1
129
	 */
130
	 */
130
	private IJavaElement element = null;
131
	private IJavaFile javaFile = null;
131
	
132
	
132
	/**
133
	/**
133
	 * The list of import declarations in textual order order; 
134
	 * The list of import declarations in textual order order; 
Lines 492-498 Link Here
492
	 * @since 3.1
493
	 * @since 3.1
493
	 */
494
	 */
494
	public IJavaElement getJavaElement() {
495
	public IJavaElement getJavaElement() {
495
		return this.element;
496
		return this.javaFile;
497
	}
498
	
499
	/**
500
	 * The Java file (an <code>org.eclipse.jdt.core.ICompilationUnit</code> or an <code>org.eclipse.jdt.core.IClassFile</code>) 
501
	 * this compilation unit was created from, or <code>null</code> if it was not created from a Java file.
502
	 * 
503
	 * @return the Java file this compilation unit was created from, or <code>null</code> if none
504
	 * @since 3.3
505
	 */
506
	public IJavaFile getJavaFile() {
507
		return this.javaFile;
496
	}
508
	}
497
	
509
	
498
	/**
510
	/**
Lines 936-946 Link Here
936
	 * Sets the Java element (an <code>org.eclipse.jdt.core.ICompilationUnit</code> or an <code>org.eclipse.jdt.core.IClassFile</code>) 
948
	 * Sets the Java element (an <code>org.eclipse.jdt.core.ICompilationUnit</code> or an <code>org.eclipse.jdt.core.IClassFile</code>) 
937
	 * this compilation unit was created from, or <code>null</code> if it was not created from a Java element.
949
	 * this compilation unit was created from, or <code>null</code> if it was not created from a Java element.
938
	 * 
950
	 * 
939
	 * @param element the Java element this compilation unit was created from
951
	 * @param javaFile the Java file this compilation unit was created from
940
	 * @since 3.1
952
	 * @since 3.1
941
	 */
953
	 */
942
	void setJavaElement(IJavaElement element) {
954
	//TODO: rename to setJavaFile(..)
943
		this.element = element;
955
	void setJavaElement(IJavaFile javaFile) {
956
		this.javaFile = javaFile;
944
	}
957
	}
945
	
958
	
946
	/**
959
	/**
(-)model/org/eclipse/jdt/core/IMember.java (+8 lines)
Lines 49-54 Link Here
49
 */
49
 */
50
ICompilationUnit getCompilationUnit();
50
ICompilationUnit getCompilationUnit();
51
/**
51
/**
52
 * Returns the Java file in which this member is declared.
53
 * This is a handle-only method.
54
 * 
55
 * @return the Java file in which this member is declared
56
 * @since 3.3
57
 */
58
IJavaFile getJavaFile();
59
/**
52
 * Returns the type in which this member is declared, or <code>null</code>
60
 * Returns the type in which this member is declared, or <code>null</code>
53
 * if this member is not declared in a type (for example, a top-level type).
61
 * if this member is not declared in a type (for example, a top-level type).
54
 * This is a handle-only method.
62
 * This is a handle-only method.
(-)model/org/eclipse/jdt/core/ICompilationUnit.java (-15 / +1 lines)
Lines 30-36 Link Here
30
 * This interface is not intended to be implemented by clients.
30
 * This interface is not intended to be implemented by clients.
31
 * </p>
31
 * </p>
32
 */
32
 */
33
public interface ICompilationUnit extends IJavaElement, ISourceReference, IParent, IOpenable, IWorkingCopy, ISourceManipulation, ICodeAssist {
33
public interface ICompilationUnit extends IJavaFile, IWorkingCopy, ISourceManipulation {
34
/**
34
/**
35
 * Constant indicating that a reconcile operation should not return an AST.
35
 * Constant indicating that a reconcile operation should not return an AST.
36
 * @since 3.0
36
 * @since 3.0
Lines 286-305 Link Here
286
 */
286
 */
287
IType[] getAllTypes() throws JavaModelException;
287
IType[] getAllTypes() throws JavaModelException;
288
/**
288
/**
289
 * Returns the smallest element within this compilation unit that 
290
 * includes the given source position (that is, a method, field, etc.), or
291
 * <code>null</code> if there is no element other than the compilation
292
 * unit itself at the given position, or if the given position is not
293
 * within the source range of this compilation unit.
294
 *
295
 * @param position a source position inside the compilation unit
296
 * @return the innermost Java element enclosing a given source position or <code>null</code>
297
 *	if none (excluding the compilation unit).
298
 * @throws JavaModelException if the compilation unit does not exist or if an
299
 *		exception occurs while accessing its corresponding resource
300
 */
301
IJavaElement getElementAt(int position) throws JavaModelException;
302
/**
303
 * Returns the first import declaration in this compilation unit with the given name.
289
 * Returns the first import declaration in this compilation unit with the given name.
304
 * This is a handle-only method. The import declaration may or may not exist. This
290
 * This is a handle-only method. The import declaration may or may not exist. This
305
 * is a convenience method - imports can also be accessed from a compilation unit's
291
 * is a convenience method - imports can also be accessed from a compilation unit's
(-)model/org/eclipse/jdt/core/IClassFile.java (-21 / +11 lines)
Lines 32-40 Link Here
32
 * @see IPackageFragmentRoot#attachSource(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath, IProgressMonitor)
32
 * @see IPackageFragmentRoot#attachSource(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath, IProgressMonitor)
33
 */
33
 */
34
 
34
 
35
public interface IClassFile extends IJavaElement, IParent, IOpenable, ISourceReference, ICodeAssist {
35
public interface IClassFile extends IJavaFile {
36
	
36
	
37
/**
37
/**
38
 * @since 3.2
39
 * @deprecated use {@link #getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor)}
40
 */
41
ICompilationUnit becomeWorkingCopy(IProblemRequestor problemRequestor, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException;
42
43
/**
38
 * Changes this class file handle into a working copy. A new {@link IBuffer} is
44
 * Changes this class file handle into a working copy. A new {@link IBuffer} is
39
 * created using the given owner. Uses the primary owner if <code>null</code> is
45
 * created using the given owner. Uses the primary owner if <code>null</code> is
40
 * specified.
46
 * specified.
Lines 56-62 Link Here
56
 * If this class file was already in working copy mode, an internal counter is incremented and no
62
 * If this class file was already in working copy mode, an internal counter is incremented and no
57
 * other action is taken on this working copy. To bring this working copy back into the original mode 
63
 * other action is taken on this working copy. To bring this working copy back into the original mode 
58
 * (where it reflects the underlying resource), {@link ICompilationUnit#discardWorkingCopy} must be call as many 
64
 * (where it reflects the underlying resource), {@link ICompilationUnit#discardWorkingCopy} must be call as many 
59
 * times as {@link #becomeWorkingCopy(IProblemRequestor, WorkingCopyOwner, IProgressMonitor)}.
65
 * times as {@link #getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor)}.
60
 * </p>
66
 * </p>
61
 * <p>
67
 * <p>
62
 * The primary compilation unit of a class file's working copy does not exist if the class file is not
68
 * The primary compilation unit of a class file's working copy does not exist if the class file is not
Lines 66-99 Link Here
66
 * The resource of a class file's working copy is <code>null</code> if the class file is in an external jar file.
72
 * The resource of a class file's working copy is <code>null</code> if the class file is in an external jar file.
67
 * </p>
73
 * </p>
68
 * 
74
 * 
75
 * @param owner the given {@link WorkingCopyOwner}, or <code>null</code> for the primary owner
69
 * @param problemRequestor a requestor which will get notified of problems detected during
76
 * @param problemRequestor a requestor which will get notified of problems detected during
70
 * 	reconciling as they are discovered. The requestor can be set to <code>null</code> indicating
77
 * 	reconciling as they are discovered. The requestor can be set to <code>null</code> indicating
71
 * 	that the client is not interested in problems.
78
 * 	that the client is not interested in problems.
72
 * @param owner the given {@link WorkingCopyOwner}, or <code>null</code> for the primary owner
73
 * @param monitor a progress monitor used to report progress while opening this compilation unit
79
 * @param monitor a progress monitor used to report progress while opening this compilation unit
74
 * 	or <code>null</code> if no progress should be reported 
80
 * 	or <code>null</code> if no progress should be reported 
75
 * @return a working copy for this class file
81
 * @return a working copy for this class file
76
 * @throws JavaModelException if this compilation unit could not become a working copy.
82
 * @throws JavaModelException if this compilation unit could not become a working copy.
77
 * @see ICompilationUnit#discardWorkingCopy()
83
 * @see ICompilationUnit#discardWorkingCopy()
78
 * @since 3.2
84
 * @since 3.3
79
 */
80
ICompilationUnit becomeWorkingCopy(IProblemRequestor problemRequestor, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException;
81
82
/**
83
 * Returns the smallest element within this class file that 
84
 * includes the given source position (a method, field, etc.), or
85
 * <code>null</code> if there is no element other than the class file
86
 * itself at the given position, or if the given position is not
87
 * within the source range of this class file.
88
 *
89
 * @param position a source position inside the class file
90
 * @return the innermost Java element enclosing a given source position or <code>null</code>
91
 *  if none (excluding the class file).
92
 *
93
 * @exception JavaModelException if this element does not exist or if an
94
 *      exception occurs while accessing its corresponding resource
95
 */
85
 */
96
IJavaElement getElementAt(int position) throws JavaModelException;
86
ICompilationUnit getWorkingCopy(WorkingCopyOwner owner, IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException;
97
/**
87
/**
98
 * Returns the type contained in this class file.
88
 * Returns the type contained in this class file.
99
 *
89
 *
(-)model/org/eclipse/jdt/core/IJavaFile.java (+58 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.core;
12
13
import org.eclipse.core.runtime.IProgressMonitor;
14
15
16
/**
17
 * Represents an entire Java type container (either an <code>ICompilationUnit</code>
18
 * or an <code>IClassFile</code>).
19
 * 
20
 * <p>
21
 * This interface is not intended to be implemented by clients.
22
 * </p>
23
 *
24
 * @see ICompilationUnit
25
 * @see IClassFile
26
 * @since 3.3
27
 */
28
public interface IJavaFile extends IJavaElement, IParent, IOpenable, ISourceReference, ICodeAssist {
29
	
30
/* 
31
 * TODO: summarize essence of javadoc from subinterfaces
32
 */
33
ICompilationUnit getWorkingCopy(WorkingCopyOwner owner, IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException;
34
35
/**
36
 * Returns the smallest element within this java file that 
37
 * includes the given source position (that is, a method, field, etc.), or
38
 * <code>null</code> if there is no element other than the java file
39
 * itself at the given position, or if the given position is not
40
 * within the source range of this compilation unit.
41
 *
42
 * @param position a source position inside the java file
43
 * @return the innermost Java element enclosing a given source position or <code>null</code>
44
 *	if none (excluding the java file).
45
 * @throws JavaModelException if the java file does not exist or if an
46
 *	exception occurs while accessing its corresponding resource
47
 */
48
IJavaElement getElementAt(int position) throws JavaModelException;
49
50
/**
51
 * Finds the primary type of this java file (that is, the type with the same name as the
52
 * compilation unit, or the type of a class file), or <code>null</code> if no such a type exists.
53
 * 
54
 * @return the found primary type of this java file, or <code>null</code> if no such a type exists
55
 */
56
IType findPrimaryType();
57
58
}

Return to bug 125504