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

Collapse All | Expand All

(-).settings/org.eclipse.jdt.core.prefs (-6 / +6 lines)
Lines 1-12 Link Here
1
#Thu Oct 05 16:52:57 CEST 2006
1
#Mon Oct 22 11:36:09 EDT 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6
org.eclipse.jdt.core.compiler.compliance=1.4
6
org.eclipse.jdt.core.compiler.compliance=1.5
7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8
org.eclipse.jdt.core.compiler.debug.localVariable=generate
9
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
11
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
11
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12
org.eclipse.jdt.core.compiler.source=1.4
12
org.eclipse.jdt.core.compiler.source=1.5
(-).settings/org.eclipse.jdt.ui.prefs (-3 lines)
Removed Link Here
1
#Thu Oct 05 16:52:57 CEST 2006
2
eclipse.preferences.version=1
3
internal.default.compliance=user
(-).classpath (+1 lines)
Lines 6-11 Link Here
6
	<classpathentry kind="src" path="utils"/>
6
	<classpathentry kind="src" path="utils"/>
7
	<classpathentry kind="src" path="parser"/>
7
	<classpathentry kind="src" path="parser"/>
8
	<classpathentry kind="src" path="templateengine"/>
8
	<classpathentry kind="src" path="templateengine"/>
9
	<classpathentry kind="src" path="remote"/>
9
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
10
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
10
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
11
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
11
	<classpathentry kind="output" path="bin"/>
12
	<classpathentry kind="output" path="bin"/>
(-)remote/org/eclipse/cdt/core/remote/IUniversalPath.java (+570 lines)
Added Link Here
1
package org.eclipse.cdt.core.remote;
2
3
import java.net.URI;
4
5
import org.eclipse.core.resources.IResource;
6
import org.eclipse.core.runtime.IPath;
7
import org.eclipse.core.runtime.Path;
8
9
/**
10
 * 
11
 * <p>
12
 * A universal representation of local and remote paths, which provides path manipulation facilities.
13
 * </p>
14
 * <p>
15
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
16
 * part of a work in progress. There is no guarantee that this API will work or
17
 * that it will remain the same. Please do not use this API without consulting
18
 * with the author.
19
 * </p>
20
 * <p>
21
 * This interface essentially bridges local paths and URIs that represent paths.
22
 * </p>
23
 * <p>
24
 * A path is an ordered collection of string segments, separated by a separator character
25
 * (either a forward slash or a backslash depending upon the path format).
26
 * A path may also have a leading and/or a trailing separator.
27
 * Paths may also be prefixed by an optional device id, which includes
28
 * the character(s) which separate the device id from the rest 
29
 * of the path. For example, "C:" and "Server/Volume:" are typical
30
 * device ids.
31
 * A device independent path has <code>null</code> for a device id.
32
 * </p>
33
 * <p>
34
 * Note that paths are value objects; all operations on paths 
35
 * return a new path; the path that is operated on is unscathed.
36
 * </p>
37
 * <p>
38
 * UNC paths are denoted by leading double-slashes such 
39
 * as <code>//Server/Volume/My/Path</code>. When a new path
40
 * is constructed all double-slashes are removed except those
41
 * appearing at the beginning of the path.
42
 * 
43
 * @author crecoskie
44
 * @see java.net.URI
45
 *
46
 */
