Search in sources :

Example 6 with StringTokenizer

use of com.intellij.util.text.StringTokenizer in project intellij-community by JetBrains.

the class AntDomTargetDependsListConverter method createReferences.

@NotNull
public PsiReference[] createReferences(GenericDomValue<TargetResolver.Result> value, PsiElement element, ConvertContext context) {
    final XmlElement xmlElement = value.getXmlElement();
    if (!(xmlElement instanceof XmlAttribute)) {
        return PsiReference.EMPTY_ARRAY;
    }
    final XmlAttributeValue valueElement = ((XmlAttribute) xmlElement).getValueElement();
    if (valueElement == null) {
        return PsiReference.EMPTY_ARRAY;
    }
    final String refsString = value.getStringValue();
    if (refsString == null) {
        return PsiReference.EMPTY_ARRAY;
    }
    final List<PsiReference> refs = new ArrayList<>();
    final AntDomTargetReference.ReferenceGroup group = new AntDomTargetReference.ReferenceGroup();
    final TextRange wholeStringRange = ElementManipulators.getValueTextRange(valueElement);
    final StringTokenizer tokenizer = new StringTokenizer(refsString, ",", false);
    while (tokenizer.hasMoreTokens()) {
        final String token = tokenizer.nextToken();
        int tokenStartOffset = tokenizer.getCurrentPosition() - token.length();
        final String ref = token.trim();
        if (ref.length() != token.length()) {
            for (int idx = 0; idx < token.length(); idx++) {
                if (Character.isWhitespace(token.charAt(idx))) {
                    tokenStartOffset++;
                } else {
                    break;
                }
            }
        }
        refs.add(new AntDomTargetReference(element, TextRange.from(wholeStringRange.getStartOffset() + tokenStartOffset, ref.length()), group));
    }
    return refs.toArray(new PsiReference[refs.size()]);
}
Also used : XmlAttribute(com.intellij.psi.xml.XmlAttribute) ArrayList(java.util.ArrayList) PsiReference(com.intellij.psi.PsiReference) TextRange(com.intellij.openapi.util.TextRange) XmlAttributeValue(com.intellij.psi.xml.XmlAttributeValue) StringTokenizer(com.intellij.util.text.StringTokenizer) XmlElement(com.intellij.psi.xml.XmlElement) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with StringTokenizer

use of com.intellij.util.text.StringTokenizer in project intellij-community by JetBrains.

the class AntDomTargetReference method getExistingNames.

private Set<String> getExistingNames() {
    final AntDomElement hostingElement = getHostingAntDomElement();
    if (hostingElement == null) {
        return Collections.emptySet();
    }
    final AntDomTarget contextTarget = hostingElement.getParentOfType(AntDomTarget.class, false);
    if (contextTarget == null) {
        return Collections.emptySet();
    }
    final Set<String> existing = new ArrayListSet<>();
    final String selfName = contextTarget.getName().getStringValue();
    if (selfName != null) {
        existing.add(selfName);
    }
    final String dependsString = contextTarget.getDependsList().getRawText();
    if (dependsString != null) {
        final StringTokenizer tokenizer = new StringTokenizer(dependsString, ",", false);
        while (tokenizer.hasMoreTokens()) {
            existing.add(tokenizer.nextToken().trim());
        }
    }
    return existing;
}
Also used : StringTokenizer(com.intellij.util.text.StringTokenizer) ArrayListSet(com.intellij.util.containers.ArrayListSet)

Example 8 with StringTokenizer

use of com.intellij.util.text.StringTokenizer in project intellij-community by JetBrains.

the class SplitterProportionsDataImpl method readExternal.

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

Example 9 with StringTokenizer

use of com.intellij.util.text.StringTokenizer in project intellij-community by JetBrains.

the class Prefs method getPreferences.

private static Preferences getPreferences(String key) {
    Preferences prefs = Preferences.userRoot();
    final int dotIndex = key.lastIndexOf('.');
    if (dotIndex > 0) {
        final StringTokenizer tokenizer = new StringTokenizer(key.substring(0, dotIndex), ".", false);
        while (tokenizer.hasMoreElements()) {
            prefs = prefs.node(tokenizer.nextElement().toLowerCase(Locale.US));
        }
    }
    return prefs;
}
Also used : StringTokenizer(com.intellij.util.text.StringTokenizer) Preferences(java.util.prefs.Preferences)

Example 10 with StringTokenizer

use of com.intellij.util.text.StringTokenizer in project intellij-community by JetBrains.

the class BootstrapClassLoaderUtil method addAdditionalClassPath.

private static void addAdditionalClassPath(Collection<URL> classpath) {
    try {
        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());
        }
    } catch (MalformedURLException e) {
        getLogger().error(e);
    }
}
Also used : StringTokenizer(com.intellij.util.text.StringTokenizer) MalformedURLException(java.net.MalformedURLException) File(java.io.File)

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