Java Code Examples for com.intellij.openapi.util.text.StringUtil#isEmptyOrSpaces()
The following examples show how to use
com.intellij.openapi.util.text.StringUtil#isEmptyOrSpaces() .
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: MacroEvaluator.java From consulo-csharp with Apache License 2.0 | 6 votes |
public static boolean evaluate(String text, Set<String> variables) { if(StringUtil.isEmptyOrSpaces(text)) { return true; } try { CompiledExpression compile = Evaluator.compile(text, ourLibrary); return compile.evaluate_boolean(new Object[]{new MacroValueProvider(variables)}); } catch(Throwable throwable) { // if expression is invalid do not break the code return throwable instanceof CompilationException; } }
Example 2
Source File: RenameUtil.java From consulo with Apache License 2.0 | 6 votes |
public static boolean isValidName(final Project project, final PsiElement psiElement, final String newName) { if (newName == null || newName.length() == 0) { return false; } final Condition<String> inputValidator = RenameInputValidatorRegistry.getInputValidator(psiElement); if (inputValidator != null) { return inputValidator.value(newName); } if (psiElement instanceof PsiFile || psiElement instanceof PsiDirectory) { return newName.indexOf('\\') < 0 && newName.indexOf('/') < 0; } if (psiElement instanceof PomTargetPsiElement) { return !StringUtil.isEmptyOrSpaces(newName); } final PsiFile file = psiElement.getContainingFile(); final Language elementLanguage = psiElement.getLanguage(); final Language fileLanguage = file == null ? null : file.getLanguage(); Language language = fileLanguage == null ? elementLanguage : fileLanguage.isKindOf(elementLanguage) ? fileLanguage : elementLanguage; return LanguageNamesValidation.INSTANCE.forLanguage(language).isIdentifier(newName.trim(), project); }
Example 3
Source File: VcsRootErrorsFinder.java From consulo with Apache License 2.0 | 6 votes |
private List<String> mappingsToPathsWithSelectedVcs(@Nonnull List<VcsDirectoryMapping> mappings) { List<String> paths = new ArrayList<String>(); for (VcsDirectoryMapping mapping : mappings) { if (StringUtil.isEmptyOrSpaces(mapping.getVcs())) { continue; } if (!mapping.isDefaultMapping()) { paths.add(mapping.systemIndependentPath()); } else { String basePath = myProject.getBasePath(); if (basePath != null) { paths.add(FileUtil.toSystemIndependentName(basePath)); } } } return paths; }
Example 4
Source File: ChangeListChooserPanel.java From consulo with Apache License 2.0 | 6 votes |
public void setSuggestedName(@Nonnull String name) { if (StringUtil.isEmptyOrSpaces(name)) return; if (getExistingChangelistByName(name) != null) { myExistingListsCombo.setSelectedItem(name); } else { myNewNameSuggested = true; if (VcsConfiguration.getInstance(myProject).PRESELECT_EXISTING_CHANGELIST) { myExistingListsCombo.insertItemAt(name, 0); selectActiveChangeListIfExist(); } else { myListPanel.setChangeListName(name); } } updateDescription(); }
Example 5
Source File: AsposeMavenModuleWizardStep.java From Aspose.OCR-for-Java with MIT License | 6 votes |
@Override public boolean validate() throws ConfigurationException { if (StringUtil.isEmptyOrSpaces(myGroupIdField.getText())) { throw new ConfigurationException("Please, specify groupId"); } if (StringUtil.isEmptyOrSpaces(myArtifactIdField.getText())) { throw new ConfigurationException("Please, specify artifactId"); } if (StringUtil.isEmptyOrSpaces(myVersionField.getText())) { throw new ConfigurationException("Please, specify version"); } return true; }
Example 6
Source File: FindSettingsImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void setFileMask(String _fileMask) { FILE_MASK = _fileMask; if (!StringUtil.isEmptyOrSpaces(_fileMask)) { FindInProjectSettingsBase.addRecentStringToList(_fileMask, recentFileMasks); } }
Example 7
Source File: FileTypeManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
private static void setFileTypeAttributes(@Nonnull UserFileType fileType, @Nullable String name, @Nullable String description, @Nullable String iconPath) { if (!StringUtil.isEmptyOrSpaces(iconPath)) { fileType.setIconPath(iconPath); } if (description != null) { fileType.setDescription(description); } if (name != null) { fileType.setName(name); } }
Example 8
Source File: BazelTestFields.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void checkRunnable(@NotNull BazelTestFields fields, @NotNull Project project) throws RuntimeConfigurationError { // check that bazel target is not empty if (StringUtil.isEmptyOrSpaces(fields.getBazelTarget())) { throw new RuntimeConfigurationError(FlutterBundle.message("flutter.run.bazel.noTargetSet")); } // check that the bazel target starts with "//" if (!fields.getBazelTarget().startsWith("//")) { throw new RuntimeConfigurationError(FlutterBundle.message("flutter.run.bazel.startWithSlashSlash")); } }
Example 9
Source File: DartVmServiceListener.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable private String evaluateExpression(final @NotNull String isolateId, final @Nullable Frame vmTopFrame, final @Nullable XExpression xExpression) { final String evalText = xExpression == null ? null : xExpression.getExpression(); if (vmTopFrame == null || StringUtil.isEmptyOrSpaces(evalText)) return null; final Ref<String> evalResult = new Ref<>(); final Semaphore semaphore = new Semaphore(); semaphore.down(); myDebugProcess.getVmServiceWrapper().evaluateInFrame(isolateId, vmTopFrame, evalText, new XDebuggerEvaluator.XEvaluationCallback() { @Override public void evaluated(@NotNull final XValue result) { if (result instanceof DartVmServiceValue) { evalResult.set(getSimpleStringPresentation(((DartVmServiceValue)result).getInstanceRef())); } semaphore.up(); } @Override public void errorOccurred(@NotNull final String errorMessage) { evalResult.set("Failed to evaluate log expression [" + evalText + "]: " + errorMessage); semaphore.up(); } }); semaphore.waitFor(1000); return evalResult.get(); }
Example 10
Source File: ValueExtractor.java From teamcity-web-parameters with MIT License | 5 votes |
@NotNull String getExpandedRequiredValue(@NotNull String key) { String value = getRequiredValue(key); String expanded = resolve(value); if (StringUtil.isEmptyOrSpaces(expanded)) { throw new RequestConfigurationException(String.format("Required parameter '%s' was expanded to nothing!", key)); } return expanded; }
Example 11
Source File: BrowserLauncherAppless.java From consulo with Apache License 2.0 | 5 votes |
@Contract("null, _, _, _ -> false") public boolean checkPath(@Nullable String browserPath, @Nullable WebBrowser browser, @Nullable Project project, @Nullable Runnable launchTask) { if (!StringUtil.isEmptyOrSpaces(browserPath)) { return true; } String message = browser != null ? browser.getBrowserNotFoundMessage() : IdeBundle.message("error.please.specify.path.to.web.browser", CommonBundle.settingsActionPath()); doShowError(message, browser, project, IdeBundle.message("title.browser.not.found"), launchTask); return false; }
Example 12
Source File: BashPsiFileUtils.java From BashSupport with Apache License 2.0 | 5 votes |
/** * Takes an existing psi file and tries to find another file relative to the first. * The file path is given as a relative path. * * @param start The existing psi file * @param relativePath The relative path as a string * @return The psi file or null if nothing has been found */ @Nullable public static PsiFile findRelativeFile(PsiFile start, String relativePath) { PsiDirectory startDirectory = BashPsiUtils.findFileContext(start).getContainingDirectory(); if (startDirectory == null || StringUtil.isEmptyOrSpaces(relativePath)) { return null; } //fixme handle escaped / chars! PsiDirectory currentDir = startDirectory; List<String> parts = StringUtil.split(relativePath, "/"); String filePart = parts.size() > 0 ? parts.get(parts.size() - 1) : ""; for (int i = 0, partsLength = parts.size() - 1; (i < partsLength) && (currentDir != null); i++) { String part = parts.get(i); if (".".equals(part)) { //ignore this } else if ("..".equals(part)) { currentDir = currentDir.getParentDirectory(); } else { currentDir = currentDir.findSubdirectory(part); } } if (currentDir != null) { return currentDir.findFile(filePart); } return null; }
Example 13
Source File: EqualsAndHashCodeToStringHandler.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
private int calcMemberRank(@NotNull PsiAnnotation includeAnnotation) { final String includeRankValue = PsiAnnotationUtil.getStringAnnotationValue(includeAnnotation, TO_STRING_RANK_ANNOTATION_PARAMETER); if (!StringUtil.isEmptyOrSpaces(includeRankValue)) { try { return Integer.parseInt(includeRankValue); } catch (NumberFormatException ignore) { } } return 0; }
Example 14
Source File: AbstractConstructorClassProcessor.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 4 votes |
private boolean isStaticConstructor(@Nullable String staticName) { return !StringUtil.isEmptyOrSpaces(staticName); }
Example 15
Source File: NewMappings.java From consulo with Apache License 2.0 | 4 votes |
private void removeRedundantMappings() { final LocalFileSystem lfs = LocalFileSystem.getInstance(); final AllVcsesI allVcses = AllVcses.getInstance(myProject); for (Iterator<String> iterator = myVcsToPaths.keySet().iterator(); iterator.hasNext(); ) { final String vcsName = iterator.next(); final Collection<VcsDirectoryMapping> mappings = myVcsToPaths.get(vcsName); List<Pair<VirtualFile, VcsDirectoryMapping>> objects = mapNotNull(mappings, dm -> { VirtualFile vf = lfs.findFileByPath(dm.getDirectory()); if (vf == null) { vf = lfs.refreshAndFindFileByPath(dm.getDirectory()); } return vf == null ? null : Pair.create(vf, dm); }); final List<Pair<VirtualFile, VcsDirectoryMapping>> filteredFiles; // todo static Function<Pair<VirtualFile, VcsDirectoryMapping>, VirtualFile> fileConvertor = pair -> pair.getFirst(); if (StringUtil.isEmptyOrSpaces(vcsName)) { filteredFiles = AbstractVcs.filterUniqueRootsDefault(objects, fileConvertor); } else { final AbstractVcs<?> vcs = allVcses.getByName(vcsName); if (vcs == null) { VcsBalloonProblemNotifier.showOverChangesView(myProject, "VCS plugin not found for mapping to : '" + vcsName + "'", MessageType.ERROR); continue; } filteredFiles = vcs.filterUniqueRoots(objects, fileConvertor); } List<VcsDirectoryMapping> filteredMappings = map(filteredFiles, Functions.pairSecond()); // to calculate what had been removed mappings.removeAll(filteredMappings); if (filteredMappings.isEmpty()) { iterator.remove(); } else { mappings.clear(); mappings.addAll(filteredMappings); } } sortedMappingsByMap(); }
Example 16
Source File: BlazeGoRunConfigurationRunner.java From intellij with Apache License 2.0 | 4 votes |
GoApplicationRunningState toNativeState(ExecutionEnvironment env) throws ExecutionException { ExecutableInfo executable = getExecutableInfo(env); if (executable == null || StringUtil.isEmptyOrSpaces(executable.binary.getPath())) { throw new ExecutionException("Blaze output binary not found"); } Project project = env.getProject(); BlazeProjectData projectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData(); if (projectData == null) { throw new ExecutionException("Project data not found. Please run blaze sync."); } GoApplicationConfiguration nativeConfig = (GoApplicationConfiguration) GoApplicationRunConfigurationType.getInstance() .getConfigurationFactories()[0] .createTemplateConfiguration(project, RunManager.getInstance(project)); nativeConfig.setKind(Kind.PACKAGE); // prevents binary from being deleted by // GoBuildingRunningState$ProcessHandler#processTerminated nativeConfig.setOutputDirectory(executable.binary.getParent()); nativeConfig.setParams(ParametersListUtil.join(getParameters(executable))); nativeConfig.setWorkingDirectory(executable.workingDir.getPath()); Map<String, String> customEnvironment = new HashMap<>(nativeConfig.getCustomEnvironment()); for (Map.Entry<String, String> entry : executable.envVars.entrySet()) { customEnvironment.put(entry.getKey(), entry.getValue()); } String testFilter = getTestFilter(); if (testFilter != null) { customEnvironment.put("TESTBRIDGE_TEST_ONLY", testFilter); } nativeConfig.setCustomEnvironment(customEnvironment); Module module = ModuleManager.getInstance(project) .findModuleByName(BlazeDataStorage.WORKSPACE_MODULE_NAME); if (module == null) { throw new ExecutionException("Workspace module not found"); } GoApplicationRunningState nativeState = new GoApplicationRunningState(env, module, nativeConfig) { @Override public boolean isDebug() { return true; } @Nullable @Override public List<String> getBuildingTarget() { return null; } @Nullable @Override public GoExecutor createBuildExecutor() { return null; } }; nativeState.setOutputFilePath(executable.binary.getPath()); return nativeState; }
Example 17
Source File: ExecutableHelper.java From consulo with Apache License 2.0 | 4 votes |
public static void debug(@Nonnull String msg) { if (!StringUtil.isEmptyOrSpaces(msg)) { LOG.info(msg); } }
Example 18
Source File: PsiTreeUtil.java From consulo with Apache License 2.0 | 4 votes |
@Nullable public static PsiElement prevVisibleLeaf(@Nonnull final PsiElement element) { PsiElement prevLeaf = prevLeaf(element, true); while (prevLeaf != null && StringUtil.isEmptyOrSpaces(prevLeaf.getText())) prevLeaf = prevLeaf(prevLeaf, true); return prevLeaf; }
Example 19
Source File: CreateLauncherScriptAction.java From consulo with Apache License 2.0 | 4 votes |
public static String defaultScriptName() { String scriptName = ApplicationNamesInfo.getInstance().getScriptName(); return StringUtil.isEmptyOrSpaces(scriptName) ? "idea" : scriptName; }
Example 20
Source File: LocalChangeListImpl.java From consulo with Apache License 2.0 | 4 votes |
void setNameImpl(@Nonnull final String name) { if (StringUtil.isEmptyOrSpaces(name) && Registry.is("vcs.log.empty.change.list.creation")) { LOG.info("Creating a changelist with empty name"); } myName = name; }