Skip to content

Commit 7cc560d

Browse files
author
Andrew Lee
committed
2 parents 571da8c + 9036e10 commit 7cc560d

File tree

34 files changed

+492
-629
lines changed

34 files changed

+492
-629
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*/*/bin
2+
sources/net.sf.j2s.lib/j2slib

incubator/net.sf.j2s.ui.cmdline/src/net/sf/j2s/ui/cmdline/JDTUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static IProject newProject(String projectPath, String name)
7777

7878
if(!isAnEclipseProject) {
7979
addJavaClassPathContainer(project);
80-
IJavaProject javaProject = JavaCore.create(project);
80+
JavaCore.create(project);
8181
}
8282
return project;
8383
}

sources/net.sf.j2s.ajax/.j2s

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
#Java2Script Configuration
2-
#Fri Jul 17 23:11:27 CST 2009
3-
j2s.abandoned.resources.list=bin/net/sf/j2s/ajax/AjaxPlugin.js,bin/net/sf/j2s/ajax/AJAXVariableInitializer.js
4-
j2s.compiler.abbreviation=true
5-
j2s.compiler.status=enable
6-
j2s.compiler.abbreviation.prefix=$_
7-
j2s.compiler.mode=debug
8-
j2s.resources.list=../../plugins/net.sf.j2s.lib_2.0.0/j2slib/java.runtime.j2x,bin/net/sf/j2s/ajax/XHRCallbackSWTAdapter.js,bin/net/sf/j2s/ajax/XHRCallbackAdapter.js,bin/net/sf/j2s/ajax/IXHRCallback.js,bin/net/sf/j2s/ajax/HttpRequest.js,bin/net/sf/j2s/ajax/AClass.js,bin/net/sf/j2s/ajax/ASWTClass.js,bin/net/sf/j2s/ajax/ARunnable.js,bin/net/sf/j2s/ajax/Base64.js,bin/net/sf/j2s/ajax/SimpleSerializable.js,bin/net/sf/j2s/ajax/SimpleRPCRunnable.js,bin/net/sf/j2s/ajax/SimpleRPCHttpServlet.js,bin/net/sf/j2s/ajax/SimpleRPCRequest.js,bin/net/sf/j2s/ajax/SimpleRPCSWTRequest.js,bin/net/sf/j2s/ajax/SimpleFilter.js,bin/net/sf/j2s/ajax/SimplePipeHelper.js,bin/net/sf/j2s/ajax/SimplePipeHttpServlet.js,bin/net/sf/j2s/ajax/SimplePipeRPCHttpServlet.js,bin/net/sf/j2s/ajax/SimplePipeRequest.js,bin/net/sf/j2s/ajax/SimplePipeRunnable.js,bin/net/sf/j2s/ajax/SimplePipeSWTRequest.js,bin/net/sf/j2s/ajax/CompoundPipeRunnable.js,bin/net/sf/j2s/ajax/PipeManager.js,bin/net/sf/j2s/ajax/PipeObject.js,bin/net/sf/j2s/ajax/CompoundPipeRequest.js,bin/net/sf/j2s/ajax/CompoundSerializable.js,bin/net/sf/j2s/ajax/CompoundPipeSWTRequest.js,bin/net/sf/j2s/ajax/CompoundPipeSession.js,bin/net/sf/j2s/ajax/CompoundPipeRPCHttpServlet.js,bin/net/sf/j2s/ajax/SWTHelper.js,bin/net/sf/j2s/ajax/AWindowRunnable.js,bin/net/sf/j2s/ajax/AWindowDelegate.js,bin/net/sf/j2s/ajax/ISimplePipePriority.js,bin/net/sf/j2s/annotation/J2SIgnore.js,bin/net/sf/j2s/annotation/J2SIngoreSuperConstructor.js,bin/net/sf/j2s/annotation/J2SKeep.js,bin/net/sf/j2s/annotation/J2SOverride.js,bin/net/sf/j2s/annotation/J2SDebug.js,bin/net/sf/j2s/annotation/J2SIgnoreImport.js,bin/net/sf/j2s/annotation/J2SRequireImport.js,bin/net/sf/j2s/annotation/J2SOptionalImport.js,bin/net/sf/j2s/annotation/J2SNative.js,bin/net/sf/j2s/annotation/J2SNativeSrc.js,bin/net/sf/j2s/annotation/J2SSuffix.js,bin/net/sf/j2s/annotation/J2SPrefix.js,bin/net/sf/j2s/store/IStore.js,bin/net/sf/j2s/store/SimpleStore.js,bin/net/sf/j2s/store/CookieStore.js,bin/net/sf/j2s/store/INIFileStore.js,bin/net/sf/j2s/store/XSSCookieStore.js,bin/net/sf/j2s/ajax/ManagedCompoundPipeRunnable.js,bin/net/sf/j2s/ajax/ManagedCompoundPipeSession.js,bin/net/sf/j2s/ajax/ManagedPipeHelper.js,bin/net/sf/j2s/ajax/IManagedPipe.js
9-
j2s.compiler.whitespace=false
10-
j2s.output.path=bin
11-
j2s.compiler.linebreak=\r\n
1+
#Java2Script Configuration
2+
#Tue Jun 27 12:46:23 CEST 2017
3+
j2s.resources.list=
4+
j2s.abandoned.resources.list=
5+
j2s.output.path=bin
6+
j2s.compiler.status=enable

sources/net.sf.j2s.ajax/.project

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,11 @@
55
<projects>
66
</projects>
77
<buildSpec>
8-
<buildCommand>
9-
<name>org.eclipse.jdt.core.javabuilder</name>
10-
<arguments>
11-
</arguments>
12-
</buildCommand>
13-
<!--
14-
DO NOT enable both javabuilder and java2scriptbuilder,
15-
or Eclipse will be locked in building this project.
16-
17-
If you are building Java2Script from SVN, try to enable
18-
javabuilder and disable java2scriptbuilder first and build
19-
out Java2Script plug-in. And after installing Java2Script,
20-
try to disable javabuilder and re-enable java2scriptbuilder.
21-
-->
22-
<!--
238
<buildCommand>
249
<name>net.sf.j2s.core.java2scriptbuilder</name>
2510
<arguments>
2611
</arguments>
2712
</buildCommand>
28-
-->
2913
<buildCommand>
3014
<name>org.eclipse.pde.ManifestBuilder</name>
3115
<arguments>

sources/net.sf.j2s.ajax/ajaxpipe/net/sf/j2s/ajax/SimplePipeRequest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,14 @@ public void run() {
341341
request.registerOnReadyStateChange(new XHRCallbackAdapter() {
342342
public void onLoaded() {
343343
String response = request.getResponseText();
344-
if (response != null && p.notifySequence < sequence && response.indexOf("$p1p3b$") != 0) {
344+
if (response == null || response.length() == 0 || response.indexOf("$p1p3b$") != 0) {
345+
// Incorrect response
346+
return;
347+
}
348+
if (p.notifySequence < sequence) {
345349
p.notifySequence = sequence;
346350
}
347-
if (response != null && response.indexOf("\"" + PIPE_STATUS_LOST + "\"") != -1) {
351+
if (response.indexOf("\"" + PIPE_STATUS_LOST + "\"") != -1) {
348352
p.pipeAlive = false;
349353
p.pipeLost();
350354
SimplePipeHelper.removePipe(pipeKey);

sources/net.sf.j2s.ajax/generator/net/sf/j2s/ajax/SimpleSource4Java.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ private static boolean importAnnotationClasses(List<Field> fields,
685685
source.append("import ").append(SimpleIn.class.getName()).append(";\r\n");
686686
}
687687
if (inOutAnnImported) {
688-
source.append("import ").append(SimpleOut.class.getName()).append(";\r\n");
688+
source.append("import ").append(SimpleInOut.class.getName()).append(";\r\n");
689689
}
690690
if (outAnnImported) {
691691
source.append("import ").append(SimpleOut.class.getName()).append(";\r\n");

sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/ASTScriptVisitor.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -672,20 +672,7 @@ public boolean visit(ClassInstanceCreation node) {
672672
buffer.append(")");
673673
} else {
674674
ITypeBinding binding = node.resolveTypeBinding();
675-
String anonClassName = null;
676-
if (binding.isAnonymous() || binding.isLocal()) {
677-
String binaryName = binding.getBinaryName();
678-
if (binaryName == null) {
679-
String bindingKey = binding.getKey();
680-
if (bindingKey != null) {
681-
binaryName = bindingKey = bindingKey.substring(1, bindingKey.length() - 1).replace('/', '.');
682-
}
683-
}
684-
anonClassName = assureQualifiedName(shortenQualifiedName(binaryName));
685-
} else {
686-
anonClassName = assureQualifiedName(shortenQualifiedName(binding.getQualifiedName()));
687-
}
688-
675+
// FIXME: commented-out code. To be removed after St. Olaf merge.
689676
// String baseClassName = assureQualifiedName(shortenQualifiedName(getFullClassName()));
690677
// String shortClassName = null;
691678
// int idx = anonClassName.lastIndexOf('.');

sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/Bindings.java

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ private Bindings() {
5050
// No instance
5151
}
5252

53-
private static final boolean CHECK_CORE_BINDING_IS_EQUAL_TO;
54-
static {
55-
String value= Platform.getDebugOption("org.eclipse.jdt.ui/debug/checkCoreBindingIsEqualTo"); //$NON-NLS-1$
56-
CHECK_CORE_BINDING_IS_EQUAL_TO= value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
57-
}
53+
// FIXME: commented-out code. To be removed after St. Olaf merge.
54+
// private static final boolean CHECK_CORE_BINDING_IS_EQUAL_TO;
55+
// static {
56+
// String value= Platform.getDebugOption("org.eclipse.jdt.ui/debug/checkCoreBindingIsEqualTo"); //$NON-NLS-1$
57+
// CHECK_CORE_BINDING_IS_EQUAL_TO= value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
58+
// }
5859
// private static final boolean CHECK_CORE_BINDING_GET_JAVA_ELEMENT;
5960
// static {
6061
// String value= Platform.getDebugOption("org.eclipse.jdt.ui/debug/checkCoreBindingGetJavaElement"); //$NON-NLS-1$
@@ -86,35 +87,9 @@ public static boolean equals(IBinding b1, IBinding b2) {
8687
isEqualTo = bb1Name.equals(bb2.getBinaryName());
8788
}
8889
}
89-
if (CHECK_CORE_BINDING_IS_EQUAL_TO) {
90-
boolean originalEquals= originalEquals(b1, b2);
91-
if (originalEquals != isEqualTo) {
92-
//String message= "Unexpected difference between Bindings.equals(..) and IBinding#isEqualTo(..)"; //$NON-NLS-1$
93-
String detail= "\nb1 == " + b1.getKey() + ",\nb2 == " + (b2 == null ? "null binding" : b2.getKey()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
94-
try {
95-
detail+= "\nb1.getJavaElement() == " + b1.getJavaElement() + ",\nb2.getJavaElement() == " + (b2 == null ? "null binding" : b2.getJavaElement().toString()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
96-
} catch (Exception e) {
97-
detail += "\nException in getJavaElement():\n" + e; //$NON-NLS-1$
98-
}
99-
//JavaPlugin.logRepeatedMessage(message, detail);
100-
}
101-
}
10290
return isEqualTo;
10391
}
10492

105-
private static boolean originalEquals(IBinding b1, IBinding b2) {
106-
Assert.isNotNull(b1);
107-
if (b1 == b2)
108-
return true;
109-
if (b2 == null)
110-
return false;
111-
String k1= b1.getKey();
112-
String k2= b2.getKey();
113-
if (k1 == null || k2 == null)
114-
return false;
115-
return k1.equals(k2);
116-
}
117-
11893
/**
11994
* Checks if the two arrays of bindings have the same length and
12095
* their elements are equal. Uses

sources/net.sf.j2s.core/src/net/sf/j2s/core/builder/JavaBuilder.java

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ private void buildAll() {
252252
if (DEBUG && this.lastState != null)
253253
System.out.println("JavaBuilder: Clearing last state : " + this.lastState); //$NON-NLS-1$
254254
clearLastState();
255+
// j2sChange: Instead of BatchImageBuilder use Java2ScriptBatchImageBuilder
255256
BatchImageBuilder imageBuilder = new Java2ScriptBatchImageBuilder(this, true);
256257
imageBuilder.build();
257258
recordNewState(imageBuilder.newState);
@@ -263,6 +264,7 @@ private void buildDeltas(SimpleLookupTable deltas) {
263264
if (DEBUG && this.lastState != null)
264265
System.out.println("JavaBuilder: Clearing last state : " + this.lastState); //$NON-NLS-1$
265266
clearLastState(); // clear the previously built state so if the build fails, a full build will occur next time
267+
// j2sChange: Instead of IncrementalImageBuilder use Java2ScriptIncrementalImageBuilder.
266268
IncrementalImageBuilder imageBuilder = new Java2ScriptIncrementalImageBuilder(this);
267269
if (imageBuilder.build(deltas)) {
268270
recordNewState(imageBuilder.newState);
@@ -419,7 +421,18 @@ private SimpleLookupTable findDeltas() {
419421
}
420422

421423
public State getLastState(IProject project) {
424+
// j2sChange: We need to convert the "Eclipse" State to the "Java2Script" State.
422425
org.eclipse.jdt.internal.core.builder.State lastBuiltState = (org.eclipse.jdt.internal.core.builder.State) JavaModelManager.getJavaModelManager().getLastBuiltState(project, this.notifier.monitor);
426+
return toJava2ScriptState(project, lastBuiltState);
427+
}
428+
429+
// j2sChange: convert an "Eclipse" State to a "Java2Script" State.
430+
private State toJava2ScriptState(IProject project, org.eclipse.jdt.internal.core.builder.State lastBuiltState) {
431+
// We use 'instance to bytes' serialization and 'bytes to instance' deserialization
432+
// to do the conversions.
433+
//
434+
// (Note: casting is not an option here, as both State classes are independent.).
435+
423436
if (lastBuiltState == null) {
424437
return null;
425438
}
@@ -785,6 +798,20 @@ private void recordNewState(State state) {
785798
if (prereqProject != null && prereqProject != this.currentProject)
786799
state.recordStructuralDependency(prereqProject, getLastState(prereqProject));
787800
}
801+
if (DEBUG)
802+
System.out.println("JavaBuilder: Recording new state : " + state); //$NON-NLS-1$
803+
// state.dump();
804+
805+
// j2sChange: We need to convert the "Java2Script" State to the "Eclipse" State.
806+
JavaModelManager.getJavaModelManager().setLastBuiltState(this.currentProject, toEclipseState(state));
807+
}
808+
809+
// j2sChange: convert a "Java2Script" State to an "Eclipse" State.
810+
private org.eclipse.jdt.internal.core.builder.State toEclipseState(State state) {
811+
// We use 'instance to bytes' serialization and 'bytes to instance' deserialization
812+
// to do the conversions.
813+
//
814+
// (Note: casting is not an option here, as both State classes are independent.).
788815

789816
ByteArrayOutputStream baos = new ByteArrayOutputStream();
790817
DataOutputStream out = new DataOutputStream(baos);
@@ -802,11 +829,7 @@ private void recordNewState(State state) {
802829
} catch (IOException e) {
803830
e.printStackTrace();
804831
}
805-
806-
if (DEBUG)
807-
System.out.println("JavaBuilder: Recording new state : " + state); //$NON-NLS-1$
808-
// state.dump();
809-
JavaModelManager.getJavaModelManager().setLastBuiltState(this.currentProject, newState);
832+
return newState;
810833
}
811834

812835
/**
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2017 java2script.org and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Udo Borkowski - initial version, based on an email memo by Zhou Renjian
10+
*
11+
******************************************************************************/
12+
13+
14+
/**
15+
Generate *.js files while compiling Java sources to *.class files.
16+
17+
<p>This package is a modified copy of the Eclipse package
18+
'<code>org.eclipse.jdt.internal.core.builder</code>' from
19+
'<code>org.eclipse.jdt.core/model</code>'
20+
(<a href="git://git.eclipse.org/gitroot/jdt/eclipse.jdt.core.git">Git</a>).
21+
22+
<p>The major changes (beside the new package name
23+
<code>net.sf.j2s.core.builder</code>) are in the class {@link JavaBuilder}.
24+
The changes mainly reference several new, Java2Script-specific classes, like
25+
{@link Java2ScriptBatchImageBuilder}, or {@link Java2ScriptIncrementalImageBuilder}.
26+
The changes in JavaBuilder are marked with '<code>// j2sChange: ...</code>' comments.
27+
28+
<p>Also notice the new <code>*Proxy</code> classes, like
29+
{@link ClasspathDirectoryProxy} or {@link CompilationParticipantResultProxy}.
30+
These <code>*Proxy</code> classes keep the original JDT classes unchanged as
31+
much as possible and expose necessary inner accesses to the Java2Script builder.
32+
33+
<p><b>Historical Note</b>
34+
35+
<p>In earlier versions of Java2Script the original JDT Core plugin was modified
36+
to add the extension point. Therefore it was necessary to re-deploy the Eclipse
37+
JDT Core plugin jars and restart Eclipse after installation. That approach
38+
caused a lot of inconveniences and was drop.
39+
*/
40+
package net.sf.j2s.core.builder;
41+

0 commit comments

Comments
 (0)