blob: 76b152f2f567ca6d4af6d195e7c3c498b4ab4f78 (
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
|
/*******************************************************************************
* Copyright (c) 2009, 2012 Wind River Systems, Inc. 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:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser;
import java.io.IOException;
import org.eclipse.cdt.core.index.IIndexFileLocation;
import org.eclipse.cdt.core.parser.IncludeFileContentProvider;
import org.eclipse.cdt.internal.core.dom.AbstractCodeReaderFactory;
import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContentProvider;
import org.eclipse.core.runtime.CoreException;
@Deprecated
public class CodeReaderFactoryAdapter extends AbstractCodeReaderFactory {
/**
* @deprecated avoid using the adapter, its for backwards compatibility, only.
*/
@Deprecated
public static org.eclipse.cdt.core.dom.ICodeReaderFactory adapt(IncludeFileContentProvider fileCreator) {
if (fileCreator == null)
return null;
if (!(fileCreator instanceof InternalFileContentProvider))
throw new IllegalArgumentException("Invalid file content provider"); //$NON-NLS-1$
if (fileCreator instanceof FileContentProviderAdapter) {
return ((FileContentProviderAdapter) fileCreator).getCodeReaderFactory();
}
return new CodeReaderFactoryAdapter((InternalFileContentProvider) fileCreator);
}
private InternalFileContentProvider fDelegate;
private CodeReaderFactoryAdapter(InternalFileContentProvider fcp) {
super(fcp.getIncludeHeuristics());
fDelegate= fcp;
}
@Override
public org.eclipse.cdt.core.parser.CodeReader createCodeReaderForInclusion(String path) {
return CodeReaderAdapter.adapt(fDelegate.getContentForInclusion(path, null));
}
@Override
public org.eclipse.cdt.core.parser.CodeReader createCodeReaderForInclusion(IIndexFileLocation ifl, String astPath)
throws CoreException, IOException {
return CodeReaderAdapter.adapt(fDelegate.getContentForInclusion(ifl, astPath));
}
@Override
public org.eclipse.cdt.core.parser.CodeReader createCodeReaderForTranslationUnit(String path) {
return CodeReaderAdapter.adapt(fDelegate.getContentForInclusion(path, null));
}
@Override
@Deprecated
public org.eclipse.cdt.core.parser.ICodeReaderCache getCodeReaderCache() {
return null;
}
@Override
public int getUniqueIdentifier() {
return 0;
}
public InternalFileContentProvider getFileContentProvider() {
return fDelegate;
}
}
|