<commit_before>// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.gradle.service.project.wizard

import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys
import com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManagerImpl.setupCreatedProject
import com.intellij.openapi.module.ModifiableModuleModel
import com.intellij.openapi.module.Module
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ui.configuration.ModulesProvider
import com.intellij.packaging.artifacts.ModifiableArtifactModel
import com.intellij.projectImport.DeprecatedProjectBuilderForImport
import com.intellij.projectImport.ProjectImportBuilder
import icons.GradleIcons
import org.jetbrains.plugins.gradle.service.project.open.importProject
import org.jetbrains.plugins.gradle.util.GradleBundle
import javax.swing.Icon


class JavaGradleProjectImportBuilder : ProjectImportBuilder<Any>(), DeprecatedProjectBuilderForImport {

  override fun getName(): String = GradleBundle.message("gradle.name")

  override fun getIcon(): Icon = GradleIcons.Gradle

  override fun getList(): List<Any> = emptyList()

  override fun isMarked(element: Any): Boolean = true

  override fun setList(list: List<Any>) {}

  override fun setOpenProjectSettingsAfter(on: Boolean) {}

  override fun createProject(name: String?, path: String): Project? {
    return setupCreatedProject(super.createProject(name, path))?.also {
      it.putUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT, true)
    }
  }

  override fun commit(project: Project,
                      model: ModifiableModuleModel?,
                      modulesProvider: ModulesProvider?,
                      artifactModel: ModifiableArtifactModel?): List<Module> {
    importProject(fileToImport, project)
    return emptyList()
  }
}<commit_msg>IDEA-214706 added correction of path to import gradle project<commit_after>// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.gradle.service.project.wizard

import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys
import com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManagerImpl.setupCreatedProject
import com.intellij.openapi.module.ModifiableModuleModel
import com.intellij.openapi.module.Module
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ui.configuration.ModulesProvider
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.packaging.artifacts.ModifiableArtifactModel
import com.intellij.projectImport.DeprecatedProjectBuilderForImport
import com.intellij.projectImport.ProjectImportBuilder
import com.intellij.projectImport.ProjectImportProvider.getDefaultPath
import icons.GradleIcons
import org.jetbrains.plugins.gradle.service.project.open.importProject
import org.jetbrains.plugins.gradle.util.GradleBundle
import javax.swing.Icon


class JavaGradleProjectImportBuilder : ProjectImportBuilder<Any>(), DeprecatedProjectBuilderForImport {

  override fun getName(): String = GradleBundle.message("gradle.name")

  override fun getIcon(): Icon = GradleIcons.Gradle

  override fun getList(): List<Any> = emptyList()

  override fun isMarked(element: Any): Boolean = true

  override fun setList(list: List<Any>) {}

  override fun setOpenProjectSettingsAfter(on: Boolean) {}

  private fun getPathToBeImported(path: String): String {
    val localForImport = LocalFileSystem.getInstance()
    val file = localForImport.refreshAndFindFileByPath(path)
    return file?.let(::getDefaultPath) ?: path
  }

  override fun setFileToImport(path: String) = super.setFileToImport(getPathToBeImported(path))

  override fun createProject(name: String?, path: String): Project? {
    return setupCreatedProject(super.createProject(name, path))?.also {
      it.putUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT, true)
    }
  }

  override fun commit(project: Project,
                      model: ModifiableModuleModel?,
                      modulesProvider: ModulesProvider?,
                      artifactModel: ModifiableArtifactModel?): List<Module> {
    importProject(fileToImport, project)
    return emptyList()
  }
}
{'fraction_non_alphanumeric': 0.08553230209281165, 'fraction_numerical': 0.005914467697907188, 'mean_word_length': 5.132496513249651, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2018917', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1201, 'n_words': 257}