Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Feinberg committed Apr 1, 2016
1 parent 3c03dde commit a9ecc2b
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 75 deletions.
8 changes: 4 additions & 4 deletions .settings/org.eclipse.jdt.core.prefs
Expand Up @@ -128,7 +128,7 @@ org.eclipse.jdt.core.formatter.alignment_for_cascading_method_invocation_with_ar
org.eclipse.jdt.core.formatter.alignment_for_cascading_method_invocation_with_arguments.count_dependent=16|-1|16
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16
org.eclipse.jdt.core.formatter.alignment_for_enum_constants.count_dependent=16|5|48
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer.count_dependent=16|5|80
Expand All @@ -137,7 +137,7 @@ org.eclipse.jdt.core.formatter.alignment_for_for_statement=16
org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments=16
org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments.count_dependent=16|-1|16
org.eclipse.jdt.core.formatter.alignment_for_local_variable_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields.count_dependent=16|-1|16
org.eclipse.jdt.core.formatter.alignment_for_new_anonymous_class=20
Expand Down Expand Up @@ -184,9 +184,9 @@ org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
org.eclipse.jdt.core.formatter.comment.format_block_comments=false
org.eclipse.jdt.core.formatter.comment.format_header=true
org.eclipse.jdt.core.formatter.comment.format_header=false
org.eclipse.jdt.core.formatter.comment.format_html=true
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=false
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
org.eclipse.jdt.core.formatter.comment.format_source_code=true
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false
Expand Down
70 changes: 30 additions & 40 deletions runtime/src/jycessing/Runner.java
Expand Up @@ -76,8 +76,8 @@ private static String loadBuildNumber() {
}
}

private static final String LAUNCHER_TEXT =
IOUtil.readResourceAsText(LaunchHelper.class, "launcher.py");
private static final String LAUNCHER_TEXT = IOUtil.readResourceAsText(LaunchHelper.class,
"launcher.py");
private static final String CORE_TEXT = IOUtil.readResourceAsText(Runner.class, "core.py");

