Skip to content

Commit 6ec3c03

Browse files
author
Andrew Lee
committed
Resolved Merge Conflicts
Pulled parallel developments in java2script/java2script to current master branch, then resolved merge conflicts with master to leeas
2 parents eb4d737 + 1c1ab86 commit 6ec3c03

File tree

44 files changed

+996
-617
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+996
-617
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
tests/net.sf.j2s.test.junit/bin/*
2+
*/*/bin
3+
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#<<<<<<< HEAD
12
#Java2Script Configuration
23
#Fri Jul 17 23:11:27 CST 2009
34
j2s.abandoned.resources.list=bin/net/sf/j2s/ajax/AjaxPlugin.js,bin/net/sf/j2s/ajax/AJAXVariableInitializer.js
@@ -9,3 +10,11 @@ j2s.resources.list=../../plugins/net.sf.j2s.lib_3.1.1/j2slib/java.runtime.j2x,bi
910
j2s.compiler.whitespace=false
1011
j2s.output.path=bin
1112
j2s.compiler.linebreak=\r\n
13+
#=======
14+
#Java2Script Configuration
15+
#Tue Jun 27 12:46:23 CEST 2017
16+
#j2s.resources.list=
17+
#j2s.abandoned.resources.list=
18+
#j2s.output.path=bin
19+
#j2s.compiler.status=enable
20+
#>>>>>>> master

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: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -685,19 +685,21 @@ public boolean visit(ClassInstanceCreation node) {
685685
buffer.append(")");
686686
} else {
687687
ITypeBinding binding = node.resolveTypeBinding();
688-
String anonClassName = null;
689-
if (binding.isAnonymous() || binding.isLocal()) {
690-
String binaryName = binding.getBinaryName();
691-
if (binaryName == null) {
692-
String bindingKey = binding.getKey();
693-
if (bindingKey != null) {
694-
binaryName = bindingKey = bindingKey.substring(1, bindingKey.length() - 1).replace('/', '.');
695-
}
696-
}
697-
anonClassName = assureQualifiedName(shortenQualifiedName(binaryName));
698-
} else {
699-
anonClassName = assureQualifiedName(shortenQualifiedName(binding.getQualifiedName()));
700-
}
688+
// BEGIN MERGE 7/5/17 (Pulled from java2script/java2script Commit bc6425216b915bd9b4ad6111c8bb9f24fa666277)
689+
// String anonClassName = null;
690+
// if (binding.isAnonymous() || binding.isLocal()) {
691+
// String binaryName = binding.getBinaryName();
692+
// if (binaryName == null) {
693+
// String bindingKey = binding.getKey();
694+
// if (bindingKey != null) {
695+
// binaryName = bindingKey = bindingKey.substring(1, bindingKey.length() - 1).replace('/', '.');
696+
// }
697+
// }
698+
// anonClassName = assureQualifiedName(shortenQualifiedName(binaryName));
699+
// } else {
700+
// anonClassName = assureQualifiedName(shortenQualifiedName(binding.getQualifiedName()));
701+
// }
702+
// END MERGE 7/5/17
701703

702704
// String baseClassName = assureQualifiedName(shortenQualifiedName(getFullClassName()));
703705
// String shortClassName = null;

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)