Skip to content

Commit

Permalink
Work in progress: an experiment on using javac from JDK for source co…
Browse files Browse the repository at this point in the history
…de modeling.
  • Loading branch information
jlahoda committed Oct 4, 2017
1 parent 81234c9 commit ffc0de5
Show file tree
Hide file tree
Showing 324 changed files with 3,081 additions and 1,455 deletions.
1 change: 1 addition & 0 deletions apisupport.project/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ test-unit-sys-prop.java.awt.headless=true
test.config.stableBTD.includes=**/*Test.class
test.config.stableBTD.excludes=\
**/ModuleOperationsTest.class
requires.nb.javac=true
1 change: 1 addition & 0 deletions apisupport.wizards/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
# under the License.
javac.source=1.6
javac.compilerargs=-Xlint -Xlint:-serial
requires.nb.javac=true
3 changes: 2 additions & 1 deletion beans/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
javac.compilerargs=-Xlint -Xlint:-serial
javac.source=1.6
spec.version.base=1.52.0

cp.extra=${tools.jar}

test.config.stable.includes=\
**/PropertyGeneration.class
Expand All @@ -30,3 +30,4 @@ test.config.beaninfo.includes=\

test.config.stable.include=\
**/StableSuite.class
requires.nb.javac=true
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.sun.source.tree.Tree;
import com.sun.source.util.SourcePositions;
import com.sun.source.util.TreePath;
import com.sun.source.util.TreePathScanner;
import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
import com.sun.source.util.Trees;
import java.io.IOException;
import java.util.Collections;
Expand Down Expand Up @@ -301,7 +301,7 @@ private static int scanForSemicolon(Document doc, int[] offset, int start, int e
return semicolon;
}

