Search in sources :

Example 16 with StringTokenizer

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("&nbsp ");
                } else {
                    tipBuilder.append(JDOMUtil.legalizeText(each));
                }
            }
        }
        tooltip.setTipText(UIUtil.toHtml(tipBuilder.toString(), 0));
    }
    tooltip.setBorder(null);
    return tooltip;
}
Also used : NonNls(org.jetbrains.annotations.NonNls) StringTokenizer(com.intellij.util.text.StringTokenizer)

Example 17 with StringTokenizer

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;
}
Also used : StringTokenizer(com.intellij.util.text.StringTokenizer)

Example 18 with StringTokenizer

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());
    }
}
Also used : StringTokenizer(com.intellij.util.text.StringTokenizer) File(java.io.File)

Example 19 with StringTokenizer

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();
    }
}
Also used : IElementType(com.intellij.psi.tree.IElementType) Lexer(com.intellij.lexer.Lexer) StringTokenizer(com.intellij.util.text.StringTokenizer) ConsoleViewContentType(com.intellij.execution.ui.ConsoleViewContentType)

Example 20 with StringTokenizer

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) StringTokenizer(com.intellij.util.text.StringTokenizer) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) LinkedList(java.util.LinkedList)

Aggregations

StringTokenizer (com.intellij.util.text.StringTokenizer)25 File (java.io.File)5 IOException (java.io.IOException)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 ArrayList (java.util.ArrayList)3 NotNull (org.jetbrains.annotations.NotNull)3 TextRange (com.intellij.openapi.util.TextRange)2 PsiReference (com.intellij.psi.PsiReference)2 InputStreamReader (java.io.InputStreamReader)2 NonNls (org.jetbrains.annotations.NonNls)2 JavacOutputParser (com.intellij.compiler.impl.javaCompiler.javac.JavacOutputParser)1 ConsoleViewContentType (com.intellij.execution.ui.ConsoleViewContentType)1 Lexer (com.intellij.lexer.Lexer)1 AccessToken (com.intellij.openapi.application.AccessToken)1 CompilerMessageCategory (com.intellij.openapi.compiler.CompilerMessageCategory)1 Document (com.intellij.openapi.editor.Document)1 RangeMarker (com.intellij.openapi.editor.RangeMarker)1 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)1 Problem (com.intellij.problems.Problem)1 WolfTheProblemSolver (com.intellij.problems.WolfTheProblemSolver)1