47
public interface IUniversalPath {
48
	
49
	/**
50
	 * Encapsulates possible formats for paths.  Paths can be either UNIX or Windows format.
51
	 *
52
	 */
53
	public enum Format {
54
		/**
55
		 * Constant indicating that this path is in UNIX format.  I.e., it has no device id, and
56
		 * the path separator is the forward slash character.
57
		 */
58
		FORMAT_UNIX,
59
		
60
		/**
61
		 * Constant indicating that this path is in Windows format.  I.e., it can have a device id, and
62
		 * the path separator is the backslash character.
63
		 */
64
		FORMAT_WINDOWS
65
	}
66
	
67
	/**
68
	 * Returns the canonicalized path obtained from the 
69
	 * concatenation of the given path's segments to the
70
	 * end of this path.  If the given path has a trailing
71
	 * separator, the result will have a trailing separator.
72
	 * The device id of this path is preserved (the one
73
	 * of the given path is ignored). Duplicate slashes
74
	 * are removed from the path except at the beginning
75
	 * where the path is considered to be UNC.
76
	 *
77
	 * @param path the path to concatenate
78
	 * @return the new path
79
	 */
80
	public IUniversalPath append(IUniversalPath tail);
81
	
82
	/**
83
	 * Returns the canonicalized path obtained from the
84
	 * concatenation of the given string path to the
85
	 * end of this path. The given string path must be a valid
86
	 * path. If it has a trailing separator, 
87
	 * the result will have a trailing separator.
88
	 * The device id of this path is preserved (the one
89
	 * of the given string is ignored). Duplicate slashes
90
	 * are removed from the path except at the beginning
91
	 * where the path is considered to be UNC.
92
	 * 
93
	 * @param path the string path to concatenate
94
	 * @return the new path
95
	 * @see #isValidPath(String)
96
	 */
97
	public IUniversalPath append(String path);
98
	
99
	/**
100
	 * Returns the device id for this path, or <code>null</code> if this
101
	 * path has no device id. Note that the result will end in ':'.
102
	 *
103
	 * @return the device id, or <code>null</code>
104
	 * @see #setDevice(String)
105
	 */
106
	public String getDevice();
107
	
108
	/**
109
	 * Returns the file extension portion of this path, 
110
	 * or <code>null</code> if there is none.
111
	 * <p>
112
	 * The file extension portion is defined as the string
113
	 * following the last period (".") character in the last segment.
114
	 * If there is no period in the last segment, the path has no
115
	 * file extension portion. If the last segment ends in a period,
116
	 * the file extension portion is the empty string.
117
	 * </p>
118
	 *
119
	 * @return the file extension or <code>null</code>
120
	 */
121
	public String getFileExtension();
122
	
123
	/**
124
	 * Returns the format for native paths on the local machine.
125
	 * 
126
	 * @return Format.FORMAT_WINDOWS if native paths are in Windows format, Format.FORMAT_UNIX otherwise 
127
	 */
128
	public Format getLocalPathFormat();
129
	
130
	
131
	/**
132
	 * Returns the format of this path as it would be represented on the targeted machine.
133
	 * The targeted machine might be local or remote.
134
	 * 
135
	 * @return Format.FORMAT_WINDOWS if this path represents a Windows path, Format.FORMAT_UNIX otherwise.
136
	 */
137
	public Format getTargetPathFormat();
138
	
139
		
140
	/**
141
	 * Gets only the filesystem specific part of the path, in the context of the target.
142
	 * The target's path format is used to format the string.
143
	 * 
144
	 * <p>
145
	 * Example:
146
	 * </p>
147
	 * <p>
148
	 * Original path:  <code>rse://remoteMachine/home/youraccount/foo/bar.cpp</code>
149
	 * </p>
150
	 * <p>
151
	 * Format:  <code>Format.FORMAT_UNIX</code>
152
	 * </p>
153
	 * <p>Result: <code>/home/youraccount/foo/bar.cpp</code>
154
	 * </p>
155
	 * 
156
	 * Example:
157
	 * </p>
158
	 * <p>
159
	 * Original path:  <code>file://C%30/foo/bar.cpp</code>
160
	 * </p>
161
	 * <p>
162
	 * Format: <code>Format.FORMAT_WINDOWS</code>
163
	 * </p>  
164
	 * <p>Result: <code>C:\foo\bar.cpp</code>
165
	 * </p>
166
	 * 
167
	 * @return a <code>String</code> corresponding to the target path
168
	 */
169
	public String getTargetPathString();
170
	
171
	/**
172
	 * Gets the path relative to the workspace.
173
	 * 
174
	 * @return an IResource corresponding to the path's location in the workspace, or
175
	 * <code>null</code> if this path is not represented in the workspace.
176
	 * 
177
	 */
178
	public IResource getWorkspaceResource();
179
	
180
	/**
181
	 * Returns whether this path has a trailing separator.
182
	 * <p>
183
	 * Note: In the root path ("/"), the separator is considered to
184
	 * be leading rather than trailing.
185
	 * </p>
186
	 *
187
	 * @return <code>true</code> if this path has a trailing
188
	 *    separator, and <code>false</code> otherwise
189
	 * @see #addTrailingSeparator()
190
	 * @see #removeTrailingSeparator()
191
	 */
192
	public boolean hasTrailingSeparator();
193
	
194
	
195
	/**
196
	 * Returns whether this path is an absolute path (ignoring
197
	 * any device id).
198
	 * <p>
199
	 * Absolute paths start with a path separator.
200
	 * A root path, like <code>/</code> or <code>C:/</code>, 
201
	 * is considered absolute.  UNC paths are always absolute.
202
	 * </p>
203
	 *
204
	 * @return <code>true</code> if this path is an absolute path,
205
	 *    and <code>false</code> otherwise
206
	 */
207
	public boolean isAbsolute();
208
	
209
	/**
210
	 * Returns whether this path has no segments and is not
211
	 * a root path.
212
	 *
213
	 * @return <code>true</code> if this path is empty,
214
	 *    and <code>false</code> otherwise
215
	 */
216
	public boolean isEmpty();
217
	
218
	/**
219
	 * @return true if the path corresponds to the local machine's native filesystem, false otherwise.
220
	 */
221
	public boolean isLocal();
222
	
223
	/**
224
	 * Returns whether this path is a prefix of the given path.
225
	 * To be a prefix, this path's segments must
226
	 * appear in the argument path in the same order,
227
	 * and their device ids must match.
228
	 * <p>
229
	 * An empty path is a prefix of all paths with the same device; a root path is a prefix of 
230
	 * all absolute paths with the same device.
231
	 * </p>
232
	 * @param anotherPath the other path
233
	 * @return <code>true</code> if this path is a prefix of the given path,
234
	 *    and <code>false</code> otherwise
235
	 */
236
	public boolean isPrefixOf(IUniversalPath anotherPath);
237
	
238
	/**
239
	 * Returns whether this path is a root path.
240
	 * <p>
241
	 * The root path is the absolute non-UNC path with zero segments; 
242
	 * e.g., <code>/</code> or <code>C:/</code>.
243
	 * The separator is considered a leading separator, not a trailing one.
244
	 * </p>
245
	 *
246
	 * @return <code>true</code> if this path is a root path,
247
	 *    and <code>false</code> otherwise
248
	 */
249
	public boolean isRoot();
250
	
251
	/**
252
	 * Returns a boolean value indicating whether or not this path
253
	 * is considered to be in UNC form. Return false if this path
254
	 * has a device set or if the first 2 characters of the path string
255
	 * are not <code>Path.SEPARATOR</code>.
256
	 * 
257
	 * @return boolean indicating if this path is UNC
258
	 */
259
	public boolean isUNC();
260
	
261
	/**
262
	 * Returns whether the given string is syntactically correct as
263
	 * a universal path.
264
	 * 
265
	 *   
266
	 * The device id is the prefix up to and including the device
267
	 * separator for the local file system; the path proper is everything to 
268
	 * the right of it, or the entire string if there is no device separator. 
269
	 * When the platform location is a file system with no meaningful device
270
	 * separator, the entire string is treated as the path proper.
271
	 * The device id is not checked for validity; the path proper is correct 
272
	* if each of the segments in its canonicalized form is valid.
273
	 *
274
	 * @param path the path to check
275
	 * @return <code>true</code> if the given string is a valid path,
276
	 *    and <code>false</code> otherwise
277
	 * @see #isValidSegment(String)
278
	 */
279
	public boolean isValidPath(String path);
280
	
281
	/**
282
	 * Returns whether the given string is valid as a segment in 
283
	 * a path. The rules for valid segments are as follows:
284
	 * <ul>
285
	 * <li> the empty string is not valid
286
	 * <li> any string containing the slash character ('/') is not valid
287
	 * <li>any string containing segment or device separator characters
288
	 * on the local file system, such as the backslash ('\') and colon (':')
289
	 * on some file systems.
290
	 * </ul>
291
	 *
292
	 * @param segment the path segment to check
293
	 * @return <code>true</code> if the given path segment is valid,
294
	 *    and <code>false</code> otherwise
295
	 */
296
	public boolean isValidSegment(String segment);
297
298
	/**
299
	 * Returns the last segment of this path, or
300
	 * <code>null</code> if it does not have any segments.
301
	 *
302
	 * @return the last segment of this path, or <code>null</code> 
303
	 */
304
	public String lastSegment();
305
	
306
	/**
307
	 * Returns an absolute path with the segments and device id of this path.
308
	 * Absolute paths start with a path separator. If this path is absolute, 
309
	 * it is simply returned.
310
	 *
311
	 * @return the new path
312
	 */
313
	public IUniversalPath makeAbsolute();
314
315
	/**
316
	 * Returns a relative path with the segments and device id of this path.
317
	 * Absolute paths start with a path separator and relative paths do not. 
318
	 * If this path is relative, it is simply returned.
319
	 *
320
	 * @return the new path
321
	 */
322
	public IUniversalPath makeRelative();
323
324
	/**
325
	 * Return a new path which is the equivalent of this path converted to UNC
326
	 * form (if the given boolean is true) or this path not as a UNC path (if the given
327
	 * boolean is false). If UNC, the returned path will not have a device and the 
328
	 * first 2 characters of the path string will be <code>Path.SEPARATOR</code>. If not UNC, the
329
	 * 	first 2 characters of the returned path string will not be <code>Path.SEPARATOR</code>.
330
	 * 
331
	 * @param toUNC true if converting to UNC, false otherwise
332
	 * @return the new path, either in UNC form or not depending on the boolean parameter
333
	 */
334
	public IUniversalPath makeUNC(boolean toUNC);
335
336
	/**
337
	 * Returns a count of the number of segments which match in
338
	 * this path and the given path (device ids are ignored),
339
	 * comparing in increasing segment number order.
340
	 *
341
	 * @param anotherPath the other path
342
	 * @return the number of matching segments
343
	 */
344
	public int matchingFirstSegments(IUniversalPath anotherPath);
345
346
	/**
347
	 * Returns a new path which is the same as this path but with
348
	 * the file extension removed.  If this path does not have an 
349
	 * extension, this path is returned.
350
	 * <p>
351
	 * The file extension portion is defined as the string
352
	 * following the last period (".") character in the last segment.
353
	 * If there is no period in the last segment, the path has no
354
	 * file extension portion. If the last segment ends in a period,
355
	 * the file extension portion is the empty string.
356
	 * </p>
357
	 *
358
	 * @return the new path
359
	 */
360
	public IUniversalPath removeFileExtension();
361
362
	/**
363
	 * Returns a copy of this path with the given number of segments
364
	 * removed from the beginning. The device id is preserved. 
365
	 * The number must be greater or equal zero.
366
	 * If the count is zero, this path is returned.
367
	 * The resulting path will always be a relative path with respect
368
	 * to this path.  If the number equals or exceeds the number
369
	 * of segments in this path, an empty relative path is returned.
370
	 *
371
	 * @param count the number of segments to remove
372
	 * @return the new path
373
	 */
374
	public IUniversalPath removeFirstSegments(int count);
375
376
	/**
377
	 * Returns a copy of this path with the given number of segments
378
	 * removed from the end. The device id is preserved.
379
	 * The number must be greater or equal zero.
380
	 * If the count is zero, this path is returned.
381
	 * <p>
382
	 * If this path has a trailing separator, it will still
383
	 * have a trailing separator after the last segments are removed
384
	 * (assuming there are some segments left).  If there is no
385
	 * trailing separator, the result will not have a trailing
386
	 * separator.
387
	 * If the number equals or exceeds the number
388
	 * of segments in this path, a path with no segments is returned.
389
	 * </p>
390
	 *
391
	 * @param count the number of segments to remove
392
	 * @return the new path
393
	 */
394
	public IUniversalPath removeLastSegments(int count);
395
396
	/**
397
	 * Returns a path with the same segments as this path
398
	 * but with a trailing separator removed.
399
	 * Does nothing if this path does not have at least one segment.
400
	 * The device id is preserved.
401
	 * <p>
402
	 * If this path does not have a trailing separator,
403
	 * this path is returned.
404
	 * </p>
405
	 *
406
	 * @return the new path
407
	 * @see #addTrailingSeparator()
408
	 * @see #hasTrailingSeparator()
409
	 */
410
	public IUniversalPath removeTrailingSeparator();
411
412
	/**
413
	 * Returns the specified segment of this path, or
414
	 * <code>null</code> if the path does not have such a segment.
415
	 *
416
	 * @param index the 0-based segment index
417
	 * @return the specified segment, or <code>null</code> 
418
	 */
419
	public String segment(int index);
420
421
	/**
422
	 * Returns the number of segments in this path.
423
	 * <p> 
424
	 * Note that both root and empty paths have 0 segments.
425
	 * </p>
426
	 *
427
	 * @return the number of segments
428
	 */
429
	public int segmentCount();
430
431
	/**
432
	 * Returns the segments in this path in order.
433
	 *
434
	 * @return an array of string segments
435
	 */
436
	public String[] segments();
437
438
	/**
439
	 * Returns a new path which is the same as this path but with 
440
	 * the given device id.  The device id must end with a ":".
441
	 * A device independent path is obtained by passing <code>null</code>.
442
	 * <p>
443
	 * For example, "C:" and "Server/Volume:" are typical device ids.
444
	 * </p>
445
	 *
446
	 * @param device the device id or <code>null</code>
447
	 * @return a new path
448
	 * @see #getDevice()
449
	 */
450
	public IUniversalPath setDevice(String device);
451
452
	/**
453
	 * Sets the format of this path as it would be represented on the targeted machine.
454
	 * The targeted machine might be local or remote.
455
	 * 
456
	 * @param format - Format of the path
457
	 * @return a new universal path with the specified format.
458
	 */
459
	public IUniversalPath setTargetPathFormat(Format format);
460
461
	/**
462
	 * Sets up a mapping between this path and a path in the workspace.  This does not in any way
463
	 * setup a link in the workspace itself or otherwise indicate to any of the workspace's resource
464
	 * management facilities that such a mapping exists.
465
	 * 
466
	 * @param resource - the resource in the workspace to map to.
467
	 * @return a new path with the appropriate mapping set.
468
	 */
469
	public IUniversalPath setWorkspaceResource(IResource resource);
470
	
471
	/**
472
	 * Returns a string representation of this path which uses the
473
	 * platform-dependent path separator defined by <code>java.io.File</code> corresponding
474
	 * to the local execution environment.
475
	 * @return a platform-dependent string representation of this path
476
	 */
477
	public String toOSString();
478
	
479
	
480
	/**
481
	 * Returns a platform-neutral string representation of this path. The 
482
	 * format is not specified, except that the resulting string can be 
483
	 * passed back to the <code>Path#fromPortableString(String)</code> 
484
	 * constructor to produce the exact same path on any platform.
485
	 * <p>
486
	 * This string is suitable for passing to <code>Path#fromPortableString(String)</code>.
487
	 * </p>
488
	 *
489
	 * @return a platform-neutral string representation of this path
490
	 * @see Path#fromPortableString(String)
491
	 * @since 3.1
492
	 */
493
	public String toPortableString();
494
495
	/**
496
	 * Returns a string representation of this path, suitable for display in the UI.
497
	 * 
498
	 * In the case of local paths, this will be a path in the local filesystem, including any device id.
499
	 * The scheme portion of the URI is not displayed for local files (i.e. c:/foo not file://c:/foo
500
	 * 
501
	 * For non-local files, the full URI of the file will be displayed.
502
	 * 
503
	 * @return a string representation of this path
504
	 */
505
	public String toString();
506
507
	/**
508
	 * Returns a string representing the path in the given format
509
	 * 
510
	 * @param format - either Format.FORMAT_UNIX or Format.FORMAT_WINDOWS
511
	 * @return
512
	 */
513
	public String toStringInFormat(Format format);
514
515
	/**
516
	 * Converts this path to a relative path in the context of the target.
517
	 * 
518
	 * <p>Example:</p>
519
	 * 
520
	 * <p>Original path:  <code>rse://remoteMachine/home/youraccount/foo/bar.cpp</code></p>
521
	 * 
522
	 * <p>pathRelativeTo:  <code>/home/yourAccount</code></p>
523
	 * 
524
	 * <p>Result:  <code>foo/bar.cpp</code></p>
525
	 * 
526
	 * @param uriRelativeTo - The URI which the path should be relative to
527
	 * @return A universal path relative to the given location
528
	 */
529
	public IUniversalPath toTargetRelativePath(IUniversalPath pathRelativeTo);
530
	
531
	/**
532
	 * Converts this path to a URI.  The URI may be absolute or relative depending upon whether or not the path
533
	 * is absolute or relative.
534
	 * 
535
	 * <p>
536
	 * In the case of local paths, path separators are converted to URI format (forward slashes),
537
	 * but any other characters which are not legally allowed in the path portion of the URI are escaped.
538
	 * E.g., in the case of paths targeting Windows systems, the URI may potentially contain an escaped colon
539
	 * corresponding to the device id.  E.g., <code>C:\foo\bar</code> becomes <code>file://C%30/foo/bar</code>.
540
	 * </p>
541
	 * 
542
	 * <p>
543
	 * This will return a URI mapping to the local filesystem (file://...) if the path is local and absolute
544
	 * (i.e. both <code>isLocal()</code> and <code>isAbsolute()</code> return true).
545
	 * </p>
546
	 * 
547
	 * @return a URI representing the path, or <code>null</code> if the path is empty. 
548
	 * 
549
	 */
550
	public URI toURI();
551
	
552
	/**
553
	 * Returns a copy of this path truncated after the
554
	 * given number of segments. The number must not be negative.
555
	 * The device id is preserved.
556
	 * <p>
557
	 * If this path has a trailing separator, the result will too
558
	 * (assuming there are some segments left). If there is no
559
	 * trailing separator, the result will not have a trailing
560
	 * separator.
561
	 * Copying up to segment zero simply means making an copy with
562
	 * no path segments.
563
	 * </p>
564
	 *
565
	 * @param count the segment number at which to truncate the path
566
	 * @return the new path
567
	 */
568
	public IUniversalPath uptoSegment(int count);
569
	
570
}

Return to bug 207078