use of com.android.tools.idea.gradle.project.ModuleImporter in project android by JetBrains.
the class ImportSourceLocationStep method checkPath.
@NotNull
@VisibleForTesting
protected PathValidationResult checkPath(@NotNull String path) {
path = path.trim();
if (Strings.isNullOrEmpty(path)) {
return PageStatus.EMPTY_PATH.result();
}
VirtualFile vfile = VfsUtil.findFileByIoFile(new File(path), false);
if (vfile == null || !vfile.exists()) {
return PageStatus.DOES_NOT_EXIST.result();
} else if (isProjectOrModule(vfile)) {
return PageStatus.IS_PROJECT_OR_MODULE.result();
}
ModuleImporter kind = ModuleImporter.importerForLocation(myContext, vfile);
if (!kind.isValid()) {
return PageStatus.NOT_ADT_OR_GRADLE.result();
}
return new PathValidationResult(PageStatus.OK, vfile, kind, null);
}
use of com.android.tools.idea.gradle.project.ModuleImporter in project android by JetBrains.
the class SourceToGradleModuleStep method createDependentSteps.
@NotNull
@Override
protected Collection<? extends ModelWizardStep> createDependentSteps() {
WizardContext context = getModel().getContext();
ArrayList<ModelWizardStep> wrappedSteps = new ArrayList<>();
for (ModuleImporter importer : ModuleImporter.getAllImporters(context)) {
for (ModuleWizardStep inputStep : importer.createWizardSteps()) {
wrappedSteps.add(new ModuleWizardStepAdapter(context, inputStep));
}
}
return wrappedSteps;
}
use of com.android.tools.idea.gradle.project.ModuleImporter in project android by JetBrains.
the class SourceToGradleModuleStep method checkPath.
@NotNull
@VisibleForTesting
PathValidationResult checkPath(@NotNull String path) {
if (Strings.isNullOrEmpty(path)) {
return PathValidationResult.ofType(EMPTY_PATH);
}
VirtualFile vFile = VfsUtil.findFileByIoFile(new File(path), false);
if (vFile == null || !vFile.exists()) {
return PathValidationResult.ofType(DOES_NOT_EXIST);
} else if (isProjectOrModule(vFile)) {
return PathValidationResult.ofType(IS_PROJECT_OR_MODULE);
}
ModuleImporter importer = ModuleImporter.importerForLocation(getModel().getContext(), vFile);
if (!importer.isValid()) {
return PathValidationResult.ofType(NOT_ADT_OR_GRADLE);
}
Collection<ModuleToImport> modules = ApplicationManager.getApplication().runReadAction((Computable<Collection<ModuleToImport>>) () -> {
try {
return importer.findModules(vFile);
} catch (IOException e) {
Logger.getInstance(SourceToGradleModuleStep.class).error(e);
return null;
}
});
if (modules == null) {
return PathValidationResult.ofType(INTERNAL_ERROR);
}
Set<String> missingSourceModuleNames = Sets.newTreeSet();
for (ModuleToImport module : modules) {
if (module.location == null || !module.location.exists()) {
missingSourceModuleNames.add(module.name);
}
}
if (!missingSourceModuleNames.isEmpty()) {
return new PathValidationResult(MISSING_SUBPROJECTS, vFile, importer, modules, missingSourceModuleNames);
}
return new PathValidationResult(OK, vFile, importer, modules, null);
}
Aggregations