Initial
This commit is contained in:
commit
1648bd2af5
73
build.xml
Normal file
73
build.xml
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- You may freely edit this file. See commented blocks below for -->
|
||||||
|
<!-- some examples of how to customize the build. -->
|
||||||
|
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||||
|
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||||
|
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||||
|
<!-- the Compile on Save feature is turned off for the project. -->
|
||||||
|
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||||
|
<!-- in the project's Project Properties dialog box.-->
|
||||||
|
<project name="JavaCompiler" default="default" basedir=".">
|
||||||
|
<description>Builds, tests, and runs the project JavaCompiler.</description>
|
||||||
|
<import file="nbproject/build-impl.xml"/>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
There exist several targets which are by default empty and which can be
|
||||||
|
used for execution of your tasks. These targets are usually executed
|
||||||
|
before and after some main targets. They are:
|
||||||
|
|
||||||
|
-pre-init: called before initialization of project properties
|
||||||
|
-post-init: called after initialization of project properties
|
||||||
|
-pre-compile: called before javac compilation
|
||||||
|
-post-compile: called after javac compilation
|
||||||
|
-pre-compile-single: called before javac compilation of single file
|
||||||
|
-post-compile-single: called after javac compilation of single file
|
||||||
|
-pre-compile-test: called before javac compilation of JUnit tests
|
||||||
|
-post-compile-test: called after javac compilation of JUnit tests
|
||||||
|
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||||
|
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||||
|
-pre-jar: called before JAR building
|
||||||
|
-post-jar: called after JAR building
|
||||||
|
-post-clean: called after cleaning build products
|
||||||
|
|
||||||
|
(Targets beginning with '-' are not intended to be called on their own.)
|
||||||
|
|
||||||
|
Example of inserting an obfuscator after compilation could look like this:
|
||||||
|
|
||||||
|
<target name="-post-compile">
|
||||||
|
<obfuscate>
|
||||||
|
<fileset dir="${build.classes.dir}"/>
|
||||||
|
</obfuscate>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
For list of available properties check the imported
|
||||||
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
|
||||||
|
Another way to customize the build is by overriding existing main targets.
|
||||||
|
The targets of interest are:
|
||||||
|
|
||||||
|
-init-macrodef-javac: defines macro for javac compilation
|
||||||
|
-init-macrodef-junit: defines macro for junit execution
|
||||||
|
-init-macrodef-debug: defines macro for class debugging
|
||||||
|
-init-macrodef-java: defines macro for class execution
|
||||||
|
-do-jar: JAR building
|
||||||
|
run: execution of project
|
||||||
|
-javadoc-build: Javadoc generation
|
||||||
|
test-report: JUnit report generation
|
||||||
|
|
||||||
|
An example of overriding the target for project execution could look like this:
|
||||||
|
|
||||||
|
<target name="run" depends="JavaCompiler-impl.jar">
|
||||||
|
<exec dir="bin" executable="launcher.exe">
|
||||||
|
<arg file="${dist.jar}"/>
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
Notice that the overridden target depends on the jar target and not only on
|
||||||
|
the compile target as the regular run target does. Again, for a list of available
|
||||||
|
properties which you can use, check the target you are overriding in the
|
||||||
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
-->
|
||||||
|
</project>
|
1419
nbproject/build-impl.xml
Normal file
1419
nbproject/build-impl.xml
Normal file
File diff suppressed because it is too large
Load Diff
8
nbproject/genfiles.properties
Normal file
8
nbproject/genfiles.properties
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
build.xml.data.CRC32=c102fd34
|
||||||
|
build.xml.script.CRC32=d4fc063e
|
||||||
|
build.xml.stylesheet.CRC32=8064a381@1.79.0.48
|
||||||
|
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||||
|
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||||
|
nbproject/build-impl.xml.data.CRC32=c102fd34
|
||||||
|
nbproject/build-impl.xml.script.CRC32=68744efb
|
||||||
|
nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.0.48
|
0
nbproject/private/config.properties
Normal file
0
nbproject/private/config.properties
Normal file
6
nbproject/private/private.properties
Normal file
6
nbproject/private/private.properties
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
compile.on.save=true
|
||||||
|
do.depend=false
|
||||||
|
do.jar=true
|
||||||
|
javac.debug=true
|
||||||
|
javadoc.preview=true
|
||||||
|
user.properties.file=C:\\Users\\aNNiMON\\AppData\\Roaming\\NetBeans\\dev\\build.properties
|
7
nbproject/private/private.xml
Normal file
7
nbproject/private/private.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||||
|
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||||
|
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||||
|
<group/>
|
||||||
|
</open-files>
|
||||||
|
</project-private>
|
76
nbproject/project.properties
Normal file
76
nbproject/project.properties
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
annotation.processing.enabled=true
|
||||||
|
annotation.processing.enabled.in.editor=false
|
||||||
|
annotation.processing.processors.list=
|
||||||
|
annotation.processing.run.all.processors=true
|
||||||
|
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||||
|
application.title=JavaCompiler
|
||||||
|
application.vendor=aNNiMON
|
||||||
|
build.classes.dir=${build.dir}/classes
|
||||||
|
build.classes.excludes=**/*.java,**/*.form
|
||||||
|
# This directory is removed when the project is cleaned:
|
||||||
|
build.dir=build
|
||||||
|
build.generated.dir=${build.dir}/generated
|
||||||
|
build.generated.sources.dir=${build.dir}/generated-sources
|
||||||
|
# Only compile against the classpath explicitly listed here:
|
||||||
|
build.sysclasspath=ignore
|
||||||
|
build.test.classes.dir=${build.dir}/test/classes
|
||||||
|
build.test.results.dir=${build.dir}/test/results
|
||||||
|
# Uncomment to specify the preferred debugger connection transport:
|
||||||
|
#debug.transport=dt_socket
|
||||||
|
debug.classpath=\
|
||||||
|
${run.classpath}
|
||||||
|
debug.test.classpath=\
|
||||||
|
${run.test.classpath}
|
||||||
|
# Files in build.classes.dir which should be excluded from distribution jar
|
||||||
|
dist.archive.excludes=
|
||||||
|
# This directory is removed when the project is cleaned:
|
||||||
|
dist.dir=dist
|
||||||
|
dist.jar=${dist.dir}/JavaCompiler.jar
|
||||||
|
dist.javadoc.dir=${dist.dir}/javadoc
|
||||||
|
endorsed.classpath=
|
||||||
|
excludes=
|
||||||
|
includes=**
|
||||||
|
jar.compress=false
|
||||||
|
javac.classpath=
|
||||||
|
# Space-separated list of extra javac options
|
||||||
|
javac.compilerargs=
|
||||||
|
javac.deprecation=false
|
||||||
|
javac.external.vm=true
|
||||||
|
javac.processorpath=\
|
||||||
|
${javac.classpath}
|
||||||
|
javac.source=1.8
|
||||||
|
javac.target=1.8
|
||||||
|
javac.test.classpath=\
|
||||||
|
${javac.classpath}:\
|
||||||
|
${build.classes.dir}
|
||||||
|
javac.test.processorpath=\
|
||||||
|
${javac.test.classpath}
|
||||||
|
javadoc.additionalparam=
|
||||||
|
javadoc.author=false
|
||||||
|
javadoc.encoding=${source.encoding}
|
||||||
|
javadoc.noindex=false
|
||||||
|
javadoc.nonavbar=false
|
||||||
|
javadoc.notree=false
|
||||||
|
javadoc.private=false
|
||||||
|
javadoc.splitindex=true
|
||||||
|
javadoc.use=true
|
||||||
|
javadoc.version=false
|
||||||
|
javadoc.windowtitle=
|
||||||
|
main.class=org.codehaus.janino.Compiler
|
||||||
|
manifest.file=manifest.mf
|
||||||
|
meta.inf.dir=${src.dir}/META-INF
|
||||||
|
mkdist.disabled=false
|
||||||
|
platform.active=default_platform
|
||||||
|
run.classpath=\
|
||||||
|
${javac.classpath}:\
|
||||||
|
${build.classes.dir}
|
||||||
|
# Space-separated list of JVM arguments used when running the project.
|
||||||
|
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
|
||||||
|
# To set system properties for unit tests define test-sys-prop.name=value:
|
||||||
|
run.jvmargs=
|
||||||
|
run.test.classpath=\
|
||||||
|
${javac.test.classpath}:\
|
||||||
|
${build.test.classes.dir}
|
||||||
|
source.encoding=UTF-8
|
||||||
|
src.dir=src
|
||||||
|
test.src.dir=test
|
15
nbproject/project.xml
Normal file
15
nbproject/project.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||||
|
<type>org.netbeans.modules.java.j2seproject</type>
|
||||||
|
<configuration>
|
||||||
|
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||||
|
<name>JavaCompiler</name>
|
||||||
|
<source-roots>
|
||||||
|
<root id="src.dir"/>
|
||||||
|
</source-roots>
|
||||||
|
<test-roots>
|
||||||
|
<root id="test.src.dir"/>
|
||||||
|
</test-roots>
|
||||||
|
</data>
|
||||||
|
</configuration>
|
||||||
|
</project>
|
39
src/com/annimon/javac/Main.java
Normal file
39
src/com/annimon/javac/Main.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package com.annimon.javac;
|
||||||
|
|
||||||
|
import com.github.javaparser.JavaParser;
|
||||||
|
import com.github.javaparser.ParseException;
|
||||||
|
import com.github.javaparser.ast.CompilationUnit;
|
||||||
|
import com.github.javaparser.ast.expr.AssignExpr;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitorAdapter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author aNNiMON
|
||||||
|
*/
|
||||||
|
public final class Main {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
try {
|
||||||
|
CompilationUnit unit = JavaParser.parse(new File("E:/javac/Main.java"), "UTF-8", false);
|
||||||
|
System.out.println(unit);
|
||||||
|
new JavaVisitor().visit(unit, null);
|
||||||
|
} catch (ParseException | IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class JavaVisitor extends VoidVisitorAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visit(AssignExpr n, Object arg) {
|
||||||
|
super.visit(n, arg);
|
||||||
|
System.out.print(n.getTarget());
|
||||||
|
System.out.print(' ');
|
||||||
|
System.out.print(n.getOperator());
|
||||||
|
System.out.print(' ');
|
||||||
|
System.out.println(n.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
299
src/com/github/javaparser/ASTHelper.java
Normal file
299
src/com/github/javaparser/ASTHelper.java
Normal file
@ -0,0 +1,299 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.CompilationUnit;
|
||||||
|
import com.github.javaparser.ast.Node;
|
||||||
|
import com.github.javaparser.ast.body.BodyDeclaration;
|
||||||
|
import com.github.javaparser.ast.body.FieldDeclaration;
|
||||||
|
import com.github.javaparser.ast.body.MethodDeclaration;
|
||||||
|
import com.github.javaparser.ast.body.Parameter;
|
||||||
|
import com.github.javaparser.ast.body.TypeDeclaration;
|
||||||
|
import com.github.javaparser.ast.body.VariableDeclarator;
|
||||||
|
import com.github.javaparser.ast.body.VariableDeclaratorId;
|
||||||
|
import com.github.javaparser.ast.expr.Expression;
|
||||||
|
import com.github.javaparser.ast.expr.MethodCallExpr;
|
||||||
|
import com.github.javaparser.ast.expr.NameExpr;
|
||||||
|
import com.github.javaparser.ast.expr.QualifiedNameExpr;
|
||||||
|
import com.github.javaparser.ast.expr.VariableDeclarationExpr;
|
||||||
|
import com.github.javaparser.ast.stmt.BlockStmt;
|
||||||
|
import com.github.javaparser.ast.stmt.ExpressionStmt;
|
||||||
|
import com.github.javaparser.ast.stmt.Statement;
|
||||||
|
import com.github.javaparser.ast.type.ClassOrInterfaceType;
|
||||||
|
import com.github.javaparser.ast.type.PrimitiveType;
|
||||||
|
import com.github.javaparser.ast.type.ReferenceType;
|
||||||
|
import com.github.javaparser.ast.type.Type;
|
||||||
|
import com.github.javaparser.ast.type.VoidType;
|
||||||
|
import com.github.javaparser.ast.type.PrimitiveType.Primitive;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class helps to construct new nodes.
|
||||||
|
*
|
||||||
|
* @author Júlio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class ASTHelper {
|
||||||
|
|
||||||
|
public static final PrimitiveType BYTE_TYPE = new PrimitiveType(Primitive.Byte);
|
||||||
|
|
||||||
|
public static final PrimitiveType SHORT_TYPE = new PrimitiveType(Primitive.Short);
|
||||||
|
|
||||||
|
public static final PrimitiveType INT_TYPE = new PrimitiveType(Primitive.Int);
|
||||||
|
|
||||||
|
public static final PrimitiveType LONG_TYPE = new PrimitiveType(Primitive.Long);
|
||||||
|
|
||||||
|
public static final PrimitiveType FLOAT_TYPE = new PrimitiveType(Primitive.Float);
|
||||||
|
|
||||||
|
public static final PrimitiveType DOUBLE_TYPE = new PrimitiveType(Primitive.Double);
|
||||||
|
|
||||||
|
public static final PrimitiveType BOOLEAN_TYPE = new PrimitiveType(Primitive.Boolean);
|
||||||
|
|
||||||
|
public static final PrimitiveType CHAR_TYPE = new PrimitiveType(Primitive.Char);
|
||||||
|
|
||||||
|
public static final VoidType VOID_TYPE = new VoidType();
|
||||||
|
|
||||||
|
private ASTHelper() {
|
||||||
|
// nop
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link NameExpr} from a qualified name.<br>
|
||||||
|
* The qualified name can contains "." (dot) characters.
|
||||||
|
*
|
||||||
|
* @param qualifiedName
|
||||||
|
* qualified name
|
||||||
|
* @return instanceof {@link NameExpr}
|
||||||
|
*/
|
||||||
|
public static NameExpr createNameExpr(String qualifiedName) {
|
||||||
|
String[] split = qualifiedName.split("\\.");
|
||||||
|
NameExpr ret = new NameExpr(split[0]);
|
||||||
|
for (int i = 1; i < split.length; i++) {
|
||||||
|
ret = new QualifiedNameExpr(ret, split[i]);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link Parameter}.
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* type of the parameter
|
||||||
|
* @param name
|
||||||
|
* name of the parameter
|
||||||
|
* @return instance of {@link Parameter}
|
||||||
|
*/
|
||||||
|
public static Parameter createParameter(Type type, String name) {
|
||||||
|
return new Parameter(type, new VariableDeclaratorId(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a {@link FieldDeclaration}.
|
||||||
|
*
|
||||||
|
* @param modifiers
|
||||||
|
* modifiers
|
||||||
|
* @param type
|
||||||
|
* type
|
||||||
|
* @param variable
|
||||||
|
* variable declarator
|
||||||
|
* @return instance of {@link FieldDeclaration}
|
||||||
|
*/
|
||||||
|
public static FieldDeclaration createFieldDeclaration(int modifiers, Type type, VariableDeclarator variable) {
|
||||||
|
List<VariableDeclarator> variables = new ArrayList<VariableDeclarator>();
|
||||||
|
variables.add(variable);
|
||||||
|
FieldDeclaration ret = new FieldDeclaration(modifiers, type, variables);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a {@link FieldDeclaration}.
|
||||||
|
*
|
||||||
|
* @param modifiers
|
||||||
|
* modifiers
|
||||||
|
* @param type
|
||||||
|
* type
|
||||||
|
* @param name
|
||||||
|
* field name
|
||||||
|
* @return instance of {@link FieldDeclaration}
|
||||||
|
*/
|
||||||
|
public static FieldDeclaration createFieldDeclaration(int modifiers, Type type, String name) {
|
||||||
|
VariableDeclaratorId id = new VariableDeclaratorId(name);
|
||||||
|
VariableDeclarator variable = new VariableDeclarator(id);
|
||||||
|
return createFieldDeclaration(modifiers, type, variable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a {@link VariableDeclarationExpr}.
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* type
|
||||||
|
* @param name
|
||||||
|
* name
|
||||||
|
* @return instance of {@link VariableDeclarationExpr}
|
||||||
|
*/
|
||||||
|
public static VariableDeclarationExpr createVariableDeclarationExpr(Type type, String name) {
|
||||||
|
List<VariableDeclarator> vars = new ArrayList<VariableDeclarator>();
|
||||||
|
vars.add(new VariableDeclarator(new VariableDeclaratorId(name)));
|
||||||
|
return new VariableDeclarationExpr(type, vars);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the given parameter to the method. The list of parameters will be
|
||||||
|
* initialized if it is <code>null</code>.
|
||||||
|
*
|
||||||
|
* @param method
|
||||||
|
* method
|
||||||
|
* @param parameter
|
||||||
|
* parameter
|
||||||
|
*/
|
||||||
|
public static void addParameter(MethodDeclaration method, Parameter parameter) {
|
||||||
|
List<Parameter> parameters = method.getParameters();
|
||||||
|
if (isNullOrEmpty(parameters)) {
|
||||||
|
parameters = new ArrayList<Parameter>();
|
||||||
|
method.setParameters(parameters);
|
||||||
|
}
|
||||||
|
parameters.add(parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the given argument to the method call. The list of arguments will be
|
||||||
|
* initialized if it is <code>null</code>.
|
||||||
|
*
|
||||||
|
* @param call
|
||||||
|
* method call
|
||||||
|
* @param arg
|
||||||
|
* argument value
|
||||||
|
*/
|
||||||
|
public static void addArgument(MethodCallExpr call, Expression arg) {
|
||||||
|
List<Expression> args = call.getArgs();
|
||||||
|
if (isNullOrEmpty(args)) {
|
||||||
|
args = new ArrayList<Expression>();
|
||||||
|
call.setArgs(args);
|
||||||
|
}
|
||||||
|
args.add(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the given type declaration to the compilation unit. The list of
|
||||||
|
* types will be initialized if it is <code>null</code>.
|
||||||
|
*
|
||||||
|
* @param cu
|
||||||
|
* compilation unit
|
||||||
|
* @param type
|
||||||
|
* type declaration
|
||||||
|
*/
|
||||||
|
public static void addTypeDeclaration(CompilationUnit cu, TypeDeclaration type) {
|
||||||
|
List<TypeDeclaration> types = cu.getTypes();
|
||||||
|
if (isNullOrEmpty(types)) {
|
||||||
|
types = new ArrayList<TypeDeclaration>();
|
||||||
|
cu.setTypes(types);
|
||||||
|
}
|
||||||
|
types.add(type);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link ReferenceType} for a class or interface.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* name of the class or interface
|
||||||
|
* @param arrayCount
|
||||||
|
* number of arrays or <code>0</code> if is not a array.
|
||||||
|
* @return instanceof {@link ReferenceType}
|
||||||
|
*/
|
||||||
|
public static ReferenceType createReferenceType(String name, int arrayCount) {
|
||||||
|
return new ReferenceType(new ClassOrInterfaceType(name), arrayCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link ReferenceType} for the given primitive type.
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* primitive type
|
||||||
|
* @param arrayCount
|
||||||
|
* number of arrays or <code>0</code> if is not a array.
|
||||||
|
* @return instanceof {@link ReferenceType}
|
||||||
|
*/
|
||||||
|
public static ReferenceType createReferenceType(PrimitiveType type, int arrayCount) {
|
||||||
|
return new ReferenceType(type, arrayCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the given statement to the specified block. The list of statements
|
||||||
|
* will be initialized if it is <code>null</code>.
|
||||||
|
*
|
||||||
|
* @param block to have expression added to
|
||||||
|
* @param stmt to be added
|
||||||
|
*/
|
||||||
|
public static void addStmt(BlockStmt block, Statement stmt) {
|
||||||
|
List<Statement> stmts = block.getStmts();
|
||||||
|
if (isNullOrEmpty(stmts)) {
|
||||||
|
stmts = new ArrayList<Statement>();
|
||||||
|
block.setStmts(stmts);
|
||||||
|
}
|
||||||
|
stmts.add(stmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the given expression to the specified block. The list of statements
|
||||||
|
* will be initialized if it is <code>null</code>.
|
||||||
|
*
|
||||||
|
* @param block to have expression added to
|
||||||
|
* @param expr to be added
|
||||||
|
*/
|
||||||
|
public static void addStmt(BlockStmt block, Expression expr) {
|
||||||
|
addStmt(block, new ExpressionStmt(expr));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the given declaration to the specified type. The list of members
|
||||||
|
* will be initialized if it is <code>null</code>.
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* type declaration
|
||||||
|
* @param decl
|
||||||
|
* member declaration
|
||||||
|
*/
|
||||||
|
public static void addMember(TypeDeclaration type, BodyDeclaration decl) {
|
||||||
|
List<BodyDeclaration> members = type.getMembers();
|
||||||
|
if (isNullOrEmpty(members)) {
|
||||||
|
members = new ArrayList<BodyDeclaration>();
|
||||||
|
type.setMembers(members);
|
||||||
|
}
|
||||||
|
members.add(decl);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <N extends Node> List<N> getNodesByType(Node container, Class<N> clazz) {
|
||||||
|
List<N> nodes = new ArrayList<N>();
|
||||||
|
for (Node child : container.getChildrenNodes()) {
|
||||||
|
if (clazz.isInstance(child)) {
|
||||||
|
nodes.add(clazz.cast(child));
|
||||||
|
}
|
||||||
|
nodes.addAll(getNodesByType(child, clazz));
|
||||||
|
}
|
||||||
|
return nodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
9148
src/com/github/javaparser/ASTParser.java
Normal file
9148
src/com/github/javaparser/ASTParser.java
Normal file
File diff suppressed because it is too large
Load Diff
414
src/com/github/javaparser/ASTParserConstants.java
Normal file
414
src/com/github/javaparser/ASTParserConstants.java
Normal file
@ -0,0 +1,414 @@
|
|||||||
|
/* Generated By:JavaCC: Do not edit this line. ASTParserConstants.java */
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* This file is part of Java 1.8 parser and Abstract Syntax Tree.
|
||||||
|
*
|
||||||
|
* Java 1.8 parser and Abstract Syntax Tree is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Java 1.8 parser and Abstract Syntax Tree. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.github.javaparser;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Token literal values and constants.
|
||||||
|
* Generated by org.javacc.parser.OtherFilesGen#start()
|
||||||
|
*/
|
||||||
|
public interface ASTParserConstants {
|
||||||
|
|
||||||
|
/** End of File. */
|
||||||
|
int EOF = 0;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int SINGLE_LINE_COMMENT = 6;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int JAVA_DOC_COMMENT = 9;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int MULTI_LINE_COMMENT = 10;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int ABSTRACT = 12;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int ASSERT = 13;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int BOOLEAN = 14;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int BREAK = 15;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int BYTE = 16;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int CASE = 17;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int CATCH = 18;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int CHAR = 19;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int CLASS = 20;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int CONST = 21;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int CONTINUE = 22;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int _DEFAULT = 23;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int DO = 24;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int DOUBLE = 25;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int ELSE = 26;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int ENUM = 27;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int EXTENDS = 28;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int FALSE = 29;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int FINAL = 30;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int FINALLY = 31;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int FLOAT = 32;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int FOR = 33;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int GOTO = 34;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int IF = 35;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int IMPLEMENTS = 36;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int IMPORT = 37;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int INSTANCEOF = 38;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int INT = 39;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int INTERFACE = 40;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int LONG = 41;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int NATIVE = 42;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int NEW = 43;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int NULL = 44;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int PACKAGE = 45;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int PRIVATE = 46;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int PROTECTED = 47;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int PUBLIC = 48;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int RETURN = 49;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int SHORT = 50;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int STATIC = 51;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int STRICTFP = 52;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int SUPER = 53;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int SWITCH = 54;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int SYNCHRONIZED = 55;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int THIS = 56;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int THROW = 57;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int THROWS = 58;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int TRANSIENT = 59;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int TRUE = 60;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int TRY = 61;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int VOID = 62;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int VOLATILE = 63;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int WHILE = 64;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int LONG_LITERAL = 65;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int INTEGER_LITERAL = 66;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int DECIMAL_LITERAL = 67;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int HEX_LITERAL = 68;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int OCTAL_LITERAL = 69;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int BINARY_LITERAL = 70;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int FLOATING_POINT_LITERAL = 71;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int DECIMAL_FLOATING_POINT_LITERAL = 72;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int DECIMAL_EXPONENT = 73;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int HEXADECIMAL_FLOATING_POINT_LITERAL = 74;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int HEXADECIMAL_EXPONENT = 75;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int CHARACTER_LITERAL = 76;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int STRING_LITERAL = 77;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int IDENTIFIER = 78;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int LETTER = 79;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int PART_LETTER = 80;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int LPAREN = 81;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int RPAREN = 82;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int LBRACE = 83;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int RBRACE = 84;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int LBRACKET = 85;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int RBRACKET = 86;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int SEMICOLON = 87;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int COMMA = 88;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int DOT = 89;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int AT = 90;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int ASSIGN = 91;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int LT = 92;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int BANG = 93;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int TILDE = 94;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int HOOK = 95;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int COLON = 96;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int EQ = 97;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int LE = 98;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int GE = 99;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int NE = 100;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int SC_OR = 101;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int SC_AND = 102;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int INCR = 103;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int DECR = 104;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int PLUS = 105;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int MINUS = 106;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int STAR = 107;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int SLASH = 108;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int BIT_AND = 109;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int BIT_OR = 110;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int XOR = 111;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int REM = 112;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int LSHIFT = 113;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int PLUSASSIGN = 114;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int MINUSASSIGN = 115;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int STARASSIGN = 116;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int SLASHASSIGN = 117;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int ANDASSIGN = 118;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int ORASSIGN = 119;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int XORASSIGN = 120;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int REMASSIGN = 121;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int LSHIFTASSIGN = 122;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int RSIGNEDSHIFTASSIGN = 123;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int RUNSIGNEDSHIFTASSIGN = 124;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int ELLIPSIS = 125;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int ARROW = 126;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int DOUBLECOLON = 127;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int RUNSIGNEDSHIFT = 128;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int RSIGNEDSHIFT = 129;
|
||||||
|
/** RegularExpression Id. */
|
||||||
|
int GT = 130;
|
||||||
|
|
||||||
|
/** Lexical state. */
|
||||||
|
int DEFAULT = 0;
|
||||||
|
/** Lexical state. */
|
||||||
|
int IN_JAVA_DOC_COMMENT = 1;
|
||||||
|
/** Lexical state. */
|
||||||
|
int IN_MULTI_LINE_COMMENT = 2;
|
||||||
|
|
||||||
|
/** Literal token values. */
|
||||||
|
String[] tokenImage = {
|
||||||
|
"<EOF>",
|
||||||
|
"\" \"",
|
||||||
|
"\"\\t\"",
|
||||||
|
"\"\\n\"",
|
||||||
|
"\"\\r\"",
|
||||||
|
"\"\\f\"",
|
||||||
|
"<SINGLE_LINE_COMMENT>",
|
||||||
|
"<token of kind 7>",
|
||||||
|
"\"/*\"",
|
||||||
|
"\"*/\"",
|
||||||
|
"\"*/\"",
|
||||||
|
"<token of kind 11>",
|
||||||
|
"\"abstract\"",
|
||||||
|
"\"assert\"",
|
||||||
|
"\"boolean\"",
|
||||||
|
"\"break\"",
|
||||||
|
"\"byte\"",
|
||||||
|
"\"case\"",
|
||||||
|
"\"catch\"",
|
||||||
|
"\"char\"",
|
||||||
|
"\"class\"",
|
||||||
|
"\"const\"",
|
||||||
|
"\"continue\"",
|
||||||
|
"\"default\"",
|
||||||
|
"\"do\"",
|
||||||
|
"\"double\"",
|
||||||
|
"\"else\"",
|
||||||
|
"\"enum\"",
|
||||||
|
"\"extends\"",
|
||||||
|
"\"false\"",
|
||||||
|
"\"final\"",
|
||||||
|
"\"finally\"",
|
||||||
|
"\"float\"",
|
||||||
|
"\"for\"",
|
||||||
|
"\"goto\"",
|
||||||
|
"\"if\"",
|
||||||
|
"\"implements\"",
|
||||||
|
"\"import\"",
|
||||||
|
"\"instanceof\"",
|
||||||
|
"\"int\"",
|
||||||
|
"\"interface\"",
|
||||||
|
"\"long\"",
|
||||||
|
"\"native\"",
|
||||||
|
"\"new\"",
|
||||||
|
"\"null\"",
|
||||||
|
"\"package\"",
|
||||||
|
"\"private\"",
|
||||||
|
"\"protected\"",
|
||||||
|
"\"public\"",
|
||||||
|
"\"return\"",
|
||||||
|
"\"short\"",
|
||||||
|
"\"static\"",
|
||||||
|
"\"strictfp\"",
|
||||||
|
"\"super\"",
|
||||||
|
"\"switch\"",
|
||||||
|
"\"synchronized\"",
|
||||||
|
"\"this\"",
|
||||||
|
"\"throw\"",
|
||||||
|
"\"throws\"",
|
||||||
|
"\"transient\"",
|
||||||
|
"\"true\"",
|
||||||
|
"\"try\"",
|
||||||
|
"\"void\"",
|
||||||
|
"\"volatile\"",
|
||||||
|
"\"while\"",
|
||||||
|
"<LONG_LITERAL>",
|
||||||
|
"<INTEGER_LITERAL>",
|
||||||
|
"<DECIMAL_LITERAL>",
|
||||||
|
"<HEX_LITERAL>",
|
||||||
|
"<OCTAL_LITERAL>",
|
||||||
|
"<BINARY_LITERAL>",
|
||||||
|
"<FLOATING_POINT_LITERAL>",
|
||||||
|
"<DECIMAL_FLOATING_POINT_LITERAL>",
|
||||||
|
"<DECIMAL_EXPONENT>",
|
||||||
|
"<HEXADECIMAL_FLOATING_POINT_LITERAL>",
|
||||||
|
"<HEXADECIMAL_EXPONENT>",
|
||||||
|
"<CHARACTER_LITERAL>",
|
||||||
|
"<STRING_LITERAL>",
|
||||||
|
"<IDENTIFIER>",
|
||||||
|
"<LETTER>",
|
||||||
|
"<PART_LETTER>",
|
||||||
|
"\"(\"",
|
||||||
|
"\")\"",
|
||||||
|
"\"{\"",
|
||||||
|
"\"}\"",
|
||||||
|
"\"[\"",
|
||||||
|
"\"]\"",
|
||||||
|
"\";\"",
|
||||||
|
"\",\"",
|
||||||
|
"\".\"",
|
||||||
|
"\"@\"",
|
||||||
|
"\"=\"",
|
||||||
|
"\"<\"",
|
||||||
|
"\"!\"",
|
||||||
|
"\"~\"",
|
||||||
|
"\"?\"",
|
||||||
|
"\":\"",
|
||||||
|
"\"==\"",
|
||||||
|
"\"<=\"",
|
||||||
|
"\">=\"",
|
||||||
|
"\"!=\"",
|
||||||
|
"\"||\"",
|
||||||
|
"\"&&\"",
|
||||||
|
"\"++\"",
|
||||||
|
"\"--\"",
|
||||||
|
"\"+\"",
|
||||||
|
"\"-\"",
|
||||||
|
"\"*\"",
|
||||||
|
"\"/\"",
|
||||||
|
"\"&\"",
|
||||||
|
"\"|\"",
|
||||||
|
"\"^\"",
|
||||||
|
"\"%\"",
|
||||||
|
"\"<<\"",
|
||||||
|
"\"+=\"",
|
||||||
|
"\"-=\"",
|
||||||
|
"\"*=\"",
|
||||||
|
"\"/=\"",
|
||||||
|
"\"&=\"",
|
||||||
|
"\"|=\"",
|
||||||
|
"\"^=\"",
|
||||||
|
"\"%=\"",
|
||||||
|
"\"<<=\"",
|
||||||
|
"\">>=\"",
|
||||||
|
"\">>>=\"",
|
||||||
|
"\"...\"",
|
||||||
|
"\"->\"",
|
||||||
|
"\"::\"",
|
||||||
|
"\">>>\"",
|
||||||
|
"\">>\"",
|
||||||
|
"\">\"",
|
||||||
|
"\"\\u001a\"",
|
||||||
|
"\"<>\"",
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
2559
src/com/github/javaparser/ASTParserTokenManager.java
Normal file
2559
src/com/github/javaparser/ASTParserTokenManager.java
Normal file
File diff suppressed because it is too large
Load Diff
629
src/com/github/javaparser/JavaCharStream.java
Normal file
629
src/com/github/javaparser/JavaCharStream.java
Normal file
@ -0,0 +1,629 @@
|
|||||||
|
/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 5.0 */
|
||||||
|
/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* This file is part of Java 1.8 parser and Abstract Syntax Tree.
|
||||||
|
*
|
||||||
|
* Java 1.8 parser and Abstract Syntax Tree is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Java 1.8 parser and Abstract Syntax Tree. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.github.javaparser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An implementation of interface CharStream, where the stream is assumed to
|
||||||
|
* contain only ASCII characters (with java-like unicode escape processing).
|
||||||
|
*/
|
||||||
|
|
||||||
|
public
|
||||||
|
class JavaCharStream
|
||||||
|
{
|
||||||
|
/** Whether parser is static. */
|
||||||
|
public static final boolean staticFlag = false;
|
||||||
|
|
||||||
|
static final int hexval(char c) throws java.io.IOException {
|
||||||
|
switch(c)
|
||||||
|
{
|
||||||
|
case '0' :
|
||||||
|
return 0;
|
||||||
|
case '1' :
|
||||||
|
return 1;
|
||||||
|
case '2' :
|
||||||
|
return 2;
|
||||||
|
case '3' :
|
||||||
|
return 3;
|
||||||
|
case '4' :
|
||||||
|
return 4;
|
||||||
|
case '5' :
|
||||||
|
return 5;
|
||||||
|
case '6' :
|
||||||
|
return 6;
|
||||||
|
case '7' :
|
||||||
|
return 7;
|
||||||
|
case '8' :
|
||||||
|
return 8;
|
||||||
|
case '9' :
|
||||||
|
return 9;
|
||||||
|
|
||||||
|
case 'a' :
|
||||||
|
case 'A' :
|
||||||
|
return 10;
|
||||||
|
case 'b' :
|
||||||
|
case 'B' :
|
||||||
|
return 11;
|
||||||
|
case 'c' :
|
||||||
|
case 'C' :
|
||||||
|
return 12;
|
||||||
|
case 'd' :
|
||||||
|
case 'D' :
|
||||||
|
return 13;
|
||||||
|
case 'e' :
|
||||||
|
case 'E' :
|
||||||
|
return 14;
|
||||||
|
case 'f' :
|
||||||
|
case 'F' :
|
||||||
|
return 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new java.io.IOException(); // Should never come here
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Position in buffer. */
|
||||||
|
public int bufpos = -1;
|
||||||
|
int bufsize;
|
||||||
|
int available;
|
||||||
|
int tokenBegin;
|
||||||
|
protected int bufline[];
|
||||||
|
protected int bufcolumn[];
|
||||||
|
|
||||||
|
protected int column = 0;
|
||||||
|
protected int line = 1;
|
||||||
|
|
||||||
|
protected boolean prevCharIsCR = false;
|
||||||
|
protected boolean prevCharIsLF = false;
|
||||||
|
|
||||||
|
protected java.io.Reader inputStream;
|
||||||
|
|
||||||
|
protected char[] nextCharBuf;
|
||||||
|
protected char[] buffer;
|
||||||
|
protected int maxNextCharInd = 0;
|
||||||
|
protected int nextCharInd = -1;
|
||||||
|
protected int inBuf = 0;
|
||||||
|
protected int tabSize = 8;
|
||||||
|
|
||||||
|
protected void setTabSize(int i) { tabSize = i; }
|
||||||
|
protected int getTabSize(int i) { return tabSize; }
|
||||||
|
|
||||||
|
protected void ExpandBuff(boolean wrapAround)
|
||||||
|
{
|
||||||
|
char[] newbuffer = new char[bufsize + 2048];
|
||||||
|
int newbufline[] = new int[bufsize + 2048];
|
||||||
|
int newbufcolumn[] = new int[bufsize + 2048];
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (wrapAround)
|
||||||
|
{
|
||||||
|
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
|
||||||
|
System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos);
|
||||||
|
buffer = newbuffer;
|
||||||
|
|
||||||
|
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
|
||||||
|
System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
|
||||||
|
bufline = newbufline;
|
||||||
|
|
||||||
|
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
|
||||||
|
System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
|
||||||
|
bufcolumn = newbufcolumn;
|
||||||
|
|
||||||
|
bufpos += (bufsize - tokenBegin);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
|
||||||
|
buffer = newbuffer;
|
||||||
|
|
||||||
|
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
|
||||||
|
bufline = newbufline;
|
||||||
|
|
||||||
|
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
|
||||||
|
bufcolumn = newbufcolumn;
|
||||||
|
|
||||||
|
bufpos -= tokenBegin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
|
throw new Error(t.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
available = (bufsize += 2048);
|
||||||
|
tokenBegin = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void FillBuff() throws java.io.IOException
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
if (maxNextCharInd == 4096)
|
||||||
|
maxNextCharInd = nextCharInd = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ((i = inputStream.read(nextCharBuf, maxNextCharInd,
|
||||||
|
4096 - maxNextCharInd)) == -1)
|
||||||
|
{
|
||||||
|
inputStream.close();
|
||||||
|
throw new java.io.IOException();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
maxNextCharInd += i;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch(java.io.IOException e) {
|
||||||
|
if (bufpos != 0)
|
||||||
|
{
|
||||||
|
--bufpos;
|
||||||
|
backup(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bufline[bufpos] = line;
|
||||||
|
bufcolumn[bufpos] = column;
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected char ReadByte() throws java.io.IOException
|
||||||
|
{
|
||||||
|
if (++nextCharInd >= maxNextCharInd)
|
||||||
|
FillBuff();
|
||||||
|
|
||||||
|
return nextCharBuf[nextCharInd];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return starting character for token. */
|
||||||
|
public char BeginToken() throws java.io.IOException
|
||||||
|
{
|
||||||
|
if (inBuf > 0)
|
||||||
|
{
|
||||||
|
--inBuf;
|
||||||
|
|
||||||
|
if (++bufpos == bufsize)
|
||||||
|
bufpos = 0;
|
||||||
|
|
||||||
|
tokenBegin = bufpos;
|
||||||
|
return buffer[bufpos];
|
||||||
|
}
|
||||||
|
|
||||||
|
tokenBegin = 0;
|
||||||
|
bufpos = -1;
|
||||||
|
|
||||||
|
return readChar();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void AdjustBuffSize()
|
||||||
|
{
|
||||||
|
if (available == bufsize)
|
||||||
|
{
|
||||||
|
if (tokenBegin > 2048)
|
||||||
|
{
|
||||||
|
bufpos = 0;
|
||||||
|
available = tokenBegin;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ExpandBuff(false);
|
||||||
|
}
|
||||||
|
else if (available > tokenBegin)
|
||||||
|
available = bufsize;
|
||||||
|
else if ((tokenBegin - available) < 2048)
|
||||||
|
ExpandBuff(true);
|
||||||
|
else
|
||||||
|
available = tokenBegin;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void UpdateLineColumn(char c)
|
||||||
|
{
|
||||||
|
column++;
|
||||||
|
|
||||||
|
if (prevCharIsLF)
|
||||||
|
{
|
||||||
|
prevCharIsLF = false;
|
||||||
|
line += (column = 1);
|
||||||
|
}
|
||||||
|
else if (prevCharIsCR)
|
||||||
|
{
|
||||||
|
prevCharIsCR = false;
|
||||||
|
if (c == '\n')
|
||||||
|
{
|
||||||
|
prevCharIsLF = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
line += (column = 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case '\r' :
|
||||||
|
prevCharIsCR = true;
|
||||||
|
break;
|
||||||
|
case '\n' :
|
||||||
|
prevCharIsLF = true;
|
||||||
|
break;
|
||||||
|
case '\t' :
|
||||||
|
column--;
|
||||||
|
column += (tabSize - (column % tabSize));
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
bufline[bufpos] = line;
|
||||||
|
bufcolumn[bufpos] = column;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Read a character. */
|
||||||
|
public char readChar() throws java.io.IOException
|
||||||
|
{
|
||||||
|
if (inBuf > 0)
|
||||||
|
{
|
||||||
|
--inBuf;
|
||||||
|
|
||||||
|
if (++bufpos == bufsize)
|
||||||
|
bufpos = 0;
|
||||||
|
|
||||||
|
return buffer[bufpos];
|
||||||
|
}
|
||||||
|
|
||||||
|
char c;
|
||||||
|
|
||||||
|
if (++bufpos == available)
|
||||||
|
AdjustBuffSize();
|
||||||
|
|
||||||
|
if ((buffer[bufpos] = c = ReadByte()) == '\\')
|
||||||
|
{
|
||||||
|
UpdateLineColumn(c);
|
||||||
|
|
||||||
|
int backSlashCnt = 1;
|
||||||
|
|
||||||
|
for (;;) // Read all the backslashes
|
||||||
|
{
|
||||||
|
if (++bufpos == available)
|
||||||
|
AdjustBuffSize();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ((buffer[bufpos] = c = ReadByte()) != '\\')
|
||||||
|
{
|
||||||
|
UpdateLineColumn(c);
|
||||||
|
// found a non-backslash char.
|
||||||
|
if ((c == 'u') && ((backSlashCnt & 1) == 1))
|
||||||
|
{
|
||||||
|
if (--bufpos < 0)
|
||||||
|
bufpos = bufsize - 1;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
backup(backSlashCnt);
|
||||||
|
return '\\';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(java.io.IOException e)
|
||||||
|
{
|
||||||
|
// We are returning one backslash so we should only backup (count-1)
|
||||||
|
if (backSlashCnt > 1)
|
||||||
|
backup(backSlashCnt-1);
|
||||||
|
|
||||||
|
return '\\';
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateLineColumn(c);
|
||||||
|
backSlashCnt++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Here, we have seen an odd number of backslash's followed by a 'u'
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while ((c = ReadByte()) == 'u')
|
||||||
|
++column;
|
||||||
|
|
||||||
|
buffer[bufpos] = c = (char)(hexval(c) << 12 |
|
||||||
|
hexval(ReadByte()) << 8 |
|
||||||
|
hexval(ReadByte()) << 4 |
|
||||||
|
hexval(ReadByte()));
|
||||||
|
|
||||||
|
column += 4;
|
||||||
|
}
|
||||||
|
catch(java.io.IOException e)
|
||||||
|
{
|
||||||
|
throw new Error("Invalid escape character at line " + line +
|
||||||
|
" column " + column + ".");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (backSlashCnt == 1)
|
||||||
|
return c;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
backup(backSlashCnt - 1);
|
||||||
|
return '\\';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UpdateLineColumn(c);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @see #getEndColumn
|
||||||
|
*/
|
||||||
|
public int getColumn() {
|
||||||
|
return bufcolumn[bufpos];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @see #getEndLine
|
||||||
|
*/
|
||||||
|
public int getLine() {
|
||||||
|
return bufline[bufpos];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get end column. */
|
||||||
|
public int getEndColumn() {
|
||||||
|
return bufcolumn[bufpos];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get end line. */
|
||||||
|
public int getEndLine() {
|
||||||
|
return bufline[bufpos];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return column of token start */
|
||||||
|
public int getBeginColumn() {
|
||||||
|
return bufcolumn[tokenBegin];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return line number of token start */
|
||||||
|
public int getBeginLine() {
|
||||||
|
return bufline[tokenBegin];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Retreat. */
|
||||||
|
public void backup(int amount) {
|
||||||
|
|
||||||
|
inBuf += amount;
|
||||||
|
if ((bufpos -= amount) < 0)
|
||||||
|
bufpos += bufsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Constructor. */
|
||||||
|
public JavaCharStream(java.io.Reader dstream,
|
||||||
|
int startline, int startcolumn, int buffersize)
|
||||||
|
{
|
||||||
|
inputStream = dstream;
|
||||||
|
line = startline;
|
||||||
|
column = startcolumn - 1;
|
||||||
|
|
||||||
|
available = bufsize = buffersize;
|
||||||
|
buffer = new char[buffersize];
|
||||||
|
bufline = new int[buffersize];
|
||||||
|
bufcolumn = new int[buffersize];
|
||||||
|
nextCharBuf = new char[4096];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Constructor. */
|
||||||
|
public JavaCharStream(java.io.Reader dstream,
|
||||||
|
int startline, int startcolumn)
|
||||||
|
{
|
||||||
|
this(dstream, startline, startcolumn, 4096);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Constructor. */
|
||||||
|
public JavaCharStream(java.io.Reader dstream)
|
||||||
|
{
|
||||||
|
this(dstream, 1, 1, 4096);
|
||||||
|
}
|
||||||
|
/** Reinitialise. */
|
||||||
|
public void ReInit(java.io.Reader dstream,
|
||||||
|
int startline, int startcolumn, int buffersize)
|
||||||
|
{
|
||||||
|
inputStream = dstream;
|
||||||
|
line = startline;
|
||||||
|
column = startcolumn - 1;
|
||||||
|
|
||||||
|
if (buffer == null || buffersize != buffer.length)
|
||||||
|
{
|
||||||
|
available = bufsize = buffersize;
|
||||||
|
buffer = new char[buffersize];
|
||||||
|
bufline = new int[buffersize];
|
||||||
|
bufcolumn = new int[buffersize];
|
||||||
|
nextCharBuf = new char[4096];
|
||||||
|
}
|
||||||
|
prevCharIsLF = prevCharIsCR = false;
|
||||||
|
tokenBegin = inBuf = maxNextCharInd = 0;
|
||||||
|
nextCharInd = bufpos = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reinitialise. */
|
||||||
|
public void ReInit(java.io.Reader dstream,
|
||||||
|
int startline, int startcolumn)
|
||||||
|
{
|
||||||
|
ReInit(dstream, startline, startcolumn, 4096);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reinitialise. */
|
||||||
|
public void ReInit(java.io.Reader dstream)
|
||||||
|
{
|
||||||
|
ReInit(dstream, 1, 1, 4096);
|
||||||
|
}
|
||||||
|
/** Constructor. */
|
||||||
|
public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
|
||||||
|
int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
|
||||||
|
{
|
||||||
|
this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Constructor. */
|
||||||
|
public JavaCharStream(java.io.InputStream dstream, int startline,
|
||||||
|
int startcolumn, int buffersize)
|
||||||
|
{
|
||||||
|
this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Constructor. */
|
||||||
|
public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
|
||||||
|
int startcolumn) throws java.io.UnsupportedEncodingException
|
||||||
|
{
|
||||||
|
this(dstream, encoding, startline, startcolumn, 4096);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Constructor. */
|
||||||
|
public JavaCharStream(java.io.InputStream dstream, int startline,
|
||||||
|
int startcolumn)
|
||||||
|
{
|
||||||
|
this(dstream, startline, startcolumn, 4096);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Constructor. */
|
||||||
|
public JavaCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
|
||||||
|
{
|
||||||
|
this(dstream, encoding, 1, 1, 4096);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Constructor. */
|
||||||
|
public JavaCharStream(java.io.InputStream dstream)
|
||||||
|
{
|
||||||
|
this(dstream, 1, 1, 4096);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reinitialise. */
|
||||||
|
public void ReInit(java.io.InputStream dstream, String encoding, int startline,
|
||||||
|
int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
|
||||||
|
{
|
||||||
|
ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reinitialise. */
|
||||||
|
public void ReInit(java.io.InputStream dstream, int startline,
|
||||||
|
int startcolumn, int buffersize)
|
||||||
|
{
|
||||||
|
ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
|
||||||
|
}
|
||||||
|
/** Reinitialise. */
|
||||||
|
public void ReInit(java.io.InputStream dstream, String encoding, int startline,
|
||||||
|
int startcolumn) throws java.io.UnsupportedEncodingException
|
||||||
|
{
|
||||||
|
ReInit(dstream, encoding, startline, startcolumn, 4096);
|
||||||
|
}
|
||||||
|
/** Reinitialise. */
|
||||||
|
public void ReInit(java.io.InputStream dstream, int startline,
|
||||||
|
int startcolumn)
|
||||||
|
{
|
||||||
|
ReInit(dstream, startline, startcolumn, 4096);
|
||||||
|
}
|
||||||
|
/** Reinitialise. */
|
||||||
|
public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
|
||||||
|
{
|
||||||
|
ReInit(dstream, encoding, 1, 1, 4096);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reinitialise. */
|
||||||
|
public void ReInit(java.io.InputStream dstream)
|
||||||
|
{
|
||||||
|
ReInit(dstream, 1, 1, 4096);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return token image as String */
|
||||||
|
public String GetImage()
|
||||||
|
{
|
||||||
|
if (bufpos >= tokenBegin)
|
||||||
|
return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
|
||||||
|
else
|
||||||
|
return new String(buffer, tokenBegin, bufsize - tokenBegin) +
|
||||||
|
new String(buffer, 0, bufpos + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return suffix */
|
||||||
|
public char[] GetSuffix(int len)
|
||||||
|
{
|
||||||
|
char[] ret = new char[len];
|
||||||
|
|
||||||
|
if ((bufpos + 1) >= len)
|
||||||
|
System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
|
||||||
|
len - bufpos - 1);
|
||||||
|
System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set buffers back to null when finished. */
|
||||||
|
public void Done()
|
||||||
|
{
|
||||||
|
nextCharBuf = null;
|
||||||
|
buffer = null;
|
||||||
|
bufline = null;
|
||||||
|
bufcolumn = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to adjust line and column numbers for the start of a token.
|
||||||
|
*/
|
||||||
|
public void adjustBeginLineColumn(int newLine, int newCol)
|
||||||
|
{
|
||||||
|
int start = tokenBegin;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
if (bufpos >= tokenBegin)
|
||||||
|
{
|
||||||
|
len = bufpos - tokenBegin + inBuf + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
len = bufsize - tokenBegin + bufpos + 1 + inBuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = 0, j = 0, k = 0;
|
||||||
|
int nextColDiff = 0, columnDiff = 0;
|
||||||
|
|
||||||
|
while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
|
||||||
|
{
|
||||||
|
bufline[j] = newLine;
|
||||||
|
nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
|
||||||
|
bufcolumn[j] = newCol + columnDiff;
|
||||||
|
columnDiff = nextColDiff;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i < len)
|
||||||
|
{
|
||||||
|
bufline[j] = newLine++;
|
||||||
|
bufcolumn[j] = newCol + columnDiff;
|
||||||
|
|
||||||
|
while (i++ < len)
|
||||||
|
{
|
||||||
|
if (bufline[j = start % bufsize] != bufline[++start % bufsize])
|
||||||
|
bufline[j] = newLine++;
|
||||||
|
else
|
||||||
|
bufline[j] = newLine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
line = bufline[j];
|
||||||
|
column = bufcolumn[j];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/* JavaCC - OriginalChecksum=5111a95355f2f1cc405246f828703097 (do not edit this line) */
|
450
src/com/github/javaparser/JavaParser.java
Normal file
450
src/com/github/javaparser/JavaParser.java
Normal file
@ -0,0 +1,450 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser;
|
||||||
|
|
||||||
|
import static com.github.javaparser.PositionUtils.areInOrder;
|
||||||
|
import static com.github.javaparser.PositionUtils.sortByBeginPosition;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.CompilationUnit;
|
||||||
|
import com.github.javaparser.ast.ImportDeclaration;
|
||||||
|
import com.github.javaparser.ast.Node;
|
||||||
|
import com.github.javaparser.ast.body.BodyDeclaration;
|
||||||
|
import com.github.javaparser.ast.comments.Comment;
|
||||||
|
import com.github.javaparser.ast.comments.CommentsCollection;
|
||||||
|
import com.github.javaparser.ast.comments.CommentsParser;
|
||||||
|
import com.github.javaparser.ast.comments.LineComment;
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
import com.github.javaparser.ast.expr.Expression;
|
||||||
|
import com.github.javaparser.ast.stmt.BlockStmt;
|
||||||
|
import com.github.javaparser.ast.stmt.Statement;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
// FIXME this file does not seem to be generated by javacc. Is the doc wrong, or the javacc config?
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* This class was generated automatically by javacc, do not edit.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* Parse Java 1.5 source code and creates Abstract Syntax Tree classes.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Júlio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class JavaParser {
|
||||||
|
private JavaParser() {
|
||||||
|
// hide the constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean _doNotAssignCommentsPreceedingEmptyLines = true;
|
||||||
|
|
||||||
|
private static boolean _doNotConsiderAnnotationsAsNodeStartForCodeAttribution = false;
|
||||||
|
|
||||||
|
public static boolean getDoNotConsiderAnnotationsAsNodeStartForCodeAttribution()
|
||||||
|
{
|
||||||
|
return _doNotConsiderAnnotationsAsNodeStartForCodeAttribution;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setDoNotConsiderAnnotationsAsNodeStartForCodeAttribution(boolean doNotConsiderAnnotationsAsNodeStartForCodeAttribution) {
|
||||||
|
_doNotConsiderAnnotationsAsNodeStartForCodeAttribution = doNotConsiderAnnotationsAsNodeStartForCodeAttribution;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getDoNotAssignCommentsPreceedingEmptyLines()
|
||||||
|
{
|
||||||
|
return _doNotAssignCommentsPreceedingEmptyLines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setDoNotAssignCommentsPreceedingEmptyLines(boolean doNotAssignCommentsPreceedingEmptyLines)
|
||||||
|
{
|
||||||
|
_doNotAssignCommentsPreceedingEmptyLines = doNotAssignCommentsPreceedingEmptyLines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CompilationUnit parse(final InputStream in,
|
||||||
|
final String encoding) throws ParseException {
|
||||||
|
return parse(in,encoding,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the Java code contained in the {@link InputStream} and returns a
|
||||||
|
* {@link CompilationUnit} that represents it.
|
||||||
|
*
|
||||||
|
* @param in
|
||||||
|
* {@link InputStream} containing Java source code
|
||||||
|
* @param encoding
|
||||||
|
* encoding of the source code
|
||||||
|
* @return CompilationUnit representing the Java source code
|
||||||
|
* @throws ParseException
|
||||||
|
* if the source code has parser errors
|
||||||
|
*/
|
||||||
|
public static CompilationUnit parse(final InputStream in,
|
||||||
|
final String encoding, boolean considerComments) throws ParseException {
|
||||||
|
try {
|
||||||
|
String code = SourcesHelper.streamToString(in, encoding);
|
||||||
|
InputStream in1 = SourcesHelper.stringToStream(code, encoding);
|
||||||
|
CompilationUnit cu = new ASTParser(in1, encoding).CompilationUnit();
|
||||||
|
if (considerComments){
|
||||||
|
insertComments(cu,code);
|
||||||
|
}
|
||||||
|
return cu;
|
||||||
|
} catch (IOException ioe){
|
||||||
|
throw new ParseException(ioe.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the Java code contained in the {@link InputStream} and returns a
|
||||||
|
* {@link CompilationUnit} that represents it.
|
||||||
|
*
|
||||||
|
* @param in
|
||||||
|
* {@link InputStream} containing Java source code
|
||||||
|
* @return CompilationUnit representing the Java source code
|
||||||
|
* @throws ParseException
|
||||||
|
* if the source code has parser errors
|
||||||
|
*/
|
||||||
|
public static CompilationUnit parse(final InputStream in)
|
||||||
|
throws ParseException {
|
||||||
|
return parse(in, null,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CompilationUnit parse(final File file, final String encoding)
|
||||||
|
throws ParseException, IOException {
|
||||||
|
return parse(file,encoding,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the Java code contained in a {@link File} and returns a
|
||||||
|
* {@link CompilationUnit} that represents it.
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* {@link File} containing Java source code
|
||||||
|
* @param encoding
|
||||||
|
* encoding of the source code
|
||||||
|
* @return CompilationUnit representing the Java source code
|
||||||
|
* @throws ParseException
|
||||||
|
* if the source code has parser errors
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public static CompilationUnit parse(final File file, final String encoding, boolean considerComments)
|
||||||
|
throws ParseException, IOException {
|
||||||
|
final FileInputStream in = new FileInputStream(file);
|
||||||
|
try {
|
||||||
|
return parse(in, encoding, considerComments);
|
||||||
|
} finally {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the Java code contained in a {@link File} and returns a
|
||||||
|
* {@link CompilationUnit} that represents it.
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* {@link File} containing Java source code
|
||||||
|
* @return CompilationUnit representing the Java source code
|
||||||
|
* @throws ParseException
|
||||||
|
* if the source code has parser errors
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public static CompilationUnit parse(final File file) throws ParseException,
|
||||||
|
IOException {
|
||||||
|
return parse(file, null,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CompilationUnit parse(final Reader reader, boolean considerComments)
|
||||||
|
throws ParseException {
|
||||||
|
try {
|
||||||
|
String code = SourcesHelper.readerToString(reader);
|
||||||
|
Reader reader1 = SourcesHelper.stringToReader(code);
|
||||||
|
CompilationUnit cu = new ASTParser(reader1).CompilationUnit();
|
||||||
|
if (considerComments){
|
||||||
|
insertComments(cu,code);
|
||||||
|
}
|
||||||
|
return cu;
|
||||||
|
} catch (IOException ioe){
|
||||||
|
throw new ParseException(ioe.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the Java block contained in a {@link String} and returns a
|
||||||
|
* {@link BlockStmt} that represents it.
|
||||||
|
*
|
||||||
|
* @param blockStatement
|
||||||
|
* {@link String} containing Java block code
|
||||||
|
* @return BlockStmt representing the Java block
|
||||||
|
* @throws ParseException
|
||||||
|
* if the source code has parser errors
|
||||||
|
*/
|
||||||
|
public static BlockStmt parseBlock(final String blockStatement)
|
||||||
|
throws ParseException {
|
||||||
|
StringReader sr = new StringReader(blockStatement);
|
||||||
|
BlockStmt result = new ASTParser(sr).Block();
|
||||||
|
sr.close();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the Java statement contained in a {@link String} and returns a
|
||||||
|
* {@link Statement} that represents it.
|
||||||
|
*
|
||||||
|
* @param statement
|
||||||
|
* {@link String} containing Java statement code
|
||||||
|
* @return Statement representing the Java statement
|
||||||
|
* @throws ParseException
|
||||||
|
* if the source code has parser errors
|
||||||
|
*/
|
||||||
|
public static Statement parseStatement(final String statement) throws ParseException {
|
||||||
|
StringReader sr = new StringReader(statement);
|
||||||
|
Statement stmt = new ASTParser(sr).Statement();
|
||||||
|
sr.close();
|
||||||
|
return stmt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the Java import contained in a {@link String} and returns a
|
||||||
|
* {@link ImportDeclaration} that represents it.
|
||||||
|
*
|
||||||
|
* @param importDeclaration
|
||||||
|
* {@link String} containing Java import code
|
||||||
|
* @return ImportDeclaration representing the Java import declaration
|
||||||
|
* @throws ParseException
|
||||||
|
* if the source code has parser errors
|
||||||
|
*/
|
||||||
|
public static ImportDeclaration parseImport(final String importDeclaration) throws ParseException {
|
||||||
|
StringReader sr = new StringReader(importDeclaration);
|
||||||
|
ImportDeclaration id = new ASTParser(sr).ImportDeclaration();
|
||||||
|
sr.close();
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the Java expression contained in a {@link String} and returns a
|
||||||
|
* {@link Expression} that represents it.
|
||||||
|
*
|
||||||
|
* @param expression
|
||||||
|
* {@link String} containing Java expression
|
||||||
|
* @return Expression representing the Java expression
|
||||||
|
* @throws ParseException
|
||||||
|
* if the source code has parser errors
|
||||||
|
*/
|
||||||
|
public static Expression parseExpression(final String expression) throws ParseException {
|
||||||
|
StringReader sr = new StringReader(expression);
|
||||||
|
Expression e = new ASTParser(sr).Expression();
|
||||||
|
sr.close();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the Java annotation contained in a {@link String} and returns a
|
||||||
|
* {@link AnnotationExpr} that represents it.
|
||||||
|
*
|
||||||
|
* @param annotation
|
||||||
|
* {@link String} containing Java annotation
|
||||||
|
* @return AnnotationExpr representing the Java annotation
|
||||||
|
* @throws ParseException
|
||||||
|
* if the source code has parser errors
|
||||||
|
*/
|
||||||
|
public static AnnotationExpr parseAnnotation(final String annotation) throws ParseException {
|
||||||
|
StringReader sr = new StringReader(annotation);
|
||||||
|
AnnotationExpr ae = new ASTParser(sr).Annotation();
|
||||||
|
sr.close();
|
||||||
|
return ae;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the Java body declaration(e.g fields or methods) contained in a
|
||||||
|
* {@link String} and returns a {@link BodyDeclaration} that represents it.
|
||||||
|
*
|
||||||
|
* @param body
|
||||||
|
* {@link String} containing Java body declaration
|
||||||
|
* @return BodyDeclaration representing the Java annotation
|
||||||
|
* @throws ParseException
|
||||||
|
* if the source code has parser errors
|
||||||
|
*/
|
||||||
|
public static BodyDeclaration parseBodyDeclaration(final String body) throws ParseException {
|
||||||
|
StringReader sr = new StringReader(body);
|
||||||
|
BodyDeclaration bd = new ASTParser(sr).AnnotationBodyDeclaration();
|
||||||
|
sr.close();
|
||||||
|
return bd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comments are attributed to the thing the comment and are removed from
|
||||||
|
* allComments.
|
||||||
|
*/
|
||||||
|
private static void insertCommentsInCu(CompilationUnit cu, CommentsCollection commentsCollection){
|
||||||
|
if (commentsCollection.size()==0) return;
|
||||||
|
|
||||||
|
// I should sort all the direct children and the comments, if a comment is the first thing then it
|
||||||
|
// a comment to the CompilationUnit
|
||||||
|
// FIXME if there is no package it could be also a comment to the following class...
|
||||||
|
// so I could use some heuristics in these cases to distinguish the two cases
|
||||||
|
|
||||||
|
List<Comment> comments = commentsCollection.getAll();
|
||||||
|
PositionUtils.sortByBeginPosition(comments);
|
||||||
|
List<Node> children = cu.getChildrenNodes();
|
||||||
|
PositionUtils.sortByBeginPosition(children);
|
||||||
|
|
||||||
|
if (cu.getPackage()!=null && (children.size()==0 || PositionUtils.areInOrder(comments.get(0), children.get(0)))){
|
||||||
|
cu.setComment(comments.get(0));
|
||||||
|
comments.remove(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
insertCommentsInNode(cu,comments);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean attributeLineCommentToNodeOrChild(Node node, LineComment lineComment)
|
||||||
|
{
|
||||||
|
// The node start and end at the same line as the comment,
|
||||||
|
// let's give to it the comment
|
||||||
|
if (node.getBeginLine()==lineComment.getBeginLine() && !node.hasComment())
|
||||||
|
{
|
||||||
|
node.setComment(lineComment);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// try with all the children, sorted by reverse position (so the
|
||||||
|
// first one is the nearest to the comment
|
||||||
|
List<Node> children = new LinkedList<Node>();
|
||||||
|
children.addAll(node.getChildrenNodes());
|
||||||
|
PositionUtils.sortByBeginPosition(children);
|
||||||
|
Collections.reverse(children);
|
||||||
|
|
||||||
|
for (Node child : children)
|
||||||
|
{
|
||||||
|
if (attributeLineCommentToNodeOrChild(child, lineComment))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method try to attributes the nodes received to child of the node.
|
||||||
|
* It returns the node that were not attributed.
|
||||||
|
*/
|
||||||
|
private static void insertCommentsInNode(Node node, List<Comment> commentsToAttribute){
|
||||||
|
if (commentsToAttribute.size()==0) return;
|
||||||
|
|
||||||
|
// the comments can:
|
||||||
|
// 1) Inside one of the child, then it is the child that have to associate them
|
||||||
|
// 2) If they are not inside a child they could be preceeding nothing, a comment or a child
|
||||||
|
// if they preceed a child they are assigned to it, otherweise they remain "orphans"
|
||||||
|
|
||||||
|
List<Node> children = node.getChildrenNodes();
|
||||||
|
PositionUtils.sortByBeginPosition(children);
|
||||||
|
|
||||||
|
for (Node child : children){
|
||||||
|
List<Comment> commentsInsideChild = new LinkedList<Comment>();
|
||||||
|
for (Comment c : commentsToAttribute){
|
||||||
|
if (PositionUtils.nodeContains(child, c, _doNotConsiderAnnotationsAsNodeStartForCodeAttribution)){
|
||||||
|
commentsInsideChild.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
commentsToAttribute.removeAll(commentsInsideChild);
|
||||||
|
insertCommentsInNode(child,commentsInsideChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
// I can attribute in line comments to elements preceeding them, if there
|
||||||
|
// is something contained in their line
|
||||||
|
List<Comment> attributedComments = new LinkedList<Comment>();
|
||||||
|
for (Comment comment : commentsToAttribute)
|
||||||
|
{
|
||||||
|
if (comment.isLineComment())
|
||||||
|
{
|
||||||
|
for (Node child : children)
|
||||||
|
{
|
||||||
|
if (child.getEndLine()==comment.getBeginLine())
|
||||||
|
{
|
||||||
|
if (attributeLineCommentToNodeOrChild(child, comment.asLineComment()))
|
||||||
|
{
|
||||||
|
attributedComments.add(comment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// at this point I create an ordered list of all remaining comments and children
|
||||||
|
Comment previousComment = null;
|
||||||
|
attributedComments = new LinkedList<Comment>();
|
||||||
|
List<Node> childrenAndComments = new LinkedList<Node>();
|
||||||
|
childrenAndComments.addAll(children);
|
||||||
|
childrenAndComments.addAll(commentsToAttribute);
|
||||||
|
PositionUtils.sortByBeginPosition(childrenAndComments, _doNotConsiderAnnotationsAsNodeStartForCodeAttribution);
|
||||||
|
|
||||||
|
for (Node thing : childrenAndComments){
|
||||||
|
if (thing instanceof Comment){
|
||||||
|
previousComment = (Comment)thing;
|
||||||
|
if (!previousComment.isOrphan())
|
||||||
|
{
|
||||||
|
previousComment = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (previousComment != null && !thing.hasComment()){
|
||||||
|
if (!_doNotAssignCommentsPreceedingEmptyLines || !thereAreLinesBetween(previousComment, thing)) {
|
||||||
|
thing.setComment(previousComment);
|
||||||
|
attributedComments.add(previousComment);
|
||||||
|
previousComment = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
commentsToAttribute.removeAll(attributedComments);
|
||||||
|
|
||||||
|
// all the remaining are orphan nodes
|
||||||
|
for (Comment c : commentsToAttribute){
|
||||||
|
if (c.isOrphan()) {
|
||||||
|
node.addOrphanComment(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean thereAreLinesBetween(Node a, Node b)
|
||||||
|
{
|
||||||
|
if (!PositionUtils.areInOrder(a, b))
|
||||||
|
{
|
||||||
|
return thereAreLinesBetween(b, a);
|
||||||
|
}
|
||||||
|
int endOfA = a.getEndLine();
|
||||||
|
return b.getBeginLine()>(a.getEndLine()+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void insertComments(CompilationUnit cu, String code) throws IOException {
|
||||||
|
CommentsParser commentsParser = new CommentsParser();
|
||||||
|
CommentsCollection allComments = commentsParser.parse(code);
|
||||||
|
|
||||||
|
insertCommentsInCu(cu,allComments);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
199
src/com/github/javaparser/ParseException.java
Normal file
199
src/com/github/javaparser/ParseException.java
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */
|
||||||
|
/* JavaCCOptions:KEEP_LINE_COL=null */
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* This file is part of Java 1.8 parser and Abstract Syntax Tree.
|
||||||
|
*
|
||||||
|
* Java 1.8 parser and Abstract Syntax Tree is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Java 1.8 parser and Abstract Syntax Tree. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.github.javaparser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This exception is thrown when parse errors are encountered.
|
||||||
|
* You can explicitly create objects of this exception type by
|
||||||
|
* calling the method generateParseException in the generated
|
||||||
|
* parser.
|
||||||
|
*
|
||||||
|
* You can modify this class to customize your error reporting
|
||||||
|
* mechanisms so long as you retain the public fields.
|
||||||
|
*/
|
||||||
|
public class ParseException extends Exception {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The version identifier for this Serializable class.
|
||||||
|
* Increment only if the <i>serialized</i> form of the
|
||||||
|
* class changes.
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constructor is used by the method "generateParseException"
|
||||||
|
* in the generated parser. Calling this constructor generates
|
||||||
|
* a new object of this type with the fields "currentToken",
|
||||||
|
* "expectedTokenSequences", and "tokenImage" set.
|
||||||
|
*/
|
||||||
|
public ParseException(Token currentTokenVal,
|
||||||
|
int[][] expectedTokenSequencesVal,
|
||||||
|
String[] tokenImageVal
|
||||||
|
)
|
||||||
|
{
|
||||||
|
super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal));
|
||||||
|
currentToken = currentTokenVal;
|
||||||
|
expectedTokenSequences = expectedTokenSequencesVal;
|
||||||
|
tokenImage = tokenImageVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The following constructors are for use by you for whatever
|
||||||
|
* purpose you can think of. Constructing the exception in this
|
||||||
|
* manner makes the exception behave in the normal way - i.e., as
|
||||||
|
* documented in the class "Throwable". The fields "errorToken",
|
||||||
|
* "expectedTokenSequences", and "tokenImage" do not contain
|
||||||
|
* relevant information. The JavaCC generated code does not use
|
||||||
|
* these constructors.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public ParseException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Constructor with message. */
|
||||||
|
public ParseException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the last token that has been consumed successfully. If
|
||||||
|
* this object has been created due to a parse error, the token
|
||||||
|
* followng this token will (therefore) be the first error token.
|
||||||
|
*/
|
||||||
|
public Token currentToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Each entry in this array is an array of integers. Each array
|
||||||
|
* of integers represents a sequence of tokens (by their ordinal
|
||||||
|
* values) that is expected at this point of the parse.
|
||||||
|
*/
|
||||||
|
public int[][] expectedTokenSequences;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a reference to the "tokenImage" array of the generated
|
||||||
|
* parser within which the parse error occurred. This array is
|
||||||
|
* defined in the generated ...Constants interface.
|
||||||
|
*/
|
||||||
|
public String[] tokenImage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It uses "currentToken" and "expectedTokenSequences" to generate a parse
|
||||||
|
* error message and returns it. If this object has been created
|
||||||
|
* due to a parse error, and you do not catch it (it gets thrown
|
||||||
|
* from the parser) the correct error message
|
||||||
|
* gets displayed.
|
||||||
|
*/
|
||||||
|
private static String initialise(Token currentToken,
|
||||||
|
int[][] expectedTokenSequences,
|
||||||
|
String[] tokenImage) {
|
||||||
|
String eol = System.getProperty("line.separator", "\n");
|
||||||
|
StringBuffer expected = new StringBuffer();
|
||||||
|
int maxSize = 0;
|
||||||
|
for (int i = 0; i < expectedTokenSequences.length; i++) {
|
||||||
|
if (maxSize < expectedTokenSequences[i].length) {
|
||||||
|
maxSize = expectedTokenSequences[i].length;
|
||||||
|
}
|
||||||
|
for (int j = 0; j < expectedTokenSequences[i].length; j++) {
|
||||||
|
expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' ');
|
||||||
|
}
|
||||||
|
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
|
||||||
|
expected.append("...");
|
||||||
|
}
|
||||||
|
expected.append(eol).append(" ");
|
||||||
|
}
|
||||||
|
String retval = "Encountered \"";
|
||||||
|
Token tok = currentToken.next;
|
||||||
|
for (int i = 0; i < maxSize; i++) {
|
||||||
|
if (i != 0) retval += " ";
|
||||||
|
if (tok.kind == 0) {
|
||||||
|
retval += tokenImage[0];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
retval += " " + tokenImage[tok.kind];
|
||||||
|
retval += " \"";
|
||||||
|
retval += add_escapes(tok.image);
|
||||||
|
retval += " \"";
|
||||||
|
tok = tok.next;
|
||||||
|
}
|
||||||
|
retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
|
||||||
|
retval += "." + eol;
|
||||||
|
if (expectedTokenSequences.length == 1) {
|
||||||
|
retval += "Was expecting:" + eol + " ";
|
||||||
|
} else {
|
||||||
|
retval += "Was expecting one of:" + eol + " ";
|
||||||
|
}
|
||||||
|
retval += expected.toString();
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The end of line string for this machine.
|
||||||
|
*/
|
||||||
|
protected String eol = System.getProperty("line.separator", "\n");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to convert raw characters to their escaped version
|
||||||
|
* when these raw version cannot be used as part of an ASCII
|
||||||
|
* string literal.
|
||||||
|
*/
|
||||||
|
static String add_escapes(String str) {
|
||||||
|
StringBuffer retval = new StringBuffer();
|
||||||
|
char ch;
|
||||||
|
for (int i = 0; i < str.length(); i++) {
|
||||||
|
switch (str.charAt(i))
|
||||||
|
{
|
||||||
|
case 0 :
|
||||||
|
continue;
|
||||||
|
case '\b':
|
||||||
|
retval.append("\\b");
|
||||||
|
continue;
|
||||||
|
case '\t':
|
||||||
|
retval.append("\\t");
|
||||||
|
continue;
|
||||||
|
case '\n':
|
||||||
|
retval.append("\\n");
|
||||||
|
continue;
|
||||||
|
case '\f':
|
||||||
|
retval.append("\\f");
|
||||||
|
continue;
|
||||||
|
case '\r':
|
||||||
|
retval.append("\\r");
|
||||||
|
continue;
|
||||||
|
case '\"':
|
||||||
|
retval.append("\\\"");
|
||||||
|
continue;
|
||||||
|
case '\'':
|
||||||
|
retval.append("\\\'");
|
||||||
|
continue;
|
||||||
|
case '\\':
|
||||||
|
retval.append("\\\\");
|
||||||
|
continue;
|
||||||
|
default:
|
||||||
|
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
|
||||||
|
String s = "0000" + Integer.toString(ch, 16);
|
||||||
|
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
|
||||||
|
} else {
|
||||||
|
retval.append(ch);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retval.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/* JavaCC - OriginalChecksum=62ba72b2159703420d5ce7232a0226fb (do not edit this line) */
|
53
src/com/github/javaparser/Position.java
Normal file
53
src/com/github/javaparser/Position.java
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.Node;
|
||||||
|
|
||||||
|
public class Position {
|
||||||
|
private int line;
|
||||||
|
private int column;
|
||||||
|
|
||||||
|
public static final Position ABSOLUTE_START = new Position(Node.ABSOLUTE_BEGIN_LINE,-1);
|
||||||
|
public static final Position ABSOLUTE_END = new Position(Node.ABSOLUTE_END_LINE,-1);
|
||||||
|
|
||||||
|
public static Position beginOf(Node node){
|
||||||
|
return new Position(node.getBeginLine(),node.getBeginColumn());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Position endOf(Node node){
|
||||||
|
return new Position(node.getEndLine(),node.getEndColumn());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position(int line, int column){
|
||||||
|
this.line = line;
|
||||||
|
this.column = column;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLine(){
|
||||||
|
return this.line;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColumn(){
|
||||||
|
return this.column;
|
||||||
|
}
|
||||||
|
}
|
143
src/com/github/javaparser/PositionUtils.java
Normal file
143
src/com/github/javaparser/PositionUtils.java
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.Node;
|
||||||
|
import com.github.javaparser.ast.body.AnnotableNode;
|
||||||
|
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
|
||||||
|
import com.github.javaparser.ast.body.FieldDeclaration;
|
||||||
|
import com.github.javaparser.ast.body.MethodDeclaration;
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
|
||||||
|
import java.lang.Override;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static java.lang.Integer.signum;
|
||||||
|
|
||||||
|
public final class PositionUtils {
|
||||||
|
|
||||||
|
private PositionUtils() {
|
||||||
|
// prevent instantiation
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T extends Node> void sortByBeginPosition(List<T> nodes){
|
||||||
|
sortByBeginPosition(nodes, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T extends Node> void sortByBeginPosition(List<T> nodes, final boolean ignoringAnnotations){
|
||||||
|
Collections.sort(nodes, new Comparator<Node>() {
|
||||||
|
@Override
|
||||||
|
public int compare(Node o1, Node o2) {
|
||||||
|
return PositionUtils.compare(o1, o2, ignoringAnnotations);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean areInOrder(Node a, Node b){
|
||||||
|
return areInOrder(a, b, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean areInOrder(Node a, Node b, boolean ignoringAnnotations){
|
||||||
|
return compare(a, b, ignoringAnnotations) <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int compare(Node a, Node b, boolean ignoringAnnotations) {
|
||||||
|
if (ignoringAnnotations) {
|
||||||
|
int signLine = signum(beginLineWithoutConsideringAnnotation(a) - beginLineWithoutConsideringAnnotation(b));
|
||||||
|
if (signLine == 0) {
|
||||||
|
return signum(beginColumnWithoutConsideringAnnotation(a) - beginColumnWithoutConsideringAnnotation(b));
|
||||||
|
} else {
|
||||||
|
return signLine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int signLine = signum( a.getBeginLine() - b.getBeginLine() );
|
||||||
|
if (signLine == 0) {
|
||||||
|
return signum(a.getBeginColumn() - b.getBeginColumn());
|
||||||
|
} else {
|
||||||
|
return signLine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AnnotationExpr getLastAnnotation(Node node) {
|
||||||
|
if (node instanceof AnnotableNode){
|
||||||
|
List<AnnotationExpr> annotations = new LinkedList<AnnotationExpr>();
|
||||||
|
annotations.addAll(((AnnotableNode) node).getAnnotations());
|
||||||
|
if (annotations.size()==0){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
sortByBeginPosition(annotations);
|
||||||
|
return annotations.get(annotations.size()-1);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int beginLineWithoutConsideringAnnotation(Node node) {
|
||||||
|
return beginNodeWithoutConsideringAnnotations(node).getBeginLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static int beginColumnWithoutConsideringAnnotation(Node node) {
|
||||||
|
return beginNodeWithoutConsideringAnnotations(node).getBeginColumn();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Node beginNodeWithoutConsideringAnnotations(Node node) {
|
||||||
|
if (node instanceof MethodDeclaration) {
|
||||||
|
MethodDeclaration casted = (MethodDeclaration) node;
|
||||||
|
return casted.getType();
|
||||||
|
} else if (node instanceof FieldDeclaration) {
|
||||||
|
FieldDeclaration casted = (FieldDeclaration) node;
|
||||||
|
return casted.getType();
|
||||||
|
} else if (node instanceof ClassOrInterfaceDeclaration) {
|
||||||
|
ClassOrInterfaceDeclaration casted = (ClassOrInterfaceDeclaration) node;
|
||||||
|
return casted.getNameExpr();
|
||||||
|
} else {
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean nodeContains(Node container, Node contained, boolean ignoringAnnotations){
|
||||||
|
if (!ignoringAnnotations || PositionUtils.getLastAnnotation(container)==null){
|
||||||
|
return container.contains(contained);
|
||||||
|
}
|
||||||
|
if (!container.contains(contained)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// if the node is contained, but it comes immediately after the annotations,
|
||||||
|
// let's not consider it contained
|
||||||
|
if (container instanceof AnnotableNode){
|
||||||
|
int bl = beginLineWithoutConsideringAnnotation(container);
|
||||||
|
int bc = beginColumnWithoutConsideringAnnotation(container);
|
||||||
|
if (bl>contained.getBeginLine()) return false;
|
||||||
|
if (bl==contained.getBeginLine() && bc>contained.getBeginColumn()) return false;
|
||||||
|
if (container.getEndLine()<contained.getEndLine()) return false;
|
||||||
|
if (container.getEndLine()==contained.getEndLine() && container.getEndColumn()<contained.getEndColumn()) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
63
src/com/github/javaparser/SourcesHelper.java
Normal file
63
src/com/github/javaparser/SourcesHelper.java
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class SourcesHelper {
|
||||||
|
|
||||||
|
static String streamToString(InputStream in, String encoding){
|
||||||
|
if (encoding == null) {
|
||||||
|
return streamToString(in);
|
||||||
|
} else {
|
||||||
|
java.util.Scanner s = new java.util.Scanner(in, encoding).useDelimiter("\\A");
|
||||||
|
return s.hasNext() ? s.next() : "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static String streamToString(InputStream in){
|
||||||
|
java.util.Scanner s = new java.util.Scanner(in).useDelimiter("\\A");
|
||||||
|
return s.hasNext() ? s.next() : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
static InputStream stringToStream(String s, String encoding) throws UnsupportedEncodingException {
|
||||||
|
byte[] rawData = encoding != null ? s.getBytes(encoding) : s.getBytes();
|
||||||
|
return new ByteArrayInputStream(rawData);
|
||||||
|
}
|
||||||
|
|
||||||
|
static String readerToString(Reader reader) throws IOException {
|
||||||
|
char[] arr = new char[8*1024]; // 8K at a time
|
||||||
|
StringBuilder buf = new StringBuilder();
|
||||||
|
int numChars;
|
||||||
|
|
||||||
|
while ((numChars = reader.read(arr, 0, arr.length)) > 0) {
|
||||||
|
buf.append(arr, 0, numChars);
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Reader stringToReader(String s){
|
||||||
|
return new StringReader(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
143
src/com/github/javaparser/Token.java
Normal file
143
src/com/github/javaparser/Token.java
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */
|
||||||
|
/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* This file is part of Java 1.8 parser and Abstract Syntax Tree.
|
||||||
|
*
|
||||||
|
* Java 1.8 parser and Abstract Syntax Tree is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Java 1.8 parser and Abstract Syntax Tree. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.github.javaparser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes the input token stream.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class Token implements java.io.Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The version identifier for this Serializable class.
|
||||||
|
* Increment only if the <i>serialized</i> form of the
|
||||||
|
* class changes.
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An integer that describes the kind of this token. This numbering
|
||||||
|
* system is determined by JavaCCParser, and a table of these numbers is
|
||||||
|
* stored in the file ...Constants.java.
|
||||||
|
*/
|
||||||
|
public int kind;
|
||||||
|
|
||||||
|
/** The line number of the first character of this Token. */
|
||||||
|
public int beginLine;
|
||||||
|
/** The column number of the first character of this Token. */
|
||||||
|
public int beginColumn;
|
||||||
|
/** The line number of the last character of this Token. */
|
||||||
|
public int endLine;
|
||||||
|
/** The column number of the last character of this Token. */
|
||||||
|
public int endColumn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The string image of the token.
|
||||||
|
*/
|
||||||
|
public String image;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A reference to the next regular (non-special) token from the input
|
||||||
|
* stream. If this is the last token from the input stream, or if the
|
||||||
|
* token manager has not read tokens beyond this one, this field is
|
||||||
|
* set to null. This is true only if this token is also a regular
|
||||||
|
* token. Otherwise, see below for a description of the contents of
|
||||||
|
* this field.
|
||||||
|
*/
|
||||||
|
public Token next;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This field is used to access special tokens that occur prior to this
|
||||||
|
* token, but after the immediately preceding regular (non-special) token.
|
||||||
|
* If there are no such special tokens, this field is set to null.
|
||||||
|
* When there are more than one such special token, this field refers
|
||||||
|
* to the last of these special tokens, which in turn refers to the next
|
||||||
|
* previous special token through its specialToken field, and so on
|
||||||
|
* until the first special token (whose specialToken field is null).
|
||||||
|
* The next fields of special tokens refer to other special tokens that
|
||||||
|
* immediately follow it (without an intervening regular token). If there
|
||||||
|
* is no such token, this field is null.
|
||||||
|
*/
|
||||||
|
public Token specialToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An optional attribute value of the Token.
|
||||||
|
* Tokens which are not used as syntactic sugar will often contain
|
||||||
|
* meaningful values that will be used later on by the compiler or
|
||||||
|
* interpreter. This attribute value is often different from the image.
|
||||||
|
* Any subclass of Token that actually wants to return a non-null value can
|
||||||
|
* override this method as appropriate.
|
||||||
|
*/
|
||||||
|
public Object getValue() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No-argument constructor
|
||||||
|
*/
|
||||||
|
public Token() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new token for the specified Image.
|
||||||
|
*/
|
||||||
|
public Token(int kind)
|
||||||
|
{
|
||||||
|
this(kind, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new token for the specified Image and Kind.
|
||||||
|
*/
|
||||||
|
public Token(int kind, String image)
|
||||||
|
{
|
||||||
|
this.kind = kind;
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the image.
|
||||||
|
*/
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new Token object, by default. However, if you want, you
|
||||||
|
* can create and return subclass objects based on the value of ofKind.
|
||||||
|
* Simply add the cases to the switch for all those special cases.
|
||||||
|
* For example, if you have a subclass of Token called IDToken that
|
||||||
|
* you want to create if ofKind is ID, simply add something like :
|
||||||
|
*
|
||||||
|
* case MyParserConstants.ID : return new IDToken(ofKind, image);
|
||||||
|
*
|
||||||
|
* to the following switch statement. Then you can cast matchedToken
|
||||||
|
* variable to the appropriate type and use sit in your lexical actions.
|
||||||
|
*/
|
||||||
|
public static Token newToken(int ofKind, String image)
|
||||||
|
{
|
||||||
|
switch(ofKind)
|
||||||
|
{
|
||||||
|
default : return new Token(ofKind, image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Token newToken(int ofKind)
|
||||||
|
{
|
||||||
|
return newToken(ofKind, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/* JavaCC - OriginalChecksum=a2058282d76ebf324ed236272a3341cb (do not edit this line) */
|
159
src/com/github/javaparser/TokenMgrError.java
Normal file
159
src/com/github/javaparser/TokenMgrError.java
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */
|
||||||
|
/* JavaCCOptions: */
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* This file is part of Java 1.8 parser and Abstract Syntax Tree.
|
||||||
|
*
|
||||||
|
* Java 1.8 parser and Abstract Syntax Tree is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Java 1.8 parser and Abstract Syntax Tree. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.github.javaparser;
|
||||||
|
|
||||||
|
/** Token Manager Error. */
|
||||||
|
public class TokenMgrError extends Error
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The version identifier for this Serializable class.
|
||||||
|
* Increment only if the <i>serialized</i> form of the
|
||||||
|
* class changes.
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ordinals for various reasons why an Error of this type can be thrown.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lexical error occurred.
|
||||||
|
*/
|
||||||
|
static final int LEXICAL_ERROR = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An attempt was made to create a second instance of a static token manager.
|
||||||
|
*/
|
||||||
|
static final int STATIC_LEXER_ERROR = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tried to change to an invalid lexical state.
|
||||||
|
*/
|
||||||
|
static final int INVALID_LEXICAL_STATE = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detected (and bailed out of) an infinite loop in the token manager.
|
||||||
|
*/
|
||||||
|
static final int LOOP_DETECTED = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the reason why the exception is thrown. It will have
|
||||||
|
* one of the above 4 values.
|
||||||
|
*/
|
||||||
|
int errorCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces unprintable characters by their escaped (or unicode escaped)
|
||||||
|
* equivalents in the given string
|
||||||
|
*/
|
||||||
|
protected static final String addEscapes(String str) {
|
||||||
|
StringBuffer retval = new StringBuffer();
|
||||||
|
char ch;
|
||||||
|
for (int i = 0; i < str.length(); i++) {
|
||||||
|
switch (str.charAt(i))
|
||||||
|
{
|
||||||
|
case 0 :
|
||||||
|
continue;
|
||||||
|
case '\b':
|
||||||
|
retval.append("\\b");
|
||||||
|
continue;
|
||||||
|
case '\t':
|
||||||
|
retval.append("\\t");
|
||||||
|
continue;
|
||||||
|
case '\n':
|
||||||
|
retval.append("\\n");
|
||||||
|
continue;
|
||||||
|
case '\f':
|
||||||
|
retval.append("\\f");
|
||||||
|
continue;
|
||||||
|
case '\r':
|
||||||
|
retval.append("\\r");
|
||||||
|
continue;
|
||||||
|
case '\"':
|
||||||
|
retval.append("\\\"");
|
||||||
|
continue;
|
||||||
|
case '\'':
|
||||||
|
retval.append("\\\'");
|
||||||
|
continue;
|
||||||
|
case '\\':
|
||||||
|
retval.append("\\\\");
|
||||||
|
continue;
|
||||||
|
default:
|
||||||
|
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
|
||||||
|
String s = "0000" + Integer.toString(ch, 16);
|
||||||
|
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
|
||||||
|
} else {
|
||||||
|
retval.append(ch);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retval.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a detailed message for the Error when it is thrown by the
|
||||||
|
* token manager to indicate a lexical error.
|
||||||
|
* Parameters :
|
||||||
|
* EOFSeen : indicates if EOF caused the lexical error
|
||||||
|
* curLexState : lexical state in which this error occurred
|
||||||
|
* errorLine : line number when the error occurred
|
||||||
|
* errorColumn : column number when the error occurred
|
||||||
|
* errorAfter : prefix that was seen before this error occurred
|
||||||
|
* curchar : the offending character
|
||||||
|
* Note: You can customize the lexical error message by modifying this method.
|
||||||
|
*/
|
||||||
|
protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
|
||||||
|
return("Lexical error at line " +
|
||||||
|
errorLine + ", column " +
|
||||||
|
errorColumn + ". Encountered: " +
|
||||||
|
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
|
||||||
|
"after : \"" + addEscapes(errorAfter) + "\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* You can also modify the body of this method to customize your error messages.
|
||||||
|
* For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
|
||||||
|
* of end-users concern, so you can return something like :
|
||||||
|
*
|
||||||
|
* "Internal Error : Please file a bug report .... "
|
||||||
|
*
|
||||||
|
* from this method for such cases in the release version of your parser.
|
||||||
|
*/
|
||||||
|
public String getMessage() {
|
||||||
|
return super.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Constructors of various flavors follow.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** No arg constructor. */
|
||||||
|
public TokenMgrError() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Constructor with message and reason. */
|
||||||
|
public TokenMgrError(String message, int reason) {
|
||||||
|
super(message);
|
||||||
|
errorCode = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Full Constructor. */
|
||||||
|
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
|
||||||
|
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* JavaCC - OriginalChecksum=f06c7e964b5c13a732337c2f3fb4f836 (do not edit this line) */
|
47
src/com/github/javaparser/ast/AccessSpecifier.java
Normal file
47
src/com/github/javaparser/ast/AccessSpecifier.java
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Access specifier. Represents one of the possible levels of
|
||||||
|
* access permitted by the language.
|
||||||
|
*
|
||||||
|
* @author Federico Tomassetti
|
||||||
|
* @since July 2014
|
||||||
|
*/
|
||||||
|
public enum AccessSpecifier {
|
||||||
|
|
||||||
|
PUBLIC("public"),
|
||||||
|
PRIVATE("private"),
|
||||||
|
PROTECTED("protected"),
|
||||||
|
DEFAULT("");
|
||||||
|
|
||||||
|
private String codeRepresenation;
|
||||||
|
|
||||||
|
private AccessSpecifier(String codeRepresentation) {
|
||||||
|
this.codeRepresenation = codeRepresentation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCodeRepresenation(){
|
||||||
|
return this.codeRepresenation;
|
||||||
|
}
|
||||||
|
}
|
184
src/com/github/javaparser/ast/CompilationUnit.java
Normal file
184
src/com/github/javaparser/ast/CompilationUnit.java
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.body.AnnotationDeclaration;
|
||||||
|
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
|
||||||
|
import com.github.javaparser.ast.body.EmptyTypeDeclaration;
|
||||||
|
import com.github.javaparser.ast.body.EnumDeclaration;
|
||||||
|
import com.github.javaparser.ast.comments.Comment;
|
||||||
|
import com.github.javaparser.ast.comments.JavadocComment;
|
||||||
|
import com.github.javaparser.ast.body.TypeDeclaration;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* This class represents the entire compilation unit. Each java file denotes a
|
||||||
|
* compilation unit.
|
||||||
|
* </p>
|
||||||
|
* The CompilationUnit is constructed following the syntax:<br>
|
||||||
|
* <pre>
|
||||||
|
* {@code
|
||||||
|
* CompilationUnit ::= ( }{@link PackageDeclaration}{@code )?
|
||||||
|
* ( }{@link ImportDeclaration}{@code )*
|
||||||
|
* ( }{@link TypeDeclaration}{@code )*
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class CompilationUnit extends Node {
|
||||||
|
|
||||||
|
private PackageDeclaration pakage;
|
||||||
|
|
||||||
|
private List<ImportDeclaration> imports;
|
||||||
|
|
||||||
|
private List<TypeDeclaration> types;
|
||||||
|
|
||||||
|
public CompilationUnit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompilationUnit(PackageDeclaration pakage, List<ImportDeclaration> imports, List<TypeDeclaration> types) {
|
||||||
|
setPackage(pakage);
|
||||||
|
setImports(imports);
|
||||||
|
setTypes(types);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompilationUnit(int beginLine, int beginColumn, int endLine, int endColumn, PackageDeclaration pakage, List<ImportDeclaration> imports, List<TypeDeclaration> types) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setPackage(pakage);
|
||||||
|
setImports(imports);
|
||||||
|
setTypes(types);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list containing all comments declared in this compilation unit.
|
||||||
|
* Including javadocs, line comments and block comments of all types,
|
||||||
|
* inner-classes and other members.<br>
|
||||||
|
* If there is no comment, <code>null</code> is returned.
|
||||||
|
*
|
||||||
|
* @return list with all comments of this compilation unit or
|
||||||
|
* <code>null</code>
|
||||||
|
* @see JavadocComment
|
||||||
|
* @see com.github.javaparser.ast.comments.LineComment
|
||||||
|
* @see com.github.javaparser.ast.comments.BlockComment
|
||||||
|
*/
|
||||||
|
public List<Comment> getComments() {
|
||||||
|
return this.getAllContainedComments();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the list of imports declared in this compilation unit or
|
||||||
|
* <code>null</code> if there is no import.
|
||||||
|
*
|
||||||
|
* @return the list of imports or <code>null</code> if there is no import
|
||||||
|
*/
|
||||||
|
public List<ImportDeclaration> getImports() {
|
||||||
|
imports = ensureNotNull(imports);
|
||||||
|
return imports;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the package declaration of this compilation unit.<br>
|
||||||
|
* If this compilation unit has no package declaration (default package),
|
||||||
|
* <code>null</code> is returned.
|
||||||
|
*
|
||||||
|
* @return the package declaration or <code>null</code>
|
||||||
|
*/
|
||||||
|
public PackageDeclaration getPackage() {
|
||||||
|
return pakage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the list of types declared in this compilation unit.<br>
|
||||||
|
* If there is no types declared, <code>null</code> is returned.
|
||||||
|
*
|
||||||
|
* @return the list of types or <code>null</code> null if there is no type
|
||||||
|
* @see AnnotationDeclaration
|
||||||
|
* @see ClassOrInterfaceDeclaration
|
||||||
|
* @see EmptyTypeDeclaration
|
||||||
|
* @see EnumDeclaration
|
||||||
|
*/
|
||||||
|
public List<TypeDeclaration> getTypes() {
|
||||||
|
types = ensureNotNull(types);
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the list of comments of this compilation unit.
|
||||||
|
*
|
||||||
|
* @param comments
|
||||||
|
* the list of comments
|
||||||
|
*/
|
||||||
|
public void setComments(List<Comment> comments) {
|
||||||
|
throw new RuntimeException("Not implemented!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the list of imports of this compilation unit. The list is initially
|
||||||
|
* <code>null</code>.
|
||||||
|
*
|
||||||
|
* @param imports
|
||||||
|
* the list of imports
|
||||||
|
*/
|
||||||
|
public void setImports(List<ImportDeclaration> imports) {
|
||||||
|
this.imports = imports;
|
||||||
|
setAsParentNodeOf(this.imports);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets or clear the package declarations of this compilation unit.
|
||||||
|
*
|
||||||
|
* @param pakage
|
||||||
|
* the pakage declaration to set or <code>null</code> to default
|
||||||
|
* package
|
||||||
|
*/
|
||||||
|
public void setPackage(PackageDeclaration pakage) {
|
||||||
|
this.pakage = pakage;
|
||||||
|
setAsParentNodeOf(this.pakage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the list of types declared in this compilation unit.
|
||||||
|
*
|
||||||
|
* @param types
|
||||||
|
* the lis of types
|
||||||
|
*/
|
||||||
|
public void setTypes(List<TypeDeclaration> types) {
|
||||||
|
this.types = types;
|
||||||
|
setAsParentNodeOf(this.types);
|
||||||
|
}
|
||||||
|
}
|
33
src/com/github/javaparser/ast/DocumentableNode.java
Normal file
33
src/com/github/javaparser/ast/DocumentableNode.java
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.comments.JavadocComment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Node which can be documented through a Javadoc comment.
|
||||||
|
*/
|
||||||
|
public interface DocumentableNode {
|
||||||
|
|
||||||
|
public JavadocComment getJavaDoc();
|
||||||
|
public void setJavaDoc(JavadocComment javadocComment);
|
||||||
|
}
|
135
src/com/github/javaparser/ast/ImportDeclaration.java
Normal file
135
src/com/github/javaparser/ast/ImportDeclaration.java
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.expr.NameExpr;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* This class represents a import declaration. Imports are optional for the
|
||||||
|
* {@link CompilationUnit}.
|
||||||
|
* </p>
|
||||||
|
* The ImportDeclaration is constructed following the syntax:<br>
|
||||||
|
* <pre>
|
||||||
|
* {@code
|
||||||
|
* ImportDeclaration ::= "import" ( "static" )? }{@link NameExpr}{@code ( "." "*" )? ";"
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class ImportDeclaration extends Node {
|
||||||
|
|
||||||
|
private NameExpr name;
|
||||||
|
|
||||||
|
private boolean static_;
|
||||||
|
|
||||||
|
private boolean asterisk;
|
||||||
|
|
||||||
|
public ImportDeclaration() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImportDeclaration(NameExpr name, boolean isStatic, boolean isAsterisk) {
|
||||||
|
setAsterisk(isAsterisk);
|
||||||
|
setName(name);
|
||||||
|
setStatic(isStatic);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImportDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, NameExpr name, boolean isStatic, boolean isAsterisk) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setAsterisk(isAsterisk);
|
||||||
|
setName(name);
|
||||||
|
setStatic(isStatic);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the name of the import.
|
||||||
|
*
|
||||||
|
* @return the name of the import
|
||||||
|
*/
|
||||||
|
public NameExpr getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return if the import ends with "*".
|
||||||
|
*
|
||||||
|
* @return <code>true</code> if the import ends with "*", <code>false</code>
|
||||||
|
* otherwise
|
||||||
|
*/
|
||||||
|
public boolean isAsterisk() {
|
||||||
|
return asterisk;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return if the import is static.
|
||||||
|
*
|
||||||
|
* @return <code>true</code> if the import is static, <code>false</code>
|
||||||
|
* otherwise
|
||||||
|
*/
|
||||||
|
public boolean isStatic() {
|
||||||
|
return static_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets if this import is asterisk.
|
||||||
|
*
|
||||||
|
* @param asterisk
|
||||||
|
* <code>true</code> if this import is asterisk
|
||||||
|
*/
|
||||||
|
public void setAsterisk(boolean asterisk) {
|
||||||
|
this.asterisk = asterisk;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name this import.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* the name to set
|
||||||
|
*/
|
||||||
|
public void setName(NameExpr name) {
|
||||||
|
this.name = name;
|
||||||
|
setAsParentNodeOf(this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets if this import is static.
|
||||||
|
*
|
||||||
|
* @param static_
|
||||||
|
* <code>true</code> if this import is static
|
||||||
|
*/
|
||||||
|
public void setStatic(boolean static_) {
|
||||||
|
this.static_ = static_;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
33
src/com/github/javaparser/ast/NamedNode.java
Normal file
33
src/com/github/javaparser/ast/NamedNode.java
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A node having a name.
|
||||||
|
*
|
||||||
|
* The main reason for this interface is to permit users to manipulate homogeneously all nodes with a getName method.
|
||||||
|
*
|
||||||
|
* @since 2.0.1
|
||||||
|
*/
|
||||||
|
public interface NamedNode {
|
||||||
|
String getName();
|
||||||
|
}
|
376
src/com/github/javaparser/ast/Node.java
Normal file
376
src/com/github/javaparser/ast/Node.java
Normal file
@ -0,0 +1,376 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.comments.Comment;
|
||||||
|
import com.github.javaparser.ast.visitor.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract class for all nodes of the AST.
|
||||||
|
*
|
||||||
|
* Each Node can have one associated comment which describe it and
|
||||||
|
* a number of "orphan comments" which it contains but are not specifically
|
||||||
|
* associated to any element.
|
||||||
|
*
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public abstract class Node implements Cloneable {
|
||||||
|
|
||||||
|
private int beginLine;
|
||||||
|
|
||||||
|
private int beginColumn;
|
||||||
|
|
||||||
|
private int endLine;
|
||||||
|
|
||||||
|
private int endColumn;
|
||||||
|
|
||||||
|
private Node parentNode;
|
||||||
|
|
||||||
|
private List<Node> childrenNodes = new LinkedList<Node>();
|
||||||
|
private List<Comment> orphanComments = new LinkedList<Comment>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This attribute can store additional information from semantic analysis.
|
||||||
|
*/
|
||||||
|
private Object data;
|
||||||
|
|
||||||
|
private Comment comment;
|
||||||
|
|
||||||
|
public Node() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Node(final int beginLine, final int beginColumn, final int endLine, final int endColumn) {
|
||||||
|
this.beginLine = beginLine;
|
||||||
|
this.beginColumn = beginColumn;
|
||||||
|
this.endLine = endLine;
|
||||||
|
this.endColumn = endColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accept method for visitor support.
|
||||||
|
*
|
||||||
|
* @param <R>
|
||||||
|
* the type the return value of the visitor
|
||||||
|
* @param <A>
|
||||||
|
* the type the argument passed to the visitor
|
||||||
|
* @param v
|
||||||
|
* the visitor implementation
|
||||||
|
* @param arg
|
||||||
|
* the argument passed to the visitor
|
||||||
|
* @return the result of the visit
|
||||||
|
*/
|
||||||
|
public abstract <R, A> R accept(GenericVisitor<R, A> v, A arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accept method for visitor support.
|
||||||
|
*
|
||||||
|
* @param <A>
|
||||||
|
* the type the argument passed for the visitor
|
||||||
|
* @param v
|
||||||
|
* the visitor implementation
|
||||||
|
* @param arg
|
||||||
|
* any value relevant for the visitor
|
||||||
|
*/
|
||||||
|
public abstract <A> void accept(VoidVisitor<A> v, A arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the begin column of this node.
|
||||||
|
*
|
||||||
|
* @return the begin column of this node
|
||||||
|
*/
|
||||||
|
public final int getBeginColumn() {
|
||||||
|
return beginColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the begin line of this node.
|
||||||
|
*
|
||||||
|
* @return the begin line of this node
|
||||||
|
*/
|
||||||
|
public final int getBeginLine() {
|
||||||
|
return beginLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a comment associated with this node.
|
||||||
|
*
|
||||||
|
* @return comment property
|
||||||
|
*/
|
||||||
|
public final Comment getComment() {
|
||||||
|
return comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this to retrieve additional information associated to this node.
|
||||||
|
*
|
||||||
|
* @return data property
|
||||||
|
*/
|
||||||
|
public final Object getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the end column of this node.
|
||||||
|
*
|
||||||
|
* @return the end column of this node
|
||||||
|
*/
|
||||||
|
public final int getEndColumn() {
|
||||||
|
return endColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the end line of this node.
|
||||||
|
*
|
||||||
|
* @return the end line of this node
|
||||||
|
*/
|
||||||
|
public final int getEndLine() {
|
||||||
|
return endLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the begin column of this node.
|
||||||
|
*
|
||||||
|
* @param beginColumn
|
||||||
|
* the begin column of this node
|
||||||
|
*/
|
||||||
|
public final void setBeginColumn(final int beginColumn) {
|
||||||
|
this.beginColumn = beginColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the begin line of this node.
|
||||||
|
*
|
||||||
|
* @param beginLine
|
||||||
|
* the begin line of this node
|
||||||
|
*/
|
||||||
|
public final void setBeginLine(final int beginLine) {
|
||||||
|
this.beginLine = beginLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this to store additional information to this node.
|
||||||
|
*
|
||||||
|
* @param comment to be set
|
||||||
|
*/
|
||||||
|
public final void setComment(final Comment comment) {
|
||||||
|
if (comment != null && (this instanceof Comment)) {
|
||||||
|
throw new RuntimeException("A comment can not be commented");
|
||||||
|
}
|
||||||
|
if (this.comment != null)
|
||||||
|
{
|
||||||
|
this.comment.setCommentedNode(null);
|
||||||
|
}
|
||||||
|
this.comment = comment;
|
||||||
|
if (comment != null) {
|
||||||
|
this.comment.setCommentedNode(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this to store additional information to this node.
|
||||||
|
*
|
||||||
|
* @param data to be set
|
||||||
|
*/
|
||||||
|
public final void setData(final Object data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the end column of this node.
|
||||||
|
*
|
||||||
|
* @param endColumn
|
||||||
|
* the end column of this node
|
||||||
|
*/
|
||||||
|
public final void setEndColumn(final int endColumn) {
|
||||||
|
this.endColumn = endColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the end line of this node.
|
||||||
|
*
|
||||||
|
* @param endLine
|
||||||
|
* the end line of this node
|
||||||
|
*/
|
||||||
|
public final void setEndLine(final int endLine) {
|
||||||
|
this.endLine = endLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the String representation of this node.
|
||||||
|
*
|
||||||
|
* @return the String representation of this node
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public final String toString() {
|
||||||
|
final DumpVisitor visitor = new DumpVisitor();
|
||||||
|
accept(visitor, null);
|
||||||
|
return visitor.getSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String toStringWithoutComments() {
|
||||||
|
final DumpVisitor visitor = new DumpVisitor(false);
|
||||||
|
accept(visitor, null);
|
||||||
|
return visitor.getSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final int hashCode() {
|
||||||
|
return toString().hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (obj == null || !(obj instanceof Node)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return EqualsVisitor.equals(this, (Node) obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Node clone() {
|
||||||
|
return this.accept(new CloneVisitor(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Node getParentNode() {
|
||||||
|
return parentNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Node> getChildrenNodes() {
|
||||||
|
return childrenNodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean contains(Node other) {
|
||||||
|
if (getBeginLine() > other.getBeginLine()) return false;
|
||||||
|
if (getBeginLine() == other.getBeginLine() && getBeginColumn() > other.getBeginColumn()) return false;
|
||||||
|
if (getEndLine() < other.getEndLine()) return false;
|
||||||
|
if (getEndLine() == other.getEndLine() && getEndColumn() < other.getEndColumn()) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addOrphanComment(Comment comment) {
|
||||||
|
orphanComments.add(comment);
|
||||||
|
comment.setParentNode(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a list of Comment which are inside the node and are not associated
|
||||||
|
* with any meaningful AST Node.
|
||||||
|
*
|
||||||
|
* For example, comments at the end of methods (immediately before the parenthesis)
|
||||||
|
* or at the end of CompilationUnit are orphan comments.
|
||||||
|
*
|
||||||
|
* When more than one comments preceed a statement, the one immediately preceeding it
|
||||||
|
* it is associated with the statements, while the others are "orphan".
|
||||||
|
* @return all comments that cannot be attributed to a concept
|
||||||
|
*/
|
||||||
|
public List<Comment> getOrphanComments() {
|
||||||
|
return orphanComments;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the list of Comment which are contained in the Node either because
|
||||||
|
* they are properly associated to one of its children or because they are floating
|
||||||
|
* around inside the Node
|
||||||
|
* @return all Comments within the node as a list
|
||||||
|
*/
|
||||||
|
public List<Comment> getAllContainedComments() {
|
||||||
|
List<Comment> comments = new LinkedList<Comment>();
|
||||||
|
comments.addAll(getOrphanComments());
|
||||||
|
|
||||||
|
for (Node child : getChildrenNodes()) {
|
||||||
|
if (child.getComment() != null) {
|
||||||
|
comments.add(child.getComment());
|
||||||
|
}
|
||||||
|
comments.addAll(child.getAllContainedComments());
|
||||||
|
}
|
||||||
|
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign a new parent to this node, removing it
|
||||||
|
* from the list of children of the previous parent, if any.
|
||||||
|
*
|
||||||
|
* @param parentNode node to be set as parent
|
||||||
|
*/
|
||||||
|
public void setParentNode(Node parentNode) {
|
||||||
|
// remove from old parent, if any
|
||||||
|
if (this.parentNode != null) {
|
||||||
|
this.parentNode.childrenNodes.remove(this);
|
||||||
|
}
|
||||||
|
this.parentNode = parentNode;
|
||||||
|
// add to new parent, if any
|
||||||
|
if (this.parentNode != null) {
|
||||||
|
this.parentNode.childrenNodes.add(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setAsParentNodeOf(List<? extends Node> childNodes) {
|
||||||
|
if (childNodes != null) {
|
||||||
|
Iterator<? extends Node> it = childNodes.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
Node current = it.next();
|
||||||
|
current.setParentNode(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setAsParentNodeOf(Node childNode) {
|
||||||
|
if (childNode != null) {
|
||||||
|
childNode.setParentNode(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final int ABSOLUTE_BEGIN_LINE = -1;
|
||||||
|
public static final int ABSOLUTE_END_LINE = -2;
|
||||||
|
|
||||||
|
public boolean isPositionedAfter(int line, int column) {
|
||||||
|
if (line == ABSOLUTE_BEGIN_LINE) return true;
|
||||||
|
if (getBeginLine() > line) {
|
||||||
|
return true;
|
||||||
|
} else if (getBeginLine() == line) {
|
||||||
|
return getBeginColumn() > column;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPositionedBefore(int line, int column) {
|
||||||
|
if (line == ABSOLUTE_END_LINE) return true;
|
||||||
|
if (getEndLine() < line) {
|
||||||
|
return true;
|
||||||
|
} else if (getEndLine() == line) {
|
||||||
|
return getEndColumn() < column;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasComment()
|
||||||
|
{
|
||||||
|
return comment != null;
|
||||||
|
}
|
||||||
|
}
|
121
src/com/github/javaparser/ast/PackageDeclaration.java
Normal file
121
src/com/github/javaparser/ast/PackageDeclaration.java
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
import com.github.javaparser.ast.expr.NameExpr;
|
||||||
|
import com.github.javaparser.ast.internal.Utils;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* This class represents the package declaration. The package declaration is
|
||||||
|
* optional for the {@link CompilationUnit}.
|
||||||
|
* </p>
|
||||||
|
* The PackageDeclaration is constructed following the syntax:<br>
|
||||||
|
* <pre>
|
||||||
|
* {@code
|
||||||
|
* PackageDeclaration ::= ( }{@link AnnotationExpr}{@code )* "package" }{@link NameExpr}{@code ) ";"
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class PackageDeclaration extends Node {
|
||||||
|
|
||||||
|
private List<AnnotationExpr> annotations;
|
||||||
|
|
||||||
|
private NameExpr name;
|
||||||
|
|
||||||
|
public PackageDeclaration() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public PackageDeclaration(NameExpr name) {
|
||||||
|
setName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PackageDeclaration(List<AnnotationExpr> annotations, NameExpr name) {
|
||||||
|
setAnnotations(annotations);
|
||||||
|
setName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PackageDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, List<AnnotationExpr> annotations, NameExpr name) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setAnnotations(annotations);
|
||||||
|
setName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the list of annotations declared before the package
|
||||||
|
* declaration. Return <code>null</code> if there are no annotations.
|
||||||
|
*
|
||||||
|
* @return list of annotations or <code>null</code>
|
||||||
|
*/
|
||||||
|
public List<AnnotationExpr> getAnnotations() {
|
||||||
|
annotations = Utils.ensureNotNull(annotations);
|
||||||
|
return annotations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the name of the package.
|
||||||
|
*
|
||||||
|
* @return the name of the package
|
||||||
|
*/
|
||||||
|
public NameExpr getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param annotations
|
||||||
|
* the annotations to set
|
||||||
|
*/
|
||||||
|
public void setAnnotations(List<AnnotationExpr> annotations) {
|
||||||
|
this.annotations = annotations;
|
||||||
|
setAsParentNodeOf(this.annotations);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name of this package declaration.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* the name to set
|
||||||
|
*/
|
||||||
|
public void setName(NameExpr name) {
|
||||||
|
this.name = name;
|
||||||
|
setAsParentNodeOf(this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
35
src/com/github/javaparser/ast/TreeVisitor.java
Normal file
35
src/com/github/javaparser/ast/TreeVisitor.java
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast;
|
||||||
|
|
||||||
|
public abstract class TreeVisitor {
|
||||||
|
|
||||||
|
public void visitDepthFirst(Node node){
|
||||||
|
process(node);
|
||||||
|
for (Node child : node.getChildrenNodes()){
|
||||||
|
visitDepthFirst(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void process(Node node);
|
||||||
|
|
||||||
|
}
|
133
src/com/github/javaparser/ast/TypeParameter.java
Normal file
133
src/com/github/javaparser/ast/TypeParameter.java
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
import com.github.javaparser.ast.type.ClassOrInterfaceType;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.ensureNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* This class represents the declaration of a generics argument.
|
||||||
|
* </p>
|
||||||
|
* The TypeParameter is constructed following the syntax:<br>
|
||||||
|
* <pre>
|
||||||
|
* {@code
|
||||||
|
* TypeParameter ::= <IDENTIFIER> ( "extends" }{@link ClassOrInterfaceType}{@code ( "&" }{@link ClassOrInterfaceType}{@code )* )?
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class TypeParameter extends Node implements NamedNode {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private List<AnnotationExpr> annotations;
|
||||||
|
|
||||||
|
private List<ClassOrInterfaceType> typeBound;
|
||||||
|
|
||||||
|
public TypeParameter() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeParameter(final String name, final List<ClassOrInterfaceType> typeBound) {
|
||||||
|
setName(name);
|
||||||
|
setTypeBound(typeBound);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeParameter(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final String name, final List<ClassOrInterfaceType> typeBound) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setName(name);
|
||||||
|
setTypeBound(typeBound);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeParameter(int beginLine, int beginColumn, int endLine,
|
||||||
|
int endColumn, String name, List<ClassOrInterfaceType> typeBound, List<AnnotationExpr> annotations) {
|
||||||
|
this(beginLine, beginColumn, endLine, endColumn, name, typeBound);
|
||||||
|
setName(name);
|
||||||
|
setTypeBound(typeBound);
|
||||||
|
this.annotations = annotations;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the name of the paramenter.
|
||||||
|
*
|
||||||
|
* @return the name of the paramenter
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the list of {@link ClassOrInterfaceType} that this parameter
|
||||||
|
* extends. Return <code>null</code> null if there are no type.
|
||||||
|
*
|
||||||
|
* @return list of types that this paramente extends or <code>null</code>
|
||||||
|
*/
|
||||||
|
public List<ClassOrInterfaceType> getTypeBound() {
|
||||||
|
typeBound = ensureNotNull(typeBound);
|
||||||
|
return typeBound;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name of this type parameter.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* the name to set
|
||||||
|
*/
|
||||||
|
public void setName(final String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the list o types.
|
||||||
|
*
|
||||||
|
* @param typeBound
|
||||||
|
* the typeBound to set
|
||||||
|
*/
|
||||||
|
public void setTypeBound(final List<ClassOrInterfaceType> typeBound) {
|
||||||
|
this.typeBound = typeBound;
|
||||||
|
setAsParentNodeOf(typeBound);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AnnotationExpr> getAnnotations() {
|
||||||
|
annotations = ensureNotNull(annotations);
|
||||||
|
return annotations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnnotations(List<AnnotationExpr> annotations) {
|
||||||
|
this.annotations = annotations;
|
||||||
|
}
|
||||||
|
}
|
36
src/com/github/javaparser/ast/body/AnnotableNode.java
Normal file
36
src/com/github/javaparser/ast/body/AnnotableNode.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An element which can be the target of annotations.
|
||||||
|
*
|
||||||
|
* @author Federico Tomassetti
|
||||||
|
* @since July 2014
|
||||||
|
*/
|
||||||
|
public interface AnnotableNode {
|
||||||
|
public List<AnnotationExpr> getAnnotations();
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.DocumentableNode;
|
||||||
|
import com.github.javaparser.ast.comments.JavadocComment;
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class AnnotationDeclaration extends TypeDeclaration implements DocumentableNode {
|
||||||
|
|
||||||
|
public AnnotationDeclaration() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnnotationDeclaration(int modifiers, String name) {
|
||||||
|
super(modifiers, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnnotationDeclaration(int modifiers, List<AnnotationExpr> annotations, String name, List<BodyDeclaration> members) {
|
||||||
|
super(annotations, modifiers, name, members);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnnotationDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, String name, List<BodyDeclaration> members) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, annotations, modifiers, name, members);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setJavaDoc(JavadocComment javadocComment) {
|
||||||
|
this.javadocComment = javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JavadocComment getJavaDoc() {
|
||||||
|
return javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JavadocComment javadocComment;
|
||||||
|
}
|
@ -0,0 +1,135 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.DocumentableNode;
|
||||||
|
import com.github.javaparser.ast.NamedNode;
|
||||||
|
import com.github.javaparser.ast.comments.JavadocComment;
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
import com.github.javaparser.ast.expr.Expression;
|
||||||
|
import com.github.javaparser.ast.type.Type;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class AnnotationMemberDeclaration extends BodyDeclaration implements DocumentableNode, NamedNode {
|
||||||
|
|
||||||
|
private int modifiers;
|
||||||
|
|
||||||
|
private Type type;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private Expression defaultValue;
|
||||||
|
|
||||||
|
public AnnotationMemberDeclaration() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnnotationMemberDeclaration(int modifiers, Type type, String name, Expression defaultValue) {
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setType(type);
|
||||||
|
setName(name);
|
||||||
|
setDefaultValue(defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnnotationMemberDeclaration(int modifiers, List<AnnotationExpr> annotations, Type type, String name, Expression defaultValue) {
|
||||||
|
super(annotations);
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setType(type);
|
||||||
|
setName(name);
|
||||||
|
setDefaultValue(defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnnotationMemberDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, Type type, String name, Expression defaultValue) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, annotations);
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setType(type);
|
||||||
|
setName(name);
|
||||||
|
setDefaultValue(defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getDefaultValue() {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the modifiers of this member declaration.
|
||||||
|
*
|
||||||
|
* @see ModifierSet
|
||||||
|
* @return modifiers
|
||||||
|
*/
|
||||||
|
public int getModifiers() {
|
||||||
|
return modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultValue(Expression defaultValue) {
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
setAsParentNodeOf(defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModifiers(int modifiers) {
|
||||||
|
this.modifiers = modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Type type) {
|
||||||
|
this.type = type;
|
||||||
|
setAsParentNodeOf(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setJavaDoc(JavadocComment javadocComment) {
|
||||||
|
this.javadocComment = javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JavadocComment getJavaDoc() {
|
||||||
|
return javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JavadocComment javadocComment;
|
||||||
|
}
|
102
src/com/github/javaparser/ast/body/BaseParameter.java
Normal file
102
src/com/github/javaparser/ast/body/BaseParameter.java
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.Node;
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.*;
|
||||||
|
|
||||||
|
public abstract class BaseParameter extends Node {
|
||||||
|
private int modifiers;
|
||||||
|
|
||||||
|
private List<AnnotationExpr> annotations;
|
||||||
|
|
||||||
|
private VariableDeclaratorId id;
|
||||||
|
|
||||||
|
public BaseParameter() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseParameter(VariableDeclaratorId id) {
|
||||||
|
setId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseParameter(int modifiers, VariableDeclaratorId id) {
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseParameter(int modifiers, List<AnnotationExpr> annotations, VariableDeclaratorId id) {
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setAnnotations(annotations);
|
||||||
|
setId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseParameter(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, VariableDeclaratorId id) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setAnnotations(annotations);
|
||||||
|
setId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the list returned could be immutable (in that case it will be empty)
|
||||||
|
*/
|
||||||
|
public List<AnnotationExpr> getAnnotations() {
|
||||||
|
annotations = ensureNotNull(annotations);
|
||||||
|
return annotations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VariableDeclaratorId getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the modifiers of this parameter declaration.
|
||||||
|
*
|
||||||
|
* @see ModifierSet
|
||||||
|
* @return modifiers
|
||||||
|
*/
|
||||||
|
public int getModifiers() {
|
||||||
|
return modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param annotations a null value is currently treated as an empty list. This behavior could change
|
||||||
|
* in the future, so please avoid passing null
|
||||||
|
*/
|
||||||
|
public void setAnnotations(List<AnnotationExpr> annotations) {
|
||||||
|
this.annotations = annotations;
|
||||||
|
setAsParentNodeOf(this.annotations);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(VariableDeclaratorId id) {
|
||||||
|
this.id = id;
|
||||||
|
setAsParentNodeOf(this.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModifiers(int modifiers) {
|
||||||
|
this.modifiers = modifiers;
|
||||||
|
}
|
||||||
|
}
|
63
src/com/github/javaparser/ast/body/BodyDeclaration.java
Normal file
63
src/com/github/javaparser/ast/body/BodyDeclaration.java
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.Node;
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
import com.github.javaparser.ast.internal.Utils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public abstract class BodyDeclaration extends Node implements AnnotableNode {
|
||||||
|
|
||||||
|
private List<AnnotationExpr> annotations;
|
||||||
|
|
||||||
|
public BodyDeclaration() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public BodyDeclaration(List<AnnotationExpr> annotations) {
|
||||||
|
setAnnotations(annotations);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BodyDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, List<AnnotationExpr> annotations) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setAnnotations(annotations);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final List<AnnotationExpr> getAnnotations() {
|
||||||
|
annotations = Utils.ensureNotNull(annotations);
|
||||||
|
return annotations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param annotations a null value is currently treated as an empty list. This behavior could change
|
||||||
|
* in the future, so please avoid passing null
|
||||||
|
*/
|
||||||
|
public final void setAnnotations(List<AnnotationExpr> annotations) {
|
||||||
|
this.annotations = annotations;
|
||||||
|
setAsParentNodeOf(this.annotations);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,153 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.DocumentableNode;
|
||||||
|
import com.github.javaparser.ast.TypeParameter;
|
||||||
|
import com.github.javaparser.ast.comments.JavadocComment;
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
import com.github.javaparser.ast.type.ClassOrInterfaceType;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.ensureNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class ClassOrInterfaceDeclaration extends TypeDeclaration implements DocumentableNode {
|
||||||
|
|
||||||
|
private boolean interface_;
|
||||||
|
|
||||||
|
private List<TypeParameter> typeParameters;
|
||||||
|
|
||||||
|
// Can contain more than one item if this is an interface
|
||||||
|
private List<ClassOrInterfaceType> extendsList;
|
||||||
|
|
||||||
|
private List<ClassOrInterfaceType> implementsList;
|
||||||
|
|
||||||
|
public ClassOrInterfaceDeclaration() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassOrInterfaceDeclaration(final int modifiers, final boolean isInterface, final String name) {
|
||||||
|
super(modifiers, name);
|
||||||
|
setInterface(isInterface);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassOrInterfaceDeclaration(final int modifiers,
|
||||||
|
final List<AnnotationExpr> annotations, final boolean isInterface, final String name,
|
||||||
|
final List<TypeParameter> typeParameters, final List<ClassOrInterfaceType> extendsList,
|
||||||
|
final List<ClassOrInterfaceType> implementsList, final List<BodyDeclaration> members) {
|
||||||
|
super(annotations, modifiers, name, members);
|
||||||
|
setInterface(isInterface);
|
||||||
|
setTypeParameters(typeParameters);
|
||||||
|
setExtends(extendsList);
|
||||||
|
setImplements(implementsList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassOrInterfaceDeclaration(final int beginLine, final int beginColumn, final int endLine,
|
||||||
|
final int endColumn, final int modifiers,
|
||||||
|
final List<AnnotationExpr> annotations, final boolean isInterface, final String name,
|
||||||
|
final List<TypeParameter> typeParameters, final List<ClassOrInterfaceType> extendsList,
|
||||||
|
final List<ClassOrInterfaceType> implementsList, final List<BodyDeclaration> members) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, annotations, modifiers, name, members);
|
||||||
|
setInterface(isInterface);
|
||||||
|
setTypeParameters(typeParameters);
|
||||||
|
setExtends(extendsList);
|
||||||
|
setImplements(implementsList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClassOrInterfaceType> getExtends() {
|
||||||
|
extendsList = ensureNotNull(extendsList);
|
||||||
|
return extendsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClassOrInterfaceType> getImplements() {
|
||||||
|
implementsList = ensureNotNull(implementsList);
|
||||||
|
return implementsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TypeParameter> getTypeParameters() {
|
||||||
|
typeParameters = ensureNotNull(typeParameters);
|
||||||
|
return typeParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInterface() {
|
||||||
|
return interface_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param extendsList a null value is currently treated as an empty list. This behavior could change
|
||||||
|
* in the future, so please avoid passing null
|
||||||
|
*/
|
||||||
|
public void setExtends(final List<ClassOrInterfaceType> extendsList) {
|
||||||
|
this.extendsList = extendsList;
|
||||||
|
setAsParentNodeOf(this.extendsList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param implementsList a null value is currently treated as an empty list. This behavior could change
|
||||||
|
* in the future, so please avoid passing null
|
||||||
|
*/
|
||||||
|
public void setImplements(final List<ClassOrInterfaceType> implementsList) {
|
||||||
|
this.implementsList = implementsList;
|
||||||
|
setAsParentNodeOf(this.implementsList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInterface(final boolean interface_) {
|
||||||
|
this.interface_ = interface_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param typeParameters a null value is currently treated as an empty list. This behavior could change
|
||||||
|
* in the future, so please avoid passing null
|
||||||
|
*/
|
||||||
|
public void setTypeParameters(final List<TypeParameter> typeParameters) {
|
||||||
|
this.typeParameters = typeParameters;
|
||||||
|
setAsParentNodeOf(this.typeParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setJavaDoc(JavadocComment javadocComment) {
|
||||||
|
this.javadocComment = javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JavadocComment getJavaDoc() {
|
||||||
|
return javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JavadocComment javadocComment;
|
||||||
|
}
|
235
src/com/github/javaparser/ast/body/ConstructorDeclaration.java
Normal file
235
src/com/github/javaparser/ast/body/ConstructorDeclaration.java
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.AccessSpecifier;
|
||||||
|
import com.github.javaparser.ast.DocumentableNode;
|
||||||
|
import com.github.javaparser.ast.NamedNode;
|
||||||
|
import com.github.javaparser.ast.TypeParameter;
|
||||||
|
import com.github.javaparser.ast.comments.JavadocComment;
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
import com.github.javaparser.ast.expr.NameExpr;
|
||||||
|
import com.github.javaparser.ast.stmt.BlockStmt;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class ConstructorDeclaration extends BodyDeclaration implements DocumentableNode, WithDeclaration,
|
||||||
|
NamedNode {
|
||||||
|
|
||||||
|
private int modifiers;
|
||||||
|
|
||||||
|
private List<TypeParameter> typeParameters;
|
||||||
|
|
||||||
|
private NameExpr name;
|
||||||
|
|
||||||
|
private List<Parameter> parameters;
|
||||||
|
|
||||||
|
private List<NameExpr> throws_;
|
||||||
|
|
||||||
|
private BlockStmt block;
|
||||||
|
|
||||||
|
public ConstructorDeclaration() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConstructorDeclaration(int modifiers, String name) {
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConstructorDeclaration(int modifiers, List<AnnotationExpr> annotations, List<TypeParameter> typeParameters,
|
||||||
|
String name, List<Parameter> parameters, List<NameExpr> throws_, BlockStmt block) {
|
||||||
|
super(annotations);
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setTypeParameters(typeParameters);
|
||||||
|
setName(name);
|
||||||
|
setParameters(parameters);
|
||||||
|
setThrows(throws_);
|
||||||
|
setBlock(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConstructorDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers,
|
||||||
|
List<AnnotationExpr> annotations, List<TypeParameter> typeParameters, String name,
|
||||||
|
List<Parameter> parameters, List<NameExpr> throws_, BlockStmt block) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, annotations);
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setTypeParameters(typeParameters);
|
||||||
|
setName(name);
|
||||||
|
setParameters(parameters);
|
||||||
|
setThrows(throws_);
|
||||||
|
setBlock(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockStmt getBlock() {
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the modifiers of this member declaration.
|
||||||
|
*
|
||||||
|
* @see ModifierSet
|
||||||
|
* @return modifiers
|
||||||
|
*/
|
||||||
|
public int getModifiers() {
|
||||||
|
return modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name == null ? null : name.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public NameExpr getNameExpr() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Parameter> getParameters() {
|
||||||
|
parameters = ensureNotNull(parameters);
|
||||||
|
return parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<NameExpr> getThrows() {
|
||||||
|
throws_ = ensureNotNull(throws_);
|
||||||
|
return throws_;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TypeParameter> getTypeParameters() {
|
||||||
|
typeParameters = ensureNotNull(typeParameters);
|
||||||
|
return typeParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlock(BlockStmt block) {
|
||||||
|
this.block = block;
|
||||||
|
setAsParentNodeOf(this.block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModifiers(int modifiers) {
|
||||||
|
this.modifiers = modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = new NameExpr(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNameExpr(NameExpr name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParameters(List<Parameter> parameters) {
|
||||||
|
this.parameters = parameters;
|
||||||
|
setAsParentNodeOf(this.parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setThrows(List<NameExpr> throws_) {
|
||||||
|
this.throws_ = throws_;
|
||||||
|
setAsParentNodeOf(this.throws_);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTypeParameters(List<TypeParameter> typeParameters) {
|
||||||
|
this.typeParameters = typeParameters;
|
||||||
|
setAsParentNodeOf(this.typeParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The declaration returned has this schema:
|
||||||
|
*
|
||||||
|
* [accessSpecifier] className ([paramType [paramName]])
|
||||||
|
* [throws exceptionsList]
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows,
|
||||||
|
boolean includingParameterName) {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
if (includingModifiers) {
|
||||||
|
AccessSpecifier accessSpecifier = ModifierSet.getAccessSpecifier(getModifiers());
|
||||||
|
sb.append(accessSpecifier.getCodeRepresenation());
|
||||||
|
sb.append(accessSpecifier == AccessSpecifier.DEFAULT ? "" : " ");
|
||||||
|
}
|
||||||
|
sb.append(getName());
|
||||||
|
sb.append("(");
|
||||||
|
boolean firstParam = true;
|
||||||
|
for (Parameter param : getParameters())
|
||||||
|
{
|
||||||
|
if (firstParam) {
|
||||||
|
firstParam = false;
|
||||||
|
} else {
|
||||||
|
sb.append(", ");
|
||||||
|
}
|
||||||
|
if (includingParameterName) {
|
||||||
|
sb.append(param.toStringWithoutComments());
|
||||||
|
} else {
|
||||||
|
sb.append(param.getType().toStringWithoutComments());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sb.append(")");
|
||||||
|
if (includingThrows) {
|
||||||
|
boolean firstThrow = true;
|
||||||
|
for (NameExpr thr : getThrows()) {
|
||||||
|
if (firstThrow) {
|
||||||
|
firstThrow = false;
|
||||||
|
sb.append(" throws ");
|
||||||
|
} else {
|
||||||
|
sb.append(", ");
|
||||||
|
}
|
||||||
|
sb.append(thr.toStringWithoutComments());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows) {
|
||||||
|
return getDeclarationAsString(includingModifiers, includingThrows, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDeclarationAsString() {
|
||||||
|
return getDeclarationAsString(true, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setJavaDoc(JavadocComment javadocComment) {
|
||||||
|
this.javadocComment = javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JavadocComment getJavaDoc() {
|
||||||
|
return javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JavadocComment javadocComment;
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.DocumentableNode;
|
||||||
|
import com.github.javaparser.ast.comments.JavadocComment;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class EmptyMemberDeclaration extends BodyDeclaration implements DocumentableNode {
|
||||||
|
|
||||||
|
public EmptyMemberDeclaration() {
|
||||||
|
super(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmptyMemberDeclaration(int beginLine, int beginColumn, int endLine, int endColumn) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setJavaDoc(JavadocComment javadocComment) {
|
||||||
|
this.javadocComment = javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JavadocComment getJavaDoc() {
|
||||||
|
return javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JavadocComment javadocComment;
|
||||||
|
}
|
61
src/com/github/javaparser/ast/body/EmptyTypeDeclaration.java
Normal file
61
src/com/github/javaparser/ast/body/EmptyTypeDeclaration.java
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.DocumentableNode;
|
||||||
|
import com.github.javaparser.ast.comments.JavadocComment;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class EmptyTypeDeclaration extends TypeDeclaration implements DocumentableNode {
|
||||||
|
|
||||||
|
public EmptyTypeDeclaration() {
|
||||||
|
super(null, 0, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmptyTypeDeclaration(int beginLine, int beginColumn, int endLine, int endColumn) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, null, 0, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setJavaDoc(JavadocComment javadocComment) {
|
||||||
|
//To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JavadocComment getJavaDoc() {
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
}
|
117
src/com/github/javaparser/ast/body/EnumConstantDeclaration.java
Normal file
117
src/com/github/javaparser/ast/body/EnumConstantDeclaration.java
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.DocumentableNode;
|
||||||
|
import com.github.javaparser.ast.NamedNode;
|
||||||
|
import com.github.javaparser.ast.comments.JavadocComment;
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
import com.github.javaparser.ast.expr.Expression;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.ensureNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class EnumConstantDeclaration extends BodyDeclaration implements DocumentableNode, NamedNode {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private List<Expression> args;
|
||||||
|
|
||||||
|
private List<BodyDeclaration> classBody;
|
||||||
|
|
||||||
|
public EnumConstantDeclaration() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumConstantDeclaration(String name) {
|
||||||
|
setName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumConstantDeclaration(List<AnnotationExpr> annotations, String name, List<Expression> args, List<BodyDeclaration> classBody) {
|
||||||
|
super(annotations);
|
||||||
|
setName(name);
|
||||||
|
setArgs(args);
|
||||||
|
setClassBody(classBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumConstantDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, List<AnnotationExpr> annotations, String name, List<Expression> args, List<BodyDeclaration> classBody) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, annotations);
|
||||||
|
setName(name);
|
||||||
|
setArgs(args);
|
||||||
|
setClassBody(classBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Expression> getArgs() {
|
||||||
|
args = ensureNotNull(args);
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<BodyDeclaration> getClassBody() {
|
||||||
|
classBody = ensureNotNull(classBody);
|
||||||
|
return classBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArgs(List<Expression> args) {
|
||||||
|
this.args = args;
|
||||||
|
setAsParentNodeOf(this.args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClassBody(List<BodyDeclaration> classBody) {
|
||||||
|
this.classBody = classBody;
|
||||||
|
setAsParentNodeOf(this.classBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setJavaDoc(JavadocComment javadocComment) {
|
||||||
|
this.javadocComment = javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JavadocComment getJavaDoc() {
|
||||||
|
return javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JavadocComment javadocComment;
|
||||||
|
}
|
105
src/com/github/javaparser/ast/body/EnumDeclaration.java
Normal file
105
src/com/github/javaparser/ast/body/EnumDeclaration.java
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.DocumentableNode;
|
||||||
|
import com.github.javaparser.ast.comments.JavadocComment;
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
import com.github.javaparser.ast.type.ClassOrInterfaceType;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class EnumDeclaration extends TypeDeclaration implements DocumentableNode {
|
||||||
|
|
||||||
|
private List<ClassOrInterfaceType> implementsList;
|
||||||
|
|
||||||
|
private List<EnumConstantDeclaration> entries;
|
||||||
|
|
||||||
|
public EnumDeclaration() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumDeclaration(int modifiers, String name) {
|
||||||
|
super(modifiers, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumDeclaration(int modifiers, List<AnnotationExpr> annotations, String name, List<ClassOrInterfaceType> implementsList, List<EnumConstantDeclaration> entries, List<BodyDeclaration> members) {
|
||||||
|
super(annotations, modifiers, name, members);
|
||||||
|
setImplements(implementsList);
|
||||||
|
setEntries(entries);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, String name, List<ClassOrInterfaceType> implementsList, List<EnumConstantDeclaration> entries, List<BodyDeclaration> members) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, annotations, modifiers, name, members);
|
||||||
|
setImplements(implementsList);
|
||||||
|
setEntries(entries);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<EnumConstantDeclaration> getEntries() {
|
||||||
|
entries = ensureNotNull(entries);
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClassOrInterfaceType> getImplements() {
|
||||||
|
implementsList = ensureNotNull(implementsList);
|
||||||
|
return implementsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntries(List<EnumConstantDeclaration> entries) {
|
||||||
|
this.entries = entries;
|
||||||
|
setAsParentNodeOf(this.entries);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImplements(List<ClassOrInterfaceType> implementsList) {
|
||||||
|
this.implementsList = implementsList;
|
||||||
|
setAsParentNodeOf(this.implementsList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setJavaDoc(JavadocComment javadocComment) {
|
||||||
|
this.javadocComment = javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JavadocComment getJavaDoc() {
|
||||||
|
return javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JavadocComment javadocComment;
|
||||||
|
}
|
132
src/com/github/javaparser/ast/body/FieldDeclaration.java
Normal file
132
src/com/github/javaparser/ast/body/FieldDeclaration.java
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.DocumentableNode;
|
||||||
|
import com.github.javaparser.ast.comments.JavadocComment;
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
import com.github.javaparser.ast.type.Type;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class FieldDeclaration extends BodyDeclaration implements DocumentableNode {
|
||||||
|
|
||||||
|
private int modifiers;
|
||||||
|
|
||||||
|
private Type type;
|
||||||
|
|
||||||
|
private List<VariableDeclarator> variables;
|
||||||
|
|
||||||
|
public FieldDeclaration() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldDeclaration(int modifiers, Type type, VariableDeclarator variable) {
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setType(type);
|
||||||
|
List<VariableDeclarator> aux = new ArrayList<VariableDeclarator>();
|
||||||
|
aux.add(variable);
|
||||||
|
setVariables(aux);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldDeclaration(int modifiers, Type type, List<VariableDeclarator> variables) {
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setType(type);
|
||||||
|
setVariables(variables);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldDeclaration(int modifiers, List<AnnotationExpr> annotations, Type type, List<VariableDeclarator> variables) {
|
||||||
|
super(annotations);
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setType(type);
|
||||||
|
setVariables(variables);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, Type type, List<VariableDeclarator> variables) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, annotations);
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setType(type);
|
||||||
|
setVariables(variables);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the modifiers of this member declaration.
|
||||||
|
*
|
||||||
|
* @see ModifierSet
|
||||||
|
* @return modifiers
|
||||||
|
*/
|
||||||
|
public int getModifiers() {
|
||||||
|
return modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<VariableDeclarator> getVariables() {
|
||||||
|
variables = ensureNotNull(variables);
|
||||||
|
return variables;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModifiers(int modifiers) {
|
||||||
|
this.modifiers = modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Type type) {
|
||||||
|
this.type = type;
|
||||||
|
setAsParentNodeOf(this.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVariables(List<VariableDeclarator> variables) {
|
||||||
|
this.variables = variables;
|
||||||
|
setAsParentNodeOf(this.variables);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setJavaDoc(JavadocComment javadocComment) {
|
||||||
|
this.javadocComment = javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JavadocComment getJavaDoc() {
|
||||||
|
return javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JavadocComment javadocComment;
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.DocumentableNode;
|
||||||
|
import com.github.javaparser.ast.comments.JavadocComment;
|
||||||
|
import com.github.javaparser.ast.stmt.BlockStmt;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class InitializerDeclaration extends BodyDeclaration implements DocumentableNode {
|
||||||
|
|
||||||
|
private boolean isStatic;
|
||||||
|
|
||||||
|
private BlockStmt block;
|
||||||
|
|
||||||
|
public InitializerDeclaration() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public InitializerDeclaration(boolean isStatic, BlockStmt block) {
|
||||||
|
super(null);
|
||||||
|
setStatic(isStatic);
|
||||||
|
setBlock(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InitializerDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, boolean isStatic, BlockStmt block) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, null);
|
||||||
|
setStatic(isStatic);
|
||||||
|
setBlock(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockStmt getBlock() {
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStatic() {
|
||||||
|
return isStatic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlock(BlockStmt block) {
|
||||||
|
this.block = block;
|
||||||
|
setAsParentNodeOf(this.block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatic(boolean isStatic) {
|
||||||
|
this.isStatic = isStatic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setJavaDoc(JavadocComment javadocComment) {
|
||||||
|
this.javadocComment = javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JavadocComment getJavaDoc() {
|
||||||
|
return javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JavadocComment javadocComment;
|
||||||
|
}
|
303
src/com/github/javaparser/ast/body/MethodDeclaration.java
Normal file
303
src/com/github/javaparser/ast/body/MethodDeclaration.java
Normal file
@ -0,0 +1,303 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.AccessSpecifier;
|
||||||
|
import com.github.javaparser.ast.DocumentableNode;
|
||||||
|
import com.github.javaparser.ast.NamedNode;
|
||||||
|
import com.github.javaparser.ast.TypeParameter;
|
||||||
|
import com.github.javaparser.ast.comments.JavadocComment;
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
import com.github.javaparser.ast.expr.NameExpr;
|
||||||
|
import com.github.javaparser.ast.stmt.BlockStmt;
|
||||||
|
import com.github.javaparser.ast.type.Type;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.ensureNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class MethodDeclaration extends BodyDeclaration implements DocumentableNode, WithDeclaration, NamedNode {
|
||||||
|
|
||||||
|
private int modifiers;
|
||||||
|
|
||||||
|
private List<TypeParameter> typeParameters;
|
||||||
|
|
||||||
|
private Type type;
|
||||||
|
|
||||||
|
private NameExpr name;
|
||||||
|
|
||||||
|
private List<Parameter> parameters;
|
||||||
|
|
||||||
|
private int arrayCount;
|
||||||
|
|
||||||
|
private List<NameExpr> throws_;
|
||||||
|
|
||||||
|
private BlockStmt body;
|
||||||
|
|
||||||
|
private boolean isDefault = false;
|
||||||
|
|
||||||
|
public MethodDeclaration() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodDeclaration(final int modifiers, final Type type, final String name) {
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setType(type);
|
||||||
|
setName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodDeclaration(final int modifiers, final Type type, final String name, final List<Parameter> parameters) {
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setType(type);
|
||||||
|
setName(name);
|
||||||
|
setParameters(parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodDeclaration(final int modifiers, final List<AnnotationExpr> annotations,
|
||||||
|
final List<TypeParameter> typeParameters, final Type type, final String name,
|
||||||
|
final List<Parameter> parameters, final int arrayCount, final List<NameExpr> throws_, final BlockStmt block) {
|
||||||
|
super(annotations);
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setTypeParameters(typeParameters);
|
||||||
|
setType(type);
|
||||||
|
setName(name);
|
||||||
|
setParameters(parameters);
|
||||||
|
setArrayCount(arrayCount);
|
||||||
|
setThrows(throws_);
|
||||||
|
setBody(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodDeclaration(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final int modifiers, final List<AnnotationExpr> annotations,
|
||||||
|
final List<TypeParameter> typeParameters, final Type type, final String name,
|
||||||
|
final List<Parameter> parameters, final int arrayCount, final List<NameExpr> throws_, final BlockStmt block) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, annotations);
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setTypeParameters(typeParameters);
|
||||||
|
setType(type);
|
||||||
|
setName(name);
|
||||||
|
setParameters(parameters);
|
||||||
|
setArrayCount(arrayCount);
|
||||||
|
setThrows(throws_);
|
||||||
|
setBody(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getArrayCount() {
|
||||||
|
return arrayCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME this is called "Block" in the constructor. Pick one.
|
||||||
|
public BlockStmt getBody() {
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the modifiers of this member declaration.
|
||||||
|
*
|
||||||
|
* @see ModifierSet
|
||||||
|
* @return modifiers
|
||||||
|
*/
|
||||||
|
public int getModifiers() {
|
||||||
|
return modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public NameExpr getNameExpr() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Parameter> getParameters() {
|
||||||
|
parameters = ensureNotNull(parameters);
|
||||||
|
return parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<NameExpr> getThrows() {
|
||||||
|
throws_ = ensureNotNull(throws_);
|
||||||
|
return throws_;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TypeParameter> getTypeParameters() {
|
||||||
|
typeParameters = ensureNotNull(typeParameters);
|
||||||
|
return typeParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArrayCount(final int arrayCount) {
|
||||||
|
this.arrayCount = arrayCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBody(final BlockStmt body) {
|
||||||
|
this.body = body;
|
||||||
|
setAsParentNodeOf(this.body);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModifiers(final int modifiers) {
|
||||||
|
this.modifiers = modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(final String name) {
|
||||||
|
this.name = new NameExpr(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNameExpr(final NameExpr name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParameters(final List<Parameter> parameters) {
|
||||||
|
this.parameters = parameters;
|
||||||
|
setAsParentNodeOf(this.parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setThrows(final List<NameExpr> throws_) {
|
||||||
|
this.throws_ = throws_;
|
||||||
|
setAsParentNodeOf(this.throws_);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(final Type type) {
|
||||||
|
this.type = type;
|
||||||
|
setAsParentNodeOf(this.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTypeParameters(final List<TypeParameter> typeParameters) {
|
||||||
|
this.typeParameters = typeParameters;
|
||||||
|
setAsParentNodeOf(typeParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isDefault() {
|
||||||
|
return isDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefault(boolean isDefault) {
|
||||||
|
this.isDefault = isDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDeclarationAsString() {
|
||||||
|
return getDeclarationAsString(true, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows) {
|
||||||
|
return getDeclarationAsString(includingModifiers, includingThrows, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The declaration returned has this schema:
|
||||||
|
*
|
||||||
|
* [accessSpecifier] [static] [abstract] [final] [native]
|
||||||
|
* [synchronized] returnType methodName ([paramType [paramName]])
|
||||||
|
* [throws exceptionsList]
|
||||||
|
* @return method declaration as String
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows, boolean includingParameterName) {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
if (includingModifiers) {
|
||||||
|
AccessSpecifier accessSpecifier = ModifierSet.getAccessSpecifier(getModifiers());
|
||||||
|
sb.append(accessSpecifier.getCodeRepresenation());
|
||||||
|
sb.append(accessSpecifier == AccessSpecifier.DEFAULT ? "" : " ");
|
||||||
|
if (ModifierSet.isStatic(getModifiers())){
|
||||||
|
sb.append("static ");
|
||||||
|
}
|
||||||
|
if (ModifierSet.isAbstract(getModifiers())){
|
||||||
|
sb.append("abstract ");
|
||||||
|
}
|
||||||
|
if (ModifierSet.isFinal(getModifiers())){
|
||||||
|
sb.append("final ");
|
||||||
|
}
|
||||||
|
if (ModifierSet.isNative(getModifiers())){
|
||||||
|
sb.append("native ");
|
||||||
|
}
|
||||||
|
if (ModifierSet.isSynchronized(getModifiers())){
|
||||||
|
sb.append("synchronized ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO verify it does not print comments connected to the type
|
||||||
|
sb.append(getType().toStringWithoutComments());
|
||||||
|
sb.append(" ");
|
||||||
|
sb.append(getName());
|
||||||
|
sb.append("(");
|
||||||
|
boolean firstParam = true;
|
||||||
|
for (Parameter param : getParameters())
|
||||||
|
{
|
||||||
|
if (firstParam) {
|
||||||
|
firstParam = false;
|
||||||
|
} else {
|
||||||
|
sb.append(", ");
|
||||||
|
}
|
||||||
|
if (includingParameterName) {
|
||||||
|
sb.append(param.toStringWithoutComments());
|
||||||
|
} else {
|
||||||
|
sb.append(param.getType().toStringWithoutComments());
|
||||||
|
if (param.isVarArgs()) {
|
||||||
|
sb.append("...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sb.append(")");
|
||||||
|
if (includingThrows) {
|
||||||
|
boolean firstThrow = true;
|
||||||
|
for (NameExpr thr : getThrows()) {
|
||||||
|
if (firstThrow) {
|
||||||
|
firstThrow = false;
|
||||||
|
sb.append(" throws ");
|
||||||
|
} else {
|
||||||
|
sb.append(", ");
|
||||||
|
}
|
||||||
|
sb.append(thr.toStringWithoutComments());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setJavaDoc(JavadocComment javadocComment) {
|
||||||
|
this.javadocComment = javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JavadocComment getJavaDoc() {
|
||||||
|
return javadocComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JavadocComment javadocComment;
|
||||||
|
}
|
146
src/com/github/javaparser/ast/body/ModifierSet.java
Normal file
146
src/com/github/javaparser/ast/body/ModifierSet.java
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.AccessSpecifier;
|
||||||
|
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class to hold modifiers.<br>
|
||||||
|
* The modifier constants declared here holds equivalent values to
|
||||||
|
* {@link Modifier} constants.
|
||||||
|
*/
|
||||||
|
public final class ModifierSet {
|
||||||
|
|
||||||
|
/* Definitions of the bits in the modifiers field. */
|
||||||
|
|
||||||
|
public static final int PUBLIC = Modifier.PUBLIC;
|
||||||
|
|
||||||
|
public static final int PRIVATE = Modifier.PRIVATE;
|
||||||
|
|
||||||
|
public static final int PROTECTED = Modifier.PROTECTED;
|
||||||
|
|
||||||
|
public static final int STATIC = Modifier.STATIC;
|
||||||
|
|
||||||
|
public static final int FINAL = Modifier.FINAL;
|
||||||
|
|
||||||
|
public static final int SYNCHRONIZED = Modifier.SYNCHRONIZED;
|
||||||
|
|
||||||
|
public static final int VOLATILE = Modifier.VOLATILE;
|
||||||
|
|
||||||
|
public static final int TRANSIENT = Modifier.TRANSIENT;
|
||||||
|
|
||||||
|
public static final int NATIVE = Modifier.NATIVE;
|
||||||
|
|
||||||
|
public static final int ABSTRACT = Modifier.ABSTRACT;
|
||||||
|
|
||||||
|
public static final int STRICTFP = Modifier.STRICT;
|
||||||
|
|
||||||
|
public static AccessSpecifier getAccessSpecifier(int modifiers) {
|
||||||
|
if (isPublic(modifiers)){
|
||||||
|
return AccessSpecifier.PUBLIC;
|
||||||
|
} else if (isProtected(modifiers)){
|
||||||
|
return AccessSpecifier.PROTECTED;
|
||||||
|
} else if (isPrivate(modifiers)){
|
||||||
|
return AccessSpecifier.PRIVATE;
|
||||||
|
} else {
|
||||||
|
return AccessSpecifier.DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int addModifier(int modifiers, int mod) {
|
||||||
|
return modifiers | mod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasModifier(int modifiers, int modifier) {
|
||||||
|
return (modifiers & modifier) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isAbstract(int modifiers) {
|
||||||
|
return (modifiers & ABSTRACT) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isFinal(int modifiers) {
|
||||||
|
return (modifiers & FINAL) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isNative(int modifiers) {
|
||||||
|
return (modifiers & NATIVE) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isPrivate(int modifiers) {
|
||||||
|
return (modifiers & PRIVATE) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isProtected(int modifiers) {
|
||||||
|
return (modifiers & PROTECTED) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the element accessible from within the package?
|
||||||
|
* It is the level of access which is applied if no modifiers are chosen,
|
||||||
|
* it is sometimes called "default".
|
||||||
|
* @param modifiers indicator
|
||||||
|
* @return true if modifier denotes package level access
|
||||||
|
*/
|
||||||
|
public static boolean hasPackageLevelAccess(int modifiers) {
|
||||||
|
return !isPublic(modifiers) && !isProtected(modifiers) && !isPrivate(modifiers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isPublic(int modifiers) {
|
||||||
|
return (modifiers & PUBLIC) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isStatic(int modifiers) {
|
||||||
|
return (modifiers & STATIC) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isStrictfp(int modifiers) {
|
||||||
|
return (modifiers & STRICTFP) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSynchronized(int modifiers) {
|
||||||
|
return (modifiers & SYNCHRONIZED) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isTransient(int modifiers) {
|
||||||
|
return (modifiers & TRANSIENT) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isVolatile(int modifiers) {
|
||||||
|
return (modifiers & VOLATILE) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the given modifier.
|
||||||
|
* @param modifiers existing modifiers
|
||||||
|
* @param mod modifier to be removed
|
||||||
|
* @return result for removing modifier
|
||||||
|
*/
|
||||||
|
public static int removeModifier(int modifiers, int mod) {
|
||||||
|
return modifiers & ~mod;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ModifierSet() {
|
||||||
|
}
|
||||||
|
}
|
67
src/com/github/javaparser/ast/body/MultiTypeParameter.java
Normal file
67
src/com/github/javaparser/ast/body/MultiTypeParameter.java
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
import com.github.javaparser.ast.type.Type;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.ensureNotNull;
|
||||||
|
|
||||||
|
public class MultiTypeParameter extends BaseParameter {
|
||||||
|
private List<Type> types;
|
||||||
|
|
||||||
|
public MultiTypeParameter() {}
|
||||||
|
|
||||||
|
public MultiTypeParameter(int modifiers, List<AnnotationExpr> annotations, List<Type> types, VariableDeclaratorId id) {
|
||||||
|
super(modifiers, annotations, id);
|
||||||
|
this.types = types;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MultiTypeParameter(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, List<Type> types, VariableDeclaratorId id) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, modifiers, annotations, id);
|
||||||
|
this.types = types;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Type> getTypes() {
|
||||||
|
types = ensureNotNull(types);
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTypes(List<Type> types) {
|
||||||
|
this.types = types;
|
||||||
|
setAsParentNodeOf(types);
|
||||||
|
}
|
||||||
|
}
|
84
src/com/github/javaparser/ast/body/Parameter.java
Normal file
84
src/com/github/javaparser/ast/body/Parameter.java
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
import com.github.javaparser.ast.type.Type;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class Parameter extends BaseParameter {
|
||||||
|
private Type type;
|
||||||
|
|
||||||
|
private boolean isVarArgs;
|
||||||
|
|
||||||
|
public Parameter() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Parameter(Type type, VariableDeclaratorId id) {
|
||||||
|
super(id);
|
||||||
|
setType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Parameter(int modifiers, Type type, VariableDeclaratorId id) {
|
||||||
|
super(modifiers, id);
|
||||||
|
setType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Parameter(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, Type type, boolean isVarArgs, VariableDeclaratorId id) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, modifiers, annotations, id);
|
||||||
|
setType(type);
|
||||||
|
setVarArgs(isVarArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVarArgs() {
|
||||||
|
return isVarArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Type type) {
|
||||||
|
this.type = type;
|
||||||
|
setAsParentNodeOf(this.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVarArgs(boolean isVarArgs) {
|
||||||
|
this.isVarArgs = isVarArgs;
|
||||||
|
}
|
||||||
|
}
|
110
src/com/github/javaparser/ast/body/TypeDeclaration.java
Normal file
110
src/com/github/javaparser/ast/body/TypeDeclaration.java
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.NamedNode;
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
import com.github.javaparser.ast.expr.NameExpr;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public abstract class TypeDeclaration extends BodyDeclaration implements NamedNode {
|
||||||
|
|
||||||
|
private NameExpr name;
|
||||||
|
|
||||||
|
private int modifiers;
|
||||||
|
|
||||||
|
private List<BodyDeclaration> members;
|
||||||
|
|
||||||
|
public TypeDeclaration() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeDeclaration(int modifiers, String name) {
|
||||||
|
setName(name);
|
||||||
|
setModifiers(modifiers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeDeclaration(List<AnnotationExpr> annotations,
|
||||||
|
int modifiers, String name,
|
||||||
|
List<BodyDeclaration> members) {
|
||||||
|
super(annotations);
|
||||||
|
setName(name);
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setMembers(members);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeDeclaration(int beginLine, int beginColumn, int endLine,
|
||||||
|
int endColumn, List<AnnotationExpr> annotations,
|
||||||
|
int modifiers, String name,
|
||||||
|
List<BodyDeclaration> members) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, annotations);
|
||||||
|
setName(name);
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setMembers(members);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final List<BodyDeclaration> getMembers() {
|
||||||
|
members = ensureNotNull(members);
|
||||||
|
return members;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the modifiers of this type declaration.
|
||||||
|
*
|
||||||
|
* @see ModifierSet
|
||||||
|
* @return modifiers
|
||||||
|
*/
|
||||||
|
public final int getModifiers() {
|
||||||
|
return modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String getName() {
|
||||||
|
return name.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMembers(List<BodyDeclaration> members) {
|
||||||
|
this.members = members;
|
||||||
|
setAsParentNodeOf(this.members);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setModifiers(int modifiers) {
|
||||||
|
this.modifiers = modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setName(String name) {
|
||||||
|
this.name = new NameExpr(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setNameExpr(NameExpr nameExpr) {
|
||||||
|
this.name = nameExpr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final NameExpr getNameExpr() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
89
src/com/github/javaparser/ast/body/VariableDeclarator.java
Normal file
89
src/com/github/javaparser/ast/body/VariableDeclarator.java
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.Node;
|
||||||
|
import com.github.javaparser.ast.expr.Expression;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class VariableDeclarator extends Node {
|
||||||
|
|
||||||
|
private VariableDeclaratorId id;
|
||||||
|
|
||||||
|
private Expression init;
|
||||||
|
|
||||||
|
public VariableDeclarator() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public VariableDeclarator(VariableDeclaratorId id) {
|
||||||
|
setId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the declaration of a variable.
|
||||||
|
* @param id The identifier for this variable. IE. The variables name.
|
||||||
|
* @param init What this variable should be initialized to.
|
||||||
|
* An {@link com.github.javaparser.ast.expr.AssignExpr} is unnecessary as the <code>=</code> operator is already added.
|
||||||
|
*/
|
||||||
|
public VariableDeclarator(VariableDeclaratorId id, Expression init) {
|
||||||
|
setId(id);
|
||||||
|
setInit(init);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VariableDeclarator(int beginLine, int beginColumn, int endLine, int endColumn, VariableDeclaratorId id, Expression init) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setId(id);
|
||||||
|
setInit(init);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VariableDeclaratorId getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getInit() {
|
||||||
|
return init;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(VariableDeclaratorId id) {
|
||||||
|
this.id = id;
|
||||||
|
setAsParentNodeOf(this.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInit(Expression init) {
|
||||||
|
this.init = init;
|
||||||
|
setAsParentNodeOf(this.init);
|
||||||
|
}
|
||||||
|
}
|
77
src/com/github/javaparser/ast/body/VariableDeclaratorId.java
Normal file
77
src/com/github/javaparser/ast/body/VariableDeclaratorId.java
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.NamedNode;
|
||||||
|
import com.github.javaparser.ast.Node;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class VariableDeclaratorId extends Node implements NamedNode {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private int arrayCount;
|
||||||
|
|
||||||
|
public VariableDeclaratorId() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public VariableDeclaratorId(String name) {
|
||||||
|
setName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VariableDeclaratorId(int beginLine, int beginColumn, int endLine, int endColumn, String name, int arrayCount) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setName(name);
|
||||||
|
setArrayCount(arrayCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getArrayCount() {
|
||||||
|
return arrayCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArrayCount(int arrayCount) {
|
||||||
|
this.arrayCount = arrayCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
57
src/com/github/javaparser/ast/body/WithDeclaration.java
Normal file
57
src/com/github/javaparser/ast/body/WithDeclaration.java
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.body;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Element with a declaration representable as a String.
|
||||||
|
*
|
||||||
|
* @author Federico Tomassetti
|
||||||
|
* @since July 2014
|
||||||
|
*/
|
||||||
|
public interface WithDeclaration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* As {@link WithDeclaration#getDeclarationAsString(boolean, boolean, boolean)} including
|
||||||
|
* the modifiers, the throws clause and the parameters with both type and name.
|
||||||
|
* @return String representation of declaration
|
||||||
|
*/
|
||||||
|
String getDeclarationAsString();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* As {@link WithDeclaration#getDeclarationAsString(boolean, boolean, boolean)} including
|
||||||
|
* the parameters with both type and name.
|
||||||
|
* @param includingModifiers flag to include the modifiers (if present) in the string produced
|
||||||
|
* @param includingThrows flag to include the throws clause (if present) in the string produced
|
||||||
|
* @return String representation of declaration based on parameter flags
|
||||||
|
*/
|
||||||
|
String getDeclarationAsString(boolean includingModifiers, boolean includingThrows);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple representation of the element declaration.
|
||||||
|
* It should fit one string.
|
||||||
|
* @param includingModifiers flag to include the modifiers (if present) in the string produced
|
||||||
|
* @param includingThrows flag to include the throws clause (if present) in the string produced
|
||||||
|
* @param includingParameterName flag to include the parameter name (while the parameter type is always included) in the string produced
|
||||||
|
* @return String representation of declaration based on parameter flags
|
||||||
|
*/
|
||||||
|
String getDeclarationAsString(boolean includingModifiers, boolean includingThrows, boolean includingParameterName);
|
||||||
|
}
|
58
src/com/github/javaparser/ast/comments/BlockComment.java
Normal file
58
src/com/github/javaparser/ast/comments/BlockComment.java
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.comments;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* AST node that represent block comments.
|
||||||
|
* </p>
|
||||||
|
* Block comments can has multi lines and are delimited by "/*" and
|
||||||
|
* "*/".
|
||||||
|
*
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class BlockComment extends Comment {
|
||||||
|
|
||||||
|
public BlockComment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockComment(String content) {
|
||||||
|
super(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockComment(int beginLine, int beginColumn, int endLine, int endColumn, String content) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, content);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
}
|
112
src/com/github/javaparser/ast/comments/Comment.java
Normal file
112
src/com/github/javaparser/ast/comments/Comment.java
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.comments;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.Node;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract class for all AST nodes that represent comments.
|
||||||
|
*
|
||||||
|
* @see BlockComment
|
||||||
|
* @see LineComment
|
||||||
|
* @see JavadocComment
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public abstract class Comment extends Node {
|
||||||
|
|
||||||
|
private String content;
|
||||||
|
private Node commentedNode;
|
||||||
|
|
||||||
|
public Comment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Comment(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Comment(int beginLine, int beginColumn, int endLine, int endColumn, String content) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the text of the comment.
|
||||||
|
*
|
||||||
|
* @return text of the comment
|
||||||
|
*/
|
||||||
|
public final String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the text of the comment.
|
||||||
|
*
|
||||||
|
* @param content
|
||||||
|
* the text of the comment to set
|
||||||
|
*/
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLineComment()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LineComment asLineComment()
|
||||||
|
{
|
||||||
|
if (isLineComment())
|
||||||
|
{
|
||||||
|
return (LineComment) this;
|
||||||
|
} else {
|
||||||
|
throw new UnsupportedOperationException("Not a line comment");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Node getCommentedNode()
|
||||||
|
{
|
||||||
|
return this.commentedNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommentedNode(Node commentedNode)
|
||||||
|
{
|
||||||
|
if (commentedNode==null)
|
||||||
|
{
|
||||||
|
this.commentedNode = commentedNode;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (commentedNode==this)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
if (commentedNode instanceof Comment)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
this.commentedNode = commentedNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOrphan()
|
||||||
|
{
|
||||||
|
return this.commentedNode == null;
|
||||||
|
}
|
||||||
|
}
|
104
src/com/github/javaparser/ast/comments/CommentsCollection.java
Normal file
104
src/com/github/javaparser/ast/comments/CommentsCollection.java
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.comments;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set of comments produced by CommentsParser.
|
||||||
|
*/
|
||||||
|
public class CommentsCollection {
|
||||||
|
private List<LineComment> lineComments = new LinkedList<LineComment>();
|
||||||
|
private List<BlockComment> blockComments = new LinkedList<BlockComment>();
|
||||||
|
private List<JavadocComment> javadocComments = new LinkedList<JavadocComment>();
|
||||||
|
|
||||||
|
public List<LineComment> getLineComments(){
|
||||||
|
return lineComments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<BlockComment> getBlockComments(){
|
||||||
|
return blockComments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<JavadocComment> getJavadocComments(){
|
||||||
|
return javadocComments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addComment(LineComment lineComment){
|
||||||
|
this.lineComments.add(lineComment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addComment(BlockComment blockComment){
|
||||||
|
this.blockComments.add(blockComment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addComment(JavadocComment javadocComment){
|
||||||
|
this.javadocComments.add(javadocComment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean contains(Comment comment){
|
||||||
|
for (Comment c : getAll()){
|
||||||
|
// we tollerate a difference of one element in the end column:
|
||||||
|
// it depends how \r and \n are calculated...
|
||||||
|
if ( c.getBeginLine()==comment.getBeginLine() &&
|
||||||
|
c.getBeginColumn()==comment.getBeginColumn() &&
|
||||||
|
c.getEndLine()==comment.getEndLine() &&
|
||||||
|
Math.abs(c.getEndColumn()-comment.getEndColumn())<2 ){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Comment> getAll(){
|
||||||
|
List<Comment> comments = new LinkedList<Comment>();
|
||||||
|
comments.addAll(lineComments);
|
||||||
|
comments.addAll(blockComments);
|
||||||
|
comments.addAll(javadocComments);
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size(){
|
||||||
|
return lineComments.size()+blockComments.size()+javadocComments.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommentsCollection minus(CommentsCollection other){
|
||||||
|
CommentsCollection result = new CommentsCollection();
|
||||||
|
for (LineComment comment : lineComments){
|
||||||
|
if (!other.contains(comment)){
|
||||||
|
result.lineComments.add(comment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (BlockComment comment : blockComments){
|
||||||
|
if (!other.contains(comment)){
|
||||||
|
result.blockComments.add(comment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (JavadocComment comment : javadocComments){
|
||||||
|
if (!other.contains(comment)){
|
||||||
|
result.javadocComments.add(comment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
171
src/com/github/javaparser/ast/comments/CommentsParser.java
Normal file
171
src/com/github/javaparser/ast/comments/CommentsParser.java
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.comments;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This parser cares exclusively about comments.
|
||||||
|
*/
|
||||||
|
public class CommentsParser {
|
||||||
|
|
||||||
|
private enum State {
|
||||||
|
CODE,
|
||||||
|
IN_LINE_COMMENT,
|
||||||
|
IN_BLOCK_COMMENT,
|
||||||
|
IN_STRING,
|
||||||
|
IN_CHAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final int COLUMNS_PER_TAB = 4;
|
||||||
|
|
||||||
|
public CommentsCollection parse(final String source) throws IOException, UnsupportedEncodingException {
|
||||||
|
InputStream in = new ByteArrayInputStream(source.getBytes(Charset.defaultCharset()));
|
||||||
|
return parse(in, Charset.defaultCharset().name());
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommentsCollection parse(final InputStream in, final String charsetName) throws IOException, UnsupportedEncodingException {
|
||||||
|
boolean lastWasASlashR = false;
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(in, charsetName));
|
||||||
|
CommentsCollection comments = new CommentsCollection();
|
||||||
|
int r;
|
||||||
|
|
||||||
|
Deque prevTwoChars = new LinkedList<Character>(Arrays.asList('z','z'));
|
||||||
|
|
||||||
|
State state = State.CODE;
|
||||||
|
LineComment currentLineComment = null;
|
||||||
|
BlockComment currentBlockComment = null;
|
||||||
|
StringBuffer currentContent = null;
|
||||||
|
|
||||||
|
int currLine = 1;
|
||||||
|
int currCol = 1;
|
||||||
|
|
||||||
|
while ((r=br.read()) != -1){
|
||||||
|
char c = (char)r;
|
||||||
|
if (c=='\r'){
|
||||||
|
lastWasASlashR = true;
|
||||||
|
} else if (c=='\n'&&lastWasASlashR){
|
||||||
|
lastWasASlashR=false;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
lastWasASlashR=false;
|
||||||
|
}
|
||||||
|
switch (state) {
|
||||||
|
case CODE:
|
||||||
|
if (prevTwoChars.peekLast().equals('/') && c == '/') {
|
||||||
|
currentLineComment = new LineComment();
|
||||||
|
currentLineComment.setBeginLine(currLine);
|
||||||
|
currentLineComment.setBeginColumn(currCol - 1);
|
||||||
|
state = State.IN_LINE_COMMENT;
|
||||||
|
currentContent = new StringBuffer();
|
||||||
|
} else if (prevTwoChars.peekLast().equals('/') && c == '*') {
|
||||||
|
currentBlockComment = new BlockComment();
|
||||||
|
currentBlockComment.setBeginLine(currLine);
|
||||||
|
currentBlockComment.setBeginColumn(currCol - 1);
|
||||||
|
state = State.IN_BLOCK_COMMENT;
|
||||||
|
currentContent = new StringBuffer();
|
||||||
|
} else if (c == '"') {
|
||||||
|
state = State.IN_STRING;
|
||||||
|
} else if (c == '\'') {
|
||||||
|
state = State.IN_CHAR;
|
||||||
|
} else {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IN_LINE_COMMENT:
|
||||||
|
if (c=='\n' || c=='\r'){
|
||||||
|
currentLineComment.setContent(currentContent.toString());
|
||||||
|
currentLineComment.setEndLine(currLine);
|
||||||
|
currentLineComment.setEndColumn(currCol);
|
||||||
|
comments.addComment(currentLineComment);
|
||||||
|
state = State.CODE;
|
||||||
|
} else {
|
||||||
|
currentContent.append(c);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IN_BLOCK_COMMENT:
|
||||||
|
if (prevTwoChars.peekLast().equals('*') && c=='/' && !prevTwoChars.peekFirst().equals('/')){
|
||||||
|
|
||||||
|
// delete last character
|
||||||
|
String content = currentContent.deleteCharAt(currentContent.toString().length()-1).toString();
|
||||||
|
|
||||||
|
if (content.startsWith("*")){
|
||||||
|
JavadocComment javadocComment = new JavadocComment();
|
||||||
|
javadocComment.setContent(content.substring(1));
|
||||||
|
javadocComment.setBeginLine(currentBlockComment.getBeginLine());
|
||||||
|
javadocComment.setBeginColumn(currentBlockComment.getBeginColumn());
|
||||||
|
javadocComment.setEndLine(currLine);
|
||||||
|
javadocComment.setEndColumn(currCol+1);
|
||||||
|
comments.addComment(javadocComment);
|
||||||
|
} else {
|
||||||
|
currentBlockComment.setContent(content);
|
||||||
|
currentBlockComment.setEndLine(currLine);
|
||||||
|
currentBlockComment.setEndColumn(currCol+1);
|
||||||
|
comments.addComment(currentBlockComment);
|
||||||
|
}
|
||||||
|
state = State.CODE;
|
||||||
|
} else {
|
||||||
|
currentContent.append(c=='\r'?'\n':c);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IN_STRING:
|
||||||
|
if (!prevTwoChars.peekLast().equals('\\') && c == '"') {
|
||||||
|
state = State.CODE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IN_CHAR:
|
||||||
|
if (!prevTwoChars.peekLast().equals('\\') && c == '\'') {
|
||||||
|
state = State.CODE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new RuntimeException("Unexpected");
|
||||||
|
}
|
||||||
|
switch (c){
|
||||||
|
case '\n':
|
||||||
|
case '\r':
|
||||||
|
currLine+=1;
|
||||||
|
currCol = 1;
|
||||||
|
break;
|
||||||
|
case '\t':
|
||||||
|
currCol+=COLUMNS_PER_TAB;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
currCol+=1;
|
||||||
|
}
|
||||||
|
prevTwoChars.remove();
|
||||||
|
prevTwoChars.add(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state==State.IN_LINE_COMMENT){
|
||||||
|
currentLineComment.setContent(currentContent.toString());
|
||||||
|
currentLineComment.setEndLine(currLine);
|
||||||
|
currentLineComment.setEndColumn(currCol);
|
||||||
|
comments.addComment(currentLineComment);
|
||||||
|
}
|
||||||
|
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
52
src/com/github/javaparser/ast/comments/JavadocComment.java
Normal file
52
src/com/github/javaparser/ast/comments/JavadocComment.java
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.comments;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class JavadocComment extends Comment {
|
||||||
|
|
||||||
|
public JavadocComment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public JavadocComment(String content) {
|
||||||
|
super(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JavadocComment(int beginLine, int beginColumn, int endLine, int endColumn, String content) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, content);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
}
|
62
src/com/github/javaparser/ast/comments/LineComment.java
Normal file
62
src/com/github/javaparser/ast/comments/LineComment.java
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.comments;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* AST node that represent line comments.
|
||||||
|
* </p>
|
||||||
|
* Line comments are started with "//" and finish at the end of the line ("\n").
|
||||||
|
*
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class LineComment extends Comment {
|
||||||
|
|
||||||
|
public LineComment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public LineComment(String content) {
|
||||||
|
super(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LineComment(int beginLine, int beginColumn, int endLine, int endColumn, String content) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, content);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLineComment()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
46
src/com/github/javaparser/ast/expr/AnnotationExpr.java
Normal file
46
src/com/github/javaparser/ast/expr/AnnotationExpr.java
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public abstract class AnnotationExpr extends Expression {
|
||||||
|
|
||||||
|
protected NameExpr name;
|
||||||
|
|
||||||
|
public AnnotationExpr() {}
|
||||||
|
|
||||||
|
public AnnotationExpr(int beginLine, int beginColumn, int endLine,
|
||||||
|
int endColumn) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NameExpr getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(NameExpr name) {
|
||||||
|
this.name = name;
|
||||||
|
setAsParentNodeOf(name);
|
||||||
|
}
|
||||||
|
}
|
77
src/com/github/javaparser/ast/expr/ArrayAccessExpr.java
Normal file
77
src/com/github/javaparser/ast/expr/ArrayAccessExpr.java
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class ArrayAccessExpr extends Expression {
|
||||||
|
|
||||||
|
private Expression name;
|
||||||
|
|
||||||
|
private Expression index;
|
||||||
|
|
||||||
|
public ArrayAccessExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayAccessExpr(Expression name, Expression index) {
|
||||||
|
setName(name);
|
||||||
|
setIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayAccessExpr(int beginLine, int beginColumn, int endLine, int endColumn, Expression name, Expression index) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setName(name);
|
||||||
|
setIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIndex(Expression index) {
|
||||||
|
this.index = index;
|
||||||
|
setAsParentNodeOf(this.index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(Expression name) {
|
||||||
|
this.name = name;
|
||||||
|
setAsParentNodeOf(this.name);
|
||||||
|
}
|
||||||
|
}
|
135
src/com/github/javaparser/ast/expr/ArrayCreationExpr.java
Normal file
135
src/com/github/javaparser/ast/expr/ArrayCreationExpr.java
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.type.Type;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class ArrayCreationExpr extends Expression {
|
||||||
|
|
||||||
|
private Type type;
|
||||||
|
|
||||||
|
private int arrayCount;
|
||||||
|
|
||||||
|
private ArrayInitializerExpr initializer;
|
||||||
|
|
||||||
|
private List<Expression> dimensions;
|
||||||
|
|
||||||
|
private List<List<AnnotationExpr>> arraysAnnotations;
|
||||||
|
|
||||||
|
public ArrayCreationExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayCreationExpr(Type type, int arrayCount, ArrayInitializerExpr initializer) {
|
||||||
|
setType(type);
|
||||||
|
setArrayCount(arrayCount);
|
||||||
|
setInitializer(initializer);
|
||||||
|
setDimensions(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayCreationExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type, int arrayCount, ArrayInitializerExpr initializer) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setType(type);
|
||||||
|
setArrayCount(arrayCount);
|
||||||
|
setInitializer(initializer);
|
||||||
|
setDimensions(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayCreationExpr(Type type, List<Expression> dimensions, int arrayCount) {
|
||||||
|
setType(type);
|
||||||
|
setArrayCount(arrayCount);
|
||||||
|
setDimensions(dimensions);
|
||||||
|
setInitializer(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayCreationExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type, List<Expression> dimensions, int arrayCount) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setType(type);
|
||||||
|
setArrayCount(arrayCount);
|
||||||
|
setDimensions(dimensions);
|
||||||
|
setInitializer(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getArrayCount() {
|
||||||
|
return arrayCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Expression> getDimensions() {
|
||||||
|
dimensions = ensureNotNull(dimensions);
|
||||||
|
return dimensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayInitializerExpr getInitializer() {
|
||||||
|
return initializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArrayCount(int arrayCount) {
|
||||||
|
this.arrayCount = arrayCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDimensions(List<Expression> dimensions) {
|
||||||
|
this.dimensions = dimensions;
|
||||||
|
setAsParentNodeOf(this.dimensions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInitializer(ArrayInitializerExpr initializer) {
|
||||||
|
this.initializer = initializer;
|
||||||
|
setAsParentNodeOf(this.initializer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Type type) {
|
||||||
|
this.type = type;
|
||||||
|
setAsParentNodeOf(this.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<List<AnnotationExpr>> getArraysAnnotations() {
|
||||||
|
arraysAnnotations = ensureNotNull(arraysAnnotations);
|
||||||
|
return arraysAnnotations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArraysAnnotations(
|
||||||
|
List<List<AnnotationExpr>> arraysAnnotations) {
|
||||||
|
this.arraysAnnotations = arraysAnnotations;
|
||||||
|
}
|
||||||
|
}
|
69
src/com/github/javaparser/ast/expr/ArrayInitializerExpr.java
Normal file
69
src/com/github/javaparser/ast/expr/ArrayInitializerExpr.java
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.ensureNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class ArrayInitializerExpr extends Expression {
|
||||||
|
|
||||||
|
private List<Expression> values;
|
||||||
|
|
||||||
|
public ArrayInitializerExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayInitializerExpr(List<Expression> values) {
|
||||||
|
setValues(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayInitializerExpr(int beginLine, int beginColumn, int endLine, int endColumn, List<Expression> values) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setValues(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Expression> getValues() {
|
||||||
|
values = ensureNotNull(values);
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValues(List<Expression> values) {
|
||||||
|
this.values = values;
|
||||||
|
setAsParentNodeOf(this.values);
|
||||||
|
}
|
||||||
|
}
|
104
src/com/github/javaparser/ast/expr/AssignExpr.java
Normal file
104
src/com/github/javaparser/ast/expr/AssignExpr.java
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class AssignExpr extends Expression {
|
||||||
|
|
||||||
|
public static enum Operator {
|
||||||
|
assign, // =
|
||||||
|
plus, // +=
|
||||||
|
minus, // -=
|
||||||
|
star, // *=
|
||||||
|
slash, // /=
|
||||||
|
and, // &=
|
||||||
|
or, // |=
|
||||||
|
xor, // ^=
|
||||||
|
rem, // %=
|
||||||
|
lShift, // <<=
|
||||||
|
rSignedShift, // >>=
|
||||||
|
rUnsignedShift, // >>>=
|
||||||
|
}
|
||||||
|
|
||||||
|
private Expression target;
|
||||||
|
|
||||||
|
private Expression value;
|
||||||
|
|
||||||
|
private Operator op;
|
||||||
|
|
||||||
|
public AssignExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssignExpr(Expression target, Expression value, Operator op) {
|
||||||
|
setTarget(target);
|
||||||
|
setValue(value);
|
||||||
|
setOperator(op);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssignExpr(int beginLine, int beginColumn, int endLine, int endColumn, Expression target, Expression value, Operator op) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setTarget(target);
|
||||||
|
setValue(value);
|
||||||
|
setOperator(op);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Operator getOperator() {
|
||||||
|
return op;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getTarget() {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOperator(Operator op) {
|
||||||
|
this.op = op;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTarget(Expression target) {
|
||||||
|
this.target = target;
|
||||||
|
setAsParentNodeOf(this.target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(Expression value) {
|
||||||
|
this.value = value;
|
||||||
|
setAsParentNodeOf(this.value);
|
||||||
|
}
|
||||||
|
}
|
111
src/com/github/javaparser/ast/expr/BinaryExpr.java
Normal file
111
src/com/github/javaparser/ast/expr/BinaryExpr.java
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class BinaryExpr extends Expression {
|
||||||
|
|
||||||
|
public static enum Operator {
|
||||||
|
or, // ||
|
||||||
|
and, // &&
|
||||||
|
binOr, // |
|
||||||
|
binAnd, // &
|
||||||
|
xor, // ^
|
||||||
|
equals, // ==
|
||||||
|
notEquals, // !=
|
||||||
|
less, // <
|
||||||
|
greater, // >
|
||||||
|
lessEquals, // <=
|
||||||
|
greaterEquals, // >=
|
||||||
|
lShift, // <<
|
||||||
|
rSignedShift, // >>
|
||||||
|
rUnsignedShift, // >>>
|
||||||
|
plus, // +
|
||||||
|
minus, // -
|
||||||
|
times, // *
|
||||||
|
divide, // /
|
||||||
|
remainder, // %
|
||||||
|
}
|
||||||
|
|
||||||
|
private Expression left;
|
||||||
|
|
||||||
|
private Expression right;
|
||||||
|
|
||||||
|
private Operator op;
|
||||||
|
|
||||||
|
public BinaryExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public BinaryExpr(Expression left, Expression right, Operator op) {
|
||||||
|
setLeft(left);
|
||||||
|
setRight(right);
|
||||||
|
setOperator(op);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BinaryExpr(int beginLine, int beginColumn, int endLine, int endColumn, Expression left, Expression right, Operator op) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setLeft(left);
|
||||||
|
setRight(right);
|
||||||
|
setOperator(op);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getLeft() {
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Operator getOperator() {
|
||||||
|
return op;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getRight() {
|
||||||
|
return right;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeft(Expression left) {
|
||||||
|
this.left = left;
|
||||||
|
setAsParentNodeOf(this.left);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOperator(Operator op) {
|
||||||
|
this.op = op;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRight(Expression right) {
|
||||||
|
this.right = right;
|
||||||
|
setAsParentNodeOf(this.right);
|
||||||
|
}
|
||||||
|
}
|
63
src/com/github/javaparser/ast/expr/BooleanLiteralExpr.java
Normal file
63
src/com/github/javaparser/ast/expr/BooleanLiteralExpr.java
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class BooleanLiteralExpr extends LiteralExpr {
|
||||||
|
|
||||||
|
private boolean value;
|
||||||
|
|
||||||
|
public BooleanLiteralExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public BooleanLiteralExpr(boolean value) {
|
||||||
|
setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BooleanLiteralExpr(int beginLine, int beginColumn, int endLine, int endColumn, boolean value) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(boolean value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
78
src/com/github/javaparser/ast/expr/CastExpr.java
Normal file
78
src/com/github/javaparser/ast/expr/CastExpr.java
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.type.Type;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class CastExpr extends Expression {
|
||||||
|
|
||||||
|
private Type type;
|
||||||
|
|
||||||
|
private Expression expr;
|
||||||
|
|
||||||
|
public CastExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public CastExpr(Type type, Expression expr) {
|
||||||
|
setType(type);
|
||||||
|
setExpr(expr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CastExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type, Expression expr) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setType(type);
|
||||||
|
setExpr(expr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getExpr() {
|
||||||
|
return expr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpr(Expression expr) {
|
||||||
|
this.expr = expr;
|
||||||
|
setAsParentNodeOf(this.expr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Type type) {
|
||||||
|
this.type = type;
|
||||||
|
setAsParentNodeOf(this.type);
|
||||||
|
}
|
||||||
|
}
|
52
src/com/github/javaparser/ast/expr/CharLiteralExpr.java
Normal file
52
src/com/github/javaparser/ast/expr/CharLiteralExpr.java
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class CharLiteralExpr extends StringLiteralExpr {
|
||||||
|
|
||||||
|
public CharLiteralExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public CharLiteralExpr(String value) {
|
||||||
|
super(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CharLiteralExpr(int beginLine, int beginColumn, int endLine, int endColumn, String value) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
}
|
70
src/com/github/javaparser/ast/expr/ClassExpr.java
Normal file
70
src/com/github/javaparser/ast/expr/ClassExpr.java
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.type.Type;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines an expression that accesses the class of a type.
|
||||||
|
* Example:
|
||||||
|
* <code>
|
||||||
|
* Object.class
|
||||||
|
* </code>
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class ClassExpr extends Expression {
|
||||||
|
|
||||||
|
private Type type;
|
||||||
|
|
||||||
|
public ClassExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassExpr(Type type) {
|
||||||
|
setType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Type type) {
|
||||||
|
this.type = type;
|
||||||
|
setAsParentNodeOf(this.type);
|
||||||
|
}
|
||||||
|
}
|
90
src/com/github/javaparser/ast/expr/ConditionalExpr.java
Normal file
90
src/com/github/javaparser/ast/expr/ConditionalExpr.java
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class ConditionalExpr extends Expression {
|
||||||
|
|
||||||
|
private Expression condition;
|
||||||
|
|
||||||
|
private Expression thenExpr;
|
||||||
|
|
||||||
|
private Expression elseExpr;
|
||||||
|
|
||||||
|
public ConditionalExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConditionalExpr(Expression condition, Expression thenExpr, Expression elseExpr) {
|
||||||
|
setCondition(condition);
|
||||||
|
setThenExpr(thenExpr);
|
||||||
|
setElseExpr(elseExpr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConditionalExpr(int beginLine, int beginColumn, int endLine, int endColumn, Expression condition, Expression thenExpr, Expression elseExpr) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setCondition(condition);
|
||||||
|
setThenExpr(thenExpr);
|
||||||
|
setElseExpr(elseExpr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getCondition() {
|
||||||
|
return condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getElseExpr() {
|
||||||
|
return elseExpr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getThenExpr() {
|
||||||
|
return thenExpr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCondition(Expression condition) {
|
||||||
|
this.condition = condition;
|
||||||
|
setAsParentNodeOf(this.condition);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setElseExpr(Expression elseExpr) {
|
||||||
|
this.elseExpr = elseExpr;
|
||||||
|
setAsParentNodeOf(this.elseExpr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setThenExpr(Expression thenExpr) {
|
||||||
|
this.thenExpr = thenExpr;
|
||||||
|
setAsParentNodeOf(this.thenExpr);
|
||||||
|
}
|
||||||
|
}
|
51
src/com/github/javaparser/ast/expr/DoubleLiteralExpr.java
Normal file
51
src/com/github/javaparser/ast/expr/DoubleLiteralExpr.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class DoubleLiteralExpr extends StringLiteralExpr {
|
||||||
|
|
||||||
|
public DoubleLiteralExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public DoubleLiteralExpr(final String value) {
|
||||||
|
super(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DoubleLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final String value) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
}
|
63
src/com/github/javaparser/ast/expr/EnclosedExpr.java
Normal file
63
src/com/github/javaparser/ast/expr/EnclosedExpr.java
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class EnclosedExpr extends Expression {
|
||||||
|
|
||||||
|
private Expression inner;
|
||||||
|
|
||||||
|
public EnclosedExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnclosedExpr(final Expression inner) {
|
||||||
|
setInner(inner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnclosedExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final Expression inner) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setInner(inner);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getInner() {
|
||||||
|
return inner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInner(final Expression inner) {
|
||||||
|
this.inner = inner;
|
||||||
|
setAsParentNodeOf(this.inner);
|
||||||
|
}
|
||||||
|
}
|
38
src/com/github/javaparser/ast/expr/Expression.java
Normal file
38
src/com/github/javaparser/ast/expr/Expression.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.Node;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public abstract class Expression extends Node {
|
||||||
|
|
||||||
|
public Expression() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression(final int beginLine, final int beginColumn, final int endLine, final int endColumn) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
101
src/com/github/javaparser/ast/expr/FieldAccessExpr.java
Normal file
101
src/com/github/javaparser/ast/expr/FieldAccessExpr.java
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.type.Type;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class FieldAccessExpr extends Expression {
|
||||||
|
|
||||||
|
private Expression scope;
|
||||||
|
|
||||||
|
private List<Type> typeArgs;
|
||||||
|
|
||||||
|
private NameExpr field;
|
||||||
|
|
||||||
|
public FieldAccessExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldAccessExpr(final Expression scope, final String field) {
|
||||||
|
setScope(scope);
|
||||||
|
setField(field);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldAccessExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final Expression scope, final List<Type> typeArgs, final String field) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setScope(scope);
|
||||||
|
setTypeArgs(typeArgs);
|
||||||
|
setField(field);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getField() {
|
||||||
|
return field.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public NameExpr getFieldExpr() {
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getScope() {
|
||||||
|
return scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Type> getTypeArgs() {
|
||||||
|
typeArgs = ensureNotNull(typeArgs);
|
||||||
|
return typeArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setField(final String field) {
|
||||||
|
this.field = new NameExpr(field);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldExpr(NameExpr field) {
|
||||||
|
this.field = field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScope(final Expression scope) {
|
||||||
|
this.scope = scope;
|
||||||
|
setAsParentNodeOf(this.scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTypeArgs(final List<Type> typeArgs) {
|
||||||
|
this.typeArgs = typeArgs;
|
||||||
|
setAsParentNodeOf(this.typeArgs);
|
||||||
|
}
|
||||||
|
}
|
77
src/com/github/javaparser/ast/expr/InstanceOfExpr.java
Normal file
77
src/com/github/javaparser/ast/expr/InstanceOfExpr.java
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.type.Type;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class InstanceOfExpr extends Expression {
|
||||||
|
|
||||||
|
private Expression expr;
|
||||||
|
|
||||||
|
private Type type;
|
||||||
|
|
||||||
|
public InstanceOfExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public InstanceOfExpr(final Expression expr, final Type type) {
|
||||||
|
setExpr(expr);
|
||||||
|
setType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InstanceOfExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final Expression expr, final Type type) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setExpr(expr);
|
||||||
|
setType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getExpr() {
|
||||||
|
return expr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpr(final Expression expr) {
|
||||||
|
this.expr = expr;
|
||||||
|
setAsParentNodeOf(this.expr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(final Type type) {
|
||||||
|
this.type = type;
|
||||||
|
setAsParentNodeOf(this.type);
|
||||||
|
}
|
||||||
|
}
|
61
src/com/github/javaparser/ast/expr/IntegerLiteralExpr.java
Normal file
61
src/com/github/javaparser/ast/expr/IntegerLiteralExpr.java
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public class IntegerLiteralExpr extends StringLiteralExpr {
|
||||||
|
|
||||||
|
private static final String UNSIGNED_MIN_VALUE = "2147483648";
|
||||||
|
|
||||||
|
protected static final String MIN_VALUE = "-" + UNSIGNED_MIN_VALUE;
|
||||||
|
|
||||||
|
public IntegerLiteralExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntegerLiteralExpr(final String value) {
|
||||||
|
super(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntegerLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final String value) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean isMinValue() {
|
||||||
|
return value != null && //
|
||||||
|
value.length() == 10 && //
|
||||||
|
value.equals(UNSIGNED_MIN_VALUE);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class IntegerLiteralMinValueExpr extends IntegerLiteralExpr {
|
||||||
|
|
||||||
|
public IntegerLiteralMinValueExpr() {
|
||||||
|
super(MIN_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntegerLiteralMinValueExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, MIN_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
96
src/com/github/javaparser/ast/expr/LambdaExpr.java
Normal file
96
src/com/github/javaparser/ast/expr/LambdaExpr.java
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.body.Parameter;
|
||||||
|
import com.github.javaparser.ast.stmt.Statement;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lambda expression.
|
||||||
|
*
|
||||||
|
* @author Raquel Pau
|
||||||
|
*/
|
||||||
|
public class LambdaExpr extends Expression {
|
||||||
|
|
||||||
|
private List<Parameter> parameters;
|
||||||
|
|
||||||
|
private boolean parametersEnclosed;
|
||||||
|
|
||||||
|
private Statement body;
|
||||||
|
|
||||||
|
public LambdaExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaExpr(int beginLine, int beginColumn, int endLine,
|
||||||
|
int endColumn, List<Parameter> parameters, Statement body,
|
||||||
|
boolean parametersEnclosed) {
|
||||||
|
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setParameters(parameters);
|
||||||
|
setBody(body);
|
||||||
|
setParametersEnclosed(parametersEnclosed);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Parameter> getParameters() {
|
||||||
|
parameters = ensureNotNull(parameters);
|
||||||
|
return parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParameters(List<Parameter> parameters) {
|
||||||
|
this.parameters = parameters;
|
||||||
|
setAsParentNodeOf(this.parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Statement getBody() {
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBody(Statement body) {
|
||||||
|
this.body = body;
|
||||||
|
setAsParentNodeOf(this.body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isParametersEnclosed() {
|
||||||
|
return parametersEnclosed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParametersEnclosed(boolean parametersEnclosed) {
|
||||||
|
this.parametersEnclosed = parametersEnclosed;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
35
src/com/github/javaparser/ast/expr/LiteralExpr.java
Normal file
35
src/com/github/javaparser/ast/expr/LiteralExpr.java
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public abstract class LiteralExpr extends Expression {
|
||||||
|
|
||||||
|
public LiteralExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
}
|
||||||
|
}
|
62
src/com/github/javaparser/ast/expr/LongLiteralExpr.java
Normal file
62
src/com/github/javaparser/ast/expr/LongLiteralExpr.java
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public class LongLiteralExpr extends StringLiteralExpr {
|
||||||
|
|
||||||
|
private static final String UNSIGNED_MIN_VALUE = "9223372036854775808";
|
||||||
|
|
||||||
|
protected static final String MIN_VALUE = "-" + UNSIGNED_MIN_VALUE + "L";
|
||||||
|
|
||||||
|
public LongLiteralExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public LongLiteralExpr(final String value) {
|
||||||
|
super(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LongLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final String value) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean isMinValue() {
|
||||||
|
return value != null && //
|
||||||
|
value.length() == 20 && //
|
||||||
|
value.startsWith(UNSIGNED_MIN_VALUE) && //
|
||||||
|
(value.charAt(19) == 'L' || value.charAt(19) == 'l');
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class LongLiteralMinValueExpr extends LongLiteralExpr {
|
||||||
|
|
||||||
|
public LongLiteralMinValueExpr() {
|
||||||
|
super(MIN_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LongLiteralMinValueExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, MIN_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
53
src/com/github/javaparser/ast/expr/MarkerAnnotationExpr.java
Normal file
53
src/com/github/javaparser/ast/expr/MarkerAnnotationExpr.java
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class MarkerAnnotationExpr extends AnnotationExpr {
|
||||||
|
|
||||||
|
public MarkerAnnotationExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkerAnnotationExpr(final NameExpr name) {
|
||||||
|
setName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkerAnnotationExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final NameExpr name) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
77
src/com/github/javaparser/ast/expr/MemberValuePair.java
Normal file
77
src/com/github/javaparser/ast/expr/MemberValuePair.java
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.NamedNode;
|
||||||
|
import com.github.javaparser.ast.Node;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class MemberValuePair extends Node implements NamedNode {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private Expression value;
|
||||||
|
|
||||||
|
public MemberValuePair() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public MemberValuePair(final String name, final Expression value) {
|
||||||
|
setName(name);
|
||||||
|
setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MemberValuePair(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final String name, final Expression value) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setName(name);
|
||||||
|
setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(final String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(final Expression value) {
|
||||||
|
this.value = value;
|
||||||
|
setAsParentNodeOf(this.value);
|
||||||
|
}
|
||||||
|
}
|
120
src/com/github/javaparser/ast/expr/MethodCallExpr.java
Normal file
120
src/com/github/javaparser/ast/expr/MethodCallExpr.java
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.type.Type;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class MethodCallExpr extends Expression {
|
||||||
|
|
||||||
|
private Expression scope;
|
||||||
|
|
||||||
|
private List<Type> typeArgs;
|
||||||
|
|
||||||
|
private NameExpr name;
|
||||||
|
|
||||||
|
private List<Expression> args;
|
||||||
|
|
||||||
|
public MethodCallExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodCallExpr(final Expression scope, final String name) {
|
||||||
|
setScope(scope);
|
||||||
|
setName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodCallExpr(final Expression scope, final String name, final List<Expression> args) {
|
||||||
|
setScope(scope);
|
||||||
|
setName(name);
|
||||||
|
setArgs(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodCallExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final Expression scope, final List<Type> typeArgs, final String name, final List<Expression> args) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setScope(scope);
|
||||||
|
setTypeArgs(typeArgs);
|
||||||
|
setName(name);
|
||||||
|
setArgs(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Expression> getArgs() {
|
||||||
|
args = ensureNotNull(args);
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public NameExpr getNameExpr() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getScope() {
|
||||||
|
return scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Type> getTypeArgs() {
|
||||||
|
typeArgs = ensureNotNull(typeArgs);
|
||||||
|
return typeArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArgs(final List<Expression> args) {
|
||||||
|
this.args = args;
|
||||||
|
setAsParentNodeOf(this.args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(final String name) {
|
||||||
|
this.name = new NameExpr(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNameExpr(NameExpr name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScope(final Expression scope) {
|
||||||
|
this.scope = scope;
|
||||||
|
setAsParentNodeOf(this.scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTypeArgs(final List<Type> typeArgs) {
|
||||||
|
this.typeArgs = typeArgs;
|
||||||
|
setAsParentNodeOf(this.typeArgs);
|
||||||
|
}
|
||||||
|
}
|
101
src/com/github/javaparser/ast/expr/MethodReferenceExpr.java
Normal file
101
src/com/github/javaparser/ast/expr/MethodReferenceExpr.java
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.TypeParameter;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method reference expressions introduced in Java 8 specifically designed to simplify lambda Expressions.
|
||||||
|
* These are some examples:
|
||||||
|
*
|
||||||
|
* System.out::println;
|
||||||
|
*
|
||||||
|
* (test ? stream.map(String::trim) : stream)::toArray;
|
||||||
|
* @author Raquel Pau
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class MethodReferenceExpr extends Expression {
|
||||||
|
|
||||||
|
private Expression scope;
|
||||||
|
|
||||||
|
private List<TypeParameter> typeParameters;
|
||||||
|
|
||||||
|
private String identifier;
|
||||||
|
|
||||||
|
public MethodReferenceExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodReferenceExpr(int beginLine, int beginColumn, int endLine,
|
||||||
|
int endColumn, Expression scope,
|
||||||
|
List<TypeParameter> typeParameters, String identifier) {
|
||||||
|
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setIdentifier(identifier);
|
||||||
|
setScope(scope);
|
||||||
|
setTypeParameters(typeParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getScope() {
|
||||||
|
return scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScope(Expression scope) {
|
||||||
|
this.scope = scope;
|
||||||
|
setAsParentNodeOf(this.scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TypeParameter> getTypeParameters() {
|
||||||
|
typeParameters = ensureNotNull(typeParameters);
|
||||||
|
return typeParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTypeParameters(List<TypeParameter> typeParameters) {
|
||||||
|
this.typeParameters = typeParameters;
|
||||||
|
setAsParentNodeOf(this.typeParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIdentifier() {
|
||||||
|
return identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdentifier(String identifier) {
|
||||||
|
this.identifier = identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
64
src/com/github/javaparser/ast/expr/NameExpr.java
Normal file
64
src/com/github/javaparser/ast/expr/NameExpr.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.NamedNode;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public class NameExpr extends Expression implements NamedNode {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public NameExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public NameExpr(final String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NameExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final String name) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setName(final String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
70
src/com/github/javaparser/ast/expr/NormalAnnotationExpr.java
Normal file
70
src/com/github/javaparser/ast/expr/NormalAnnotationExpr.java
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class NormalAnnotationExpr extends AnnotationExpr {
|
||||||
|
|
||||||
|
private List<MemberValuePair> pairs;
|
||||||
|
|
||||||
|
public NormalAnnotationExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public NormalAnnotationExpr(final NameExpr name, final List<MemberValuePair> pairs) {
|
||||||
|
setName(name);
|
||||||
|
setPairs(pairs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NormalAnnotationExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final NameExpr name, final List<MemberValuePair> pairs) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setName(name);
|
||||||
|
setPairs(pairs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MemberValuePair> getPairs() {
|
||||||
|
pairs = ensureNotNull(pairs);
|
||||||
|
return pairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPairs(final List<MemberValuePair> pairs) {
|
||||||
|
this.pairs = pairs;
|
||||||
|
setAsParentNodeOf(this.pairs);
|
||||||
|
}
|
||||||
|
}
|
46
src/com/github/javaparser/ast/expr/NullLiteralExpr.java
Normal file
46
src/com/github/javaparser/ast/expr/NullLiteralExpr.java
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class NullLiteralExpr extends LiteralExpr {
|
||||||
|
|
||||||
|
public NullLiteralExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public NullLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
}
|
138
src/com/github/javaparser/ast/expr/ObjectCreationExpr.java
Normal file
138
src/com/github/javaparser/ast/expr/ObjectCreationExpr.java
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.body.BodyDeclaration;
|
||||||
|
import com.github.javaparser.ast.type.ClassOrInterfaceType;
|
||||||
|
import com.github.javaparser.ast.type.Type;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines constructor call expression.
|
||||||
|
* Example:
|
||||||
|
* <code>
|
||||||
|
* new Object()
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class ObjectCreationExpr extends Expression {
|
||||||
|
|
||||||
|
private Expression scope;
|
||||||
|
|
||||||
|
private ClassOrInterfaceType type;
|
||||||
|
|
||||||
|
private List<Type> typeArgs;
|
||||||
|
|
||||||
|
private List<Expression> args;
|
||||||
|
|
||||||
|
// This can be null, to indicate there is no body
|
||||||
|
private List<BodyDeclaration> anonymousClassBody;
|
||||||
|
|
||||||
|
public ObjectCreationExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a call to a constructor.
|
||||||
|
* @param scope may be null
|
||||||
|
* @param type this is the class that the constructor is being called for.
|
||||||
|
* @param args Any arguments to pass to the constructor
|
||||||
|
*/
|
||||||
|
public ObjectCreationExpr(final Expression scope, final ClassOrInterfaceType type, final List<Expression> args) {
|
||||||
|
setScope(scope);
|
||||||
|
setType(type);
|
||||||
|
setArgs(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectCreationExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final Expression scope, final ClassOrInterfaceType type, final List<Type> typeArgs,
|
||||||
|
final List<Expression> args, final List<BodyDeclaration> anonymousBody) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setScope(scope);
|
||||||
|
setType(type);
|
||||||
|
setTypeArgs(typeArgs);
|
||||||
|
setArgs(args);
|
||||||
|
setAnonymousClassBody(anonymousBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can be null, to indicate there is no body
|
||||||
|
*/
|
||||||
|
public List<BodyDeclaration> getAnonymousClassBody() {
|
||||||
|
return anonymousClassBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Expression> getArgs() {
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getScope() {
|
||||||
|
return scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassOrInterfaceType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Type> getTypeArgs() {
|
||||||
|
typeArgs = ensureNotNull(typeArgs);
|
||||||
|
return typeArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnonymousClassBody(final List<BodyDeclaration> anonymousClassBody) {
|
||||||
|
this.anonymousClassBody = anonymousClassBody;
|
||||||
|
setAsParentNodeOf(this.anonymousClassBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArgs(final List<Expression> args) {
|
||||||
|
this.args = args;
|
||||||
|
setAsParentNodeOf(this.args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScope(final Expression scope) {
|
||||||
|
this.scope = scope;
|
||||||
|
setAsParentNodeOf(this.scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(final ClassOrInterfaceType type) {
|
||||||
|
this.type = type;
|
||||||
|
setAsParentNodeOf(this.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTypeArgs(final List<Type> typeArgs) {
|
||||||
|
this.typeArgs = typeArgs;
|
||||||
|
setAsParentNodeOf(this.typeArgs);
|
||||||
|
}
|
||||||
|
}
|
64
src/com/github/javaparser/ast/expr/QualifiedNameExpr.java
Normal file
64
src/com/github/javaparser/ast/expr/QualifiedNameExpr.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class QualifiedNameExpr extends NameExpr {
|
||||||
|
|
||||||
|
private NameExpr qualifier;
|
||||||
|
|
||||||
|
public QualifiedNameExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public QualifiedNameExpr(final NameExpr scope, final String name) {
|
||||||
|
super(name);
|
||||||
|
setQualifier(scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
public QualifiedNameExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final NameExpr scope, final String name) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn, name);
|
||||||
|
setQualifier(scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NameExpr getQualifier() {
|
||||||
|
return qualifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQualifier(final NameExpr qualifier) {
|
||||||
|
this.qualifier = qualifier;
|
||||||
|
setAsParentNodeOf(this.qualifier);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class SingleMemberAnnotationExpr extends AnnotationExpr {
|
||||||
|
|
||||||
|
private Expression memberValue;
|
||||||
|
|
||||||
|
public SingleMemberAnnotationExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public SingleMemberAnnotationExpr(final NameExpr name, final Expression memberValue) {
|
||||||
|
setName(name);
|
||||||
|
setMemberValue(memberValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SingleMemberAnnotationExpr(final int beginLine, final int beginColumn, final int endLine,
|
||||||
|
final int endColumn, final NameExpr name, final Expression memberValue) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setName(name);
|
||||||
|
setMemberValue(memberValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getMemberValue() {
|
||||||
|
return memberValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberValue(final Expression memberValue) {
|
||||||
|
this.memberValue = memberValue;
|
||||||
|
setAsParentNodeOf(this.memberValue);
|
||||||
|
}
|
||||||
|
}
|
62
src/com/github/javaparser/ast/expr/StringLiteralExpr.java
Normal file
62
src/com/github/javaparser/ast/expr/StringLiteralExpr.java
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public class StringLiteralExpr extends LiteralExpr {
|
||||||
|
|
||||||
|
protected String value;
|
||||||
|
|
||||||
|
public StringLiteralExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringLiteralExpr(final String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final String value) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setValue(final String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
63
src/com/github/javaparser/ast/expr/SuperExpr.java
Normal file
63
src/com/github/javaparser/ast/expr/SuperExpr.java
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class SuperExpr extends Expression {
|
||||||
|
|
||||||
|
private Expression classExpr;
|
||||||
|
|
||||||
|
public SuperExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperExpr(final Expression classExpr) {
|
||||||
|
setClassExpr(classExpr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final Expression classExpr) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setClassExpr(classExpr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getClassExpr() {
|
||||||
|
return classExpr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClassExpr(final Expression classExpr) {
|
||||||
|
this.classExpr = classExpr;
|
||||||
|
setAsParentNodeOf(this.classExpr);
|
||||||
|
}
|
||||||
|
}
|
63
src/com/github/javaparser/ast/expr/ThisExpr.java
Normal file
63
src/com/github/javaparser/ast/expr/ThisExpr.java
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class ThisExpr extends Expression {
|
||||||
|
|
||||||
|
private Expression classExpr;
|
||||||
|
|
||||||
|
public ThisExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ThisExpr(final Expression classExpr) {
|
||||||
|
setClassExpr(classExpr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ThisExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final Expression classExpr) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setClassExpr(classExpr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getClassExpr() {
|
||||||
|
return classExpr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClassExpr(final Expression classExpr) {
|
||||||
|
this.classExpr = classExpr;
|
||||||
|
setAsParentNodeOf(this.classExpr);
|
||||||
|
}
|
||||||
|
}
|
65
src/com/github/javaparser/ast/expr/TypeExpr.java
Normal file
65
src/com/github/javaparser/ast/expr/TypeExpr.java
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.type.Type;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is just instantiated as scopes for MethodReferenceExpr nodes to encapsulate Types.
|
||||||
|
* @author Raquel Pau
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TypeExpr extends Expression{
|
||||||
|
|
||||||
|
private Type type;
|
||||||
|
|
||||||
|
public TypeExpr(){}
|
||||||
|
|
||||||
|
public TypeExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(VoidVisitor<A> v, A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Type type) {
|
||||||
|
this.type = type;
|
||||||
|
setAsParentNodeOf(this.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
86
src/com/github/javaparser/ast/expr/UnaryExpr.java
Normal file
86
src/com/github/javaparser/ast/expr/UnaryExpr.java
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class UnaryExpr extends Expression {
|
||||||
|
|
||||||
|
public static enum Operator {
|
||||||
|
positive, // +
|
||||||
|
negative, // -
|
||||||
|
preIncrement, // ++
|
||||||
|
preDecrement, // --
|
||||||
|
not, // !
|
||||||
|
inverse, // ~
|
||||||
|
posIncrement, // ++
|
||||||
|
posDecrement, // --
|
||||||
|
}
|
||||||
|
|
||||||
|
private Expression expr;
|
||||||
|
|
||||||
|
private Operator op;
|
||||||
|
|
||||||
|
public UnaryExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnaryExpr(final Expression expr, final Operator op) {
|
||||||
|
setExpr(expr);
|
||||||
|
setOperator(op);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnaryExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final Expression expr, final Operator op) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setExpr(expr);
|
||||||
|
setOperator(op);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getExpr() {
|
||||||
|
return expr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Operator getOperator() {
|
||||||
|
return op;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpr(final Expression expr) {
|
||||||
|
this.expr = expr;
|
||||||
|
setAsParentNodeOf(this.expr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOperator(final Operator op) {
|
||||||
|
this.op = op;
|
||||||
|
}
|
||||||
|
}
|
122
src/com/github/javaparser/ast/expr/VariableDeclarationExpr.java
Normal file
122
src/com/github/javaparser/ast/expr/VariableDeclarationExpr.java
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.expr;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.body.ModifierSet;
|
||||||
|
import com.github.javaparser.ast.body.VariableDeclarator;
|
||||||
|
import com.github.javaparser.ast.type.Type;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class VariableDeclarationExpr extends Expression {
|
||||||
|
|
||||||
|
private int modifiers;
|
||||||
|
|
||||||
|
private List<AnnotationExpr> annotations;
|
||||||
|
|
||||||
|
private Type type;
|
||||||
|
|
||||||
|
private List<VariableDeclarator> vars;
|
||||||
|
|
||||||
|
public VariableDeclarationExpr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public VariableDeclarationExpr(final Type type, final List<VariableDeclarator> vars) {
|
||||||
|
setType(type);
|
||||||
|
setVars(vars);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VariableDeclarationExpr(final int modifiers, final Type type, final List<VariableDeclarator> vars) {
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setType(type);
|
||||||
|
setVars(vars);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VariableDeclarationExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final int modifiers, final List<AnnotationExpr> annotations, final Type type,
|
||||||
|
final List<VariableDeclarator> vars) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setModifiers(modifiers);
|
||||||
|
setAnnotations(annotations);
|
||||||
|
setType(type);
|
||||||
|
setVars(vars);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AnnotationExpr> getAnnotations() {
|
||||||
|
annotations = ensureNotNull(annotations);
|
||||||
|
return annotations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the modifiers of this variable declaration.
|
||||||
|
*
|
||||||
|
* @see ModifierSet
|
||||||
|
* @return modifiers
|
||||||
|
*/
|
||||||
|
public int getModifiers() {
|
||||||
|
return modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<VariableDeclarator> getVars() {
|
||||||
|
vars = ensureNotNull(vars);
|
||||||
|
return vars;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnnotations(final List<AnnotationExpr> annotations) {
|
||||||
|
this.annotations = annotations;
|
||||||
|
setAsParentNodeOf(this.annotations);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModifiers(final int modifiers) {
|
||||||
|
this.modifiers = modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(final Type type) {
|
||||||
|
this.type = type;
|
||||||
|
setAsParentNodeOf(this.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVars(final List<VariableDeclarator> vars) {
|
||||||
|
this.vars = vars;
|
||||||
|
setAsParentNodeOf(this.vars);
|
||||||
|
}
|
||||||
|
}
|
40
src/com/github/javaparser/ast/internal/Utils.java
Normal file
40
src/com/github/javaparser/ast/internal/Utils.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.internal;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Federico Tomassetti
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
|
public class Utils {
|
||||||
|
public static <T> List<T> ensureNotNull(List<T> list) {
|
||||||
|
return list == null ? new ArrayList<T>() : list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <E> boolean isNullOrEmpty(Collection<E> collection) {
|
||||||
|
return collection == null || collection.isEmpty();
|
||||||
|
}
|
||||||
|
}
|
83
src/com/github/javaparser/ast/stmt/AssertStmt.java
Normal file
83
src/com/github/javaparser/ast/stmt/AssertStmt.java
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.stmt;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.expr.Expression;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class AssertStmt extends Statement {
|
||||||
|
|
||||||
|
private Expression check;
|
||||||
|
|
||||||
|
private Expression msg;
|
||||||
|
|
||||||
|
public AssertStmt() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssertStmt(final Expression check) {
|
||||||
|
setCheck(check);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssertStmt(final Expression check, final Expression msg) {
|
||||||
|
setCheck(check);
|
||||||
|
setMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssertStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final Expression check, final Expression msg) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
|
||||||
|
setCheck(check);
|
||||||
|
setMessage(msg);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getCheck() {
|
||||||
|
return check;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression getMessage() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCheck(final Expression check) {
|
||||||
|
this.check = check;
|
||||||
|
setAsParentNodeOf(this.check);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(final Expression msg) {
|
||||||
|
this.msg = msg;
|
||||||
|
setAsParentNodeOf(this.msg);
|
||||||
|
}
|
||||||
|
}
|
70
src/com/github/javaparser/ast/stmt/BlockStmt.java
Normal file
70
src/com/github/javaparser/ast/stmt/BlockStmt.java
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.stmt;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.github.javaparser.ast.internal.Utils.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class BlockStmt extends Statement {
|
||||||
|
|
||||||
|
private List<Statement> stmts;
|
||||||
|
|
||||||
|
public BlockStmt() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockStmt(final List<Statement> stmts) {
|
||||||
|
setStmts(stmts);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockStmt(final int beginLine, final int beginColumn,
|
||||||
|
final int endLine, final int endColumn, final List<Statement> stmts) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setStmts(stmts);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Statement> getStmts() {
|
||||||
|
stmts = ensureNotNull(stmts);
|
||||||
|
return stmts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStmts(final List<Statement> stmts) {
|
||||||
|
this.stmts = stmts;
|
||||||
|
setAsParentNodeOf(this.stmts);
|
||||||
|
}
|
||||||
|
}
|
61
src/com/github/javaparser/ast/stmt/BreakStmt.java
Normal file
61
src/com/github/javaparser/ast/stmt/BreakStmt.java
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.stmt;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class BreakStmt extends Statement {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
public BreakStmt() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public BreakStmt(final String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BreakStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, final String id) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(final String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
}
|
88
src/com/github/javaparser/ast/stmt/CatchClause.java
Normal file
88
src/com/github/javaparser/ast/stmt/CatchClause.java
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
|
||||||
|
* Copyright (C) 2011, 2013-2015 The JavaParser Team.
|
||||||
|
*
|
||||||
|
* This file is part of JavaParser.
|
||||||
|
*
|
||||||
|
* JavaParser can be used either under the terms of
|
||||||
|
* a) the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* b) the terms of the Apache License
|
||||||
|
*
|
||||||
|
* You should have received a copy of both licenses in LICENCE.LGPL and
|
||||||
|
* LICENCE.APACHE. Please refer to those files for details.
|
||||||
|
*
|
||||||
|
* JavaParser is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.javaparser.ast.stmt;
|
||||||
|
|
||||||
|
import com.github.javaparser.ast.Node;
|
||||||
|
import com.github.javaparser.ast.body.MultiTypeParameter;
|
||||||
|
import com.github.javaparser.ast.body.VariableDeclaratorId;
|
||||||
|
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||||
|
import com.github.javaparser.ast.type.Type;
|
||||||
|
import com.github.javaparser.ast.visitor.GenericVisitor;
|
||||||
|
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Julio Vilmar Gesser
|
||||||
|
*/
|
||||||
|
public final class CatchClause extends Node {
|
||||||
|
|
||||||
|
private MultiTypeParameter except;
|
||||||
|
|
||||||
|
private BlockStmt catchBlock;
|
||||||
|
|
||||||
|
public CatchClause() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public CatchClause(final MultiTypeParameter except, final BlockStmt catchBlock) {
|
||||||
|
setExcept(except);
|
||||||
|
setCatchBlock(catchBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CatchClause(int exceptModifier, List<AnnotationExpr> exceptAnnotations, List<Type> exceptTypes, VariableDeclaratorId exceptId, BlockStmt catchBlock) {
|
||||||
|
this(new MultiTypeParameter(exceptModifier, exceptAnnotations, exceptTypes, exceptId), catchBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CatchClause(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
|
||||||
|
final int exceptModifier, final List<AnnotationExpr> exceptAnnotations, final List<Type> exceptTypes,
|
||||||
|
final VariableDeclaratorId exceptId, final BlockStmt catchBlock) {
|
||||||
|
super(beginLine, beginColumn, endLine, endColumn);
|
||||||
|
setExcept(new MultiTypeParameter(beginLine, beginColumn, endLine, endColumn, exceptModifier, exceptAnnotations, exceptTypes, exceptId));
|
||||||
|
setCatchBlock(catchBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
|
||||||
|
return v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public <A> void accept(final VoidVisitor<A> v, final A arg) {
|
||||||
|
v.visit(this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockStmt getCatchBlock() {
|
||||||
|
return catchBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MultiTypeParameter getExcept() {
|
||||||
|
return except;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCatchBlock(final BlockStmt catchBlock) {
|
||||||
|
this.catchBlock = catchBlock;
|
||||||
|
setAsParentNodeOf(this.catchBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExcept(final MultiTypeParameter except) {
|
||||||
|
this.except = except;
|
||||||
|
setAsParentNodeOf(this.except);
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user