Java Code Examples for com.intellij.util.text.StringTokenizer#nextToken()
The following examples show how to use
com.intellij.util.text.StringTokenizer#nextToken() .
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: ConsoleViewUtil.java From consulo with Apache License 2.0 | 6 votes |
public static void printWithHighlighting(@Nonnull ConsoleView console, @Nonnull String text, @Nonnull SyntaxHighlighter highlighter, Runnable doOnNewLine) { Lexer lexer = highlighter.getHighlightingLexer(); lexer.start(text, 0, text.length(), 0); IElementType tokenType; while ((tokenType = lexer.getTokenType()) != null) { ConsoleViewContentType contentType = getContentTypeForToken(tokenType, highlighter); StringTokenizer eolTokenizer = new StringTokenizer(lexer.getTokenText(), "\n", true); while (eolTokenizer.hasMoreTokens()) { String tok = eolTokenizer.nextToken(); console.print(tok, contentType); if (doOnNewLine != null && "\n".equals(tok)) { doOnNewLine.run(); } } lexer.advance(); } }
Example 2
Source File: HaxeCompilerServices.java From intellij-haxe with Apache License 2.0 | 5 votes |
private void formatAndAddCompilerArguments(ArrayList<String> commandLineArguments, String flags) { if (null != flags && !flags.isEmpty()) { final StringTokenizer flagsTokenizer = new StringTokenizer(flags); while (flagsTokenizer.hasMoreTokens()) { String nextToken = flagsTokenizer.nextToken(); if (!nextToken.isEmpty()) { commandLineArguments.add(nextToken); } } } }
Example 3
Source File: TestsLocationProviderUtil.java From consulo with Apache License 2.0 | 5 votes |
public static List<VirtualFile> findSuitableFilesFor(final String filePath, final Project project) { final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex(); // at first let's try to find file as is, by it's real path // and check that file belongs to current project // this location provider designed for tests thus we will check only project content // (we cannot check just sources or tests folders because RM doesn't use it final VirtualFile file = getByFullPath(filePath); final boolean inProjectContent = file != null && (index.isInContent(file)); if (inProjectContent) { return Collections.singletonList(file); } //split file by "/" in parts final LinkedList<String> folders = new LinkedList<String>(); final StringTokenizer st = new StringTokenizer(filePath, "/", false); String fileName = null; while (st.hasMoreTokens()) { final String pathComponent = st.nextToken(); if (st.hasMoreTokens()) { folders.addFirst(pathComponent); } else { // last token fileName = pathComponent; } } if (fileName == null) { return Collections.emptyList(); } return findFilesClosestToTarget(folders, collectCandidates(project, fileName, true), MIN_PROXIMITY_THRESHOLD); }
Example 4
Source File: SplitterProportionsDataImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void readExternal(Element element) throws InvalidDataException { proportions.clear(); String prop = element.getAttributeValue(ATTRIBUTE_PROPORTIONS); String version = element.getAttributeValue(ATTRIBUTE_VERSION); if (prop != null && Comparing.equal(version, DATA_VERSION)) { StringTokenizer tokenizer = new StringTokenizer(prop, ","); while (tokenizer.hasMoreTokens()) { String p = tokenizer.nextToken(); proportions.add(Float.valueOf(p)); } } }
Example 5
Source File: LibraryUtil.java From consulo with Apache License 2.0 | 5 votes |
private static boolean findInFile(VirtualFile file, final StringTokenizer tokenizer) { if (!tokenizer.hasMoreTokens()) return true; @NonNls StringBuilder name = new StringBuilder(tokenizer.nextToken()); if (!tokenizer.hasMoreTokens()) { name.append(".class"); } final VirtualFile child = file.findChild(name.toString()); return child != null && findInFile(child, tokenizer); }
Example 6
Source File: HorizontalLabeledIcon.java From consulo with Apache License 2.0 | 5 votes |
/** * @param icon not <code>null</code> icon. * @param text to be painted under the <code>icon<code>. This parameter can * be <code>null</code> if text isn't specified. In that case <code>LabeledIcon</code> */ public HorizontalLabeledIcon(Icon icon, String text, String mnemonic) { myIcon = icon; if (text != null) { StringTokenizer tokenizer = new StringTokenizer(text, "\n"); myStrings = new String[tokenizer.countTokens()]; for (int i = 0; tokenizer.hasMoreTokens(); i++) { myStrings[i] = tokenizer.nextToken(); } } else { myStrings = null; } myMnemonic = mnemonic; }
Example 7
Source File: MyLookupItem.java From CppTools with Apache License 2.0 | 4 votes |
public MyLookupItem(String s) { try { StringTokenizer tokenizer = new StringTokenizer(s, Communicator.DELIMITER_STRING); final String completionType = tokenizer.nextElement(); name = tokenizer.nextToken(); signature = tokenizer.nextToken(); boolean hasFileNameInTypeSignature = false; boolean takeReturnOrDeclarationType = false; if ("func".equals(completionType)) { icon = Icons.METHOD_ICON; takeReturnOrDeclarationType = true; } else if ("var".equals(completionType)) { icon = Icons.VARIABLE_ICON; takeReturnOrDeclarationType = true; } else if ("type".equals(completionType)) { icon = Icons.CLASS_ICON; } else if ("macro".equals(completionType)) { icon = macroIcon; hasFileNameInTypeSignature = true; } else if ("macro-param".equals(completionType)) { icon = Icons.PARAMETER_ICON; } else if ("filename".equals(completionType)) { icon = Icons.FILE_ICON; hasFileNameInTypeSignature = true; } else if ("dirname".equals(completionType)) { icon = Icons.DIRECTORY_OPEN_ICON; hasFileNameInTypeSignature = true; } if (!hasFileNameInTypeSignature && takeReturnOrDeclarationType) { final int i = signature.indexOf(name); if (i != -1) { type = signature.substring(0, i).trim(); } else { final int spaceIndex = signature.indexOf(' '); type = signature.substring(0, spaceIndex != -1 ? spaceIndex:signature.length()); } } else { type = signature; } if (type != null && type.length() > 50) { StringBuilder builder = new StringBuilder(50); builder.append(type.substring(0, 15)); builder.append("..."); builder.append(type.substring(type.length() - 35, type.length())); type = builder.toString(); } } catch (NoSuchElementException e1) { throw e1; } }