use of com.intellij.util.text.StringTokenizer in project intellij-community by JetBrains.
the class EncodingAwareProperties method load.
public void load(File file, String encoding) throws IOException {
String propText = FileUtil.loadFile(file, encoding);
propText = StringUtil.convertLineSeparators(propText);
StringTokenizer stringTokenizer = new StringTokenizer(propText, "\n");
while (stringTokenizer.hasMoreElements()) {
String line = stringTokenizer.nextElement();
int i = line.indexOf('=');
String propName = i == -1 ? line : line.substring(0, i);
String propValue = i == -1 ? "" : line.substring(i + 1);
setProperty(propName, propValue);
}
}
use of com.intellij.util.text.StringTokenizer in project kotlin by JetBrains.
the class VfsTestUtil method createFileOrDir.
private static VirtualFile createFileOrDir(VirtualFile root, String relativePath, String text, boolean dir) {
try {
AccessToken token = WriteAction.start();
try {
VirtualFile parent = root;
Assert.assertNotNull(parent);
StringTokenizer parents = new StringTokenizer(PathUtil.getParentPath(relativePath), "/");
while (parents.hasMoreTokens()) {
String name = parents.nextToken();
VirtualFile child = parent.findChild(name);
if (child == null || !child.isValid()) {
child = parent.createChildDirectory(VfsTestUtil.class, name);
}
parent = child;
}
VirtualFile file;
//need this to ensure that fileCreated event is fired
parent.getChildren();
if (dir) {
file = parent.createChildDirectory(VfsTestUtil.class, PathUtil.getFileName(relativePath));
} else {
file = parent.findFileByRelativePath(relativePath);
if (file == null) {
file = parent.createChildData(VfsTestUtil.class, PathUtil.getFileName(relativePath));
}
VfsUtil.saveText(file, text);
}
return file;
} finally {
token.finish();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of com.intellij.util.text.StringTokenizer in project android 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-plugins by JetBrains.
the class ExternalTask method scheduleInputStreamReading.
protected void scheduleInputStreamReading() {
ApplicationManager.getApplication().executeOnPooledThread(() -> {
boolean usageStarted = false;
final InputStreamReader reader = FlexCommonUtils.createInputStreamReader(myProcess.getInputStream());
try {
char[] buf = new char[4096];
int read;
while ((read = reader.read(buf, 0, buf.length)) >= 0) {
final String output = new String(buf, 0, read);
debug("Process output: " + output);
if (!usageStarted) {
final StringTokenizer tokenizer = new StringTokenizer(output, "\r\n");
while (tokenizer.hasMoreElements()) {
final String message = tokenizer.nextElement();
if (!StringUtil.isEmptyOrSpaces(message)) {
if (message.trim().toLowerCase().startsWith("usage:")) {
usageStarted = true;
break;
}
if (message.trim().endsWith("password:")) {
final OutputStream outputStream = myProcess.getOutputStream();
outputStream.write("\n".getBytes());
outputStream.flush();
} else {
myMessages.add(message);
}
}
}
}
}
} catch (IOException e) {
myMessages.add(e.getMessage());
} finally {
cancel();
try {
reader.close();
} catch (IOException e) {
/*ignore*/
}
}
});
}
use of com.intellij.util.text.StringTokenizer in project intellij-plugins by JetBrains.
the class ASC20CompilationTask method readInputStream.
private void readInputStream(final FlexCompilationManager compilationManager) {
ApplicationManager.getApplication().executeOnPooledThread(() -> {
final InputStreamReader reader = FlexCommonUtils.createInputStreamReader(myProcess.getInputStream());
try {
char[] buf = new char[2048];
int read;
while ((read = reader.read(buf, 0, buf.length)) >= 0) {
final String output = new String(buf, 0, read);
final StringTokenizer tokenizer = new StringTokenizer(output, "\r\n");
while (tokenizer.hasMoreElements()) {
final String message = tokenizer.nextElement();
if (StringUtil.isEmptyOrSpaces(message))
continue;
final boolean ok = handleCompilerMessage(compilationManager, message.trim());
if (!ok) {
myCompilationFailed = true;
}
}
}
printPreviousLine(compilationManager);
} catch (IOException e) {
compilationManager.addMessage(this, CompilerMessageCategory.ERROR, e.getMessage(), null, -1, -1);
myCompilationFailed = true;
} finally {
cancel();
try {
reader.close();
} catch (IOException e) {
/*ignore*/
}
}
});
}
Aggregations