use of com.intellij.util.text.StringTokenizer in project intellij-community by JetBrains.
the class DebuggerTreeBase method createTipContent.
private JComponent createTipContent(String tipText, DebuggerTreeNodeImpl node) {
final JToolTip tooltip = new JToolTip();
if (tipText == null) {
tooltip.setTipText(tipText);
} else {
Dimension rootSize = getVisibleRect().getSize();
Insets borderInsets = tooltip.getBorder().getBorderInsets(tooltip);
rootSize.width -= (borderInsets.left + borderInsets.right) * 2;
rootSize.height -= (borderInsets.top + borderInsets.bottom) * 2;
@NonNls StringBuilder tipBuilder = new StringBuilder();
final String markupText = node.getMarkupTooltipText();
if (markupText != null) {
tipBuilder.append(markupText);
}
if (!tipText.isEmpty()) {
final StringTokenizer tokenizer = new StringTokenizer(tipText, "\n ", true);
while (tokenizer.hasMoreElements()) {
final String each = tokenizer.nextElement();
if ("\n".equals(each)) {
tipBuilder.append("<br>");
} else if (" ".equals(each)) {
tipBuilder.append("  ");
} else {
tipBuilder.append(JDOMUtil.legalizeText(each));
}
}
}
tooltip.setTipText(UIUtil.toHtml(tipBuilder.toString(), 0));
}
tooltip.setBorder(null);
return tooltip;
}
use of com.intellij.util.text.StringTokenizer in project intellij-community by JetBrains.
the class AntDomTargetDependsListConverter method fromString.
public TargetResolver.Result fromString(@Nullable @NonNls String s, ConvertContext context) {
final AntDomProject project = context.getInvocationElement().getParentOfType(AntDomProject.class, false);
if (project == null) {
return null;
}
final AntDomTarget contextTarget = context.getInvocationElement().getParentOfType(AntDomTarget.class, false);
if (contextTarget == null) {
return null;
}
final List<String> refs;
if (s == null) {
refs = Collections.emptyList();
} else {
refs = new ArrayList<>();
final StringTokenizer tokenizer = new StringTokenizer(s, ",", false);
while (tokenizer.hasMoreTokens()) {
final String ref = tokenizer.nextToken();
refs.add(ref.trim());
}
}
final TargetResolver.Result result = TargetResolver.resolve(project.getContextAntProject(), contextTarget, refs);
result.setRefsString(s);
return result;
}
use of com.intellij.util.text.StringTokenizer in project intellij-community by JetBrains.
the class IdeTestApplication method addAdditionalClassPath.
private static void addAdditionalClassPath(@NotNull Collection<URL> classpath) throws MalformedURLException {
StringTokenizer tokenizer = new StringTokenizer(System.getProperty(PROPERTY_ADDITIONAL_CLASSPATH, ""), File.pathSeparator, false);
while (tokenizer.hasMoreTokens()) {
String pathItem = tokenizer.nextToken();
classpath.add(new File(pathItem).toURI().toURL());
}
}
use of com.intellij.util.text.StringTokenizer in project intellij-community by JetBrains.
the class ConsoleViewUtil method printWithHighlighting.
public static void printWithHighlighting(@NotNull ConsoleView console, @NotNull String text, @NotNull 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();
}
}
use of com.intellij.util.text.StringTokenizer in project intellij-community by JetBrains.
the class TestsLocationProviderUtil method findSuitableFilesFor.
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<>();
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();
}
final List<VirtualFile> target = findFilesClosestToTarget(folders, collectCandidates(project, fileName, true), MIN_PROXIMITY_THRESHOLD);
return target.isEmpty() && file != null ? Collections.singletonList(file) : target;
}
Aggregations