/** * Parses single entries and removes git output prefixes. * * @param text input data * @return single unignored entry */ @Nullable @Override protected String parseOutput(@NotNull String text) { return StringUtil.trim(StringUtil.trimStart(text, GIT_UNIGNORED_FILES_PREFIX)); } }
@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; }
/** * Returns entry value without leading `!` if entry is negated. * * @return entry value without `!` negation sign */ @NotNull public String getValue() { String value = getText(); if (isNegated()) { value = StringUtil.trimStart(value, "!"); } return value; }
@Nullable public String getBuildFlags() { GoFileStub stub = getStub(); if (stub != null) { return stub.getBuildFlags(); } // https://code.google.com/p/go/source/browse/src/pkg/go/build/build.go?r=2449e85a115014c3d9251f86d499e5808141e6bc#790 Collection<String> buildFlags = ContainerUtil.newArrayList(); int buildFlagLength = GoConstants.BUILD_FLAG.length(); for (PsiComment comment : getCommentsToConsider(this)) { String commentText = StringUtil.trimStart(comment.getText(), "//").trim(); if (commentText.startsWith(GoConstants.BUILD_FLAG) && commentText.length() > buildFlagLength && StringUtil.isWhiteSpace(commentText.charAt(buildFlagLength))) { ContainerUtil.addIfNotNull(buildFlags, StringUtil.nullize(commentText.substring(buildFlagLength).trim(), true)); } } return !buildFlags.isEmpty() ? StringUtil.join(buildFlags, "|") : null; }
public boolean matchBuildFlag(@NotNull String name) { if (name.isEmpty()) return false; if (StringUtil.containsChar(name, ',')) { // comma separated list for (String tag : StringUtil.split(name, ",")) { if (!matchBuildFlag(tag)) { return false; } } return true; } // bad syntax, reject always if (name.startsWith("!!")) return false; // negation if (name.startsWith("!")) return !matchBuildFlag(name.substring(1)); if (matchOS(name)) return true; if (GoConstants.KNOWN_COMPILERS.contains(name)) { return myTarget.compiler == null || name.equals(myTarget.compiler); } if (GoConstants.KNOWN_VERSIONS.contains(name)) { return myTarget.goVersion == null || GoSdkUtil.compareVersions(myTarget.goVersion, StringUtil.trimStart(name, "go")) >= 0; } if ("cgo".equals(name)) { return myTarget.cgoEnabled == ThreeState.YES; } return myTarget.supportsFlag(name); }
virtualFile = findInGoPath(fileName); if (virtualFile == null && fileName.startsWith("src/")) { virtualFile = findInGoPath(StringUtil.trimStart(fileName, "src/")); if (virtualFile == null && fileName.startsWith("src/")) { virtualFile = baseDir.findFileByRelativePath(StringUtil.trimStart(fileName, "src/"));
private String name() { return StringUtil.decapitalize(StringUtil.trimEnd(StringUtil.trimStart(getClass().getSimpleName(), "Gitignore"), "InspectionTest")); }
protected String getProjectName(){ return StringUtil.decapitalize(StringUtil.trimStart(getName(), "test")); }
continue; relativePath = StringUtil.trimStart(file.getPath(), workingDirectory.getPath()); } else { final VirtualFile vcsRoot = getVcsRootFor(file); continue; relativePath = StringUtil.trimStart(file.getPath(), parentPath); relativePath = StringUtil.trimEnd(StringUtil.trimStart(relativePath, "/"), "/"); if (StringUtil.isEmpty(relativePath)) { continue;
@NotNull @Override protected String doCleanDistributionItem(@NotNull String rawItem) { return StringUtil.trimStart(rawItem, "i ").trim(); }
private String cleanupComment(String text) { List<String> lines = StringUtil.split(text, "\n"); StringBuilder result = new StringBuilder(); for (String line : lines) { String cleanedLine = StringUtil.trimStart(line.substring(1), " "); result.append(StringEscapeUtils.escapeHtml(cleanedLine)); result.append("<br/>"); } return result.toString(); }
public static List<String> getTagValues(List<PsiComment> comment, String tag) { return comment.stream() .filter(c -> c.getText().startsWith("//!")) .map(c -> StringUtil.trimStart(c.getText(), "//!").trim()) .filter(line -> line.startsWith(tag)) .map(line -> StringUtil.trimStart(line, tag).trim()) .collect(Collectors.toList()); } }
/** * Strips class name from Object#toString if present. * To be used as custom data type renderer for java.lang.Object. * To activate just add <code>StringUtil.toShortString(this)</code> * expression in <em>Settings | Debugger | Data Views</em>. */ @Contract("null->null;!null->!null") @SuppressWarnings("UnusedDeclaration") static String toShortString(@Nullable Object o) { if (o == null) return null; if (o instanceof CharSequence) return o.toString(); String className = o.getClass().getName(); String s = o.toString(); if (!s.startsWith(className)) return s; return s.length() > className.length() && !Character.isLetter(s.charAt(className.length())) ? trimStart(s, className) : s; }
/** * Return Color object from string. The following formats are allowed: * <code>#abc123</code>, * <code>ABC123</code>, * <code>ab5</code>, * <code>#FFF</code>. * * @param str hex string * @return Color object */ public static Color fromHex(String str) { str = StringUtil.trimStart(str, "#"); if (str.length() == 3) { return new Color( 17 * Integer.valueOf(String.valueOf(str.charAt(0)), 16).intValue(), 17 * Integer.valueOf(String.valueOf(str.charAt(1)), 16).intValue(), 17 * Integer.valueOf(String.valueOf(str.charAt(2)), 16).intValue()); } else if (str.length() == 6) { return Color.decode("0x" + str); } else { throw new IllegalArgumentException("Should be String of 3 or 6 chars length."); } }
public InvokableInformation(String fullSignature, String name) { String signatureWithoutName = StringUtil.trimStart(fullSignature, name); Matcher m = CypherElementWithSignature.FULL_SIGNATURE_REGEXP.matcher(signatureWithoutName); if (m.find()) { signature = m.group(1); returnTypeString = m.group(2); } else { // should never happen, unless Neo4j changes signature syntax signature = fullSignature; returnTypeString = "ANY?"; } returnType = CypherType.parse(returnTypeString); this.name = name; this.hasParameters = !this.signature.startsWith("()"); this.arguments = parseArguments(); this.arity = calculateArity(); }
@NotNull @Override public Collection<PsiElement> getTargets(@NotNull TargetLocatorParameter parameter) { if(!parameter.getTarget().startsWith("file://")) { return Collections.emptyList(); } String projectFile = parameter.getTarget().substring("file://".length()); projectFile = StringUtil.trimStart(projectFile.replaceAll("\\\\+", "/").replaceAll("/+", "/"), "/"); VirtualFile relativeFile = VfsUtil.findRelativeFile(parameter.getProject().getBaseDir(), projectFile.split("/")); if(relativeFile == null) { return Collections.emptyList(); } PsiFile file = PsiManager.getInstance(parameter.getProject()).findFile(relativeFile); if(file == null) { return Collections.emptyList(); } Collection<PsiElement> targets = new ArrayList<>(); targets.add(file); return targets; } }
private static String adjustMultiLine(String expected) { final List<String> strings = StringUtil.split(StringUtil.trimStart(expected, "\n"), "\n"); int min = Integer.MAX_VALUE; for (String s : strings) { int k = 0; while (k < s.length() && s.charAt(k) == ' ') { k++; } min = Math.min(min, k); } List<String> lines = new ArrayList<String>(); for (String s : strings) { lines.add(s.substring(min)); } return StringUtil.join(lines, "\n") + "\n"; }
public static String getRelativeJavaTestDataPath() { final String absolute = getJavaTestDataPath(); return StringUtil.trimStart(absolute, PathManager.getHomePath()); }