本文整理汇总了Java中com.intellij.openapi.roots.CompilerProjectExtension.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java CompilerProjectExtension.getInstance方法的具体用法?Java CompilerProjectExtension.getInstance怎么用?Java CompilerProjectExtension.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.roots.CompilerProjectExtension
的用法示例。
在下文中一共展示了CompilerProjectExtension.getInstance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compile
import com.intellij.openapi.roots.CompilerProjectExtension; //导入方法依赖的package包/类
public static Class compile(@NotNull PsiClass psiClass) {
Class cls = null;
String compileText = psiClass.getText();
String compileName = psiClass.getName();
CompilerProjectExtension extension = CompilerProjectExtension.getInstance(psiClass.getProject());
String outputRootUrl = extension.getCompilerOutputUrl();
File root = new File(outputRootUrl + "/tmp");
File sourceFile = new File(root, compileName + ".java");
sourceFile.getParentFile().mkdirs();
try {
new FileWriter(sourceFile).append(compileText).close();
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
compiler.run(null, null, null, sourceFile.getPath());
URLClassLoader classLoader = URLClassLoader.newInstance(new URL[]{root.toURI().toURL()});
cls = Class.forName(compileName, true, classLoader);
sourceFile.delete();
} catch (Exception e) {
e.printStackTrace();
}
return cls;
}
示例2: setCompilerOutput
import com.intellij.openapi.roots.CompilerProjectExtension; //导入方法依赖的package包/类
protected void setCompilerOutput(@NotNull Project project) {
CompilerProjectExtension compilerProjectExtension = CompilerProjectExtension.getInstance(project);
String basePath = project.getBasePath();
if (compilerProjectExtension != null && basePath != null) {
compilerProjectExtension.setCompilerOutputUrl(VfsUtilCore.pathToUrl(FileUtilRt.toSystemDependentName(basePath)));
}
}
示例3: getDefaultArtifactOutputPath
import com.intellij.openapi.roots.CompilerProjectExtension; //导入方法依赖的package包/类
@Nullable
public static String getDefaultArtifactOutputPath(@NotNull String artifactName, final @NotNull Project project) {
final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(project);
if (extension == null) return null;
String outputUrl = extension.getCompilerOutputUrl();
if (outputUrl == null || outputUrl.length() == 0) {
final VirtualFile baseDir = project.getBaseDir();
if (baseDir == null) return null;
outputUrl = baseDir.getUrl() + "/out";
}
return VfsUtilCore.urlToPath(outputUrl) + "/artifacts/" + FileUtil.sanitizeFileName(artifactName);
}
示例4: isExcludeRoot
import com.intellij.openapi.roots.CompilerProjectExtension; //导入方法依赖的package包/类
@Override
public boolean isExcludeRoot(final VirtualFile file) {
CompilerProjectExtension compilerProjectExtension = CompilerProjectExtension.getInstance(myProject);
if (isEqualWithFileOrUrl(file, compilerProjectExtension.getCompilerOutput(), compilerProjectExtension.getCompilerOutputUrl())) return true;
for (Module m : ModuleManager.getInstance(myProject).getModules()) {
CompilerModuleExtension rm = CompilerModuleExtension.getInstance(m);
if (isEqualWithFileOrUrl(file, rm.getCompilerOutputPath(), rm.getCompilerOutputUrl())) return true;
if (isEqualWithFileOrUrl(file, rm.getCompilerOutputPathForTests(), rm.getCompilerOutputUrlForTests())) return true;
}
return false;
}
示例5: getDefaultArtifactOutputPath
import com.intellij.openapi.roots.CompilerProjectExtension; //导入方法依赖的package包/类
@Nullable
public static String getDefaultArtifactOutputPath(@NotNull String artifactName, final @NotNull Project project) {
final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(project);
if (extension == null) return null;
String outputUrl = extension.getCompilerOutputUrl();
if (outputUrl == null || outputUrl.length() == 0) {
final VirtualFile baseDir = project.getBaseDir();
if (baseDir == null) return null;
outputUrl = baseDir.getUrl() + "/out";
}
return VfsUtil.urlToPath(outputUrl) + "/artifacts/" + FileUtil.sanitizeFileName(artifactName);
}
示例6: getImpl
import com.intellij.openapi.roots.CompilerProjectExtension; //导入方法依赖的package包/类
private static CompilerProjectExtensionImpl getImpl(final Project project) {
return (CompilerProjectExtensionImpl)CompilerProjectExtension.getInstance(project);
}
示例7: getOriginalCompilerOutputUrl
import com.intellij.openapi.roots.CompilerProjectExtension; //导入方法依赖的package包/类
@Nullable
private String getOriginalCompilerOutputUrl() {
final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(myProject);
return extension != null ? extension.getCompilerOutputUrl() : null;
}