Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 6aecb3a57a831904e8c7b0b588d110af9af12290 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<html>

<head>
<title>JDT Core Porting Guide</title>
</head>

<body>

<h1>JDT Core 3.0 Porting Guide</h1>
<p>Last modified 16:45 CET November 18, 2003</p>

<a name="bug_36987"></a>
<h4>Interface IWorkingCopy (package org.eclipse.jdt.core; plug-in org.eclipse.jdt.core)</h4>
<ul>
	<li>Prior to 3.0, <code>IWorkingCopy</code> gathered all working copy concerns, and <code>ICompilationUnit</code> 
  		implemented this interface. However, though only the factory method made sense for compilation units, they still had to implement
  		the entire working copy contract., which was not relevant to clients (implementation detail).
        <code>IWorkingCopy</code> also implemented the spec'ed factory method, but it didn't work for these.
	</li>
	<li>One possible solution would have been to inverse the hierarchy and make <code>IWorkingCopy</code> implement
	     <code>ICompilationUnit</code>. However as explained in the next <a href="#bug_36888">section</a>, closing the gap 
	     between resource based compilation units and working copies required to merge these two interfaces. As a consequence 
	     the interface <code>IWorkingCopy</code> is removed and all its functionality is merged into <code>ICompilationUnit</code>. 
	</li>
	<li>Clients using <code>IWorkingCopy</code> and <code>ICompilationUnit</code> can adapt to this change by referencing 
	     <code>ICompilationUnit</code> instead of <code>IWorkingCopy</code> when a working copy is needed. For example:
         <pre>
         ICompilationUnit compilationUnit = ...;
         IWorkingCopy workingCopy = (IWorkingCopy)compilationUnit.getWorkingCopy();
         workingCopy.reconcile(true/*force problem detection*/, null/*no progress monitor*/);
         </pre>
         should be converted into:
         <pre>
         ICompilationUnit compilationUnit = ...;
         ICompilationUnit workingCopy = compilationUnit.getWorkingCopy(null/*no progress monitor*/);
         workingCopy.reconcile(true/*force problem detection*/, null/*no progress monitor*/);
         </pre>
	</li>
	<li>To convert usage of <code>IWorkingCopy</code> functionality into usage of <code>ICompilationUnit</code> use this table:
		<p>
		<table BORDER CELLSPACING=2 CELLPADDING=2 >
		<th>IWorkingCopy</th>
		<th>ICompilationUnit</th>
		<th>Note</th>
		<tr>
		<td>commit(boolean, IProgressMonitor)</td>
		<td>commitWorkingCopy(boolean, IProgressMonitor)</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td>destroy()</td>
		<td>discardWorkingCopy()</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td>findElements(IJavaElement)</td>
		<td>findElements(IJavaElement)</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td>findPrimaryType()</td>
		<td>findPrimaryType()</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td>findSharedWorkingCopy(IBufferFactory)</td>
		<td>&nbsp;</td>
		<td>No direct correspondance. See <a href="#bug_36888">next section</a> for details.</td>
		</tr>
		<tr>
		<td>getOriginal(IJavaElement)</td>
		<td>&nbsp;</td>
		<td>Use IJavaElement.getPrimaryElement() instead.</td>
		</tr>
		<tr>
		<td>getOriginalElement()</td>
		<td>getPrimary()</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td>getSharedWorkingCopy(IProgressMonitor, IBufferFactory, IProblemRequestor)</td>
		<td>getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor)</td>
		<td>See <a href="#bug_36888">next section</a> for details.</td>
		</tr>
		<tr>
		<td>getWorkingCopy()</td>
		<td>getWorkingCopy(IProgressMonitor)</td>
		<td>The returned object is no longer an <code>IJavaElement</code> but an <code>ICompilationUnit</code>.</td>
		</tr>
		<tr>
		<td>getWorkingCopy(IProgressMonitor, IBufferFactory, IProblemRequestor)</td>
		<td>&nbsp;</td>
		<td>No direct correspondance. See <a href="#bug_36888">next section</a> for details.</td>
		</tr>
		<tr>
		<td>isBasedOn(IResource)</td>
		<td>hasResourceChanged()</td>
		<td>The IResource was always the working copy's resource. There was no need to pass it in.</td>
		</tr>
		<tr>
		<td>isWorkingCopy()</td>
		<td>isWorkingCopy()</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td>reconcile()</td>
		<td>reconcile(boolean, IProgressMonitor)</td>
		<td>Pass in <code>false</code> to have the equivalent functionality. Note that this method doesn't return anything.</td>
		</tr>
		<tr>
		<td>reconcile(boolean, IProgressMonitor)</td>
		<td>reconcile(boolean, IProgressMonitor)</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td>restore()</td>
		<td>restore()</td>
		<td>&nbsp;</td>
		</tr>
		</table>
		</p>
	</li>
</ul>

<a name="bug_36888"></a>
<h4>Interface ICompilationUnit (package org.eclipse.jdt.core; plug-in org.eclipse.jdt.core)<br>
        (closing the gap between between resource based compilation units and working copies)</h4>
TO DO

</body>

</html>

Back to the top