Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 520b5e5cd9d1a7fd99391423f9cb3d27bd38770f (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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*******************************************************************************
 * Copyright (c) 2000, 2014 QNX Software Systems and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     QNX Software Systems - Initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.core.model;

import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.IProgressMonitor;

/**
 * Represent the root C element corresponding to the workspace.
 * Since there is only one such root element, it is commonly referred to as
 * <em>the</em> C model element.
 * The C model element needs to be opened before it can be navigated or manipulated.
 * The C model element has no parent (it is the root of the C element
 * hierarchy). Its children are {@code ICProject}s.
 * <p>
 * This interface provides methods for performing copy, move, rename, and
 * delete operations on multiple C elements.
 *
 * @see CoreModel#create(org.eclipse.core.resources.IWorkspaceRoot)
 *
 * @noextend This interface is not intended to be extended by clients.
 * @noimplement This interface is not intended to be implemented by clients.
 */
public interface ICModel extends ICElement, IParent, IOpenable {
	/**
	 * Copies the given elements to the specified container(s).
	 * If one container is specified, all elements are copied to that
	 * container. If more than one container is specified, the number of
	 * elements and containers must match, and each element is copied to
	 * its associated container.
	 * <p>
	 * Optionally, each copy can positioned before a sibling
	 * element. If {@code null} is specified for a given sibling, the copy
	 * is inserted as the last child of its associated container.
	 * <p>
	 * Optionally, each copy can be renamed. If
	 * {@code null} is specified for the new name, the copy
	 * is not renamed.
	 * <p>
	 * Optionally, any existing child in the destination container with
	 * the same name can be replaced by specifying {@code true} for
	 * force. Otherwise an exception is thrown in the event that a name
	 * collision occurs.
	 *
	 * @param elements the elements to copy
	 * @param containers the container, or list of containers
	 * @param siblings the list of sibling elements, any of which may be
	 *     {@code null}, or {@code null}
	 * @param renamings the list of new names, any of which may be
	 *     {@code null}, or {@code null}
	 * @param replace {@code true} if any existing child in a target container
	 *     with the target name should be replaced, and {@code false} to throw an
	 *     exception in the event of a name collision
	 * @param monitor a progress monitor
	 * @exception CModelException if an element could not be copied. Reasons include:
	 * <ul>
	 * <li> A specified element, container, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)</li>
	 * <li> A {@code CoreException} occurred while updating an underlying resource
	 * <li> A container is of an incompatible type ({@code INVALID_DESTINATION})
	 * <li> A sibling is not a child of it associated container ({@code INVALID_SIBLING})
	 * <li> A new name is invalid ({@code INVALID_NAME})
	 * <li> A child in its associated container already exists with the same
	 * 		name and {@code replace} has been specified as {@code false}
	 *      ({@code NAME_COLLISION})
	 * <li> A container or element is read-only ({@code READ_ONLY})
	 * </ul>
	 */
	void copy(ICElement[] elements, ICElement[] containers, ICElement[] siblings, String[] renamings, boolean replace,
			IProgressMonitor monitor) throws CModelException;

	/**
	 * Deletes the given elements, forcing the operation if necessary and specified.
	 *
	 * @param elements the elements to delete
	 * @param force a flag controlling whether underlying resources that are not
	 *     in sync with the local file system will be tolerated
	 * @param monitor a progress monitor
	 * @exception CModelException if an element could not be deleted. Reasons include:
	 * <ul>
	 * <li> A specified element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
	 * <li> A {@code CoreException} occurred while updating an underlying resource
	 * <li> An element is read-only ({@code READ_ONLY})
	 * </ul>
	 */
	void delete(ICElement[] elements, boolean force, IProgressMonitor monitor) throws CModelException;

	/**
	 * Moves the given elements to the specified container(s).
	 * If one container is specified, all elements are moved to that
	 * container. If more than one container is specified, the number of
	 * elements and containers must match, and each element is moved to
	 * its associated container.
	 * <p>
	 * Optionally, each element can positioned before a sibling
	 * element. If {@code null} is specified for sibling, the element
	 * is inserted as the last child of its associated container.
	 * <p>
	 * Optionally, each element can be renamed. If
	 * {@code null} is specified for the new name, the element
	 * is not renamed.
	 * <p>
	 * Optionally, any existing child in the destination container with
	 * the same name can be replaced by specifying {@code true} for
	 * force. Otherwise an exception is thrown in the event that a name
	 * collision occurs.
	 *
	 * @param elements the elements to move
	 * @param containers the container, or list of containers
	 * @param siblings the list of siblings element any of which may be
	 *     {@code null}; or {@code null}
	 * @param renamings the list of new names any of which may be
	 *     {@code null}; or {@code null}
	 * @param replace {@code true} if any existing child in a target container
	 *     with the target name should be replaced, and {@code false} to throw an
	 *     exception in the event of a name collision
	 * @param monitor a progress monitor
	 * @exception CModelException if an element could not be moved. Reasons include:
	 * <ul>
	 * <li> A specified element, container, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)</li>
	 * <li> A {@code CoreException} occurred while updating an underlying resource
	 * <li> A container is of an incompatible type ({@code INVALID_DESTINATION})
	 * <li> A sibling is not a child of it associated container ({@code INVALID_SIBLING})
	 * <li> A new name is invalid ({@code INVALID_NAME})
	 * <li> A child in its associated container already exists with the same
	 * 		name and {@code replace} has been specified as {@code false}
	 *      ({@code NAME_COLLISION})
	 * <li> A container or element is read-only ({@code READ_ONLY})
	 * </ul>
	 *
	 * @exception IllegalArgumentException any element or container is {@code null}
	 */
	void move(ICElement[] elements, ICElement[] containers, ICElement[] siblings, String[] renamings, boolean replace,
			IProgressMonitor monitor) throws CModelException;

	/**
	 * Renames the given elements as specified.
	 * If one container is specified, all elements are renamed within that
	 * container. If more than one container is specified, the number of
	 * elements and containers must match, and each element is renamed within
	 * its associated container.
	 *
	 * @param elements the elements to rename
	 * @param destinations the container, or list of containers
	 * @param names the list of new names
	 * @param replace {@code true} if an existing child in a target container
	 *     with the target name should be replaced, and {@code false} to throw an
	 *     exception in the event of a name collision
	 * @param monitor a progress monitor
	 * @exception CModelException if an element could not be renamed. Reasons include:
	 * <ul>
	 * <li> A specified element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
	 * <li> A {@code CoreException} occurred while updating an underlying resource
	 * <li> A new name is invalid ({@code INVALID_NAME})
	 * <li> A child already exists with the same name and {@code replace} has been specified as
	 *      {@code false} ({@code NAME_COLLISION})
	 * <li> An element is read-only ({@code READ_ONLY})
	 * </ul>
	 */
	void rename(ICElement[] elements, ICElement[] destinations, String[] names, boolean replace,
			IProgressMonitor monitor) throws CModelException;

	/**
	 * Returns the C project with the given name. This is a handle-only method.
	 * The project may or may not exist.
	 *
	 * @param name of the project
	 */
	ICProject getCProject(String name);

	/**
	 * Returns the C projects.
	 */
	ICProject[] getCProjects() throws CModelException;

	/**
	 * Returns an array of non-C resources (i.e. non-C projects) in the workspace.
	 * <p>
	 * Non-C projects include all projects that are closed (even if they have the C nature).
	 *
	 * @return an array of non-C projects contained in the workspace.
	 * @throws CModelException if this element does not exist or if an exception occurs
	 *     while accessing its corresponding resource
	 * @since 2.1
	 */
	Object[] getNonCResources() throws CModelException;

	/**
	 * Returns the workspace associated with this C model.
	 */
	IWorkspace getWorkspace();
}

Back to the top