blob: 660e7bc9f52e689fefe11081e84bd173bdf88ff0 (
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
|
/*******************************************************************************
* Copyright (c) 2007 BEA Systems, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* wharley@bea.com - initial API and implementation
*
*******************************************************************************/
package org.eclipse.jdt.internal.apt.pluggable.core.filer;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.net.URI;
import java.util.Collection;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.NestingKind;
import javax.tools.JavaFileObject;
import org.eclipse.core.resources.IFile;
import org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeProcessingEnvImpl;
/**
* Implementation of JavaFileObject used for Java 6 annotation processing within the IDE.
* This object is used only for writing source and class files.
*
* @since 3.3
*/
public class IdeOutputJavaFileObject extends IdeOutputFileObject implements JavaFileObject {
private final IdeProcessingEnvImpl _env;
private final CharSequence _name;
private final Collection<IFile> _parentFiles;
public IdeOutputJavaFileObject(IdeProcessingEnvImpl env, CharSequence name, Collection<IFile> parentFiles) {
_env = env;
_parentFiles = parentFiles;
_name = name;
}
@Override
public Modifier getAccessLevel() {
//TODO
throw new UnsupportedOperationException("Not yet implemented");
}
/* (non-Javadoc)
* @see javax.tools.JavaFileObject#getKind()
*/
@Override
public Kind getKind() {
//TODO
throw new UnsupportedOperationException("Not yet implemented");
}
/* (non-Javadoc)
* @see javax.tools.FileObject#getName()
*/
@Override
public String getName() {
return _name.toString();
}
@Override
public NestingKind getNestingKind() {
//TODO
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public boolean isNameCompatible(String simpleName, Kind kind) {
//TODO
throw new UnsupportedOperationException("Not yet implemented");
}
/* (non-Javadoc)
* @see javax.tools.FileObject#openOutputStream()
*/
@Override
public OutputStream openOutputStream() throws IOException {
return new IdeJavaSourceOutputStream(_env, _name, _parentFiles);
}
/* (non-Javadoc)
* @see javax.tools.FileObject#openWriter()
*/
@Override
public Writer openWriter() throws IOException {
return new PrintWriter(openOutputStream());
}
/* (non-Javadoc)
* @see javax.tools.FileObject#toUri()
* The file does not exist until its writer is closed, so the URI we are
* constructing here does not point to a real resource.
*/
@Override
public URI toUri() {
IFile file = _env.getAptProject().getGeneratedFileManager().getIFileForTypeName(_name.toString());
return file.getLocationURI();
}
}
|