// -Dverbose=true for some logging
Expand Down Expand Up @@ -111,28 +111,24 @@ private static void searchForExtraStuff(final File dir, final Set<String> entrie

log("Searching: ", dir);

final File[] dlls =
dir.listFiles(
new FilenameFilter() {
@Override
public boolean accept(final File dir, final String name) {
return name.matches("^.+\\.(so|dll|jnilib|dylib)$");
}
});
final File[] dlls = dir.listFiles(new FilenameFilter() {
@Override
public boolean accept(final File dir, final String name) {
return name.matches("^.+\\.(so|dll|jnilib|dylib)$");
}
});
if (dlls != null && dlls.length > 0) {
entries.add(dir.getAbsolutePath());
} else {
log("No DLLs in ", dir);
}

final File[] jars =
dir.listFiles(
new FilenameFilter() {
@Override
public boolean accept(final File dir, final String name) {
return name.matches("^.+\\.jar$");
}
});
final File[] jars = dir.listFiles(new FilenameFilter() {
@Override
public boolean accept(final File dir, final String name) {
return name.matches("^.+\\.jar$");
}
});
if (!(jars == null || jars.length == 0)) {
for (final File jar : jars) {
entries.add(jar.getAbsolutePath());
Expand All @@ -141,14 +137,12 @@ public boolean accept(final File dir, final String name) {
log("No JARs in ", dir);
}

final File[] dirs =
dir.listFiles(
new FileFilter() {
@Override
public boolean accept(final File f) {
return f.isDirectory() && f.getName().charAt(0) != '.';
}
});
final File[] dirs = dir.listFiles(new FileFilter() {
@Override
public boolean accept(final File f) {
return f.isDirectory() && f.getName().charAt(0) != '.';
}
});
if (!(dirs == null || dirs.length == 0)) {
for (final File d : dirs) {
searchForExtraStuff(d, entries);
Expand Down Expand Up @@ -283,18 +277,14 @@ public static void warmup() {
}
}

public synchronized static void runSketchBlocking(
final RunnableSketch sketch, final Printer stdout, final Printer stderr)
throws PythonSketchError {
public synchronized static void runSketchBlocking(final RunnableSketch sketch,
final Printer stdout, final Printer stderr) throws PythonSketchError {
runSketchBlocking(sketch, stdout, stderr, null);
}

public synchronized static void runSketchBlocking(
final RunnableSketch sketch,
final Printer stdout,
final Printer stderr,
final SketchPositionListener sketchPositionListener)
throws PythonSketchError {
public synchronized static void runSketchBlocking(final RunnableSketch sketch,
final Printer stdout, final Printer stderr,
final SketchPositionListener sketchPositionListener) throws PythonSketchError {
final Properties props = new Properties();

// Suppress sys-package-manager output.
Expand All @@ -318,9 +308,9 @@ public synchronized static void runSketchBlocking(
PythonInterpreter.initialize(null, props, args);

final PySystemState sys = Py.getSystemState();
final PyStringMap originalModules = ((PyStringMap) sys.modules).copy();
final PyList originalPath = new PyList((PyObject) sys.path);
final PyStringMap builtins = (PyStringMap) sys.getBuiltins();
final PyStringMap originalModules = ((PyStringMap)sys.modules).copy();
final PyList originalPath = new PyList((PyObject)sys.path);
final PyStringMap builtins = (PyStringMap)sys.getBuiltins();
final PyStringMap originalBuiltins = builtins.copy();
try {
final InteractiveConsole interp = new InteractiveConsole();
Expand Down Expand Up @@ -376,8 +366,8 @@ public synchronized static void runSketchBlocking(
interp.set("__stdout__", stdout);
interp.set("__stderr__", stderr);
final PAppletJythonDriver applet =
new PAppletJythonDriver(
interp, sketch.getMainFile().toString(), sketch.getMainCode(), stdout);
new PAppletJythonDriver(interp, sketch.getMainFile().toString(), sketch.getMainCode(),
stdout);
interp.set("__papplet__", applet);
interp.exec(CORE_TEXT);

Expand Down
2 changes: 1 addition & 1 deletion runtime/src/jycessing/mode/PyEditor.java
Expand Up @@ -171,7 +171,7 @@ public void actionPerformed(final ActionEvent e) {
@Override
public JMenu buildHelpMenu() {
final JMenu menu = new JMenu("Help");
menu.add(new JMenuItem(new AbstractAction("References") {
menu.add(new JMenuItem(new AbstractAction("References") {
@Override
public void actionPerformed(final ActionEvent e) {
Platform.openURL("http://py.processing.org/reference/");
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/jycessing/mode/PyInputHandler.java
Expand Up @@ -239,8 +239,8 @@ public void indent(final int sign) {

private int getAbsoluteCaretPositionRelativeToLineEnd(final int line,
final int lineEndRelativePosition) {
return Math.max(textArea.getLineStopOffset(line) - lineEndRelativePosition,
textArea.getLineStartOffset(line));
return Math.max(textArea.getLineStopOffset(line) - lineEndRelativePosition, textArea
.getLineStartOffset(line));
}

private void indentLineBy(final int line, final int deltaIndent) {
Expand Down
6 changes: 3 additions & 3 deletions runtime/src/jycessing/mode/PythonMode.java
Expand Up @@ -74,10 +74,10 @@ public Editor createEditor(final Base base, final String path, final EditorState
sketchServiceManager.start();
}

try {
try {
return new PyEditor(base, path, state, this);
} catch(EditorException e) {
Messages.showError("Editor Exception", "Issue Creating Editor", e);
} catch (EditorException e) {
Messages.showError("Editor Exception", "Issue Creating Editor", e);
return null;
}
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/jycessing/mode/export/ImportExtractor.java
Expand Up @@ -60,8 +60,8 @@ private void extract() {
final mod ast;
try {
ast =
ParserFacade.parseExpressionOrModule(new StringReader(code.getProgram()),
code.getFileName(), new CompilerFlags());
ParserFacade.parseExpressionOrModule(new StringReader(code.getProgram()), code
.getFileName(), new CompilerFlags());
} catch (final Exception e) {
System.err.println("Couldn't parse " + code.getFileName());
// I don't like this but I'm not sure what else to do
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/jycessing/mode/export/LinuxExport.java
Expand Up @@ -175,8 +175,8 @@ private void buildShellScript(final File destFolder, final boolean embedJava) th

log("Setting script executable.");
try {
Files.setPosixFilePermissions(scriptFile.toPath(),
PosixFilePermissions.fromString("rwxrwxrwx"));
Files.setPosixFilePermissions(scriptFile.toPath(), PosixFilePermissions
.fromString("rwxrwxrwx"));
} catch (final UnsupportedOperationException e) {
// Windows, probably
log("Couldn't set script executable... we'll assume whoever gets it can handle it");
Expand Down
17 changes: 9 additions & 8 deletions runtime/src/jycessing/mode/export/MacExport.java
Expand Up @@ -110,12 +110,13 @@ public void export() throws IOException {
*/
private void copyJDKPlugin(final File targetPluginsFolder) throws IOException {
// This is how Java Mode finds it... basically
final File sourceJDKFolder = Platform.getContentFile("../PlugIns").listFiles(new FilenameFilter() {
@Override
public boolean accept(final File dir, final String name) {
return name.endsWith(".jdk") && !name.startsWith(".");
}
})[0].getAbsoluteFile();
final File sourceJDKFolder =
Platform.getContentFile("../PlugIns").listFiles(new FilenameFilter() {
@Override
public boolean accept(final File dir, final String name) {
return name.endsWith(".jdk") && !name.startsWith(".");
}
})[0].getAbsoluteFile();

log("Copying JDK from " + sourceJDKFolder);

Expand Down Expand Up @@ -270,8 +271,8 @@ private void setUpExecutable(final File binFolder, final File processingFolder,

log("Setting script executable.");
try {
Files.setPosixFilePermissions(scriptFile.toPath(),
PosixFilePermissions.fromString("rwxrwxrwx"));
Files.setPosixFilePermissions(scriptFile.toPath(), PosixFilePermissions
.fromString("rwxrwxrwx"));
} catch (final UnsupportedOperationException e) {
// Windows, probably
log("Couldn't set script executable... .app should work anyway, though");
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/jycessing/mode/export/PlatformExport.java
Expand Up @@ -106,8 +106,8 @@ public void copyBasicStructure(final File destFolder) throws IOException {
{
jycessingFolder.mkdirs();
log("Copying core processing stuff to export");
for (final File exportFile : new Library(Platform.getContentFile("core")).getApplicationExports(
id, Integer.toString(arch.bits))) {
for (final File exportFile : new Library(Platform.getContentFile("core"))
.getApplicationExports(id, Integer.toString(arch.bits))) {
if (exportFile.isDirectory()) {
Util.copyDir(exportFile, new File(jycessingFolder, exportFile.getName()));
} else {
Expand Down
7 changes: 4 additions & 3 deletions runtime/src/jycessing/mode/run/SketchRunner.java
Expand Up @@ -118,11 +118,12 @@ public void sketchMoved(final Point leftTop) {
Runner.runSketchBlocking(sketch, stdout, stderr, sketchPositionListener);
} catch (final PythonSketchError e) {
log("Sketch runner caught " + e);
modeService.handleSketchException(id, convertPythonSketchError(e, sketch.codeFileNames));
modeService
.handleSketchException(id, convertPythonSketchError(e, sketch.codeFileNames));
} catch (final Exception e) {
if (e.getCause() != null && e.getCause() instanceof PythonSketchError) {
modeService.handleSketchException(id,
convertPythonSketchError((PythonSketchError)e.getCause(), sketch.codeFileNames));
modeService.handleSketchException(id, convertPythonSketchError((PythonSketchError)e
.getCause(), sketch.codeFileNames));
} else {
modeService.handleSketchException(id, e);
}
Expand Down
10 changes: 4 additions & 6 deletions runtime/src/jycessing/mode/run/SketchServiceProcess.java
Expand Up @@ -128,12 +128,10 @@ private ProcessBuilder createServerCommand() {
command.add("-Djava.library.path=" + System.getProperty("java.library.path"));

final List<String> cp = new ArrayList<>();
cp.addAll(filter(
Arrays.asList(System.getProperty("java.class.path")
.split(Pattern.quote(File.pathSeparator))),
not(or(
containsPattern("(ant|ant-launcher|antlr|netbeans.*|osgi.*|jdi.*|ibm\\.icu.*|jna)\\.jar$"),
containsPattern("/processing/app/(test|lib)/")))));
cp.addAll(filter(Arrays.asList(System.getProperty("java.class.path").split(
Pattern.quote(File.pathSeparator))), not(or(
containsPattern("(ant|ant-launcher|antlr|netbeans.*|osgi.*|jdi.*|ibm\\.icu.*|jna)\\.jar$"),
containsPattern("/processing/app/(test|lib)/")))));
for (final File jar : new File(Platform.getContentFile("core"), "library").listFiles(JARS)) {
cp.add(jar.getAbsolutePath());
}
Expand Down
4 changes: 2 additions & 2 deletions testing/src/test/jycessing/TestSketch.java
Expand Up @@ -20,13 +20,13 @@ public class TestSketch implements RunnableSketch {
private final Path sourcePath;
private final String sourceText;
private final String name;

public TestSketch(final Path sourcePath, final String sourceText, final String name) {
this.sourcePath = sourcePath;
this.sourceText = sourceText;
this.name = name;
}

@Override
public File getMainFile() {
return sourcePath.toFile();
Expand Down

0 comments on commit a9ecc2b

Please sign in to comment.