use of com.google.idea.blaze.base.ideinfo.TargetIdeInfo in project intellij by bazelbuild.
the class BlazeKotlinRunConfigurationProducer method doIsConfigFromContext.
@Override
protected boolean doIsConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context) {
TargetIdeInfo target = getTargetIdeInfo(context);
BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
return target != null && handlerState != null && Objects.equals(handlerState.getCommandState().getCommand(), BlazeCommandName.RUN) && configuration.getTarget() != null && Objects.equals(configuration.getTarget(), target.key.label);
}
use of com.google.idea.blaze.base.ideinfo.TargetIdeInfo in project intellij by bazelbuild.
the class BlazeKotlinRunConfigurationProducer method doSetupConfigFromContext.
@Override
protected boolean doSetupConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
Location<?> location = context.getLocation();
if (location == null) {
return false;
}
sourceElement.set(location.getPsiElement());
TargetIdeInfo target = getTargetIdeInfo(context);
if (target == null) {
return false;
}
BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null) {
return false;
}
handlerState.getCommandState().setCommand(BlazeCommandName.RUN);
configuration.setTargetInfo(target.toTargetInfo());
configuration.setGeneratedName();
return true;
}
use of com.google.idea.blaze.base.ideinfo.TargetIdeInfo in project intellij by bazelbuild.
the class BlazeScalaWorkspaceImporter method importWorkspace.
public BlazeScalaImportResult importWorkspace() {
ProjectViewTargetImportFilter importFilter = new ProjectViewTargetImportFilter(project, workspaceRoot, projectViewSet);
Collection<Kind> scalaKinds = Kind.allKindsForLanguage(LanguageClass.SCALA);
List<TargetKey> scalaSourceTargets = targetMap.targets().stream().filter(target -> target.javaIdeInfo != null).filter(target -> target.kindIsOneOf(scalaKinds)).filter(importFilter::isSourceTarget).map(target -> target.key).collect(Collectors.toList());
Map<LibraryKey, BlazeJarLibrary> libraries = Maps.newHashMap();
// but since they'll all merged into one set, we will end up with exactly one of each.
for (TargetKey dependency : TransitiveDependencyMap.getTransitiveDependencies(scalaSourceTargets, targetMap)) {
TargetIdeInfo target = targetMap.get(dependency);
if (target == null) {
continue;
}
// Except source targets.
if (JavaSourceFilter.importAsSource(importFilter, target)) {
continue;
}
if (target.javaIdeInfo != null) {
target.javaIdeInfo.jars.stream().map(BlazeJarLibrary::new).forEach(library -> libraries.putIfAbsent(library.key, library));
}
}
return new BlazeScalaImportResult(ImmutableMap.copyOf(libraries));
}
use of com.google.idea.blaze.base.ideinfo.TargetIdeInfo in project intellij by bazelbuild.
the class BlazeScalaMainClassRunConfigurationProducer method doSetupConfigFromContext.
@Override
protected boolean doSetupConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
ScObject mainObject = getMainObject(context);
if (mainObject == null) {
return false;
}
Option<PsiMethod> mainMethod = ScalaMainMethodUtil.findMainMethod(mainObject);
if (mainMethod.isEmpty()) {
sourceElement.set(mainObject);
} else {
sourceElement.set(mainMethod.get());
}
TargetIdeInfo target = getTarget(context.getProject(), mainObject);
if (target == null) {
return false;
}
configuration.setTargetInfo(target.toTargetInfo());
BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null) {
return false;
}
handlerState.getCommandState().setCommand(BlazeCommandName.RUN);
configuration.setGeneratedName();
return true;
}
use of com.google.idea.blaze.base.ideinfo.TargetIdeInfo in project intellij by bazelbuild.
the class BlazeScalaMainClassRunConfigurationProducer method doIsConfigFromContext.
@Override
protected boolean doIsConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context) {
BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null) {
return false;
}
if (!Objects.equals(handlerState.getCommandState().getCommand(), BlazeCommandName.RUN)) {
return false;
}
ScObject mainObject = getMainObject(context);
if (mainObject == null) {
return false;
}
TargetIdeInfo target = getTarget(context.getProject(), mainObject);
return target != null && Objects.equals(configuration.getTarget(), target.key.label);
}
Aggregations