Java Code Examples for com.intellij.openapi.util.text.StringUtil#indexOfIgnoreCase()
The following examples show how to use
com.intellij.openapi.util.text.StringUtil#indexOfIgnoreCase() .
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: TypoTolerantMatcher.java From consulo with Apache License 2.0 | 6 votes |
private int indexOfIgnoreCase(int fromIndex, int patternIndex, @Nonnull ErrorState errorState) { char p = charAt(patternIndex, errorState); if (isAsciiName && IOUtil.isAscii(p)) { int i = indexIgnoringCaseAscii(fromIndex, patternIndex, p); if (i != -1) return i; if (myAllowTypos) { int leftMiss = indexIgnoringCaseAscii(fromIndex, patternIndex, leftMiss(p)); if (leftMiss != -1) return leftMiss; int rightMiss = indexIgnoringCaseAscii(fromIndex, patternIndex, rightMiss(p)); if (rightMiss != -1) return rightMiss; } return -1; } return StringUtil.indexOfIgnoreCase(myName, p, fromIndex); }
Example 2
Source File: MinusculeMatcherImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private FList<TextRange> matchBySubstring(@Nonnull String name) { boolean infix = isPatternChar(0, '*'); char[] patternWithoutWildChar = filterWildcard(myPattern); if (name.length() < patternWithoutWildChar.length) { return null; } if (infix) { int index = StringUtil.indexOfIgnoreCase(name, new CharArrayCharSequence(patternWithoutWildChar, 0, patternWithoutWildChar.length), 0); if (index >= 0) { return FList.<TextRange>emptyList().prepend(TextRange.from(index, patternWithoutWildChar.length - 1)); } return null; } if (CharArrayUtil.regionMatches(patternWithoutWildChar, 0, patternWithoutWildChar.length, name)) { return FList.<TextRange>emptyList().prepend(new TextRange(0, patternWithoutWildChar.length)); } return null; }
Example 3
Source File: SearchUtil.java From consulo with Apache License 2.0 | 6 votes |
private static String markupInText(String textToMarkup, Pattern insideHtmlTagPattern, String option) { String result = ""; int beg = 0; int idx; while ((idx = StringUtil.indexOfIgnoreCase(textToMarkup, option, beg)) != -1) { final String prefix = textToMarkup.substring(beg, idx); final String toMark = textToMarkup.substring(idx, idx + option.length()); if (insideHtmlTagPattern.matcher(prefix).matches()) { final int lastIdx = textToMarkup.indexOf(">", idx); result += prefix + textToMarkup.substring(idx, lastIdx + 1); beg = lastIdx + 1; } else { result += prefix + "<font color='#ffffff' bgColor='#1d5da7'>" + toMark + "</font>"; beg = idx + option.length(); } } result += textToMarkup.substring(beg); return result; }
Example 4
Source File: MinusculeMatcherImpl.java From consulo with Apache License 2.0 | 5 votes |
private int indexOfIgnoreCase(String name, int fromIndex, char p, int patternIndex, boolean isAsciiName) { if (isAsciiName && IOUtil.isAscii(p)) { char pUpper = toUpperCase[patternIndex]; char pLower = toLowerCase[patternIndex]; for (int i = fromIndex; i < name.length(); i++) { char c = name.charAt(i); if (c == p || toUpperAscii(c) == pUpper || toLowerAscii(c) == pLower) { return i; } } return -1; } return StringUtil.indexOfIgnoreCase(name, p, fromIndex); }
Example 5
Source File: DocumentationComponent.java From consulo with Apache License 2.0 | 5 votes |
private static int findContentStart(String text) { int index = StringUtil.indexOfIgnoreCase(text, "<body>", 0); if (index >= 0) return index + 6; index = StringUtil.indexOfIgnoreCase(text, "</head>", 0); if (index >= 0) return index + 7; index = StringUtil.indexOfIgnoreCase(text, "</style>", 0); if (index >= 0) return index + 8; index = StringUtil.indexOfIgnoreCase(text, "<html>", 0); if (index >= 0) return index + 6; return -1; }
Example 6
Source File: AbstractExternalFilter.java From consulo with Apache License 2.0 | 5 votes |
private static boolean reachTheEnd(StringBuilder data, String read, StringBuilder classDetails) { if (StringUtil.indexOfIgnoreCase(read, FIELD_SUMMARY, 0) != -1 || StringUtil.indexOfIgnoreCase(read, CLASS_SUMMARY, 0) != -1) { data.append(classDetails); data.append(HTML_CLOSE); return true; } return false; }
Example 7
Source File: BaseAnalysisActionDialog.java From consulo with Apache License 2.0 | 5 votes |
private int getSelectedScopeMnemonic() { final int fileIdx = StringUtil.indexOfIgnoreCase(myFileName, "file", 0); if (fileIdx > -1) { return fileIdx; } final int dirIdx = StringUtil.indexOfIgnoreCase(myFileName, "directory", 0); if (dirIdx > -1) { return dirIdx; } return 0; }
Example 8
Source File: GotoActionModel.java From consulo with Apache License 2.0 | 5 votes |
private static void appendWithColoredMatches(SimpleColoredComponent nameComponent, @Nonnull String name, @Nonnull String pattern, Color fg, boolean selected) { SimpleTextAttributes plain = new SimpleTextAttributes(STYLE_PLAIN, fg); SimpleTextAttributes highlighted = new SimpleTextAttributes(null, fg, null, STYLE_SEARCH_MATCH); List<TextRange> fragments = new ArrayList<>(); if (selected) { int matchStart = StringUtil.indexOfIgnoreCase(name, pattern, 0); if (matchStart >= 0) { fragments.add(TextRange.from(matchStart, pattern.length())); } } SpeedSearchUtil.appendColoredFragments(nameComponent, name, fragments, plain, highlighted); }
Example 9
Source File: ReplacePathToMacroMap.java From consulo with Apache License 2.0 | 4 votes |
private String replacePathMacroRecursively(String text, final String path, boolean caseSensitive) { if (text.length() < path.length()) { return text; } if (path.isEmpty()) return text; final StringBuilder newText = new StringBuilder(); final boolean isWindowsRoot = path.endsWith(":/"); int i = 0; while (i < text.length()) { int occurrenceOfPath = caseSensitive ? text.indexOf(path, i) : StringUtil.indexOfIgnoreCase(text, path, i); if (occurrenceOfPath >= 0) { int endOfOccurrence = occurrenceOfPath + path.length(); if (!isWindowsRoot && endOfOccurrence < text.length() && text.charAt(endOfOccurrence) != '/' && text.charAt(endOfOccurrence) != '\"' && text.charAt(endOfOccurrence) != ' ' && !text.substring(endOfOccurrence).startsWith("!/")) { newText.append(text.substring(i, endOfOccurrence)); i = endOfOccurrence; continue; } if (occurrenceOfPath > 0) { char prev = text.charAt(occurrenceOfPath - 1); if (Character.isLetterOrDigit(prev) || prev == '_') { newText.append(text.substring(i, endOfOccurrence)); i = endOfOccurrence; continue; } } } if (occurrenceOfPath < 0) { if (newText.length() == 0) { return text; } newText.append(text.substring(i)); break; } else { newText.append(text.substring(i, occurrenceOfPath)); newText.append(myMacroMap.get(path)); i = occurrenceOfPath + path.length(); } } return newText.toString(); }