blob: ee5da5334e455db46740a92905fad741367971d8 (
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
|
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.CoreModelUtil;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ISourceEntry;
import org.eclipse.cdt.core.model.ISourceRoot;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
/**
* SourceRoot
*/
public class SourceRoot extends CContainer implements ISourceRoot {
ISourceEntry sourceEntry;
/**
* @param parent
* @param res
*/
public SourceRoot(ICElement parent, IResource res, ISourceEntry entry) {
super(parent, res);
sourceEntry = entry;
IPath path = getPath();
IPath cpath = getParent().getPath();
if (path.segmentCount() > cpath.segmentCount()) {
IPath p = path.removeFirstSegments(cpath.segmentCount());
setElementName(p.toString());
}
}
public ISourceEntry getSourceEntry() {
return sourceEntry;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ISourceRoot#isOnclasspath(org.eclipse.cdt.core.model.ICElement)
*/
public boolean isOnSourceEntry(ICElement element) {
IPath path = element.getPath();
return this.isOnSourceEntry(path);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ISourceRoot#isOnSourceEntry(org.eclipse.core.resources.IResource)
*/
public boolean isOnSourceEntry(IResource res) {
IPath path = res.getFullPath();
return isOnSourceEntry(path);
}
private boolean isOnSourceEntry(IPath path) {
if (sourceEntry.getPath().isPrefixOf(path)
&& !CoreModelUtil.isExcluded(path, sourceEntry.fullExclusionPatternChars())) {
return true;
}
return false;
}
}
|