本文整理汇总了Java中com.intellij.openapi.compiler.CompilerManager类的典型用法代码示例。如果您正苦于以下问题:Java CompilerManager类的具体用法?Java CompilerManager怎么用?Java CompilerManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompilerManager类属于com.intellij.openapi.compiler包,在下文中一共展示了CompilerManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compileAndAnalyze
import com.intellij.openapi.compiler.CompilerManager; //导入依赖的package包/类
private void compileAndAnalyze(final Project project, final AnalysisScope scope) {
if (project.isDisposed()) {
return;
}
final CompilerManager compilerManager = CompilerManager.getInstance(project);
compilerManager.make(compilerManager.createProjectCompileScope(project), new CompileStatusNotification() {
@Override
public void finished(final boolean aborted, final int errors, final int warnings, final CompileContext compileContext) {
if (aborted || errors != 0) return;
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
doAnalyze(project, scope);
}
});
}});
}
示例2: getFilesToPackage
import com.intellij.openapi.compiler.CompilerManager; //导入依赖的package包/类
@NotNull
private static List<VirtualFile> getFilesToPackage(@NotNull AnActionEvent e, @NotNull Project project) {
final VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
if (files == null) return Collections.emptyList();
List<VirtualFile> result = new ArrayList<VirtualFile>();
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
final CompilerManager compilerManager = CompilerManager.getInstance(project);
for (VirtualFile file : files) {
if (file == null || file.isDirectory() ||
fileIndex.isUnderSourceRootOfType(file, JavaModuleSourceRootTypes.SOURCES) && compilerManager.isCompilableFileType(file.getFileType())) {
return Collections.emptyList();
}
final Collection<? extends Artifact> artifacts = ArtifactBySourceFileFinder.getInstance(project).findArtifacts(file);
for (Artifact artifact : artifacts) {
if (!StringUtil.isEmpty(artifact.getOutputPath())) {
result.add(file);
break;
}
}
}
return result;
}
示例3: doAction
import com.intellij.openapi.compiler.CompilerManager; //导入依赖的package包/类
protected void doAction(DataContext dataContext, Project project) {
Module[] modules = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataContext);
Module module;
if (modules == null) {
module = LangDataKeys.MODULE.getData(dataContext);
if (module == null) {
return;
}
modules = new Module[]{module};
}
try {
CompilerManager.getInstance(project).make(modules[0].getProject(), modules, null);
}
catch (Exception e) {
LOG.error(e);
}
}
示例4: init
import com.intellij.openapi.compiler.CompilerManager; //导入依赖的package包/类
public void init() {
CompilerManager compilerManager = CompilerManager.getInstance(myProject);
class MyCompileTask implements CompileTask {
private final boolean myBefore;
MyCompileTask(boolean before) {
myBefore = before;
}
@Override
public boolean execute(CompileContext context) {
return doExecuteCompileTasks(myBefore, context);
}
}
compilerManager.addBeforeTask(new MyCompileTask(true));
compilerManager.addAfterTask(new MyCompileTask(false));
fireTasksChanged();
}
示例5: generate
import com.intellij.openapi.compiler.CompilerManager; //导入依赖的package包/类
private static void generate(Project project, final Module... modules) {
CompilerManager.getInstance(project).executeTask(new CompileTask() {
@Override
public boolean execute(CompileContext context) {
// todo: compatibility with background autogenerating
for (Module module : modules) {
final AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet != null) {
for (AndroidAutogeneratorMode mode : AndroidAutogeneratorMode.values()) {
AndroidCompileUtil.generate(facet, mode, context, true);
}
}
}
return true;
}
}, new ModuleCompileScope(project, modules, false), AndroidBundle.message("android.compile.messages.generating.r.java.content.name"),
null);
}
示例6: buildAndSignIntellijProject
import com.intellij.openapi.compiler.CompilerManager; //导入依赖的package包/类
private void buildAndSignIntellijProject() {
CompilerManager.getInstance(myProject).make(myCompileScope, new CompileStatusNotification() {
@Override
public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
if (aborted || errors != 0) {
return;
}
final String title = AndroidBundle.message("android.extract.package.task.title");
ProgressManager.getInstance().run(new Task.Backgroundable(myProject, title, true, null) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
createAndAlignApk(myApkPath);
}
});
}
});
}
示例7: setUpInWriteAction
import com.intellij.openapi.compiler.CompilerManager; //导入依赖的package包/类
@Override
protected void setUpInWriteAction() throws Exception {
super.setUpInWriteAction();
final GradleResourceCompilerConfigurationGenerator buildConfigurationGenerator = new GradleResourceCompilerConfigurationGenerator(myProject);
CompilerManager.getInstance(myProject).addBeforeTask(new CompileTask() {
@Override
public boolean execute(CompileContext context) {
AccessToken token = ReadAction.start();
try {
buildConfigurationGenerator.generateBuildConfiguration(context);
}
finally {
token.finish();
}
return true;
}
});
}
示例8: runActivity
import com.intellij.openapi.compiler.CompilerManager; //导入依赖的package包/类
@Override
public void runActivity(@NotNull final Project project) {
configureBuildClasspath(project);
showNotificationForUnlinkedGradleProject(project);
final GradleResourceCompilerConfigurationGenerator buildConfigurationGenerator = new GradleResourceCompilerConfigurationGenerator(project);
CompilerManager.getInstance(project).addBeforeTask(new CompileTask() {
@Override
public boolean execute(CompileContext context) {
AccessToken token = ReadAction.start();
try {
buildConfigurationGenerator.generateBuildConfiguration(context);
}
finally {
token.finish();
}
return true;
}
});
}
示例9: compileAndUpload
import com.intellij.openapi.compiler.CompilerManager; //导入依赖的package包/类
private void compileAndUpload() {
final Runnable startUploading = new Runnable() {
public void run() {
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
startUploadingProcess();
}
});
}
};
final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
final CompileScope moduleScope = compilerManager.createModuleCompileScope(myAppEngineFacet.getModule(), true);
final CompileScope compileScope = ArtifactCompileScope.createScopeWithArtifacts(moduleScope, Collections.singletonList(myArtifact));
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
compilerManager.make(compileScope, new CompileStatusNotification() {
public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
if (!aborted && errors == 0) {
startUploading.run();
}
}
});
}
});
}
示例10: initComponent
import com.intellij.openapi.compiler.CompilerManager; //导入依赖的package包/类
@Override
public void initComponent() {
if (!isNormalProject()) return;
if (isInitialized.getAndSet(true)) return;
CompilerManager compilerManager = CompilerManager.getInstance(myProject);
class MyCompileTask implements CompileTask {
private final boolean myBefore;
MyCompileTask(boolean before) {
myBefore = before;
}
@Override
public boolean execute(CompileContext context) {
return doExecute(myBefore, context);
}
}
compilerManager.addBeforeTask(new MyCompileTask(true));
compilerManager.addAfterTask(new MyCompileTask(false));
}
示例11: actionPerformed
import com.intellij.openapi.compiler.CompilerManager; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final PsiClass psiClass = getPsiClass(e);
if (psiClass == null) return;
final VirtualFile virtualFile = psiClass.getContainingFile().getVirtualFile();
final Module module = ModuleUtilCore.findModuleForPsiElement(psiClass);
if (module == null || virtualFile == null) return;
final String className = ClassUtil.getJVMClassName(psiClass);
final Project project = getEventProject(e);
CompilerManager.getInstance(project).make(new FileSetCompileScope(Collections.singletonList(virtualFile), new Module[]{module}), new CompileStatusNotification() {
@Override
public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
if (aborted || errors > 0) return;
generateAndShowXml(module, className);
}
});
}
示例12: actionPerformed
import com.intellij.openapi.compiler.CompilerManager; //导入依赖的package包/类
public void actionPerformed(final AnActionEvent e) {
final CreateIpaDialog dialog = new CreateIpaDialog(e.getProject());
dialog.show();
if(dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
// create IPA
IpaConfig ipaConfig = dialog.getIpaConfig();
CompileScope scope = CompilerManager.getInstance(e.getProject()).createModuleCompileScope(ipaConfig.module, true);
scope.putUserData(IPA_CONFIG_KEY, ipaConfig);
CompilerManager.getInstance(e.getProject()).compile(scope, new CompileStatusNotification() {
@Override
public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
RoboVmPlugin.logInfo(e.getProject(), "IPA creation complete, %d errors, %d warnings", errors, warnings);
}
});
}
}
示例13: initComponent
import com.intellij.openapi.compiler.CompilerManager; //导入依赖的package包/类
public void initComponent() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
FileTypeManager.getInstance().registerFileType(F3_FILE_TYPE, F3_FILE_EXTENSION);
ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() {
public void projectOpened(Project project) {
CompilerManager compilerManager = CompilerManager.getInstance(project);
compilerManager.addCompiler(new F3Compiler());
compilerManager.addCompilableFileType(F3_FILE_TYPE);
DebuggerManager.getInstance (project).registerPositionManagerFactory (new Function<DebugProcess, PositionManager>() {
public PositionManager fun (DebugProcess debugProcess) {
return new F3PositionManager (debugProcess);
}
});
}
});
}
});
}
示例14: registerManagerExecution
import com.intellij.openapi.compiler.CompilerManager; //导入依赖的package包/类
private void registerManagerExecution(Project project, ExecutionMoment executionMoment) {
CompilerManager compilerManager = CompilerManager.getInstance(project);
switch (executionMoment) {
case BEFORE:
compilerManager.addBeforeTask(this);
break;
case AFTER:
compilerManager.addAfterTask(this);
break;
case BOTH:
compilerManager.addBeforeTask(this);
compilerManager.addAfterTask(this);
break;
default:
throw new IllegalStateException("Cannot be reached");
}
}
示例15: getFilesToPackage
import com.intellij.openapi.compiler.CompilerManager; //导入依赖的package包/类
@NotNull
private static List<VirtualFile> getFilesToPackage(@NotNull AnActionEvent e, @NotNull Project project) {
final VirtualFile[] files = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY);
if (files == null) return Collections.emptyList();
List<VirtualFile> result = new ArrayList<VirtualFile>();
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
final CompilerManager compilerManager = CompilerManager.getInstance(project);
for (VirtualFile file : files) {
if (file == null || file.isDirectory() ||
fileIndex.isInSourceContent(file) && compilerManager.isCompilableFileType(file.getFileType())) {
return Collections.emptyList();
}
final Collection<? extends Artifact> artifacts = ArtifactBySourceFileFinder.getInstance(project).findArtifacts(file);
for (Artifact artifact : artifacts) {
if (!StringUtil.isEmpty(artifact.getOutputPath())) {
result.add(file);
break;
}
}
}
return result;
}