Skip to content

Commit 6e0fa54

Browse files
committed
Work on new scope system.
1 parent 2edd8dd commit 6e0fa54

File tree

5 files changed

+150
-35
lines changed

5 files changed

+150
-35
lines changed

src/main/java/com/sillelien/jas/Demo.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
1+
/*
2+
* Copyright (c) 2014-2017 Neil Ellis
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.sillelien.jas;
218

319
import com.sillelien.jas.jproxy.JProxy;
420
import com.sillelien.jas.jproxy.JProxyConfig;
521
import com.sillelien.jas.jproxy.JProxyScriptEngine;
622
import com.sillelien.jas.jproxy.JProxyScriptEngineFactory;
23+
import org.jetbrains.annotations.NotNull;
24+
import org.slf4j.Logger;
25+
import org.slf4j.LoggerFactory;
726

827
import javax.script.Bindings;
928
import javax.script.ScriptEngine;
@@ -15,6 +34,9 @@
1534

1635
public class Demo {
1736

37+
@NotNull
38+
private static final Logger log = LoggerFactory.getLogger("Demo");
39+
1840
public static void main(String[] ignored) throws Exception {
1941

2042
//Initializing and configuring the JSR-223 script engine
@@ -31,7 +53,7 @@ public static void main(String[] ignored) throws Exception {
3153
List<Diagnostic<? extends JavaFileObject>> diagnosticList = diagnostics.getDiagnostics();
3254
diagnosticList.stream()
3355
.filter(diagnostic -> diagnostic.getKind().equals(Diagnostic.Kind.ERROR))
34-
.forEach(System.err::println);
56+
.forEach(i->log.debug(i.toString()));
3557
});
3658

3759
JProxyScriptEngineFactory factory = JProxyScriptEngineFactory.create();

src/main/java/com/sillelien/jas/impl/jproxy/core/clsmgr/JProxyEngine.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
1+
/*
2+
* Copyright (c) 2014-2017 Neil Ellis
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.sillelien.jas.impl.jproxy.core.clsmgr;
218

3-
import com.sillelien.jas.RelProxyException;
419
import com.sillelien.jas.impl.jproxy.core.JProxyImpl;
5-
import com.sillelien.jas.impl.jproxy.core.clsmgr.cldesc.*;
20+
import com.sillelien.jas.impl.jproxy.core.clsmgr.cldesc.ClassDescriptor;
21+
import com.sillelien.jas.impl.jproxy.core.clsmgr.cldesc.ClassDescriptorInner;
22+
import com.sillelien.jas.impl.jproxy.core.clsmgr.cldesc.ClassDescriptorSourceFileRegistry;
23+
import com.sillelien.jas.impl.jproxy.core.clsmgr.cldesc.ClassDescriptorSourceScript;
24+
import com.sillelien.jas.impl.jproxy.core.clsmgr.cldesc.ClassDescriptorSourceUnit;
625
import com.sillelien.jas.impl.jproxy.core.clsmgr.srcunit.SourceScriptRoot;
726
import com.sillelien.jas.jproxy.JProxyCompilerListener;
827
import com.sillelien.jas.jproxy.JProxyDiagnosticsListener;
928
import com.sillelien.jas.jproxy.JProxyInputSourceFileExcludedListener;
1029
import org.jetbrains.annotations.NotNull;
1130
import org.jetbrains.annotations.Nullable;
31+
import org.slf4j.Logger;
32+
import org.slf4j.LoggerFactory;
1233

1334
import java.util.LinkedList;
1435
import java.util.Timer;
@@ -19,6 +40,10 @@
1940
*/
2041
public class JProxyEngine {
2142
protected final Object monitor = new Object(); // Podríamos usar este objeto JProxyEngine directamente pero el monitor es mejor para análisis de dependencias
43+
44+
@NotNull
45+
private static final Logger log = LoggerFactory.getLogger("JProxyEngine");
46+
2247
@NotNull
2348
protected final JProxyImpl parent;
2449
@NotNull
@@ -104,7 +129,8 @@ public void run() {
104129
try {
105130
detectChangesInSources(); // Está sincronizado las partes que lo necesitan
106131
} catch (Exception ex) {
107-
ex.printStackTrace(System.err); // Si dejamos subir la excepción se acabó el timer
132+
log.error(ex.getMessage(),ex); // Si dejamos subir la excepción se acabó el
133+
// timer
108134
}
109135
}
110136
};

