forked from Haehnchen/idea-php-symfony2-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbstract.java
38 lines (30 loc) · 1.11 KB
/
Abstract.java
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
package fr.adrienbrault.idea.io.File;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.jetbrains.php.lang.psi.PhpPsiElementFactory;
import fr.adrienbrault.idea.io.IFile;
import fr.adrienbrault.idea.symfony2plugin.util.PsiElementUtils;
import java.io.*;
import java.nio.charset.Charset;
public abstract class Abstract implements IFile {
@Override
public PsiFile toPsiFile(Project project) {
/**
* Todo:Check the file type to use the PsiElementFactory for the right Filetype
*/
try {
return PhpPsiElementFactory.createPsiFileFromText(project, this.getContents());
} catch (IOException e) {
return null;
}
}
@Override
public InputStream getInputStream() throws IOException {
InputStream is = new ByteArrayInputStream(this.getContents().getBytes(Charset.forName("UTF-8")));
return is;
}
}