private static final class ImportFQNsHack extends TreePathScanner<Void, Void> {
private static final class ImportFQNsHack extends ErrorAwareTreePathScanner<Void, Void> {

private WorkingCopy wc;
private int start;
Expand Down
2 changes: 2 additions & 0 deletions core.startup/src/org/netbeans/core/startup/NbInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,13 @@ private void checkForHiddenPackages(Module m) throws InvalidException {
List<Module.PackageExport> hiddenPackages = new ArrayList<Module.PackageExport>();
List<Module> mWithDeps = new LinkedList<Module>();
mWithDeps.add(m);
mWithDeps.addAll(mgr.getAttachedFragments(m));
for (Dependency d : m.getDependencies()) {
if (d.getType() == Dependency.TYPE_MODULE) {
Module _m = mgr.get((String) Util.parseCodeName(d.getName())[0]);
assert _m != null : d;
mWithDeps.add(_m);
mWithDeps.addAll(mgr.getAttachedFragments(_m));
}
}
for (Module _m : mWithDeps) {
Expand Down
1 change: 1 addition & 0 deletions debugger.jpda.ant/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ ant.jar=${ant.core.lib}
javac.compilerargs=-Xlint:unchecked
javac.source=1.6
javadoc.arch=${basedir}/arch.xml
requires.nb.javac=true
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.netbeans.modules.debugger.jpda.projects;

import com.sun.source.tree.ClassTree;
import com.sun.source.util.TreePathScanner;
import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
import com.sun.source.util.Trees;
import javax.lang.model.element.TypeElement;
import javax.lang.model.util.Elements;
Expand All @@ -30,7 +30,7 @@
*
* @author martin
*/
class ClassScanner extends TreePathScanner<TypeElement, Void> {
class ClassScanner extends ErrorAwareTreePathScanner<TypeElement, Void> {

private Trees trees;
private Elements elements;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import com.sun.source.tree.VariableTree;
import com.sun.source.util.SourcePositions;
import com.sun.source.util.TreePath;
import com.sun.source.util.TreePathScanner;
import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
Expand Down Expand Up @@ -1428,8 +1428,8 @@ public static String[] getImports(String url) {

public static <R,D> R interpretOrCompileCode(final Expression<Object> expression,
final String url, final int line,
final TreePathScanner<Boolean,D> canInterpret,
final TreePathScanner<R,D> interpreter,
final ErrorAwareTreePathScanner<Boolean,D> canInterpret,
final ErrorAwareTreePathScanner<R,D> interpreter,
final D context, boolean staticContext,
final Function<Pair<String, byte[]>, Boolean> compiledClassHandler,
final SourcePathProvider sp) throws InvalidExpressionException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import com.sun.source.tree.VariableTree;
import com.sun.source.tree.WhileLoopTree;
import com.sun.source.util.SourcePositions;
import com.sun.source.util.TreeScanner;
import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;

import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -69,7 +69,7 @@
*
* @author Martin Entlicher
*/
class ExpressionScanner extends TreeScanner<List<Tree>, ExpressionScanner.ExpressionsInfo> {
class ExpressionScanner extends ErrorAwareTreeScanner<List<Tree>, ExpressionScanner.ExpressionsInfo> {

private int lineNumber;
private int statementStart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.sun.source.tree.TypeParameterTree;
import com.sun.source.tree.VariableTree;
import com.sun.source.util.SourcePositions;
import com.sun.source.util.TreeScanner;
import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
import java.util.List;
import javax.tools.Diagnostic;
import org.netbeans.spi.debugger.jpda.EditorContext.MethodArgument;
Expand All @@ -39,7 +39,7 @@
*
* @author Martin Entlicher
*/
class MethodArgumentsScanner extends TreeScanner<MethodArgument[], Object> {
class MethodArgumentsScanner extends ErrorAwareTreeScanner<MethodArgument[], Object> {

private int offset;
private CompilationUnitTree tree;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.sun.source.tree.Tree;
import com.sun.source.util.SourcePositions;
import com.sun.source.util.TreePath;
import com.sun.source.util.TreePathScanner;
import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
import com.sun.source.util.Trees;
import java.io.IOException;
import java.net.MalformedURLException;
Expand Down Expand Up @@ -404,8 +404,8 @@ private static JavaSource getJavaSource(SourcePathProvider sp) {
@NbBundle.Messages("MSG_NoParseNoEval=Can not evaluate expression - parsing failed.")
public <R,D> R interpretOrCompileCode(final Expression<Object> expression,
final String url, final int line,
final TreePathScanner<Boolean,D> canInterpret,
final TreePathScanner<R,D> interpreter,
final ErrorAwareTreePathScanner<Boolean,D> canInterpret,
final ErrorAwareTreePathScanner<R,D> interpreter,
final D context, boolean staticContext,
final Function<Pair<String, byte[]>, Boolean> compiledClassHandler,
final SourcePathProvider sp) throws InvalidExpressionException {
Expand Down Expand Up @@ -654,7 +654,7 @@ public int getCodeOffset() {

private static boolean isErroneous(Tree tree) {

class TreeChecker extends TreePathScanner<Boolean,Void> {
class TreeChecker extends ErrorAwareTreePathScanner<Boolean,Void> {

@Override
public Boolean scan(Tree tree, Void p) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.sun.source.tree.Tree;
import com.sun.source.tree.VariableTree;
import com.sun.source.util.TreePath;
import com.sun.source.util.TreePathScanner;
import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.LinkedHashSet;
Expand All @@ -51,7 +51,7 @@
*
* @author sdedic, Martin Entlicher
*/
final class ScanLocalVars extends TreePathScanner<Void, Void> {
final class ScanLocalVars extends ErrorAwareTreePathScanner<Void, Void> {

private static final Set<ElementKind> LOCAL_VARIABLES = EnumSet.of(ElementKind.EXCEPTION_PARAMETER,
ElementKind.LOCAL_VARIABLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.netbeans.modules.debugger.jpda.projectsui;

import com.sun.source.util.TreePathScanner;
import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
import java.awt.Color;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
Expand Down Expand Up @@ -817,8 +817,8 @@ public String[] getImports (
}

public <R,D> R interpretOrCompileCode(final Expression<Object> expression, String url, final int line,
final TreePathScanner<Boolean,D> canInterpret,
final TreePathScanner<R,D> interpreter,
final ErrorAwareTreePathScanner<Boolean,D> canInterpret,
final ErrorAwareTreePathScanner<R,D> interpreter,
final D context, final boolean staticContext,
final Function<Pair<String, byte[]>, Boolean> compiledClassHandler,
final SourcePathProvider sp) throws InvalidExpressionException {
Expand Down
8 changes: 8 additions & 0 deletions debugger.jpda.visual/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.java.source.base</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>2.30</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.options.api</code-name-base>
<build-prerequisite/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package org.netbeans.modules.debugger.jpda;

import com.sun.jdi.AbsentInformationException;
import com.sun.source.util.TreePathScanner;
import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.net.MalformedURLException;
Expand Down Expand Up @@ -96,16 +96,16 @@ public static Tree getExpressionTree(final String expression, String url, final

public static <R,D> R interpretOrCompileCode(final Expression<Object> expression,
final String url, final int line,
final TreePathScanner<Boolean,D> canInterpret,
final TreePathScanner<R,D> interpreter,
final ErrorAwareTreePathScanner<Boolean,D> canInterpret,
final ErrorAwareTreePathScanner<R,D> interpreter,
final D context, final boolean staticContext,
final Function<Pair<String, byte[]>, Boolean> compiledClassHandler,
final SourcePathProvider sp) throws InvalidExpressionException {
try {
return (R) getContext ().getClass().getMethod(
"interpretOrCompileCode",
new Class[] { Expression.class, String.class, Integer.TYPE,
TreePathScanner.class, TreePathScanner.class,
ErrorAwareTreePathScanner.class, ErrorAwareTreePathScanner.class,
Object.class, Boolean.TYPE, Function.class,
SourcePathProvider.class }).
invoke(getContext(), new Object[] { expression, url, line,
Expand Down Expand Up @@ -347,17 +347,17 @@ public Object annotate (

public <R,D> R interpretOrCompileCode(final Expression<Object> expression,
final String url, final int line,
final TreePathScanner<Boolean,D> canInterpret,
final TreePathScanner<R,D> interpreter,
final ErrorAwareTreePathScanner<Boolean,D> canInterpret,
final ErrorAwareTreePathScanner<R,D> interpreter,
final D context, final boolean staticContext,
final Function<Pair<String, byte[]>, Boolean> compiledClassHandler,
final SourcePathProvider sp) throws InvalidExpressionException {
R ret = null;
try {
ret = (R) cp1.getClass().getMethod(
"interpretOrCompileCode",
new Class[] { Expression.class, String.class, Integer.TYPE, TreePathScanner.class,
TreePathScanner.class, Object.class, Boolean.TYPE, Function.class,
new Class[] { Expression.class, String.class, Integer.TYPE, ErrorAwareTreePathScanner.class,
ErrorAwareTreePathScanner.class, Object.class, Boolean.TYPE, Function.class,
SourcePathProvider.class }).
invoke(cp1, new Object[] { expression, url, line, canInterpret, interpreter,
context, staticContext, compiledClassHandler, sp });
Expand All @@ -375,8 +375,8 @@ public <R,D> R interpretOrCompileCode(final Expression<Object> expression,
try {
ret = (R) cp2.getClass().getMethod(
"interpretOrCompileCode",
new Class[] { Expression.class, String.class, Integer.TYPE, TreePathScanner.class,
TreePathScanner.class, Object.class, Boolean.TYPE, Function.class,
new Class[] { Expression.class, String.class, Integer.TYPE, ErrorAwareTreePathScanner.class,
ErrorAwareTreePathScanner.class, Object.class, Boolean.TYPE, Function.class,
SourcePathProvider.class }).
invoke(cp2, new Object[] { expression, url, line, canInterpret, interpreter,
context, staticContext, compiledClassHandler, sp });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
import com.sun.source.tree.Tree;
import com.sun.source.tree.UsesTree;
import com.sun.source.tree.WhileLoopTree;
import com.sun.source.util.TreePathScanner;
import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;

/**
* Test of ability and suitability of an interpreter or compiler when evaluating.
*
* @author Martin
*/
class CanInterpretVisitor extends TreePathScanner<Boolean, EvaluationContext> {
class CanInterpretVisitor extends ErrorAwareTreePathScanner<Boolean, EvaluationContext> {

@Override
public Boolean reduce(Boolean r1, Boolean r2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
import com.sun.source.tree.WhileLoopTree;
import com.sun.source.tree.WildcardTree;
import com.sun.source.util.TreePath;
import com.sun.source.util.TreePathScanner;
import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -184,7 +184,7 @@
* @author Martin Entlicher
*/
@SuppressWarnings("ClassWithMultipleLoggers")
public class EvaluatorVisitor extends TreePathScanner<Mirror, EvaluationContext> {
public class EvaluatorVisitor extends ErrorAwareTreePathScanner<Mirror, EvaluationContext> {

private static final Logger loggerMethod = Logger.getLogger("org.netbeans.modules.debugger.jpda.invokeMethod"); // NOI18N
private static final Logger loggerValue = Logger.getLogger("org.netbeans.modules.debugger.jpda.getValue"); // NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.sun.source.tree.Tree;
import com.sun.source.tree.TypeCastTree;
import com.sun.source.util.TreePath;
import com.sun.source.util.TreeScanner;
import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
import com.sun.source.util.Trees;
import java.util.List;
import javax.lang.model.element.Element;
Expand Down Expand Up @@ -142,7 +142,7 @@ public void run(CompilationController ci) throws Exception {
return successPtr[0];
}

private static class JDICallsScanner extends TreeScanner<Void, Object> {
private static class JDICallsScanner extends ErrorAwareTreeScanner<Void, Object> {

private Trees trees;
private Types types;
Expand Down
2 changes: 2 additions & 0 deletions form.binding/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
is.eager=true
javac.source=1.6
spec.version.base=0.18.0
cp.extra=${tools.jar}
requires.nb.javac=true
2 changes: 2 additions & 0 deletions form.j2ee/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
is.eager=true
javac.source=1.6
spec.version.base=0.34.0
cp.extra=${tools.jar}
requires.nb.javac=true
2 changes: 2 additions & 0 deletions form.nb/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
is.eager=true
javac.source=1.6
spec.version.base=0.19.0
cp.extra=${tools.jar}
requires.nb.javac=true
2 changes: 2 additions & 0 deletions form.refactoring/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
is.eager=true
javac.source=1.6
spec.version.base=0.18.0
cp.extra=${tools.jar}
requires.nb.javac=true
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.sun.source.tree.IdentifierTree;
import com.sun.source.tree.Tree;
import com.sun.source.util.TreePath;
import com.sun.source.util.TreePathScanner;
import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
import com.sun.source.util.Trees;
import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -106,7 +106,7 @@ private static boolean emptyOrWhite(String s){
}

private static class MemberVisitor
extends TreePathScanner<Void, Void>
extends ErrorAwareTreePathScanner<Void, Void>
implements CancellableTask<CompilationController>{

private CompilationInfo info;
Expand Down
3 changes: 3 additions & 0 deletions hibernate/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ test.config.stableBTD.excludes=\
**/HibernateEnvironmentTest.class,\
**/HibernateMappingCompletionManagerTest.class,\
**/HibernateMappingHyperlinkProviderTest.class

cp.extra=${tools.jar}
requires.nb.javac=true
2 changes: 2 additions & 0 deletions i18n/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ javadoc.arch=${basedir}/arch.xml
disable.qa-functional.tests=true

test.config.stableBTD.includes=**/*Test.class
cp.extra=${tools.jar}
requires.nb.javac=true
Loading

0 comments on commit ffc0de5

Please sign in to comment.