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()]);
}
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;
}
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));
}
}
}
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;
}
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);
}
}
Aggregations