in internal/platform/product/product_info.go [267:357]
func GuessProduct(idePath string, analyzer Analyzer) Product {
homePath := idePath
if //goland:noinspection GoBoolExpressions
runtime.GOOS == "darwin" {
contentsDir := filepath.Join(homePath, "Contents")
if _, err := os.Stat(contentsDir); err == nil {
homePath = contentsDir
}
}
if homePath == "" {
if home, ok := os.LookupEnv(qdenv.QodanaDistEnv); ok {
homePath = home
} else if qdenv.IsContainer() {
homePath = "/opt/idea"
} else { // guess from the executable location
ex, err := os.Executable()
if err != nil {
log.Fatal(err)
}
homePath = filepath.Dir(filepath.Dir(ex))
}
}
ideBinPath := ideBin(homePath)
var baseScriptName string
if //goland:noinspection GoBoolExpressions
runtime.GOOS == "darwin" {
baseScriptName = findIde(filepath.Join(homePath, "MacOS"))
} else {
baseScriptName = findIde(ideBinPath)
}
if baseScriptName == "" {
msg.WarningMessage(
"Supported IDE not found in %s, you can declare the path to IDE home via %s variable",
homePath,
qdenv.QodanaDistEnv,
)
log.Fatal("IDE to run is not found")
}
var ideScript string
if //goland:noinspection ALL
runtime.GOOS == "darwin" {
ideScript = filepath.Join(homePath, "MacOS", baseScriptName)
} else {
ideScript = filepath.Join(ideBinPath, fmt.Sprintf("%s%s", baseScriptName, getScriptSuffix()))
}
productInfo, err := ReadIdeProductInfo(homePath)
if err != nil {
log.Fatalf("Can't read product-info.json: %v ", err)
}
flavourProductCode := ReadDistFlavour(homePath)
version := productInfo.Version
ideCode := productInfo.ProductCode
var code string
if flavourProductCode != "" {
code = flavourProductCode
} else {
code = toQodanaCode(ideCode)
}
linter := FindLinterByProductCode(code)
if linter == UnknownLinter {
log.Fatalf("Unknown product code %s", code)
}
name := linter.PresentableName
build := productInfo.BuildNumber
eap := IsEap(productInfo)
prod := Product{
Analyzer: analyzer,
Name: name,
IdeCode: ideCode,
Code: code,
Version: version,
BaseScriptName: baseScriptName,
IdeScript: ideScript,
Build: build,
Home: homePath,
IsEap: eap,
}
log.Debug(prod)
qdenv.SetEnv(qdenv.QodanaDistEnv, prod.Home)
if prod.isRuby() {
qdenv.UnsetRubyVariables()
}
return prod
}