com.intellij.util.PlatformUtils Java Examples
The following examples show how to use
com.intellij.util.PlatformUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlazeJavascriptSyncPluginTest.java From intellij with Apache License 2.0 | 6 votes |
@Test public void testJavascriptLanguageAvailableForUltimateEdition() { TestUtils.setPlatformPrefix(testDisposable, PlatformUtils.IDEA_PREFIX); ProjectViewSet projectViewSet = ProjectViewSet.builder() .add( ProjectView.builder() .add( ScalarSection.builder(WorkspaceTypeSection.KEY) .set(WorkspaceType.JAVASCRIPT)) .add( ListSection.builder(AdditionalLanguagesSection.KEY) .add(LanguageClass.JAVASCRIPT)) .build()) .build(); WorkspaceLanguageSettings workspaceLanguageSettings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet); errorCollector.assertNoIssues(); assertThat(workspaceLanguageSettings) .isEqualTo( new WorkspaceLanguageSettings( WorkspaceType.JAVASCRIPT, ImmutableSet.of(LanguageClass.JAVASCRIPT, LanguageClass.GENERIC))); }
Example #2
Source File: BlazeJavascriptSyncPluginTest.java From intellij with Apache License 2.0 | 6 votes |
@Test public void testJavascriptWorkspaceTypeUnavailableForCommunityEdition() { TestUtils.setPlatformPrefix(testDisposable, PlatformUtils.IDEA_CE_PREFIX); ProjectViewSet projectViewSet = ProjectViewSet.builder() .add( ProjectView.builder() .add( ScalarSection.builder(WorkspaceTypeSection.KEY) .set(WorkspaceType.JAVASCRIPT)) .build()) .build(); WorkspaceLanguageSettings workspaceLanguageSettings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet); LanguageSupport.validateLanguageSettings(context, workspaceLanguageSettings); errorCollector.assertIssues("Workspace type 'javascript' is not supported by this plugin"); }
Example #3
Source File: BlazeTypescriptSyncPluginTest.java From intellij with Apache License 2.0 | 6 votes |
@Test public void testTypescriptLanguageAvailableInUltimateEdition() { TestUtils.setPlatformPrefix(testDisposable, PlatformUtils.IDEA_PREFIX); ProjectViewSet projectViewSet = ProjectViewSet.builder() .add( ProjectView.builder() .add(ScalarSection.builder(WorkspaceTypeSection.KEY).set(WorkspaceType.JAVA)) .add( ListSection.builder(AdditionalLanguagesSection.KEY) .add(LanguageClass.TYPESCRIPT)) .build()) .build(); WorkspaceLanguageSettings workspaceLanguageSettings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet); errorCollector.assertNoIssues(); assertThat(workspaceLanguageSettings) .isEqualTo( new WorkspaceLanguageSettings( WorkspaceType.JAVA, ImmutableSet.of( LanguageClass.TYPESCRIPT, LanguageClass.GENERIC, LanguageClass.JAVA))); }
Example #4
Source File: WakaTime.java From jetbrains-wakatime with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void initComponent() { VERSION = PluginManager.getPlugin(PluginId.getId("com.wakatime.intellij.plugin")).getVersion(); log.info("Initializing WakaTime plugin v" + VERSION + " (https://wakatime.com/)"); //System.out.println("Initializing WakaTime plugin v" + VERSION + " (https://wakatime.com/)"); // Set runtime constants IDE_NAME = PlatformUtils.getPlatformPrefix(); IDE_VERSION = ApplicationInfo.getInstance().getFullVersion(); setupDebugging(); setLoggingLevel(); Dependencies.configureProxy(); checkApiKey(); checkCli(); setupEventListeners(); setupQueueProcessor(); checkDebug(); log.info("Finished initializing WakaTime plugin"); }
Example #5
Source File: BlazeTypescriptSyncPluginTest.java From intellij with Apache License 2.0 | 6 votes |
@Test public void testTypescriptNotLanguageAvailableInCommunityEdition() { TestUtils.setPlatformPrefix(testDisposable, PlatformUtils.IDEA_CE_PREFIX); ProjectViewSet projectViewSet = ProjectViewSet.builder() .add( ProjectView.builder() .add(ScalarSection.builder(WorkspaceTypeSection.KEY).set(WorkspaceType.JAVA)) .add( ListSection.builder(AdditionalLanguagesSection.KEY) .add(LanguageClass.TYPESCRIPT)) .build()) .build(); WorkspaceLanguageSettings workspaceLanguageSettings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet); LanguageSupport.validateLanguageSettings(context, workspaceLanguageSettings); errorCollector.assertIssues("Language 'typescript' is not supported by this plugin"); }
Example #6
Source File: FlutterCreateAdditionalSettingsFields.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void addSettingsFields(@NotNull SettingsStep settingsStep) { settingsStep.addSettingsField(FlutterBundle.message("flutter.module.create.settings.description.label"), descriptionField); settingsStep.addSettingsField(FlutterBundle.message("flutter.module.create.settings.type.label"), projectTypeForm.getComponent()); settingsStep.addSettingsField(FlutterBundle.message("flutter.module.create.settings.radios.org.label"), orgField); settingsStep.addSettingsField(FlutterBundle.message("flutter.module.create.settings.radios.android.label"), androidLanguageRadios.getComponent()); settingsStep.addSettingsField(FlutterBundle.message("flutter.module.create.settings.radios.ios.label"), iosLanguageRadios.getComponent()); // WebStorm has a smaller area for the wizard UI. if (!PlatformUtils.isWebStorm()) { settingsStep.addSettingsComponent(new SettingsHelpForm().getComponent()); } settingsStep.addSettingsComponent(createParams.setInitialValues().getComponent()); }
Example #7
Source File: FlutterModuleUtils.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Return true if the passed module is of a Flutter type. Before version M16 this plugin had its own Flutter {@link ModuleType}. * Post M16 a Flutter module is defined by the following: * <p> * <code> * [Flutter support enabled for a module] === * [Dart support enabled && referenced Dart SDK is the one inside a Flutter SDK] * </code> */ public static boolean isFlutterModule(@Nullable final Module module) { if (module == null || module.isDisposed()) return false; if (PlatformUtils.isIntelliJ() || FlutterUtils.isAndroidStudio()) { // [Flutter support enabled for a module] === // [Dart support enabled && referenced Dart SDK is the one inside a Flutter SDK] final DartSdk dartSdk = DartPlugin.getDartSdk(module.getProject()); final String dartSdkPath = dartSdk != null ? dartSdk.getHomePath() : null; return validDartSdkPath(dartSdkPath) && DartPlugin.isDartSdkEnabled(module); } else { // If not IntelliJ, assume a small IDE (no multi-module project support). return declaresFlutter(module); } }
Example #8
Source File: TabNineProcess.java From tabnine-intellij with MIT License | 6 votes |
void startTabNine() throws IOException { if (this.proc != null) { this.proc.destroy(); this.proc = null; } // When we tell TabNine that it's talking to IntelliJ, it won't suggest language server // setup since we assume it's already built into the IDE List<String> command = new ArrayList<>(); command.add(TabNineFinder.getTabNinePath()); List<String> metadata = new ArrayList<>(); metadata.add("--client-metadata"); metadata.add("pluginVersion=" + Utils.getPluginVersion()); metadata.add("clientIsUltimate=" + PlatformUtils.isIdeaUltimate()); final ApplicationInfo applicationInfo = ApplicationInfo.getInstance(); if (applicationInfo != null) { command.add("--client"); command.add(applicationInfo.getVersionName()); metadata.add("clientVersion=" + applicationInfo.getFullVersion()); metadata.add("clientApiVersion=" + applicationInfo.getApiVersion()); } command.addAll(metadata); ProcessBuilder builder = new ProcessBuilder(command); this.proc = builder.start(); this.procLineReader = new BufferedReader(new InputStreamReader(this.proc.getInputStream(), StandardCharsets.UTF_8)); }
Example #9
Source File: FlutterCreateAdditionalSettingsFields.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void addSettingsFields(@NotNull SettingsStep settingsStep) { settingsStep.addSettingsField(FlutterBundle.message("flutter.module.create.settings.description.label"), descriptionField); settingsStep.addSettingsField(FlutterBundle.message("flutter.module.create.settings.type.label"), projectTypeForm.getComponent()); settingsStep.addSettingsField(FlutterBundle.message("flutter.module.create.settings.radios.org.label"), orgField); settingsStep.addSettingsField(FlutterBundle.message("flutter.module.create.settings.radios.android.label"), androidLanguageRadios.getComponent()); settingsStep.addSettingsField(FlutterBundle.message("flutter.module.create.settings.radios.ios.label"), iosLanguageRadios.getComponent()); // WebStorm has a smaller area for the wizard UI. if (!PlatformUtils.isWebStorm()) { settingsStep.addSettingsComponent(new SettingsHelpForm().getComponent()); } settingsStep.addSettingsComponent(createParams.setInitialValues().getComponent()); }
Example #10
Source File: FlutterModuleUtils.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Return true if the passed module is of a Flutter type. Before version M16 this plugin had its own Flutter {@link ModuleType}. * Post M16 a Flutter module is defined by the following: * <p> * <code> * [Flutter support enabled for a module] === * [Dart support enabled && referenced Dart SDK is the one inside a Flutter SDK] * </code> */ public static boolean isFlutterModule(@Nullable final Module module) { if (module == null || module.isDisposed()) return false; if (PlatformUtils.isIntelliJ() || FlutterUtils.isAndroidStudio()) { // [Flutter support enabled for a module] === // [Dart support enabled && referenced Dart SDK is the one inside a Flutter SDK] final DartSdk dartSdk = DartPlugin.getDartSdk(module.getProject()); final String dartSdkPath = dartSdk != null ? dartSdk.getHomePath() : null; return validDartSdkPath(dartSdkPath) && DartPlugin.isDartSdkEnabled(module); } else { // If not IntelliJ, assume a small IDE (no multi-module project support). return declaresFlutter(module); } }
Example #11
Source File: JavascriptSyncTest.java From intellij with Apache License 2.0 | 6 votes |
@Test public void testErrorMessageInCommunityEdition() { TestUtils.setPlatformPrefix(getTestRootDisposable(), PlatformUtils.IDEA_CE_PREFIX); setProjectView( "directories:", " common/jslayout", "targets:", " //common/jslayout/...:all", "workspace_type: javascript"); workspace.createDirectory(new WorkspacePath("common/jslayout")); BlazeSyncParams syncParams = BlazeSyncParams.builder() .setTitle("Full Sync") .setSyncMode(SyncMode.FULL) .setSyncOrigin("test") .setBlazeBuildParams(BlazeBuildParams.fromProject(getProject())) .setAddProjectViewTargets(true) .build(); runBlazeSync(syncParams); errorCollector.assertHasErrors(); }
Example #12
Source File: TestUtils.java From intellij with Apache License 2.0 | 5 votes |
/** * Sets the platform prefix system property, reverting to the previous value when the supplied * parent disposable is disposed. */ public static void setPlatformPrefix(Disposable parentDisposable, String platformPrefix) { String prevValue = System.getProperty(PlatformUtils.PLATFORM_PREFIX_KEY); System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, platformPrefix); Disposer.register( parentDisposable, () -> { if (prevValue != null) { System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, prevValue); } else { System.clearProperty(PlatformUtils.PLATFORM_PREFIX_KEY); } }); }
Example #13
Source File: JavascriptSyncTest.java From intellij with Apache License 2.0 | 5 votes |
@Test public void testTestSourcesMissingFromDirectoriesSectionAreAdded() { TestUtils.setPlatformPrefix(getTestRootDisposable(), PlatformUtils.IDEA_PREFIX); setProjectView( "directories:", " common/jslayout", "targets:", " //common/jslayout/...:all", "test_sources:", " */tests", "workspace_type: javascript"); VirtualFile testDir = workspace.createDirectory(new WorkspacePath("common/jslayout/tests")); BlazeSyncParams syncParams = BlazeSyncParams.builder() .setTitle("Full Sync") .setSyncMode(SyncMode.FULL) .setSyncOrigin("test") .setBlazeBuildParams(BlazeBuildParams.fromProject(getProject())) .setAddProjectViewTargets(true) .build(); runBlazeSync(syncParams); errorCollector.assertNoIssues(); ImmutableList<ContentEntry> contentEntries = getWorkspaceContentEntries(); assertThat(contentEntries).hasSize(1); SourceFolder root = findSourceFolder(contentEntries.get(0), testDir.getParent()); assertThat(root.isTestSource()).isFalse(); SourceFolder testRoot = findSourceFolder(contentEntries.get(0), testDir); assertThat(testRoot).isNotNull(); assertThat(testRoot.isTestSource()).isTrue(); }
Example #14
Source File: IntelliJBazelPrefetchFileSourceTest.java From intellij with Apache License 2.0 | 5 votes |
@Test public void testPrefetchedExtensions() { if (PlatformUtils.isIdeaUltimate()) { assertThat(PrefetchFileSource.getAllPrefetchFileExtensions()) .containsExactly("java", "proto", "dart", "js", "html", "css", "gss", "ts", "tsx"); } else { assertThat(PrefetchFileSource.getAllPrefetchFileExtensions()) .containsExactly("java", "proto", "dart"); } }
Example #15
Source File: JUnitPluginDependencyWarning.java From intellij with Apache License 2.0 | 5 votes |
@Override public void initComponent() { Topics.subscribe( AppLifecycleListener.TOPIC, /* disposable= */ null, new AppLifecycleListener() { @Override public void appStarting(@Nullable Project projectFromCommandLine) { if (PlatformUtils.isIntelliJ() && !PluginUtils.isPluginEnabled(JUNIT_PLUGIN_ID)) { notifyJUnitNotEnabled(); } } }); }
Example #16
Source File: BlazeFlags.java From intellij with Apache License 2.0 | 5 votes |
@VisibleForTesting public static String getToolTagFlag() { String platformPrefix = PlatformUtils.getPlatformPrefix(); // IDEA Community Edition is "Idea", whereas IDEA Ultimate Edition is "idea". // That's dumb. Let's make them more useful. if (PlatformUtils.isIdeaCommunity()) { platformPrefix = "IDEA:community"; } else if (PlatformUtils.isIdeaUltimate()) { platformPrefix = "IDEA:ultimate"; } return TOOL_TAG + platformPrefix; }
Example #17
Source File: FileGitHubIssueAction.java From intellij with Apache License 2.0 | 5 votes |
private static String getProductId() { String platformPrefix = PlatformUtils.getPlatformPrefix(); // IDEA Community Edition is "Idea", whereas IDEA Ultimate Edition is "idea". Let's make them // more useful. if (PlatformUtils.isIdeaCommunity()) { platformPrefix = "IdeaCommunity"; } else if (PlatformUtils.isIdeaUltimate()) { platformPrefix = "IdeaUltimate"; } return platformPrefix; }
Example #18
Source File: BlazeGoSyncPlugin.java From intellij with Apache License 2.0 | 4 votes |
@Nullable @Override public WorkspaceType getDefaultWorkspaceType() { return PlatformUtils.isGoIde() ? WorkspaceType.GO : null; }
Example #19
Source File: PythonPluginUtils.java From intellij with Apache License 2.0 | 4 votes |
public boolean matchesCurrent() { ApplicationInfo appInfo = ApplicationInfo.getInstance(); return PlatformUtils.getPlatformPrefix().equals(prefix) && matchesVersion(majorVersion, appInfo.getMajorVersion()) && matchesVersion(minorVersion, appInfo.getMinorVersion()); }
Example #20
Source File: AlwaysPresentGoSyncPlugin.java From intellij with Apache License 2.0 | 4 votes |
private static boolean goWorkspaceTypeSupported() { return PlatformUtils.isGoIde(); }
Example #21
Source File: AlwaysPresentGoSyncPlugin.java From intellij with Apache License 2.0 | 4 votes |
/** Go plugin is only supported in IJ UE and GoLand. */ private static boolean isGoPluginSupported() { return PlatformUtils.isGoIde() || PlatformUtils.isIdeaUltimate() || ApplicationManager.getApplication().isUnitTestMode(); }
Example #22
Source File: JavascriptSyncTest.java From intellij with Apache License 2.0 | 4 votes |
@Test public void testTestSourceChildrenAreNotAddedAsSourceFolders() { TestUtils.setPlatformPrefix(getTestRootDisposable(), PlatformUtils.IDEA_PREFIX); // child directories of test sources are always test sources, so they should never // appear as separate SourceFolders. setProjectView( "directories:", " common/jslayout", "targets:", " //common/jslayout/...:all", "test_sources:", " */tests/*", "workspace_type: javascript"); VirtualFile rootDir = workspace.createDirectory(new WorkspacePath("common/jslayout")); VirtualFile nestedTestDir = workspace.createDirectory(new WorkspacePath("common/jslayout/tests/foo")); BlazeSyncParams syncParams = BlazeSyncParams.builder() .setTitle("Full Sync") .setSyncMode(SyncMode.FULL) .setSyncOrigin("test") .setBlazeBuildParams(BlazeBuildParams.fromProject(getProject())) .setAddProjectViewTargets(true) .build(); runBlazeSync(syncParams); errorCollector.assertNoIssues(); ImmutableList<ContentEntry> contentEntries = getWorkspaceContentEntries(); assertThat(contentEntries).hasSize(1); SourceFolder root = findSourceFolder(contentEntries.get(0), rootDir); assertThat(root.isTestSource()).isFalse(); SourceFolder child = findSourceFolder(contentEntries.get(0), nestedTestDir); assertThat(child).isNull(); SourceFolder testRoot = findSourceFolder(contentEntries.get(0), nestedTestDir.getParent()); assertThat(testRoot).isNotNull(); assertThat(testRoot.isTestSource()).isTrue(); }
Example #23
Source File: BlazeGoSyncPlugin.java From intellij with Apache License 2.0 | 4 votes |
@Override public ImmutableList<WorkspaceType> getSupportedWorkspaceTypes() { return PlatformUtils.isGoIde() ? ImmutableList.of(WorkspaceType.GO) : ImmutableList.of(); }
Example #24
Source File: BlazeTestSystemPropertiesRule.java From intellij with Apache License 2.0 | 4 votes |
/** Sets up the necessary system properties for running IntelliJ tests via blaze/bazel. */ private static void configureSystemProperties() throws IOException { File sandbox = new File(TestUtils.getTmpDirFile(), "_intellij_test_sandbox"); setSandboxPath("idea.home.path", new File(sandbox, "home")); setSandboxPath("idea.config.path", new File(sandbox, "config")); setSandboxPath("idea.system.path", new File(sandbox, "system")); setSandboxPath("java.util.prefs.userRoot", new File(sandbox, "userRoot")); setSandboxPath("java.util.prefs.systemRoot", new File(sandbox, "systemRoot")); setIfEmpty("idea.classpath.index.enabled", "false"); // Some plugins have a since-build and until-build restriction, so we need // to update the build number here String buildNumber = readApiVersionNumber(); if (buildNumber == null) { buildNumber = BuildNumber.currentVersion().asString(); } setIfEmpty("idea.plugins.compatible.build", buildNumber); setIfEmpty(PlatformUtils.PLATFORM_PREFIX_KEY, determinePlatformPrefix(buildNumber)); // Tests fail if they access files outside of the project roots and other system directories. // Ensure runfiles and platform api are whitelisted. VfsRootAccess.allowRootAccess(RUNFILES_PATH); String platformApi = getPlatformApiPath(); if (platformApi != null) { VfsRootAccess.allowRootAccess(platformApi); } List<String> pluginJars = Lists.newArrayList(); try { Enumeration<URL> urls = BlazeTestSystemPropertiesRule.class.getClassLoader().getResources("META-INF/plugin.xml"); while (urls.hasMoreElements()) { URL url = urls.nextElement(); addArchiveFile(url, pluginJars); } } catch (IOException e) { System.err.println("Cannot find plugin.xml resources"); e.printStackTrace(); } setIfEmpty("idea.plugins.path", Joiner.on(File.pathSeparator).join(pluginJars)); }
Example #25
Source File: JavascriptSyncTest.java From intellij with Apache License 2.0 | 4 votes |
@Test public void testSimpleTestSourcesIdentified() { TestUtils.setPlatformPrefix(getTestRootDisposable(), PlatformUtils.IDEA_PREFIX); setProjectView( "directories:", " common/jslayout/calendar", " common/jslayout/tests", "targets:", " //common/jslayout/...:all", "test_sources:", " common/jslayout/tests", "workspace_type: javascript"); VirtualFile rootFile = workspace.createDirectory(new WorkspacePath("common/jslayout/calendar")); VirtualFile testFile = workspace.createFile(new WorkspacePath("common/jslayout/tests/date_formatter_test.js")); BlazeSyncParams syncParams = BlazeSyncParams.builder() .setTitle("Full Sync") .setSyncMode(SyncMode.FULL) .setSyncOrigin("test") .setBlazeBuildParams(BlazeBuildParams.fromProject(getProject())) .setAddProjectViewTargets(true) .build(); runBlazeSync(syncParams); errorCollector.assertNoIssues(); assertThat(getWorkspaceContentEntries()).hasSize(2); ContentEntry sourceEntry = findContentEntry(rootFile); assertThat(sourceEntry.getSourceFolders()).hasLength(1); SourceFolder nonTestSource = findSourceFolder(sourceEntry, rootFile); assertThat(nonTestSource.isTestSource()).isFalse(); ContentEntry testEntry = findContentEntry(testFile.getParent()); assertThat(testEntry.getSourceFolders()).hasLength(1); SourceFolder testSource = findSourceFolder(testEntry, testFile.getParent()); assertThat(testSource.isTestSource()).isTrue(); }
Example #26
Source File: ShopwareInstallerProjectGenerator.java From idea-php-shopware-plugin with MIT License | 4 votes |
public boolean isPrimaryGenerator() { return PlatformUtils.isPhpStorm(); }
Example #27
Source File: BaseFunctionalTestCase.java From intellij-xquery with Apache License 2.0 | 4 votes |
public BaseFunctionalTestCase() { System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, PlatformUtils.IDEA_CE_PREFIX); }
Example #28
Source File: BaseGuiTest.java From intellij-xquery with Apache License 2.0 | 4 votes |
protected BaseGuiTest() { System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, PlatformUtils.PYCHARM_PREFIX); }
Example #29
Source File: SymfonyInstallerProjectGenerator.java From idea-php-symfony2-plugin with MIT License | 4 votes |
public boolean isPrimaryGenerator() { return PlatformUtils.isPhpStorm(); }
Example #30
Source File: BlazeJavaUserSettings.java From intellij with Apache License 2.0 | 4 votes |
static boolean allowJarCache() { return !SystemInfo.isMac || BuildSystemProvider.defaultBuildSystem().buildSystem() == BuildSystem.Bazel || "AndroidStudio".equals(PlatformUtils.getPlatformPrefix()); }