Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 0fa233ce548e9df851c8ea5c2cf5d7fa9ef5a884 (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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*******************************************************************************
 * Copyright (c) 2000, 2009 IBM Corporation 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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.core.filebuffers;


import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.internal.filebuffers.FileBuffersPlugin;

import org.eclipse.core.runtime.IPath;

import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.source.IAnnotationModel;


/**
 * A text file buffer manager manages text file buffers for files whose contents
 * is considered text.
 * <p>
 * Clients are not supposed to implement that interface.
 * </p>
 *
 * @since 3.0
 * @noimplement This interface is not intended to be implemented by clients.
 * @noextend This interface is not intended to be extended by clients.
 */
public interface ITextFileBufferManager extends IFileBufferManager {

	/**
	 * The default text file buffer manager.
	 * @since 3.3
	 */
	ITextFileBufferManager DEFAULT= FileBuffersPlugin.getDefault().getFileBufferManager();

	/**
	 * Returns the text file buffer managed for the file at the given location
	 * or <code>null</code> if either there is no such text file buffer.
	 * <p>
	 * The provided location is either a full path of a workspace resource or
	 * an absolute path in the local file system. The file buffer manager does
	 * not resolve the location of workspace resources in the case of linked
	 * resources.
	 * </p>
	 *
	 * @param location the location
	 * @return the text file buffer managed for that location or <code>null</code>
	 * @deprecated As of 3.3, replaced by {@link #getTextFileBuffer(IPath, LocationKind)}
	 */
	@Deprecated
	ITextFileBuffer getTextFileBuffer(IPath location);

	/**
	 * Returns the text file buffer managed for the file at the given location
	 * or <code>null</code> if there is no such text file buffer.
	 * <p>
	 * The type of the provided location is specified by the given
	 * <code>locationKind</code>.
	 * </p>
	 *
	 * @param location the location
	 * @param locationKind the kind of the given location
	 * @return the text file buffer managed for that location or <code>null</code>
	 * @see LocationKind
	 * @since 3.3
	 */
	ITextFileBuffer getTextFileBuffer(IPath location, LocationKind locationKind);

	/**
	 * Returns the text file buffer managed for the given file store
	 * or <code>null</code> if there is no such text file buffer.
	 * <p>
	 * <strong>Note:</strong> This API must not be used if the given file
	 * store maps to a resource contained in the workspace. A file buffer
	 * that has been connected using a path will not be found. The encoding
	 * of the file in the workspace will not be considered.
	 * </p>
	 * <p>
	 * We had to use a different name than <code>getTextFileBuffer</code> for this method
	 * due to https://bugs.eclipse.org/bugs/show_bug.cgi?id=148844
	 * </p>
	 *
	 * @param fileStore the file store
	 * @return the text file buffer managed for that file store or <code>null</code>
	 * @since 3.3
	 */
	ITextFileBuffer getFileStoreTextFileBuffer(IFileStore fileStore);

	/**
	 * Returns the text file buffer managed for the given document
	 * or <code>null</code> if there is no such text file buffer.
	 * <p>
	 * <strong>Note:</strong> This method goes through the list
	 * of registered buffers and tests whether its document matches
	 * the given one. Therefore this method should not be used in
	 * performance critical code.
	 * </p>
	 *
	 * @param document the document for which to find the text file buffer
	 * @return the text file buffer managed for that document or <code>null</code>
	 * @since 3.3
	 */
	ITextFileBuffer getTextFileBuffer(IDocument document);

	/**
	 * Returns the default encoding that is used to read the contents of text files
	 * if no other encoding is specified.
	 *
	 * @return the default text file encoding
	 */
	String getDefaultEncoding();

	/**
	 * Creates a new empty document. The document is set up in the same way as it would be used in a
	 * text file buffer for a file at the given location.
	 * <p>
	 * The provided location is either a full path of a workspace resource or an absolute path in
	 * the local file system. The file buffer manager does not resolve the location of workspace
	 * resources in the case of linked resources.
	 * </p>
	 *
	 * @param location the location used to set up the newly created document or <code>null</code>
	 *            if unknown
	 * @return a new empty document
	 * @deprecated As of 3.3, replaced by {@link #createEmptyDocument(IPath, LocationKind)}
	 */
	@Deprecated
	IDocument createEmptyDocument(IPath location);

	/**
	 * Creates a new empty document. The document is set up in the same way as it would be used in a
	 * text file buffer for a file at the given location.
	 * <p>
	 * The type of the provided location is specified by the given <code>locationKind</code>.
	 * </p>
	 *
	 * @param location the location used to set up the newly created document or <code>null</code>
	 *            if unknown
	 * @param locationKind the kind of the given location
	 * @return a new empty document
	 * @since 3.3
	 */
	IDocument createEmptyDocument(IPath location, LocationKind locationKind);

	/**
	 * Creates a new annotation for the given location.
	 * <p>
	 * The provided location is either a full path of a workspace resource or an
	 * absolute path in the local file system. The file buffer manager does not
	 * resolve the location of workspace resources in the case of linked
	 * resources.
	 * </p>
	 *
	 * @param location the location used to create the new annotation model
	 * @return the newly created annotation model
	 * @deprecated As of 3.3, replaced by {@link #createAnnotationModel(IPath, LocationKind)}
	 */
	@Deprecated
	IAnnotationModel createAnnotationModel(IPath location);

	/**
	 * Creates a new annotation for the given location.
	 * <p>
	 * The type of the provided location is specified by the given
	 * <code>locationKind</code>.
	 * </p>
	 *
	 * @param location the location used to create the new annotation model
	 * @param locationKind the kind of the given location
	 * @return the newly created annotation model
	 * @since 3.3
	 */
	IAnnotationModel createAnnotationModel(IPath location, LocationKind locationKind);

	/**
	 * Returns whether a file at the given location is or can be considered a
	 * text file. If the file exists, the concrete content type of the file is
	 * checked. If the concrete content type for the existing file can not be
	 * determined, this method returns <code>true</code>. If the file does
	 * not exist, it is checked whether a text content type is associated with
	 * the given location. If no content type is associated with the location,
	 * this method returns <code>true</code>.
	 * <p>
	 * The provided location is either a full path of a workspace resource or an
	 * absolute path in the local file system. The file buffer manager does not
	 * resolve the location of workspace resources in the case of linked
	 * resources.
	 * </p>
	 *
	 * @param location the location to check
	 * @return <code>true</code> if the location is a text file location
	 * @since 3.1
	 * @deprecated As of 3.2, replaced by {@link #isTextFileLocation(IPath, boolean)}
	 */
	@Deprecated
	boolean isTextFileLocation(IPath location);
	/**
	 * Returns whether a file at the given location is or can be considered a
	 * text file. If the file exists, the concrete content type of the file is
	 * checked. If the concrete content type for the existing file can not be
	 * determined, this method returns <code>!strict</code>. If the file does
	 * not exist, it is checked whether a text content type is associated with
	 * the given location. If no content type is associated with the location,
	 * this method returns <code>!strict</code>.
	 * <p>
	 * The provided location is either a full path of a workspace resource or an
	 * absolute path in the local file system. The file buffer manager does not
	 * resolve the location of workspace resources in the case of linked
	 * resources.
	 * </p>
	 *
	 * @param location	the location to check
	 * @param strict	<code>true</code> if a file with unknown content type
	 * 					is not treated as text file, <code>false</code> otherwise
	 * @return <code>true</code> if the location is a text file location
	 * @since 3.2
	 */
	boolean isTextFileLocation(IPath location, boolean strict);
}

Back to the top