|
| 1 | +/* |
| 2 | + * Copyright (C) 2020 Bence Sipka |
| 3 | + * |
| 4 | + * This program is free software: you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU General Public License as published by |
| 6 | + * the Free Software Foundation, version 3. |
| 7 | + * |
| 8 | + * This program is distributed in the hope that it will be useful, |
| 9 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | + * GNU General Public License for more details. |
| 12 | + * |
| 13 | + * You should have received a copy of the GNU General Public License |
| 14 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | + */ |
| 16 | +package saker.java.compiler.jdk.impl; |
| 17 | + |
| 18 | +import java.util.Collections; |
| 19 | +import java.util.List; |
| 20 | + |
| 21 | +import javax.lang.model.element.Element; |
| 22 | +import javax.lang.model.element.TypeElement; |
| 23 | +import javax.lang.model.type.TypeMirror; |
| 24 | +import javax.lang.model.util.Elements; |
| 25 | +import javax.tools.JavaFileManager; |
| 26 | +import javax.tools.StandardJavaFileManager; |
| 27 | + |
| 28 | +import com.sun.source.tree.CompilationUnitTree; |
| 29 | +import com.sun.source.util.Trees; |
| 30 | + |
| 31 | +import saker.build.thirdparty.saker.rmi.connection.RMITransferProperties; |
| 32 | +import saker.java.compiler.impl.compile.file.IncrementalDirectoryPaths; |
| 33 | +import saker.java.compiler.impl.compile.handler.info.RealizedSignatureData; |
| 34 | +import saker.java.compiler.impl.compile.handler.invoker.CompilationContextInformation; |
| 35 | +import saker.java.compiler.impl.compile.signature.parser.ParserCache; |
| 36 | +import saker.java.compiler.jdk.impl.incremental.model.IncrementalElementsTypes; |
| 37 | +import saker.java.compiler.jdk.impl.parser.signature.CompilationUnitSignatureParser; |
| 38 | +import saker.java.compiler.jdk.impl.parser.usage.AbiUsageParser; |
| 39 | +import saker.java.compiler.util12.impl.Java12LanguageUtils; |
| 40 | +import saker.java.compiler.util13.impl.Java13LanguageUtils; |
| 41 | +import saker.java.compiler.util14.impl.Java14LanguageUtils; |
| 42 | +import saker.java.compiler.util15.impl.Java15LanguageUtils; |
| 43 | +import saker.java.compiler.util8.impl.Java8LanguageUtils; |
| 44 | +import saker.java.compiler.util9.impl.Java9LanguageUtils; |
| 45 | +import saker.java.compiler.util9.impl.file.IncrementalJavaFileManager9; |
| 46 | + |
| 47 | +public class JavaCompilationUtils { |
| 48 | + private JavaCompilationUtils() { |
| 49 | + throw new UnsupportedOperationException(); |
| 50 | + } |
| 51 | + |
| 52 | + public static CompilationUnitSignatureParser createSignatureParser(Trees trees, String srcver, ParserCache cache) { |
| 53 | + return new CompilationUnitSignatureParser(trees, srcver, cache); |
| 54 | + } |
| 55 | + |
| 56 | + public static AbiUsageParser createAbiUsageParser(Trees trees, String srcver, ParserCache cache) { |
| 57 | + return new AbiUsageParser(trees, srcver, cache); |
| 58 | + } |
| 59 | + |
| 60 | + public static IncrementalElementsTypes createElementsTypes(Elements realelements, Object javacsync, |
| 61 | + CompilationContextInformation context, ParserCache cache) { |
| 62 | + return new IncrementalElementsTypes(realelements, javacsync, cache, context); |
| 63 | + } |
| 64 | + |
| 65 | + public static RealizedSignatureData getRealizedSignatures(CompilationUnitTree unit, Trees trees, String filename, |
| 66 | + ParserCache cache) { |
| 67 | + return Java9LanguageUtils.getRealizedSignatures(unit, trees, filename, cache); |
| 68 | + } |
| 69 | + |
| 70 | + public static JavaFileManager createFileManager(StandardJavaFileManager stdfilemanager, |
| 71 | + IncrementalDirectoryPaths directorypaths) { |
| 72 | + return new IncrementalJavaFileManager9(stdfilemanager, directorypaths); |
| 73 | + } |
| 74 | + |
| 75 | + public static void applyRMIProperties(RMITransferProperties.Builder builder) { |
| 76 | + Java8LanguageUtils.applyRMIProperties(builder); |
| 77 | + Java9LanguageUtils.applyRMIProperties(builder); |
| 78 | + Java12LanguageUtils.applyRMIProperties(builder); |
| 79 | + Java13LanguageUtils.applyRMIProperties(builder); |
| 80 | + Java14LanguageUtils.applyRMIProperties(builder); |
| 81 | + Java15LanguageUtils.applyRMIProperties(builder); |
| 82 | + } |
| 83 | + |
| 84 | + public static String getModuleNameOf(Element elem) { |
| 85 | + return Java9LanguageUtils.getModuleNameOf(elem); |
| 86 | + } |
| 87 | + |
| 88 | + public static List<? extends TypeMirror> getPermittedSubclasses(TypeElement elem) { |
| 89 | + return elem.getPermittedSubclasses(); |
| 90 | + } |
| 91 | +} |
0 commit comments