private void decreaseIndent() { myIndent = StringUtil.trimEnd(myIndent, MY_INDENT); }
@Nullable private static String suggestSdkDirectoryPathFromEnv() { File fileFromPath = PathEnvironmentVariableUtil.findInPath("go"); if (fileFromPath != null) { File canonicalFile; try { canonicalFile = fileFromPath.getCanonicalFile(); String path = canonicalFile.getPath(); if (path.endsWith("bin/go")) { return StringUtil.trimEnd(path, "bin/go"); } } catch (IOException ignore) { } } return null; }
@NotNull private static String commitButtonMessage(@Nullable CommitExecutor executor, @NotNull CheckinProjectPanel panel) { return StringUtil.trimEnd(executor != null ? executor.getActionText() : panel.getCommitActionName(), "..."); }
@Nullable private static String getGaeExecutablePath(@NotNull String sdkHomePath) { String goExecutablePath = PathUtil.toSystemIndependentName(sdkHomePath); goExecutablePath = StringUtil.trimEnd(goExecutablePath, GoConstants.APP_ENGINE_GO_ROOT_DIRECTORY_PATH); boolean gcloudInstallation = goExecutablePath.endsWith(GoConstants.GCLOUD_APP_ENGINE_DIRECTORY_PATH); if (gcloudInstallation) { LOG.debug("Detected gcloud GAE installation at " + goExecutablePath); goExecutablePath = FileUtil.join(StringUtil.trimEnd(goExecutablePath, GoConstants.GCLOUD_APP_ENGINE_DIRECTORY_PATH), "bin"); } String executablePath = FileUtil.join(goExecutablePath, GoEnvironmentUtil.getGaeExecutableFileName(gcloudInstallation)); return new File(executablePath).exists() ? executablePath : null; }
@Nullable private static String suggestSdkDirectoryPathFromEnv() { File fileFromPath = PathEnvironmentVariableUtil.findInPath("ballerina"); if (fileFromPath != null) { File canonicalFile; try { canonicalFile = fileFromPath.getCanonicalFile(); String path = canonicalFile.getPath(); if (path.endsWith(BALLERINA_EXEC_PATH)) { return StringUtil.trimEnd(path, BALLERINA_EXEC_PATH); } } catch (IOException ignore) { } } return null; }
@Nullable public static String getTestTargetPackage(@Nullable PsiFile file) { if (isTestFile(file)) { String packageName = ((GoFile)file).getPackageName(); if (packageName != null && packageName.endsWith(GoConstants.TEST_SUFFIX)) { return StringUtil.nullize(StringUtil.trimEnd(packageName, GoConstants.TEST_SUFFIX)); } } return null; }
/** * Handles single output line. * * @param text execution response * @param outputType output type */ public void onTextAvailable(@NotNull String text, @NotNull Key outputType) { if (outputType == ProcessOutputTypes.SYSTEM) { return; } if (outputType == ProcessOutputTypes.STDERR) { errorsReported = true; return; } ContainerUtil.addIfNotNull(outputs, parseOutput(StringUtil.trimEnd(text, "\n").trim())); }
public boolean matchFileName(@NotNull String fileName) { String name = StringUtil.substringAfter(fileName, "_"); if (StringUtil.isEmpty(name)) { return true; } name = StringUtil.trimEnd(FileUtil.getNameWithoutExtension(name), GoConstants.TEST_SUFFIX); List<String> parts = StringUtil.split(name, "_"); int n = parts.size(); if (n >= 2 && GoConstants.KNOWN_OS.contains(parts.get(n - 2)) && GoConstants.KNOWN_ARCH.contains(parts.get(n - 1))) { if (!myTarget.arch.equals(parts.get(n - 1))) { return false; } return matchOS(parts.get(n - 2)); } if (n >= 1) { if (GoConstants.KNOWN_OS.contains(parts.get(n - 1))) { return matchOS(parts.get(n - 1)); } if (GoConstants.KNOWN_ARCH.contains(parts.get(n - 1))) { return myTarget.arch.equals(parts.get(n - 1)); } } return true; }
@NotNull @Override public Collection<PsiElement> findClassesForTest(@NotNull PsiElement element) { PsiFile testFile = InjectedLanguageUtil.getTopLevelFile(element); if (testFile instanceof GoFile) { PsiDirectory directory = testFile.getContainingDirectory(); PsiFile sourceFile = directory.findFile(StringUtil.trimEnd(testFile.getName(), GoConstants.TEST_SUFFIX_WITH_EXTENSION) + EXTENSION); if (sourceFile != null) { return ContainerUtil.newSmartList(sourceFile); } } return Collections.emptyList(); }
public String getCanonicalPackageName() { String packageName = getPackageName(); if (StringUtil.isNotEmpty(packageName) && GoTestFinder.isTestFile(this)) { return StringUtil.trimEnd(packageName, GoConstants.TEST_SUFFIX); } return packageName; }
@NotNull private static List<String> getStrings(@NotNull List<PsiComment> comments) { List<String> strings = ContainerUtil.newArrayList(); for (PsiComment comment : comments) { IElementType type = comment.getTokenType(); if (type == GoParserDefinition.LINE_COMMENT) { strings.add(StringUtil.trimStart(StringUtil.trimStart(comment.getText(), "//"), " ")); } else if (type == GoParserDefinition.MULTILINE_COMMENT) { String text = StringUtil.trimEnd(comment.getText(), "*/"); text = StringUtil.trimStart(text, "/*"); text = LEADING_TAB.matcher(text).replaceAll(""); Collections.addAll(strings, StringUtil.splitByLines(text, false)); } } return strings; }
protected void reparse() { ProgressManager.checkCanceled(); String str = StringUtil.trimEnd(getPathString(), getSeparatorString()); final List<FileReference> referencesList = ContainerUtil.newArrayList();
private String name() { return StringUtil.decapitalize(StringUtil.trimEnd(StringUtil.trimStart(getClass().getSimpleName(), "Gitignore"), "InspectionTest")); }
protected void processOutput(@NotNull String text, Key outputType, ServiceMessageVisitor visitor) throws ParseException { if (text.isEmpty()) { return; } boolean isErrorMessage = ProcessOutputTypes.STDERR == outputType; if (myCurrentTestName != null) { ServiceMessageBuilder builder = isErrorMessage ? ServiceMessageBuilder.testStdErr(myCurrentTestName) : ServiceMessageBuilder.testStdOut(myCurrentTestName); super.processServiceMessages(builder.addAttribute("out", text).toString(), outputType, visitor); return; } ServiceMessageBuilder messageBuilder = new ServiceMessageBuilder(ServiceMessageTypes.MESSAGE); if (isErrorMessage) { messageBuilder.addAttribute("text", StringUtil.trimEnd(text, "\n")).addAttribute("status", "ERROR"); } else { messageBuilder.addAttribute("text", text).addAttribute("status", "NORMAL"); } super.processServiceMessages(messageBuilder.toString(), outputType, visitor); }
public GoRunConfigurationBase(String name, GoModuleBasedConfiguration configurationModule, ConfigurationFactory factory) { super(name, configurationModule, factory); Module module = configurationModule.getModule(); if (module == null) { Collection<Module> modules = getValidModules(); if (modules.size() == 1) { module = ContainerUtil.getFirstItem(modules); getConfigurationModule().setModule(module); } } if (module != null) { if (FileUtil.exists(module.getModuleFilePath())) { myWorkingDirectory = StringUtil.trimEnd(PathUtil.getParentPath(module.getModuleFilePath()), ".idea"); } } else { myWorkingDirectory = StringUtil.notNullize(configurationModule.getProject().getBasePath()); } }
Set<String> allTestFunctionNames = collectAllTestNames(allPackageFunctionNames, project, (GoFile)file); String fileNameWithoutTestPrefix = StringUtil.trimEnd(file.getName(), GoConstants.TEST_SUFFIX_WITH_EXTENSION) + ".go"; GlobalSearchScope packageScope = GoPackageUtil.packageScope(containingDirectory, ((GoFile)file).getCanonicalPackageName()); GlobalSearchScope scope = new GoUtil.ExceptTestsScope(packageScope);
public BallerinaRunConfigurationBase(String name, BallerinaModuleBasedConfiguration configurationModule, ConfigurationFactory factory) { super(name, configurationModule, factory); Module module = configurationModule.getModule(); if (module == null) { Collection<Module> modules = getValidModules(); if (modules.size() == 1) { module = ContainerUtil.getFirstItem(modules); getConfigurationModule().setModule(module); } } if (module != null) { if (FileUtil.exists(module.getModuleFilePath())) { myWorkingDirectory = StringUtil.trimEnd(PathUtil.getParentPath(module.getModuleFilePath()), BallerinaConstants.IDEA_CONFIG_DIRECTORY); } } else { myWorkingDirectory = StringUtil.notNullize(configurationModule.getProject().getBasePath()); } setFileOutputPath(myWorkingDirectory); }
relativePath = StringUtil.trimEnd(StringUtil.trimStart(relativePath, "/"), "/"); if (StringUtil.isEmpty(relativePath)) { continue;