src/main/java/com/sillelien/jas/impl/jproxy/core/clsmgr/comp/JProxyCompilerContext.java

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
1+
/*
2+
* Copyright (c) 2014-2017 Neil Ellis
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.sillelien.jas.impl.jproxy.core.clsmgr.comp;
218

319
import com.sillelien.jas.RelProxyException;
420
import com.sillelien.jas.jproxy.JProxyDiagnosticsListener;
521
import org.jetbrains.annotations.NotNull;
622
import org.jetbrains.annotations.Nullable;
23+
import org.slf4j.Logger;
24+
import org.slf4j.LoggerFactory;
725

826
import javax.tools.Diagnostic;
927
import javax.tools.DiagnosticCollector;
@@ -18,10 +36,16 @@
1836
public class JProxyCompilerContext {
1937
@NotNull
2038
protected StandardJavaFileManager standardFileManager;
39+
40+
@Nullable
2141
protected DiagnosticCollector<JavaFileObject> diagnostics;
42+
2243
@Nullable
2344
protected JProxyDiagnosticsListener diagnosticsListener;
2445

46+
@NotNull
47+
private static final Logger log = LoggerFactory.getLogger("JProxyCompilerContext");
48+
2549
public JProxyCompilerContext(@NotNull StandardJavaFileManager standardFileManager, DiagnosticCollector<JavaFileObject> diagnostics, @Nullable JProxyDiagnosticsListener diagnosticsListener) {
2650
this.standardFileManager = standardFileManager;
2751
this.diagnostics = diagnostics;
@@ -53,16 +77,16 @@ public void close() {
5377
} else {
5478
int i = 1;
5579
for (Diagnostic diagnostic : diagList) {
56-
System.err.println("Diagnostic " + i);
57-
System.err.println(" code: " + diagnostic.getCode());
58-
System.err.println(" kind: " + diagnostic.getKind());
59-
System.err.println(" line number: " + diagnostic.getLineNumber());
60-
System.err.println(" column number: " + diagnostic.getColumnNumber());
61-
System.err.println(" start position: " + diagnostic.getStartPosition());
62-
System.err.println(" position: " + diagnostic.getPosition());
63-
System.err.println(" end position: " + diagnostic.getEndPosition());
64-
System.err.println(" source: " + diagnostic.getSource());
65-
System.err.println(" message: " + diagnostic.getMessage(null));
80+
log.debug("Diagnostic " + i);
81+
log.debug(" code: " + diagnostic.getCode());
82+
log.debug(" kind: " + diagnostic.getKind());
83+
log.debug(" line number: " + diagnostic.getLineNumber());
84+
log.debug(" column number: " + diagnostic.getColumnNumber());
85+
log.debug(" start position: " + diagnostic.getStartPosition());
86+
log.debug(" position: " + diagnostic.getPosition());
87+
log.debug(" end position: " + diagnostic.getEndPosition());
88+
log.debug(" source: " + diagnostic.getSource());
89+
log.debug(" message: " + diagnostic.getMessage(null));
6690
i++;
6791
}
6892
}

src/test/java/com/sillelien/jas/jproxy/JProxyJavaScriptEngineNoManagerTest.java

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (c) 2014-2017 Neil Ellis
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.sillelien.jas.jproxy;
218

319
import com.sillelien.jas.RelProxyOnReloadListener;
@@ -8,6 +24,8 @@
824
import org.junit.Before;
925
import org.junit.BeforeClass;
1026
import org.junit.Test;
27+
import org.slf4j.Logger;
28+
import org.slf4j.LoggerFactory;
1129

1230
import javax.script.Bindings;
1331
import javax.script.ScriptEngine;
@@ -28,7 +46,10 @@
2846
*/
2947
public class JProxyJavaScriptEngineNoManagerTest
3048
{
31-
49+
50+
@NotNull
51+
private static final Logger log = LoggerFactory.getLogger("JProxyJavaScriptEngineNoManagerTest");
52+
3253
public JProxyJavaScriptEngineNoManagerTest()
3354
{
3455
}
@@ -98,16 +119,16 @@ public void onDiagnostics(@NotNull DiagnosticCollector<JavaFileObject> diagnosti
98119
int i = 1;
99120
for (Diagnostic diagnostic : diagList)
100121
{
101-
System.err.println("Diagnostic " + i);
102-
System.err.println(" code: " + diagnostic.getCode());
103-
System.err.println(" kind: " + diagnostic.getKind());
104-
System.err.println(" line number: " + diagnostic.getLineNumber());
105-
System.err.println(" column number: " + diagnostic.getColumnNumber());
106-
System.err.println(" start position: " + diagnostic.getStartPosition());
107-
System.err.println(" position: " + diagnostic.getPosition());
108-
System.err.println(" end position: " + diagnostic.getEndPosition());
109-
System.err.println(" source: " + diagnostic.getSource());
110-
System.err.println(" message: " + diagnostic.getMessage(null));
122+
log.debug("Diagnostic " + i);
123+
log.debug(" code: " + diagnostic.getCode());
124+
log.debug(" kind: " + diagnostic.getKind());
125+
log.debug(" line number: " + diagnostic.getLineNumber());
126+
log.debug(" column number: " + diagnostic.getColumnNumber());
127+
log.debug(" start position: " + diagnostic.getStartPosition());
128+
log.debug(" position: " + diagnostic.getPosition());
129+
log.debug(" end position: " + diagnostic.getEndPosition());
130+
log.debug(" source: " + diagnostic.getSource());
131+
log.debug(" message: " + diagnostic.getMessage(null));
111132
i++;
112133
}
113134
}

src/test/java/com/sillelien/jas/jproxy/JProxyJavaScriptEngineTest.java

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (c) 2014-2017 Neil Ellis
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.sillelien.jas.jproxy;
218

319
import com.sillelien.jas.RelProxyOnReloadListener;
@@ -8,6 +24,8 @@
824
import org.junit.Before;
925
import org.junit.BeforeClass;
1026
import org.junit.Test;
27+
import org.slf4j.Logger;
28+
import org.slf4j.LoggerFactory;
1129

1230
import javax.script.Bindings;
1331
import javax.script.ScriptEngine;
@@ -29,6 +47,10 @@
2947
*/
3048
public class JProxyJavaScriptEngineTest
3149
{
50+
51+
@NotNull
52+
private static final Logger log = LoggerFactory.getLogger("JProxyJavaScriptEngineTest");
53+
3254

3355
public JProxyJavaScriptEngineTest()
3456
{
@@ -99,16 +121,16 @@ public void onDiagnostics(@NotNull DiagnosticCollector<JavaFileObject> diagnosti
99121
int i = 1;
100122
for (Diagnostic diagnostic : diagList)
101123
{
102-
System.err.println("Diagnostic " + i);
103-
System.err.println(" code: " + diagnostic.getCode());
104-
System.err.println(" kind: " + diagnostic.getKind());
105-
System.err.println(" line number: " + diagnostic.getLineNumber());
106-
System.err.println(" column number: " + diagnostic.getColumnNumber());
107-
System.err.println(" start position: " + diagnostic.getStartPosition());
108-
System.err.println(" position: " + diagnostic.getPosition());
109-
System.err.println(" end position: " + diagnostic.getEndPosition());
110-
System.err.println(" source: " + diagnostic.getSource());
111-
System.err.println(" message: " + diagnostic.getMessage(null));
124+
log.debug("Diagnostic " + i);
125+
log.debug(" code: " + diagnostic.getCode());
126+
log.debug(" kind: " + diagnostic.getKind());
127+
log.debug(" line number: " + diagnostic.getLineNumber());
128+
log.debug(" column number: " + diagnostic.getColumnNumber());
129+
log.debug(" start position: " + diagnostic.getStartPosition());
130+
log.debug(" position: " + diagnostic.getPosition());
131+
log.debug(" end position: " + diagnostic.getEndPosition());
132+
log.debug(" source: " + diagnostic.getSource());
133+
log.debug(" message: " + diagnostic.getMessage(null));
112134
i++;
113135
}
114136
}

0 commit comments

Comments
 (0)