diff --git a/src/main/java/com/tabnine/general/StaticConfig.java b/src/main/java/com/tabnine/general/StaticConfig.java
index 924c50a2a..bc3ade9aa 100644
--- a/src/main/java/com/tabnine/general/StaticConfig.java
+++ b/src/main/java/com/tabnine/general/StaticConfig.java
@@ -3,6 +3,7 @@
import static com.tabnine.general.Utils.isUnitTestMode;
import static java.awt.Color.decode;
+import com.intellij.ide.util.PropertiesComponent;
import com.intellij.notification.NotificationDisplayType;
import com.intellij.notification.NotificationGroup;
import com.intellij.openapi.application.Application;
@@ -22,11 +23,15 @@
import java.util.*;
import javax.swing.*;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
public class StaticConfig {
// Must be identical to what is written under com.tabnine.TabNine in plugin.xml !!!
public static final String TABNINE_PLUGIN_ID_RAW =
Config.IS_ON_PREM ? "com.tabnine.TabNine-Enterprise" : "com.tabnine.TabNine";
+ public static final String TABNINE_ENTERPRISE_URL_PROPERTIES_KEY =
+ TABNINE_PLUGIN_ID_RAW + ".enterpriseUrl";
+
public static final PluginId TABNINE_PLUGIN_ID = PluginId.getId(TABNINE_PLUGIN_ID_RAW);
public static final int MAX_COMPLETIONS = 5;
public static final String BINARY_PROTOCOL_VERSION = "4.4.223";
@@ -102,11 +107,26 @@ public static Optional getLogLevel() {
return Optional.empty();
}
+ // if the self-hosted updater injected the value, it'll be found here
+ @Nullable
+ public static String getInjectedEnterpriseUrlFromProperties() {
+ if (ApplicationManager.getApplication().isUnitTestMode()) {
+ return null;
+ }
+ return PropertiesComponent.getInstance().getValue(TABNINE_ENTERPRISE_URL_PROPERTIES_KEY);
+ }
+
public static Optional getTabnineEnterpriseHost() {
String path = AppSettingsState.getInstance().getCloud2Url();
if (!path.isEmpty()) {
return Optional.of(path);
}
+
+ String injectedHost = getInjectedEnterpriseUrlFromProperties();
+ if (injectedHost != null) {
+ return Optional.of(injectedHost);
+ }
+
return Optional.ofNullable(System.getProperty(TABNINE_ENTERPRISE_HOST));
}
diff --git a/src/main/java/com/tabnine/userSettings/AppSettingsComponent.kt b/src/main/java/com/tabnine/userSettings/AppSettingsComponent.kt
index 4d578a975..494916a0a 100644
--- a/src/main/java/com/tabnine/userSettings/AppSettingsComponent.kt
+++ b/src/main/java/com/tabnine/userSettings/AppSettingsComponent.kt
@@ -90,7 +90,12 @@ class AppSettingsComponent {
.addLabeledComponent("Log level (requires restart): ", logLevelComponent, 1, false)
if (Config.IS_ON_PREM) {
- panelBuilder.addLabeledComponent("Tabnine Enterprise URL (requires restart): ", cloud2UrlComponent, 1, false)
+ panelBuilder.addLabeledComponent(
+ "Tabnine Enterprise URL (requires restart): ",
+ cloud2UrlComponent,
+ 1,
+ false
+ )
}
if (!isFixedDebounceConfigured()) {
panelBuilder
diff --git a/src/main/java/com/tabnine/userSettings/AppSettingsState.kt b/src/main/java/com/tabnine/userSettings/AppSettingsState.kt
index 8db0f4999..3c1684ce4 100644
--- a/src/main/java/com/tabnine/userSettings/AppSettingsState.kt
+++ b/src/main/java/com/tabnine/userSettings/AppSettingsState.kt
@@ -5,6 +5,7 @@ import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.util.xmlb.XmlSerializerUtil
+import com.tabnine.general.StaticConfig
import com.tabnine.inline.render.GraphicsUtils
val settingsDefaultColor = GraphicsUtils.niceContrastColor.rgb
@@ -26,7 +27,7 @@ class AppSettingsState : PersistentStateComponent {
var debounceTime: Long = 0
var autoImportEnabled: Boolean = true
var binariesFolderOverride: String = ""
- var cloud2Url: String = ""
+ var cloud2Url: String = StaticConfig.getInjectedEnterpriseUrlFromProperties() ?: ""
private var colorState = settingsDefaultColor