当前位置: 首页>>代码示例>>Java>>正文


Java CompilerProjectExtension.getInstance方法代码示例

本文整理汇总了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;
}
 
开发者ID:nrudenko,项目名称:OrmGeneratorPlugin,代码行数:25,代码来源:CompileSourceInMemory.java

示例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)));
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:8,代码来源:EduIntellijCourseProjectGeneratorBase.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ArtifactUtil.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:ExcludeCompilerOutputPolicy.java

示例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);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:ArtifactUtil.java

示例6: getImpl

import com.intellij.openapi.roots.CompilerProjectExtension; //导入方法依赖的package包/类
private static CompilerProjectExtensionImpl getImpl(final Project project) {
  return (CompilerProjectExtensionImpl)CompilerProjectExtension.getInstance(project);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:CompilerProjectExtensionImpl.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:ProjectConfigurable.java


注:本文中的com.intellij.openapi.roots.CompilerProjectExtension.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。