Compare commits

..
Author SHA1 Message Date
Eberhard Graether 9550ea1fdc delta time for loader 2016-07-08 14:37:49 +02:00
Eberhard Graether cad473c097 started with delay 2016-07-08 14:37:49 +02:00
Eberhard Graether 89264d97bb in code view 2016-07-08 14:37:49 +02:00
Eberhard Graether 096291a6c4 fixed animation 2016-07-08 14:37:49 +02:00
Eberhard Graether 1fcb241189 View interface 2016-07-08 14:37:49 +02:00
Eberhard Graether 996b33b1fb overlay for code view 2016-07-08 14:37:49 +02:00
Eberhard Graether fea26bfc60 animated loader with circles 2016-07-08 14:37:49 +02:00
Eberhard Graether 6a3717b8c1 basic overlay for graph view 2016-07-08 14:37:49 +02:00
947 changed files with 19849 additions and 96640 deletions
+1 -6
View File
@@ -5,7 +5,6 @@
/bin/app/Debug/
/bin/app/Release/
/bin/app/data/projects/ignored/
/bin/app/data/java/
/bin/app/user/log/
/bin/app/user/ApplicationSettings.xml
/bin/app/user/window_settings.ini
@@ -24,10 +23,7 @@
/bin/test/data/temp.xml
/bin/test/data/TestSettings.xml
/java_indexer/bin/
/java_indexer/lib/
/setup/Linux/lib/
/setup/Linux/lib/*
.DS_Store
.idea
@@ -71,4 +67,3 @@ Makefile
/deployment/windows/CoatiTrialSetup/SetupRemoveCacheFiles/bin/
/deployment/windows/CoatiTrialSetup/SetupRemoveCacheFiles/obj/
/deployment/windows/wixSetup/
+153 -61
View File
@@ -12,10 +12,10 @@ include(cmake/licenses.cmake)
set(PROJECT_NAME Coati)
set(APP_PROJECT_NAME "${PROJECT_NAME}")
set(TRIAL_PROJECT_NAME "${PROJECT_NAME}_trial")
set(LIB_LICENSE_PROJECT_NAME "${PROJECT_NAME}_lib_license")
set(LIB_GUI_PROJECT_NAME "${PROJECT_NAME}_lib_gui")
set(LIB_CXX_PROJECT_NAME "${PROJECT_NAME}_lib_cxx")
set(LIB_JAVA_PROJECT_NAME "${PROJECT_NAME}_lib_java")
set(LIB_PARSER_PROJECT_NAME "${PROJECT_NAME}_lib_parser")
set(LIB_PROJECT_NAME "${PROJECT_NAME}_lib")
set(LICENSE_GENERATOR_PROJECT_NAME "${PROJECT_NAME}_license_generator")
set(TEST_PROJECT_NAME "${PROJECT_NAME}_test")
@@ -33,12 +33,13 @@ endif ()
project(${PROJECT_NAME})
# set Standard build type to Release
# set Standerd build type to Release
set(CMAKE_BUILD_TYPE_INIT "Release")
#RPATH
if(UNIX AND NOT APPLE)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib/:$$ORIGIN/lib/")
include(cmake/external.cmake)
@@ -53,8 +54,9 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option -fcolor-diagnostics")
endif()
if (UNIX AND "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
add_definitions(-fno-omit-frame-pointer -DQT_COMPILING_QSTRING_COMPAT_CPP )
if (UNIX)
#add_definitions(-std=c++11 -Wno-unknown-warning-option -fcolor-diagnostics -DQT_COMPILING_QSTRING_COMPAT_CPP )
add_definitions(-fno-omit-frame-pointer -DQT_COMPILING_QSTRING_COMPAT_CPP )
endif ()
# Clang ------------------------------------------------------------------------
@@ -85,16 +87,25 @@ endif()
set(Boost_USE_MULTITHREAD ON)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_NO_SYSTEM_PATHS ON)
Set(Boost_NO_SYSTEM_PATHS ON)
set(BOOST_LIBRARYDIR $ENV{BOOST_159_DIR})
find_package(Boost 1.59 COMPONENTS system program_options filesystem date_time REQUIRED)
# Eigen ------------------------------------------------------------------------
add_definitions(-DEIGEN_MPL2_ONLY)
if(UNIX AND NOT APPLE)
set(EIGEN_ROOT ${EXTERNAL_SRC}/eigen)
else()
set(EIGEN_ROOT $ENV{EIGEN_DIR})
endif()
# Botan -------------------------------------------------------------------------
set(BOTAN_VERSION "botan-1.11")
if(APPLE)
if(UNIX AND APPLE)
find_library(BOTAN ${BOTAN_VERSION} $ENV{BOTAN_DIR}/release NO_DEFAULT_PATH)
find_library(BOTAN_D ${BOTAN_VERSION} $ENV{BOTAN_DIR}/debug NO_DEFAULT_PATH)
elseif(UNIX)
@@ -103,22 +114,22 @@ else()
find_library(BOTAN botan "$ENV{BOTAN_DIR}/release")
find_library(BOTAN_D botan "$ENV{BOTAN_DIR}/debug")
endif()
if(${BOTAN} STREQUAL "BOTAN-NOTFOUND")
message(FATAL_ERROR "Botan not found")
else()
message(STATUS "Botan found")
endif()
if(UNIX AND NOT APPLE)
set(BOTAN_INCLUDE_DIR "${EXTERNAL_BUILD}/botan")
else()
set(BOTAN_INCLUDE_DIR "$ENV{BOTAN_DIR}")
endif()
# Lib License -------------------------------------------------------------------
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib_license)
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib_license)
add_subdirectory(src/lib_license)
add_library(${LIB_LICENSE_PROJECT_NAME} ${LIB_LICENSE_FILES})
@@ -131,12 +142,23 @@ set_property(
"${CMAKE_SOURCE_DIR}/src/lib_license"
)
set_target_properties(
${LIB_LICENSE_PROJECT_NAME}
PROPERTIES
DEBUG_OUTPUT_NAME ${LIB_LICENSE_PROJECT_NAME}_d
RELEASE_OUTPUT_NAME ${LIB_LICENSE_PROJECT_NAME}
)
target_include_directories(${LIB_LICENSE_PROJECT_NAME} SYSTEM
PUBLIC
${Boost_INCLUDE_DIRS}
${LIB_LICENSE_PROJECT_NAME}
${BOTAN_INCLUDE_DIR}
)
# target_include_directories(${LIB_LICENSE_PROJECT_NAME} optimized "$ENV{BOTAN_DIR}/release")
# target_include_directories(${LIB_LICENSE_PROJECT_NAME} debug "$ENV{BOTAN_DIR}/debug")
if(UNIX)
target_link_libraries(${LIB_LICENSE_PROJECT_NAME} ${BOTAN})
else()
@@ -147,9 +169,11 @@ else()
target_link_libraries(${LIB_LICENSE_PROJECT_NAME} optimized ${BOTAN})
endif()
# Lib --------------------------------------------------------------------------
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib)
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib)
add_subdirectory(src/lib)
add_subdirectory(src/external)
@@ -162,44 +186,59 @@ create_source_groups(${LIB_FILES})
create_source_groups(${EXTERNAL_FILES})
create_source_groups(${EXTERNAL_C_FILES})
set_target_properties(
${LIB_PROJECT_NAME}
PROPERTIES
DEBUG_OUTPUT_NAME ${PROJECT_NAME}_d
RELEASE_OUTPUT_NAME ${PROJECT_NAME}
)
set_property(
TARGET ${LIB_PROJECT_NAME}
PROPERTY INCLUDE_DIRECTORIES
"${CMAKE_SOURCE_DIR}/src/lib"
"${CMAKE_SOURCE_DIR}/src/external"
"${CMAKE_SOURCE_DIR}/src/lib_license"
"${CMAKE_SOURCE_DIR}/src/lib_cxx"
"${CMAKE_SOURCE_DIR}/src/lib_java"
"${CMAKE_SOURCE_DIR}/build/src/lib_license"
)
target_include_directories(${LIB_PROJECT_NAME} SYSTEM
PUBLIC ${Boost_INCLUDE_DIRS}
PUBLIC ${LLVM_INCLUDE_DIRS}
${CLANG_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${EIGEN_ROOT}
"${CMAKE_SOURCE_DIR}/src/external"
)
target_link_libraries(${LIB_PROJECT_NAME} ${Boost_LIBRARIES} ${LIB_LICENSE_PROJECT_NAME})
# Lib Parser -------------------------------------------------------------------
# Lib Cxx -------------------------------------------------------------------
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib_parser)
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib_parser)
add_subdirectory(src/lib_cxx)
add_subdirectory(src/lib_parser)
set_source_files_properties(${CLANG_FILES} PROPERTIES COMPILE_FLAGS "-fno-rtti")
add_library(${LIB_CXX_PROJECT_NAME} ${CLANG_FILES} ${LIB_CXX_FILES})
add_library(${LIB_PARSER_PROJECT_NAME} ${CLANG_FILES})
create_source_groups(${CLANG_FILES})
create_source_groups(${LIB_CXX_FILES})
set_property(
TARGET ${LIB_CXX_PROJECT_NAME}
TARGET ${LIB_PARSER_PROJECT_NAME}
PROPERTY INCLUDE_DIRECTORIES
"${CMAKE_SOURCE_DIR}/src/lib_cxx"
"${CMAKE_SOURCE_DIR}/src/lib_parser"
"${CMAKE_SOURCE_DIR}/src/lib"
)
target_include_directories(${LIB_CXX_PROJECT_NAME} SYSTEM
set_target_properties(
${LIB_PARSER_PROJECT_NAME}
PROPERTIES
DEBUG_OUTPUT_NAME ${LIB_PARSER_PROJECT_NAME}_d
RELEASE_OUTPUT_NAME ${LIB_PARSER_PROJECT_NAME}
)
target_include_directories(${LIB_PARSER_PROJECT_NAME} SYSTEM
PUBLIC ${LLVM_INCLUDE_DIRS}
${CLANG_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
@@ -208,36 +247,13 @@ target_include_directories(${LIB_CXX_PROJECT_NAME} SYSTEM
link_directories(${LLVM_LIBRARY_DIRS} ${CLANG_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS})
llvm_map_components_to_libnames(REQ_LLVM_LIBS support core libdriver)
target_link_libraries(${LIB_CXX_PROJECT_NAME} ${CLANG_LIBRARIES} ${REQ_LLVM_LIBS})
# Lib Java -------------------------------------------------------------------
find_package(JNI)
add_subdirectory(src/lib_java)
add_library(${LIB_JAVA_PROJECT_NAME} ${LIB_JAVA_FILES})
create_source_groups(${LIB_JAVA_FILES})
set_property(
TARGET ${LIB_JAVA_PROJECT_NAME}
PROPERTY INCLUDE_DIRECTORIES
"${CMAKE_SOURCE_DIR}/src/lib_java"
"${CMAKE_SOURCE_DIR}/src/lib"
)
target_include_directories(${LIB_JAVA_PROJECT_NAME} SYSTEM
PUBLIC ${JNI_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
)
link_directories(${Boost_LIBRARY_DIRS})
target_link_libraries(${LIB_PARSER_PROJECT_NAME} ${CLANG_LIBRARIES} ${REQ_LLVM_LIBS})
# Lib Gui ----------------------------------------------------------------------
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib_gui)
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib_gui)
add_subdirectory(src/lib_gui)
# Find includes in corresponding build directories
@@ -294,17 +310,24 @@ create_source_groups(${LIB_GUI_FILES})
set_property(
TARGET ${LIB_GUI_PROJECT_NAME}
PROPERTY INCLUDE_DIRECTORIES
"${CMAKE_SOURCE_DIR}/src/lib_gui"
"${CMAKE_SOURCE_DIR}/build/src/lib_gui"
"${CMAKE_SOURCE_DIR}/src/lib"
"${CMAKE_SOURCE_DIR}/src/lib_cxx"
"${CMAKE_SOURCE_DIR}/src/lib_gui"
"${CMAKE_SOURCE_DIR}/src/lib_license"
"${CMAKE_SOURCE_DIR}/build/src/lib_license"
)
set_target_properties(
${LIB_GUI_PROJECT_NAME}
PROPERTIES
DEBUG_OUTPUT_NAME ${LIB_GUI_PROJECT_NAME}_d
RELEASE_OUTPUT_NAME ${LIB_GUI_PROJECT_NAME}
)
# include external header without warnings
target_include_directories(${LIB_GUI_PROJECT_NAME} SYSTEM
PUBLIC "${CMAKE_SOURCE_DIR}/src/external"
PUBLIC ${BOTAN_INCLUDE_DIR}
PUBLIC ${Boost_INCLUDE_DIRS}
)
@@ -349,7 +372,7 @@ if (WIN32)
"IDI_ICON1 ICON \"${CMAKE_SOURCE_DIR}/build/coati.ico\"\n"
)
add_executable(${APP_PROJECT_NAME} ${APP_FILES} ${CMAKE_SOURCE_DIR}/build/Coati.rc)
add_executable(${APP_PROJECT_NAME} ${APP_FILES} ${CLANG_FILES} ${GEN_FILES} ${CMAKE_SOURCE_DIR}/build/Coati.rc)
# hide the console when running a release build.
set_target_properties(${APP_PROJECT_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
@@ -359,12 +382,12 @@ if (WIN32)
set_target_properties(${APP_PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "/ENTRY:\"mainCRTStartup\" /SUBSYSTEM:WINDOWS")
set_target_properties(${APP_PROJECT_NAME} PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS")
else ()
add_executable(${APP_PROJECT_NAME} ${APP_FILES})
add_executable(${APP_PROJECT_NAME} ${APP_FILES} ${GEN_FILES})
endif ()
create_source_groups(${APP_FILES})
target_link_libraries(${APP_PROJECT_NAME} ${LIB_GUI_PROJECT_NAME} ${LIB_CXX_PROJECT_NAME} ${LIB_JAVA_PROJECT_NAME} ${LIB_PROJECT_NAME} ${LIB_LICENSE_PROJECT_NAME})
target_link_libraries(${APP_PROJECT_NAME} ${LIB_GUI_PROJECT_NAME} ${LIB_PARSER_PROJECT_NAME} ${LIB_PROJECT_NAME} ${LIB_LICENSE_PROJECT_NAME})
set_property(
TARGET ${APP_PROJECT_NAME}
@@ -373,11 +396,10 @@ set_property(
"${CMAKE_SOURCE_DIR}/src/lib"
"${CMAKE_SOURCE_DIR}/src/lib_gui"
"${CMAKE_SOURCE_DIR}/src/lib_license"
"${CMAKE_SOURCE_DIR}/src/lib_cxx"
"${CMAKE_SOURCE_DIR}/src/lib_java"
"${CMAKE_SOURCE_DIR}/src/lib_parser"
"${CMAKE_SOURCE_DIR}/build/src/lib_gui"
"${CMAKE_SOURCE_DIR}/build/src/lib_license"
#"${CMAKE_SOURCE_DIR}/build/src/app"
"${CMAKE_SOURCE_DIR}/build/src/app"
)
target_include_directories(${APP_PROJECT_NAME} SYSTEM
@@ -395,6 +417,71 @@ if (APPLE)
target_link_libraries(${APP_PROJECT_NAME} ${CORE_FOUNDATION})
endif ()
# Trial ---------------------------------------------------------------------
if (UNIX)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/app/${CMAKE_BUILD_TYPE})
else ()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/app/)
endif ()
add_subdirectory(src/trial)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
if (WIN32)
file(WRITE ${CMAKE_SOURCE_DIR}/build/Coati.rc
"// Icon with lowest ID value placed first to ensure application icon\n"
"// remains consistent on all systems.\n"
"IDI_ICON1 ICON \"${CMAKE_SOURCE_DIR}/build/coati.ico\"\n"
)
add_executable(${TRIAL_PROJECT_NAME} ${TRIAL_FILES} ${CMAKE_SOURCE_DIR}/build/Coati.rc)
# hide the console when running a release build.
set_target_properties(${TRIAL_PROJECT_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
set_target_properties(${TRIAL_PROJECT_NAME} PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE")
set_target_properties(${TRIAL_PROJECT_NAME} PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
set_target_properties(${TRIAL_PROJECT_NAME} PROPERTIES COMPILE_DEFINITIONS_RELWITHDEBINFO "_CONSOLE")
set_target_properties(${TRIAL_PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "/ENTRY:\"mainCRTStartup\" /SUBSYSTEM:WINDOWS")
set_target_properties(${TRIAL_PROJECT_NAME} PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS")
else ()
add_executable(${TRIAL_PROJECT_NAME} ${TRIAL_FILES} ${GEN_FILES})
endif ()
create_source_groups(${TRIAL_FILES})
target_link_libraries(${TRIAL_PROJECT_NAME} ${LIB_GUI_PROJECT_NAME} ${LIB_PROJECT_NAME} ${LIB_LICENSE_PROJECT_NAME} )
if(UNIX AND NOT APPLE)
target_link_libraries(${TRIAL_PROJECT_NAME} pthread dl rt)
endif()
set_property(
TARGET ${TRIAL_PROJECT_NAME}
PROPERTY INCLUDE_DIRECTORIES
"${CMAKE_SOURCE_DIR}/src/trial"
"${CMAKE_SOURCE_DIR}/src/lib"
"${CMAKE_SOURCE_DIR}/src/lib_gui"
"${CMAKE_SOURCE_DIR}/build/src/lib_gui"
"${CMAKE_SOURCE_DIR}/build/src/lib_license"
)
target_include_directories(${TRIAL_PROJECT_NAME} SYSTEM
PUBLIC "${CMAKE_SOURCE_DIR}/src/external"
PUBLIC ${Boost_INCLUDE_DIRS}
)
# Use the Widgets module from Qt 5.
qt5_use_modules(${TRIAL_PROJECT_NAME} Widgets)
qt5_use_modules(${TRIAL_PROJECT_NAME} Network)
# add platform specific libraries
if (APPLE)
find_library(CORE_FOUNDATION CoreFoundation)
target_link_libraries(${TRIAL_PROJECT_NAME} ${CORE_FOUNDATION})
endif ()
# MacOSX Bundle ----------------------------------------------------------------
@@ -438,6 +525,12 @@ if (APPLE)
@ONLY
)
configure_file(
${PROJECT_SOURCE_DIR}/setup/MacOSX/Info_trial.plist.in
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/bundle_info_trial.plist
@ONLY
)
endif ()
# License Generator --------------------------------------------------------
@@ -494,7 +587,7 @@ add_executable (${TEST_PROJECT_NAME} ${TESTGEN_FILE} ${TEST_FILES} )
create_source_groups(${TEST_FILES})
target_link_libraries(${TEST_PROJECT_NAME} ${LIB_CXX_PROJECT_NAME} ${LIB_JAVA_PROJECT_NAME} ${LIB_PROJECT_NAME} ${LIB_LICENSE_PROJECT_NAME})
target_link_libraries(${TEST_PROJECT_NAME} ${LIB_PARSER_PROJECT_NAME} ${LIB_PROJECT_NAME} ${LIB_LICENSE_PROJECT_NAME})
find_package(CxxTest)
if (CXXTEST_FOUND)
@@ -503,11 +596,10 @@ if (CXXTEST_FOUND)
PROPERTY INCLUDE_DIRECTORIES
"${CXXTEST_INCLUDE_DIR}"
"${CMAKE_SOURCE_DIR}/src/lib"
"${CMAKE_SOURCE_DIR}/src/lib_cxx"
"${CMAKE_SOURCE_DIR}/src/lib_java"
"${CMAKE_SOURCE_DIR}/src/lib_parser"
"${CMAKE_SOURCE_DIR}/src/external"
"${CMAKE_SOURCE_DIR}/src/lib_license"
"${Boost_INCLUDE_DIRS}"
${Boost_INCLUDE_DIRS}
)
endif (CXXTEST_FOUND)
+3 -84
View File
@@ -1,4 +1,4 @@
## Coati
## Masterproject
### Setup
@@ -9,6 +9,7 @@
* Valgrind 3.9.0 (linux)
* Clang & LLVM 3.8 (doesnt quite work for windows, use unix setup below and skip all the ninja stuff)(installation guide http://clang.llvm.org/docs/LibASTMatchersTutorial.html)
* Boost 1.59
* Eigen 3.2.6
* Botan 1.11.24
#### Environment Variables
@@ -17,6 +18,7 @@
* CXX_TEST_DIR - .../cxxtest-4.3
* CLANG_DIR - .../clang-llvm
* BOOST_159_DIR - .../boost_1_59_0
* EIGEN_DIR - .../eigen
* BOTAN_DIR - .../Botan-1.11.24
For Win32:
@@ -90,91 +92,8 @@ $ ninja -j4 check-all
$ git tag -a VERSION_NUMBER -m "DESCRIPTION"
$ git push --tags
### Loader gif creation from png sequence
// from png sequence
convert -delay 3 -loop 0 coati_*.png coati.gif
// less colors
gifsicle --colors 255 coati.gif > color.gif
// crop size
gifsicle --crop 0,5+0x-5 color.gif > crop.gif
// add transparency
gifsicle --unoptimize --disposal=previous --transparent="#FFFFFF" crop.gif > trans.gif
// resize
gifsicle --resize-height 18 trans.gif > loader.gif
### Changelog
#### 0.8.21
released 2016-09-16
* Added options for checking multiple paths in Indexed Header Paths dialog during project setup from Compilation Database #190
* Added all C/C++ standards supported by clang
* Fixed C language setting in empty project setup not propagated to indexer #177
* Added Sublime plugin to Sublime Text Package Control
* Improved indexer parallelization for faster indexing
* Changed all font-sizes to px for similar look on all platforms
* Added font face dropdown to Preferences showing all available monospace fonts #172
* Smoother font rendering on Windows by setting font engine to FreeType via qt.conf file #137
* Interrupt indexing while AST visiting for C/C++ for shorter waiting time
* Save graph as PNG image via context menu in graph view #180
* Added base folder to Linux package #181
* Use inverted golden ratio in indexing progress dialog
#### 0.8.0
released 2016-09-01
* Improved titles and help texts in project setup UI
* Fixed error locations not saved with absolute file paths in Compilation Database projects
* Added missing source files extensions setting to the Edit Project dialog #132
* Changed default text colors to black in project setup UI #140
* Added plugin ports settings to Preferences #145
* Improved project state handling on refreshing
* Added Java sample project JavaParser: http://javaparser.org/
* Fixed regex for system includes used wrongly in syntax highlighter
* Added setting to disable file and console logging, default is off #157
* Added migrations between different ApplicationSettings versions
* Added auto detection for Java library to Preferences
* Removed auto refresh option from Search view
* Added progress dialogs for indexing and block UI #143
* Hide name qualifiers for graph nodes in Java projects
* Added handling when java library not found
* Added plain text editing dialog to path list boxes
* Use language dependent symbol name delimiter in UI
* Added scroll speed setting to preferences #112
* Added Java project setup UI
* Record start and end locations of scopes in Java
* Display unresolved types names in Java as 'unresolved-type'
* Cache stats for overview to speed up display
* Fixed graph nodes to restore their expand state when going back #118
* Added shortcuts for navigating to next and previous reference in code view
* Pressing Tab in search completes up to next ::, Delete erases to last :: #133
* Bundle anonymous namespaces separately in graph overview #126
* Added 'Show Data Folder' and 'Show Log Folder' items to Help menu
* Added new status bar loader gif with higher resolution
* Record type aliases in C++
* Added Java indexer
* Changed public icon in graph and added default icon
* Scroll to file location when finding no symbol at specified location from plugin message
* Added shortcut for Preferences on Windows/Linux
* Leave code view at original line when expanding scopes
* Pan graph view to center on name of active symbol after activation
* Moved color scheme selection to Preferences
* Moved Preferences menu item to Edit menu on Windows/Linux #113
* Added setting for hiding non-fatal errors in unindexed files to preferences, turned on by default
* Fixed file out-of-date asterisk disappearing when showing snippets after minimize state
* Implemented Atom plugin: https://github.com/CoatiSoftware/atom-coati
* Implemented CLion/IntelliJ plugin: https://github.com/CoatiSoftware/idea-coati
* Implemented Eclipse plugin: https://github.com/CoatiSoftware/eCoati
* Implemented emacs plugin: https://github.com/CoatiSoftware/emacs-coati
* Improved code view rendering times
* Don't show implicit nodes in search auto completion list
#### 0.7.0.22
released 2016-07-07
@@ -7,8 +7,6 @@
<!-- COLOR: int int int int - rgba e.g. 125 125 125 255 -->
<config>
<version><!-- INTEGER: Version number --></version>
<info>
<description><!-- STRING: optional description shown in overview. Symbols can be linked with syntax [main] --></description>
</info>
-4
View File
@@ -173,14 +173,11 @@
<!-- OPTIONAL: type specific node colors can be overriden by using the TEMPLATE within a type tag below -->
<type></type>
<builtin_type></builtin_type>
<class></class>
<interface></interface>
<struct></struct>
<enum></enum>
<typedef></typedef>
<template_parameter_type></template_parameter_type>
<type_parameter></type_parameter>
<function></function>
<method></method>
@@ -191,7 +188,6 @@
<undefined></undefined>
<namespace></namespace>
<package></package>
<file></file>
<macro></macro>
+9 -56
View File
@@ -100,9 +100,7 @@
<line_number>
<text>#C4C4C4</text>
<inactive_text>#A0A0A0</inactive_text>
<background>#494949</background>
<marker>#C4C4C4</marker>
</line_number>
<syntax>
@@ -117,11 +115,6 @@
</syntax>
<selection>
<text>black</text>
<background>#CCCCCC</background>
</selection>
<annotation>
<token>
<normal>
<border>transparent</border>
@@ -174,11 +167,8 @@
<fill>#C2AFEF</fill>
<text>#3D3D3D</text>
</normal>
<focus>
<fill>#987CEA</fill>
</focus>
</fulltext>
</annotation>
</selection>
</snippet>
</code>
@@ -216,15 +206,9 @@
<normal>#FFFFFF</normal>
</icon>
</type>
<builtin_type>
<like>type</like>
</builtin_type>
<class>
<like>type</like>
</class>
<interface>
<like>type</like>
</interface>
<struct>
<like>type</like>
</struct>
@@ -237,9 +221,6 @@
<template_parameter_type>
<like>type</like>
</template_parameter_type>
<type_parameter>
<like>type</like>
</type_parameter>
<function>
<fill>
@@ -279,9 +260,6 @@
</enum_constant>
<undefined>
<like>type</like>
</undefined>
<namespace>
<fill>
<normal>#EE7326</normal>
<focus>#EE8A4C</focus>
@@ -290,10 +268,10 @@
<normal>#80FFFFFF</normal>
<focus>#FFFFFF</focus>
</border>
</undefined>
<namespace>
<like>undefined</like>
</namespace>
<package>
<like>namespace</like>
</package>
<file>
<fill>
@@ -364,21 +342,18 @@
<normal>#2A6484</normal>
</use>
<template_parameter>
<normal>#C1305D</normal>
</template_parameter>
<template_argument>
<normal>#C1305D</normal>
</template_argument>
<type_argument>
<like>template_argument</like>
</type_argument>
<template_default_argument>
<like>template_argument</like>
<normal>#C1305D</normal>
</template_default_argument>
<template_specialization>
<like>template_argument</like>
<normal>#C1305D</normal>
</template_specialization>
<template_member_specialization>
<like>template_argument</like>
</template_member_specialization>
<include>
<normal>#4E82F6</normal>
@@ -393,26 +368,4 @@
</aggregation>
</edge>
</graph>
<error>
<background>#494949</background>
<table>#C4C4C4</table>
<text>
<normal>#C4C4C4</normal>
<active>black</active>
</text>
<table_line_1>
<normal>#494949</normal>
<active>#7B7B7B</active>
</table_line_1>
<table_line_2>
<normal>#383838</normal>
<active>#7B7B7B</active>
</table_line_2>
</error>
<tab>
<background>#494949</background>
<active>#C4C4C4</active>
<hover>#878787</hover>
<text>#878787</text>
</tab>
</config>
+11 -55
View File
@@ -100,9 +100,7 @@
<line_number>
<text>black</text>
<inactive_text>#A0A0A0</inactive_text>
<background>white</background>
<marker>#A0A0A0</marker>
</line_number>
<syntax>
@@ -117,11 +115,6 @@
</syntax>
<selection>
<text>black</text>
<background>#E0E0E0</background>
</selection>
<annotation>
<token>
<normal>
<border>transparent</border>
@@ -172,11 +165,8 @@
<fill>#C7C7E2</fill>
<text>#000000</text>
</normal>
<focus>
<fill>#ABABDD</fill>
</focus>
</fulltext>
</annotation>
</selection>
</snippet>
</code>
@@ -208,15 +198,9 @@
<focus>#3C3C3C</focus>
</border>
</type>
<builtin_type>
<like>type</like>
</builtin_type>
<class>
<like>type</like>
</class>
<interface>
<like>type</like>
</interface>
<struct>
<like>type</like>
</struct>
@@ -229,9 +213,6 @@
<template_parameter_type>
<like>type</like>
</template_parameter_type>
<type_parameter>
<like>type</like>
</type_parameter>
<function>
<fill>
@@ -265,9 +246,6 @@
</enum_constant>
<undefined>
<like>type</like>
</undefined>
<namespace>
<fill>
<normal>#CC8D91</normal>
</fill>
@@ -275,10 +253,10 @@
<normal>#803C3C3C</normal>
<focus>#3C3C3C</focus>
</border>
</undefined>
<namespace>
<like>undefined</like>
</namespace>
<package>
<like>namespace</like>
</package>
<file>
<fill>
@@ -337,20 +315,20 @@
<normal>#3190BA</normal>
</use>
<template_argument>
<template_parameter>
<normal>#C1305D</normal>
</template_parameter>
<template_argument>
<like>template_parameter</like>
</template_argument>
<type_argument>
<like>template_argument</like>
</type_argument>
<template_default_argument>
<like>template_argument</like>
<like>template_parameter</like>
</template_default_argument>
<template_specialization>
<like>template_argument</like>
<like>template_parameter</like>
</template_specialization>
<template_member_specialization>
<like>template_argument</like>
<like>template_parameter</like>
</template_member_specialization>
<aggregation>
@@ -359,26 +337,4 @@
</aggregation>
</edge>
</graph>
<error>
<background>white</background>
<table>#aaa</table>
<text>
<normal>black</normal>
<active>white</active>
</text>
<table_line_1>
<normal>white</normal>
<active>grey</active>
</table_line_1>
<table_line_2>
<normal>#F1F1F1</normal>
<active>grey</active>
</table_line_2>
</error>
<tab>
<background>white</background>
<active>black</active>
<hover>#878787</hover>
<text>#878787</text>
</tab>
</config>
+30 -60
View File
@@ -119,9 +119,7 @@
<line_number>
<text>#F7F7F7</text>
<inactive_text>#A0A0A0</inactive_text>
<background>#272728</background>
<marker>#969696</marker>
</line_number>
<syntax>
@@ -136,11 +134,6 @@
</syntax>
<selection>
<text>white</text>
<background>#777777</background>
</selection>
<annotation>
<token>
<normal>
<border>transparent</border>
@@ -193,12 +186,8 @@
<fill>#207EA8</fill>
<text>#F7F7F7</text>
</normal>
<focus>
<border>#006D93</border>
<fill>#134B63</fill>
</focus>
</fulltext>
</annotation>
</selection>
</snippet>
</code>
@@ -230,30 +219,36 @@
<focus>#C3C3C3</focus>
</border>
</type>
<builtin_type>
<like>type</like>
</builtin_type>
<class>
<like>type</like>
<border>
<normal>#20C3C3C3</normal>
<focus>#C3C3C3</focus>
</border>
</class>
<interface>
<like>type</like>
</interface>
<struct>
<like>type</like>
<border>
<normal>#20C3C3C3</normal>
<focus>#C3C3C3</focus>
</border>
</struct>
<enum>
<like>type</like>
<border>
<normal>#20C3C3C3</normal>
<focus>#C3C3C3</focus>
</border>
</enum>
<typedef>
<like>type</like>
<border>
<normal>#20C3C3C3</normal>
<focus>#C3C3C3</focus>
</border>
</typedef>
<template_parameter_type>
<like>type</like>
<border>
<normal>#20C3C3C3</normal>
<focus>#C3C3C3</focus>
</border>
</template_parameter_type>
<type_parameter>
<like>type</like>
</type_parameter>
<function>
<fill>
@@ -287,9 +282,6 @@
</enum_constant>
<undefined>
<like>type</like>
</undefined>
<namespace>
<fill>
<normal>#78282D</normal>
</fill>
@@ -297,10 +289,10 @@
<normal>#80C3C3C3</normal>
<focus>#C3C3C3</focus>
</border>
</undefined>
<namespace>
<like>undefined</like>
</namespace>
<package>
<like>namespace</like>
</package>
<file>
<fill>
@@ -359,20 +351,20 @@
<normal>#2A6484</normal>
</use>
<template_parameter>
<normal>#C1305D</normal>
</template_parameter>
<template_argument>
<normal>#C1305D</normal>
</template_argument>
<type_argument>
<like>template_argument</like>
</type_argument>
<template_default_argument>
<like>template_argument</like>
<normal>#C1305D</normal>
</template_default_argument>
<template_specialization>
<like>template_argument</like>
<normal>#C1305D</normal>
</template_specialization>
<template_member_specialization>
<like>template_argument</like>
<normal>#C1305D</normal>
</template_member_specialization>
<include>
@@ -388,26 +380,4 @@
</aggregation>
</edge>
</graph>
<error>
<background>#272728</background>
<table>white</table>
<text>
<normal>white</normal>
<active>black</active>
</text>
<table_line_1>
<normal>darkgrey</normal>
<active>#969696</active>
</table_line_1>
<table_line_2>
<normal>#343434</normal>
<active>#969696</active>
</table_line_2>
</error>
<tab>
<background>#272728</background>
<active>white</active>
<hover>#878787</hover>
<text>#878787</text>
</tab>
</config>
+1 -1
View File
@@ -8,7 +8,7 @@
background: transparent;
border: none;
color: white;
font-size: 14px;
font-size: 14pt;
height: 24px;
width: 24px;
}
+10 -12
View File
@@ -1,4 +1,4 @@
#code_container, #code_file_list {
#code_file_list_base, #code_file_list {
background-color: <color:code/background>;
}
@@ -8,7 +8,7 @@
border-radius: 12px;
border-top-left-radius: 14px;
border-top-right-radius: 14px;
font-size: <setting:font_size>px;
font-size: <setting:font_size>pt;
padding-bottom: 7px;
}
@@ -16,7 +16,7 @@
background-color: <color:code/file/background>;
border-top-left-radius: 7px;
border-top-right-radius: 7px;
font-size: <setting:font_size>px;
font-size: <setting:font_size>pt;
padding-right: 5px;
}
@@ -25,7 +25,7 @@
border: none;
border-radius: 3px;
color: <color:code/file/title/text>;
font-size: <setting:font_size>px;
font-size: <setting:font_size>pt;
padding: 2px 4px;
margin: 1px 8px 3px;
}
@@ -43,7 +43,7 @@
border: none;
border-radius: 10px;
color: <color:code/file/ref_count/text>;
font-size: <setting:font_size-2>px;
font-size: <setting:font_size-2>pt;
padding: 0px 3px;
margin: 4px 0px 4px;
}
@@ -51,7 +51,7 @@
#code_file #code_snippet {
background-color: <color:code/snippet/background>;
border-top: 2px solid <color:code/file/background>;
font-size: <setting:font_size>px;
font-size: <setting:font_size>pt;
}
#code_file #code_snippet[isFirst=true] {
@@ -64,7 +64,7 @@
border: none;
color: <color:code/snippet/title/text>;
font-family: "<setting:font_name>";
font-size: <setting:font_size>px;
font-size: <setting:font_size>pt;
}
#code_file #code_snippet #scope_name:hover {
@@ -73,7 +73,7 @@
#code_file #code_snippet #dots {
background-color: <color:code/snippet/line_number/background>;
padding-right: 16px;
padding-right: 13px;
text-align: right;
}
@@ -87,16 +87,14 @@
border: none;
color: <color:code/snippet/line_number/text>;
font-family: "<setting:font_name>";
font-size: <setting:font_size>px;
font-size: <setting:font_size>pt;
}
#code_area {
background-color: transparent;
color: <color:code/snippet/syntax/normal>;
font-family: "<setting:font_name>";
font-size: <setting:font_size>px;
selection-color: <color:code/snippet/selection/text>;
selection-background-color: <color:code/snippet/selection/background>;
font-size: <setting:font_size>pt;
}
#code_file #maximize_button, #code_file #snippet_button, #code_file #minimize_button {
@@ -1,90 +0,0 @@
QTableView {
color: <color:error/text/normal>;
background-color: <color:error/table_line_1/normal>;
alternate-background-color: <color:error/table_line_2/normal>;
border-radius: 10px;
border: 1px solid <color:error/table>;
margin: 10px;
padding-right: 10px;
font-size: <setting:font_size>px;
}
QFrame {
background-color: <color:error/background>;
}
QTableView::item {
border-left: 1px solid <color:error/table>;
}
QTableView::item:selected {
color: <color:error/text/active>;
background-color: <color:error/table_line_1/active>;
alternate-background-color: <color:error/table_line_2/active>;
}
QHeaderView {
background-color: transparent;
}
QHeaderView::section:horizontal {
background-color: transparent;
border: none;
border-bottom: 1px solid <color:error/table>;
border-left: 1px solid <color:error/table>;
color: <color:error/text/normal>;
font-size: <setting:font_size>px;
font-weight: bold;
padding: 1px 6px;
height: <setting:font_size+5>px;;
}
QCheckBox {
color: <color:error/text/normal>;
border-color: <color:error/table>;
/*background-color: <color:error/table>;*/
}
QHeaderView::section:vertical {
background-color: transparent;
border: none;
color: <color:error/text/normal>;
font-size: <setting:font_size>px;
padding-right: 5px;
padding-left: 5px;
}
QScrollBar:vertical {
}
QScrollBar::handle:vertical {
min-height: 20px;
}
QScrollBar::add-line:vertical {
height: 20px;
subcontrol-position: bottom;
subcontrol-origin: margin;
}
QScrollBar::sub-line:vertical {
height: 20px;
subcontrol-position: top;
subcontrol-origin: margin;
}
QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {
width: 3px;
height: 3px;
background: white;
}
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
background: none;
}
QTableView QTableCornerButton::section {
background-color: <color:error/background>;
border-bottom: 1px solid <color:error/table>;
border-top-left-radius: 10px;
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 532 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

@@ -1,57 +0,0 @@
QLabel {
color: white;
}
#topHalf {
background: #007AC2;
border-top-left-radius: 15px;
border-top-right-radius: 15px;
}
#title {
color: white;
font-size: 22px;
font-weight: bold;
}
#percent {
font-size: 22px;
font-weight: bold;
}
#message {
font-size: 14px;
font-weight: bold;
}
#filePath {
font-size: 11px;
}
#errorCount {
border: none;
background: transparent;
color: white;
font-size: 14px;
}
#windowButton {
background: transparent;
border: 1px solid white;
color: white;
}
#windowButton:hover {
background: transparent;
border: 1px solid white;
color: white;
}
#windowButton:hover {
color: #2E3C86;
background: white;
}
#windowButton:default {
border: 2px solid white;
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 B

+2 -3
View File
@@ -1,11 +1,10 @@
QLabel {
font-size: 12px;
color: black;
font-size: 12pt;
}
#licenseField {
font-family: "<setting:font_name>";
font-size: 11px;
font-size: 10pt;
height: 200px;
padding: 5px;
width: 470px;
+4 -1
View File
@@ -1,6 +1,9 @@
QToolTip {
background-color: #E0E0E0;
color: black;
font-size: <setting:font_size>px;
font-size: <setting:font_size>pt;
}
* {
font-family: "Roboto";
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 915 B

@@ -22,7 +22,12 @@ QPushButton:pressed {
}
#refresh_button {
/*border-bottom-left-radius: 12px;*/
/*border-top-left-radius: 12px;*/
border-radius: 12px;
border-bottom-left-radius: 12px;
border-top-left-radius: 12px;
margin-right: 2px;
}
#auto_refresh_button {
border-bottom-right-radius: 12px;
border-top-right-radius: 12px;
}
+2 -2
View File
@@ -1,10 +1,10 @@
* {
font-size: <setting:font_size>px;
font-size: <setting:font_size>pt;
}
#search_box, #search_box * {
font-family: "<setting:font_name>";
font-size: <setting:font_size+2>px;
font-size: <setting:font_size+2>pt;
}
#search_bar {
+7 -7
View File
@@ -4,7 +4,7 @@
border-radius: 8px;
color: black;
padding: 3px 5px 2px;
font-size: 14px;
font-size: 14pt;
min-width: 6em;
}
@@ -17,14 +17,14 @@
background: none;
border: none;
color: black;
font-size: 12px;
font-size: 12pt;
}
#recentButtonMissing {
background: none;
border: none;
color: grey;
font-size: 12px;
font-size: 12pt;
}
#recentButton:hover, #recentButtonMissing:hover {
@@ -34,23 +34,23 @@
#recentLabel {
color: black;
font-size: 16px;
font-size: 16pt;
font-weight: bold;
margin-left: 6px;
}
#versionLabel {
color: black;
font-size: 12px;
font-size: 12pt;
font-weight: bold;
}
#updateLabel {
color: black;
font-size: 12px;
font-size: 12pt;
}
#welcomeLabel {
color: black;
font-size: 12px;
font-size: 12pt;
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

@@ -1,31 +0,0 @@
QTabWidget::tab-bar {
alignment: left;
}
QTabBar::tab {
background-color: <color:tab/background>;
color: <color:tab/text>;
padding: 12px 75px 5px 12px;
border: 0px;
border-bottom: 4px solid <color:tab/background>;
/*font-size: <setting:font_size>px;*/
/*font-weight: bold;*/
}
QTabBar::tab:hover {
border-bottom: 4px solid <color:tab/hover>;
}
QTabBar::tab:selected {
border-bottom: 4px solid <color:tab/active>;
color: <color:tab/active>;
}
QTabWidget::pane {
top: 0px;
background: <color:tab/background>;
color: <color:tab/text>;
border: 0px;
margin: 0px;
padding: 0px;
}
+3 -13
View File
@@ -1,5 +1,5 @@
* {
font-size: 12px;
font-size: 12pt;
}
QtDirectoryListBox {
@@ -15,8 +15,8 @@ QListWidget {
}
QListWidget::item {
border-bottom: 1px solid lightgray;
height: 20px;
border-bottom: 1px solid lightgray;
}
QListWidget::item:selected {
@@ -26,7 +26,6 @@ QListWidget::item:selected {
QtListItemWidget #field {
background-color: transparent;
border: none;
color: black;
margin-top: 2px;
margin-left: 5px;
}
@@ -35,7 +34,7 @@ QtListItemWidget #field {
border-top: 1px solid lightgray;
}
#plusButton, #minusButton, #dotsButton, #editButton {
#plusButton, #minusButton, #dotsButton {
color: white;
height: 1em;
margin-right: 3px;
@@ -71,15 +70,6 @@ QtListItemWidget #field {
border-image: url(<setting:gui_path>window/dots_hover.png);
}
#editButton {
border-image: url(<setting:gui_path>code_view/images/edit.png);
margin-left: 6px;
}
#editButton:hover {
background-color: #EEE;
}
#dropInfo {
color: #999;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 875 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 849 B

+18 -31
View File
@@ -1,18 +1,16 @@
* {
font-size: 12px;
}
QLabel, QCheckBox {
color: black;
font-size: 12pt;
}
#title {
font-size: 16px;
color: black;
font-size: 16pt;
font-weight: bold;
}
#projectTitle {
font-size: 14px;
#section, #projectTitle {
color: black;
font-size: 14pt;
font-weight: bold;
}
@@ -23,38 +21,38 @@ QLabel, QCheckBox {
}
#projectDescription {
font-size: 12px;
font-size: 12pt;
margin-left: 20px;
}
#description {
font-size: 12px;
font-size: 12pt;
}
#label {
font-size: 12px;
font-size: 12pt;
font-weight: bold;
}
#titleLabel {
font-size: 14px;
font-size: 14pt;
font-weight: bold;
}
#formArea {
background: transparent;
background: white;
border: none;
}
#scrollArea {
background: transparent;
background: white;
border: none;
border-top: 1px solid lightgrey;
border-bottom: 1px solid lightgrey;
}
#form {
background: transparent;
background: white;
}
#helpButton, #dotsButton, #refreshButton {
@@ -89,10 +87,8 @@ QLabel, QCheckBox {
}
#name, #picker {
background: white;
border-radius: 10px;
border: 1px solid lightgrey;
color: black;
padding: 2px 5px 0px;
}
@@ -100,7 +96,6 @@ QLabel, QCheckBox {
background: white;
border: none;
border-radius: 5px;
color: black;
margin-left: 5px;
margin-top: 2px;
}
@@ -115,7 +110,7 @@ QLabel, QCheckBox {
border-radius: 8px;
color: black;
padding: 3px 5px 2px;
font-size: 14px;
font-size: 14pt;
min-width: 5em;
}
@@ -125,8 +120,7 @@ QLabel, QCheckBox {
border-radius: 8px;
border-bottom-right-radius: 0px;
border-top-right-radius: 0px;
color: black;
font-size: 15px;
font-size: 15pt;
margin-right: 0px;
height: 25px;
width: 90px;
@@ -134,11 +128,7 @@ QLabel, QCheckBox {
#windowButton:hover {
color: white;
background: #2D3C86;
}
#windowButton:default {
border: 2px solid lightgray;
background: #2D3F85;
}
#menuButton:hover, #menuButton:checked {
@@ -160,8 +150,7 @@ QLabel, QCheckBox {
#projectButton {
background: white;
border-radius: 8px;
color: black;
font-size: 12px;
font-size: 12pt;
width: 7em;
height: 7em;
margin-top: 10px;
@@ -171,10 +160,8 @@ QLabel, QCheckBox {
background: #CFD2E0;
}
#textField, #pathList {
background: white;
#files {
border: 1px solid lightgray;
border-radius: 12px;
color: black;
padding: 6px;
}
+1
View File
@@ -0,0 +1 @@
%windir%\system32\msiexec.exe /I{E6E16577-C547-4A66-8202-AB30A02DDBC2}
+1
View File
@@ -0,0 +1 @@
%windir%\system32\msiexec.exe /I{225E11DF-20A0-4AE0-AD5C-00944A9E3D71}
-1
View File
@@ -1 +0,0 @@
%windir%\system32\msiexec.exe /x {596E7336-D5B9-449A-95E9-6040F354E283}
@@ -1,33 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<config>
<info>
<description>
WHAT IS THIS?\n
\tJavaParser is an open-source Java project for parsing Java code and\n
\tgenerating an Abstract Syntax Tree (AST). Additionally it supports a\n
\tvisitor pattern to traverse the generated AST. For more information on\n
\tthis project please visit javaparser.org\n
\n
LET'S GET STARTED!\n
\tHave you ever wondered what a parser for a real programming language\n
\tmay look like? Go ahead and find out!\n
\n
\tIf you ask yourself where to start, click the symbol linked below.\n
\n
[com\ts\tp\tngithub\ts\tp\tnjavaparser\ts\tp\tnast\ts\tp\tnbody\ts\tp\tnClassOrInterfaceDeclaration\ts\tp] // &lt;- start here!\n\n
</description>
</info>
<language_settings>
<language>Java</language>
<standard>8</standard>
</language_settings>
<source>
<extensions>
<source_extensions>.java</source_extensions>
</extensions>
<source_paths>
<source_path>./src/main/java</source_path>
<source_path>./target/generated-sources/javacc</source_path>
</source_paths>
</source>
</config>
@@ -1,232 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.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.utils.PositionUtils;
import java.io.IOException;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
/**
* Assigns comments to nodes of the AST.
*
* @author Sebastian Kuerten
* @author Júlio Vilmar Gesser
*/
class CommentsInserter {
private boolean doNotAssignCommentsPreceedingEmptyLines = true;
private boolean doNotConsiderAnnotationsAsNodeStartForCodeAttribution = false;
CommentsInserter() {
}
/**
* Adds the comments found in the source code of a compilation unit to that compilation unit.
* @param cu an already created compilation unit
* @param cuSourceCode the source code of the compilation unit. It will be parsed to find comments.
*/
public void insertComments(CompilationUnit cu, String cuSourceCode) throws IOException {
CommentsParser commentsParser = new CommentsParser();
CommentsCollection allComments = commentsParser.parse(cuSourceCode);
insertCommentsInCu(cu, allComments);
}
public boolean getDoNotConsiderAnnotationsAsNodeStartForCodeAttribution() {
return doNotConsiderAnnotationsAsNodeStartForCodeAttribution;
}
public void setDoNotConsiderAnnotationsAsNodeStartForCodeAttribution(boolean newValue) {
this.doNotConsiderAnnotationsAsNodeStartForCodeAttribution = newValue;
}
public boolean getDoNotAssignCommentsPreceedingEmptyLines() {
return doNotAssignCommentsPreceedingEmptyLines;
}
public void setDoNotAssignCommentsPreceedingEmptyLines(boolean newValue) {
this.doNotAssignCommentsPreceedingEmptyLines = newValue;
}
/**
* Comments are attributed to the thing the comment and are removed from
* allComments.
*/
private 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.isEmpty() || PositionUtils.areInOrder(
comments.get(0), children.get(0)))) {
cu.setComment(comments.get(0));
comments.remove(0);
}
insertCommentsInNode(cu, comments);
}
/**
* This method try to attributes the nodes received to child of the node. It
* returns the node that were not attributed.
*/
private void insertCommentsInNode(Node node,
List<Comment> commentsToAttribute) {
if (commentsToAttribute.isEmpty())
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.getEnd().line == comment.getBegin().line
&& 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 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.getBegin().line == lineComment.getBegin().line
&& !node.hasComment()) {
if(!(node instanceof Comment)) {
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;
}
}
private boolean thereAreLinesBetween(Node a, Node b) {
if (!PositionUtils.areInOrder(a, b)) {
return thereAreLinesBetween(b, a);
}
int endOfA = a.getEnd().line;
return b.getBegin().line > (endOfA + 1);
}
}
@@ -1,563 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.*;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.ImportDeclaration;
import com.github.javaparser.ast.body.BodyDeclaration;
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.nio.charset.Charset;
import java.util.List;
import static com.github.javaparser.utils.Utils.readerToString;
/**
* Parse Java source code and creates Abstract Syntax Tree classes.
*
* @author Júlio Vilmar Gesser
*/
public final class JavaParser {
private static final CommentsInserter commentsInserter = new CommentsInserter();
private static final Charset UTF8 = Charset.forName("utf-8");
private ASTParser astParser = null;
private Provider provider = null;
/**
* Instantiate the parser. Note that parsing can also be done with the static methods on this class.
* Creating an instance will reduce setup time between parsing files.
*/
public JavaParser() {
// No specific constructors for this class.
}
public JavaParser setSource(Provider provider) {
this.provider=provider;
if(astParser==null) {
astParser = new ASTParser(provider);
}else{
astParser.ReInit(provider);
}
return this;
}
public JavaParser setSource(Reader reader) {
return setSource(new StreamProvider(reader));
}
public JavaParser setSource(InputStream input) throws IOException {
return setSource(new StreamProvider(input));
}
public JavaParser setSource(InputStream input, Charset encoding) throws IOException {
return setSource(new StreamProvider(input, encoding.name()));
}
public JavaParser setSource(File file) throws IOException {
return setSource(new FileInputStream(file));
}
public JavaParser setSource(File file, Charset encoding) throws IOException {
return setSource(new FileInputStream(file), encoding);
}
public JavaParser setSource(String source) {
return setSource(new StringReader(source));
}
/**
* Return the list of tokens that have been encountered while parsing code
* using this parser.
*
* @return a list of tokens
*/
public List<Token> getTokens() {
checkSourceSet();
return astParser.getTokens();
}
private void checkSourceSet() {
if (astParser == null || provider == null) {
throw new IllegalStateException("Please setSource() before doing any parsing.");
}
}
/**
* Parses the Java code and returns a {@link CompilationUnit} that
* represents it.
*
* @return CompilationUnit representing the Java source code
* @throws ParseException
* if the source code has parser errors
*/
public CompilationUnit parse() throws ParseException {
try {
checkSourceSet();
return astParser.CompilationUnit();
} finally {
closeProvider();
}
}
private void closeProvider() {
try {
checkSourceSet();
provider.close();
} catch (IOException e) {
// Since we're done parsing and have our result, we don't care about any errors.
}
}
/**
* Parses the Java block and returns a {@link BlockStmt} that represents it.
*
* @return BlockStmt representing the Java block
* @throws ParseException
* if the source code has parser errors
*/
public BlockStmt parseBlock() throws ParseException {
try{
checkSourceSet();
return astParser.Block();
} finally {
closeProvider();
}
}
/**
* Parses the Java block and returns a {@link List} of {@link Statement}s
* that represents it.
*
* @return Statement representing the Java statement
* @throws ParseException
* if the source code has parser errors
*/
public List<Statement> parseStatements() throws ParseException {
try {
checkSourceSet();
return astParser.Statements();
} finally {
closeProvider();
}
}
/**
* Parses the Java statement and returns a {@link Statement} that represents
* it.
*
* @return Statement representing the Java statement
* @throws ParseException
* if the source code has parser errors
*/
public Statement parseStatement() throws ParseException {
try {
checkSourceSet();
return astParser.Statement();
} finally {
closeProvider();
}
}
/**
* Parses the Java import and returns a {@link ImportDeclaration} that
* represents it.
*
* @return ImportDeclaration representing the Java import declaration
* @throws ParseException
* if the source code has parser errors
*/
public ImportDeclaration parseImport() throws ParseException {
try {
checkSourceSet();
return astParser.ImportDeclaration();
} finally {
closeProvider();
}
}
/**
* Parses the Java expression and returns a {@link Expression} that
* represents it.
*
* @return Expression representing the Java expression
* @throws ParseException
* if the source code has parser errors
*/
public Expression parseExpression() throws ParseException {
try {
checkSourceSet();
return astParser.Expression();
} finally {
closeProvider();
}
}
/**
* Parses the Java annotation and returns a {@link AnnotationExpr} that
* represents it.
*
* @return AnnotationExpr representing the Java annotation
* @throws ParseException
* if the source code has parser errors
*/
public AnnotationExpr parseAnnotation() throws ParseException {
try {
checkSourceSet();
return astParser.Annotation();
} finally {
closeProvider();
}
}
/**
* Parses the Java body declaration(e.g fields or methods) and returns a
* {@link BodyDeclaration} that represents it.
*
* @return BodyDeclaration representing the Java body
* @throws ParseException
* if the source code has parser errors
*/
public BodyDeclaration<?> parseBodyDeclaration() throws ParseException {
try {
checkSourceSet();
return astParser.AnnotationBodyDeclaration();
} finally {
closeProvider();
}
}
/**
* Parses a Java class body declaration(e.g fields or methods) and returns a
* {@link BodyDeclaration} that represents it.
*
* @return BodyDeclaration representing the Java class body
* @throws ParseException
* if the source code has parser errors
*/
public BodyDeclaration<?> parseClassBodyDeclaration() throws ParseException {
try {
checkSourceSet();
return astParser.ClassOrInterfaceBodyDeclaration(false);
} finally {
closeProvider();
}
}
/**
* Parses a Java interface body declaration(e.g fields or methods) and returns a
* {@link BodyDeclaration} that represents it.
*
* @return BodyDeclaration representing the Java interface body
* @throws ParseException
* if the source code has parser errors
*/
public BodyDeclaration<?> parseInterfaceBodyDeclaration() throws ParseException {
try {
checkSourceSet();
return astParser.ClassOrInterfaceBodyDeclaration(true);
} finally {
closeProvider();
}
}
public static boolean getDoNotConsiderAnnotationsAsNodeStartForCodeAttribution() {
return commentsInserter.getDoNotConsiderAnnotationsAsNodeStartForCodeAttribution();
}
public static void setDoNotConsiderAnnotationsAsNodeStartForCodeAttribution(boolean newValue) {
commentsInserter.setDoNotConsiderAnnotationsAsNodeStartForCodeAttribution(newValue);
}
public static boolean getDoNotAssignCommentsPreceedingEmptyLines() {
return commentsInserter.getDoNotAssignCommentsPreceedingEmptyLines();
}
public static void setDoNotAssignCommentsPreceedingEmptyLines(boolean newValue) {
commentsInserter.setDoNotAssignCommentsPreceedingEmptyLines(newValue);
}
public static CompilationUnit parse(final InputStream in,
final Charset 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,
Charset encoding,
boolean considerComments) throws ParseException {
try {
try (InputStreamReader inputStreamReader = new InputStreamReader(in, encoding)) {
return parse(inputStreamReader, considerComments);
}
} 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.<br>
* Note: Uses UTF-8 encoding
*
* @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, UTF8, true);
}
public static CompilationUnit parse(final File file, final Charset 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
*/
public static CompilationUnit parse(final File file, final Charset encoding, boolean considerComments)
throws ParseException {
try {
try (FileInputStream in = new FileInputStream(file)) {
return parse(in, encoding, considerComments);
}
} catch (IOException ioe) {
throw new ParseException(ioe.getMessage());
}
}
/**
* Parses the Java code contained in a {@link File} and returns a
* {@link CompilationUnit} that represents it.<br>
* Note: Uses UTF-8 encoding
*
*
* @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, UTF8, true);
}
public static CompilationUnit parse(final Reader reader)
throws ParseException {
return parse(reader, true);
}
public static CompilationUnit parse(final Reader reader, boolean considerComments)
throws ParseException {
try {
String comments = readerToString(reader);
CompilationUnit cu = new JavaParser().setSource(comments).parse();
if (considerComments){
commentsInserter.insertComments(cu, comments);
}
return cu;
} catch (IOException ioe){
throw new ParseException(ioe.getMessage());
}
}
/**
* Parses the Java code contained in code and returns a
* {@link CompilationUnit} that represents it.
*
* @param code Java source code
* @param considerComments parse or ignore comments
* @return CompilationUnit representing the Java source code
* @throws ParseException if the source code has parser errors
*/
public static CompilationUnit parse(String code, boolean considerComments) throws ParseException {
return parse(new StringReader(code), considerComments);
}
/**
* Parses the Java code contained in code and returns a
* {@link CompilationUnit} that represents it.
*
* @param code Java source code
* @return CompilationUnit representing the Java source code
* @throws ParseException if the source code has parser errors
*/
public static CompilationUnit parse(String code) throws ParseException {
return parse(code, true);
}
/**
* 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 {
return new JavaParser().setSource(blockStatement).parseBlock();
}
/**
* 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 {
return new JavaParser().setSource(statement).parseStatement();
}
/**
* Parses the Java statements contained in a {@link String} and returns a
* list of {@link Statement} that represents it.
*
* @param statements
* {@link String} containing Java statements
* @return list of Statement representing the Java statement
* @throws ParseException
* if the source code has parser errors
*/
public static List<Statement> parseStatements(final String statements) throws ParseException {
return new JavaParser().setSource(statements).parseStatements();
}
/**
* 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 {
return new JavaParser().setSource(importDeclaration).parseImport();
}
/**
* 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 {
return new JavaParser().setSource(expression).parseExpression();
}
/**
* 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 {
return new JavaParser().setSource(annotation).parseAnnotation();
}
/**
* 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 {
return new JavaParser().setSource(body).parseBodyDeclaration();
}
/**
* Parses a Java class body declaration(e.g fields or methods) and returns a
* {@link BodyDeclaration} that represents it.
*
* @param body the body of a class
* @return BodyDeclaration representing the Java class body
* @throws ParseException
* if the source code has parser errors
*/
public static BodyDeclaration<?> parseClassBodyDeclaration(String body) throws ParseException {
return new JavaParser().setSource(body).parseClassBodyDeclaration();
}
/**
* Parses a Java interface body declaration(e.g fields or methods) and returns a
* {@link BodyDeclaration} that represents it.
*
* @param body the body of an interface
* @return BodyDeclaration representing the Java interface body
* @throws ParseException
* if the source code has parser errors
*/
public static BodyDeclaration parseInterfaceBodyDeclaration(String body) throws ParseException {
return new JavaParser().setSource(body).parseInterfaceBodyDeclaration();
}
}
@@ -1,137 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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;
/**
* A position in a source file. Lines and columns start counting at 1.
*/
public class Position implements Comparable<Position> {
public final int line;
public final 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);
/**
* The first position in the file
*/
public static final Position HOME = new Position(1, 1);
public static final Position UNKNOWN = new Position(0, 0);
public Position(int line, int column) {
if (line < Node.ABSOLUTE_END_LINE) {
throw new IllegalArgumentException("Can't position at line " + line);
}
if (column < -1) {
throw new IllegalArgumentException("Can't position at column " + column);
}
this.line = line;
this.column = column;
}
/**
* Convenient factory method.
*/
public static Position pos(int line, int column) {
return new Position(line, column);
}
public Position withColumn(int column) {
return new Position(this.line, column);
}
public Position withLine(int line) {
return new Position(line, this.column);
}
/**
* Check if the position is usable. Does not know what it is pointing at, so it can't check if the position is after the end of the source.
*/
public boolean valid() {
return line > 0 && column > 0;
}
public boolean invalid() {
return !valid();
}
public Position orIfInvalid(Position anotherPosition) {
if (valid()) {
return this;
}
return anotherPosition;
}
public boolean isAfter(Position position) {
if (position.line == Node.ABSOLUTE_BEGIN_LINE) return true;
if (line > position.line) {
return true;
} else if (line == position.line) {
return column > position.column;
}
return false;
}
public boolean isBefore(Position position) {
if (position.line == Node.ABSOLUTE_END_LINE) return true;
if (line < position.line) {
return true;
} else if (line == position.line) {
return column < position.column;
}
return false;
}
@Override
public int compareTo(Position o) {
if (isBefore(o)) {
return -1;
}
if (isAfter(o)) {
return 1;
}
return 0;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Position position = (Position) o;
return line == position.line && column == position.column;
}
@Override
public int hashCode() {
return 31 * line + column;
}
@Override
public String toString() {
return "(line " + line + ",col " + column + ")";
}
}
@@ -1,89 +0,0 @@
package com.github.javaparser;
import static com.github.javaparser.Position.pos;
/**
* A range of characters in a source file, from "begin" to "end", including the characters at "begin" and "end".
*/
public class Range {
public static final Range UNKNOWN = range(Position.UNKNOWN, Position.UNKNOWN);
public final Position begin;
public final Position end;
public Range(Position begin, Position end) {
if (begin == null) {
throw new IllegalArgumentException("begin can't be null");
}
if (end == null) {
throw new IllegalArgumentException("end can't be null");
}
this.begin = begin;
this.end = end;
}
public static Range range(Position begin, Position end) {
return new Range(begin, end);
}
public static Range range(int beginLine, int beginColumn, int endLine, int endColumn) {
return new Range(pos(beginLine, beginColumn), pos(endLine, endColumn));
}
public Range withBeginColumn(int column) {
return range(begin.withColumn(column), end);
}
public Range withBeginLine(int line) {
return range(begin.withLine(line), end);
}
public Range withEndColumn(int column) {
return range(begin, end.withColumn(column));
}
public Range withEndLine(int line) {
return range(begin, end.withLine(line));
}
public Range withBegin(Position begin) {
return range(begin, this.end);
}
public Range withEnd(Position end) {
return range(this.begin, end);
}
public boolean contains(Range other) {
return begin.isBefore(other.begin) && end.isAfter(other.end);
}
public boolean isBefore(Position position) {
return end.isBefore(position);
}
public boolean isAfter(Position position) {
return begin.isAfter(position);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Range range = (Range) o;
return begin.equals(range.begin) && end.equals(range.end);
}
@Override
public int hashCode() {
return 31 * begin.hashCode() + end.hashCode();
}
@Override
public String toString() {
return begin+"-"+end;
}
}
@@ -1,47 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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;
AccessSpecifier(String codeRepresentation) {
this.codeRepresenation = codeRepresentation;
}
public String getCodeRepresenation(){
return this.codeRepresenation;
}
}
@@ -1,404 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.utils.Utils.ensureNotNull;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.stream.Collectors;
import com.github.javaparser.ast.expr.NameExpr;
import com.github.javaparser.utils.ClassUtils;
import com.github.javaparser.Range;
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.body.TypeDeclaration;
import com.github.javaparser.ast.comments.Comment;
import com.github.javaparser.ast.comments.JavadocComment;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
/**
* <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(Range range, PackageDeclaration pakage, List<ImportDeclaration> imports,
List<TypeDeclaration<?>> types) {
super(range);
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);
}
/**
* sets the package declaration of this compilation unit
*
* @param name the name of the package
* @return this, the {@link CompilationUnit}
*/
public CompilationUnit setPackageName(String name) {
setPackage(new PackageDeclaration(NameExpr.create(name)));
return this;
}
/**
* Add an import to the list of {@link ImportDeclaration} of this compilation unit<br>
* shorthand for {@link #addImport(String, boolean, boolean)} with name,false,false
*
* @param name the import name
* @return this, the {@link CompilationUnit}
*/
public CompilationUnit addImport(String name) {
return addImport(name, false, false);
}
/**
* Add an import to the list of {@link ImportDeclaration} of this compilation unit<br>
* shorthand for {@link #addImport(String)} with clazz.getName()
*
* @param clazz the class to import
* @return this, the {@link CompilationUnit}
*/
public CompilationUnit addImport(Class<?> clazz) {
if (ClassUtils.isPrimitiveOrWrapper(clazz) || clazz.getName().startsWith("java.lang"))
return this;
else if (clazz.isArray() && !ClassUtils.isPrimitiveOrWrapper(clazz.getComponentType())
&& !clazz.getComponentType().getName().startsWith("java.lang"))
return addImport(clazz.getComponentType().getName());
return addImport(clazz.getName());
}
/**
* Add an import to the list of {@link ImportDeclaration} of this compilation unit<br>
* <b>This method check if no import with the same name is already in the list</b>
*
* @param name the import name
* @param isStatic is it an "import static"
* @param isAsterisk does the import end with ".*"
* @return this, the {@link CompilationUnit}
*/
public CompilationUnit addImport(String name, boolean isStatic, boolean isAsterisk) {
if (getImports().stream().anyMatch(i -> i.getName().toString().equals(name)))
return this;
else {
ImportDeclaration importDeclaration = new ImportDeclaration(NameExpr.create(name), isStatic,
isAsterisk);
getImports().add(importDeclaration);
importDeclaration.setParentNode(this);
return this;
}
}
/**
* Add a public class to the types of this compilation unit
*
* @param name the class name
* @return the newly created class
*/
public ClassOrInterfaceDeclaration addClass(String name) {
return addClass(name, Modifier.PUBLIC);
}
/**
* Add a class to the types of this compilation unit
*
* @param name the class name
* @param modifiers the modifiers (like Modifier.PUBLIC)
* @return the newly created class
*/
public ClassOrInterfaceDeclaration addClass(String name, Modifier... modifiers) {
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = new ClassOrInterfaceDeclaration(
Arrays.stream(modifiers)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Modifier.class))),
false, name);
getTypes().add(classOrInterfaceDeclaration);
classOrInterfaceDeclaration.setParentNode(this);
return classOrInterfaceDeclaration;
}
/**
* Add a public interface class to the types of this compilation unit
*
* @param name the interface name
* @return the newly created class
*/
public ClassOrInterfaceDeclaration addInterface(String name) {
return addInterface(name, Modifier.PUBLIC);
}
/**
* Add an interface to the types of this compilation unit
*
* @param name the interface name
* @param modifiers the modifiers (like Modifier.PUBLIC)
* @return the newly created class
*/
public ClassOrInterfaceDeclaration addInterface(String name, Modifier... modifiers) {
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = new ClassOrInterfaceDeclaration(
Arrays.stream(modifiers)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Modifier.class))),
true, name);
getTypes().add(classOrInterfaceDeclaration);
classOrInterfaceDeclaration.setParentNode(this);
return classOrInterfaceDeclaration;
}
/**
* Add a public enum to the types of this compilation unit
*
* @param name the enum name
* @return the newly created class
*/
public EnumDeclaration addEnum(String name) {
return addEnum(name, Modifier.PUBLIC);
}
/**
* Add an enum to the types of this compilation unit
*
* @param name the enum name
* @param modifiers the modifiers (like Modifier.PUBLIC)
* @return the newly created class
*/
public EnumDeclaration addEnum(String name, Modifier... modifiers) {
EnumDeclaration enumDeclaration = new EnumDeclaration(Arrays.stream(modifiers)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Modifier.class))), name);
getTypes().add(enumDeclaration);
enumDeclaration.setParentNode(this);
return enumDeclaration;
}
/**
* Add a public annotation declaration to the types of this compilation unit
*
* @param name the annotation name
* @return the newly created class
*/
public AnnotationDeclaration addAnnotationDeclaration(String name) {
return addAnnotationDeclaration(name, Modifier.PUBLIC);
}
/**
* Add an annotation declaration to the types of this compilation unit
*
* @param name the annotation name
* @param modifiers the modifiers (like Modifier.PUBLIC)
* @return the newly created class
*/
public AnnotationDeclaration addAnnotationDeclaration(String name, Modifier... modifiers) {
AnnotationDeclaration annotationDeclaration = new AnnotationDeclaration(Arrays.stream(modifiers)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Modifier.class))), name);
getTypes().add(annotationDeclaration);
annotationDeclaration.setParentNode(this);
return annotationDeclaration;
}
/**
* Try to get a class by its name
*
* @param className the class name (case-sensitive)
* @return null if not found, the class otherwise
*/
public ClassOrInterfaceDeclaration getClassByName(String className) {
return (ClassOrInterfaceDeclaration) getTypes().stream().filter(type -> type.getName().equals(className)
&& type instanceof ClassOrInterfaceDeclaration && !((ClassOrInterfaceDeclaration) type).isInterface())
.findFirst().orElse(null);
}
/**
* Try to get an interface by its name
*
* @param interfaceName the interface name (case-sensitive)
* @return null if not found, the interface otherwise
*/
public ClassOrInterfaceDeclaration getInterfaceByName(String interfaceName) {
return (ClassOrInterfaceDeclaration) getTypes().stream().filter(type -> type.getName().equals(interfaceName)
&& type instanceof ClassOrInterfaceDeclaration && ((ClassOrInterfaceDeclaration) type).isInterface())
.findFirst().orElse(null);
}
/**
* Try to get an enum by its name
*
* @param enumName the enum name (case-sensitive)
* @return null if not found, the enum otherwise
*/
public EnumDeclaration getEnumByName(String enumName) {
return (EnumDeclaration) getTypes().stream().filter(type -> type.getName().equals(enumName)
&& type instanceof EnumDeclaration)
.findFirst().orElse(null);
}
/**
* Try to get an annotation by its name
*
* @param annotationName the annotation name (case-sensitive)
* @return null if not found, the annotation otherwise
*/
public AnnotationDeclaration getAnnotationDeclarationByName(String annotationName) {
return (AnnotationDeclaration) getTypes().stream().filter(type -> type.getName().equals(annotationName)
&& type instanceof AnnotationDeclaration)
.findFirst().orElse(null);
}
}
@@ -1,185 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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 or an empty 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>
* An enmpty import declaration is simply a semicolon among the import declarations.
* @author Julio Vilmar Gesser
*/
public final class ImportDeclaration extends Node {
private NameExpr name;
private boolean static_;
private boolean asterisk;
private boolean isEmptyImportDeclaration;
private ImportDeclaration() {
this.isEmptyImportDeclaration = true;
static_ = false;
asterisk = false;
}
private ImportDeclaration(Range range) {
super(range);
this.isEmptyImportDeclaration = true;
static_ = false;
asterisk = false;
}
/**
* Create an empty import declaration without specifying its position.
*/
public static ImportDeclaration createEmptyDeclaration(){
return new ImportDeclaration();
}
/**
* Create an empty import declaration specifying its position.
*/
public static ImportDeclaration createEmptyDeclaration(Range range){
return new ImportDeclaration(range);
}
public ImportDeclaration(NameExpr name, boolean isStatic, boolean isAsterisk) {
setAsterisk(isAsterisk);
setName(name);
setStatic(isStatic);
this.isEmptyImportDeclaration = false;
}
public ImportDeclaration(Range range, NameExpr name, boolean isStatic, boolean isAsterisk) {
super(range);
setAsterisk(isAsterisk);
setName(name);
setStatic(isStatic);
this.isEmptyImportDeclaration = false;
}
/**
* Is this an empty import declaration or a normal import declaration?
*/
public boolean isEmptyImportDeclaration(){
return this.isEmptyImportDeclaration;
}
@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
* @throws UnsupportedOperationException when invoked on an empty import declaration
*/
public NameExpr getName() {
if (isEmptyImportDeclaration) {
throw new UnsupportedOperationException("Empty import declarations have no name");
}
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
* @throws UnsupportedOperationException when setting true on an empty import declaration
*/
public void setAsterisk(boolean asterisk) {
if (isEmptyImportDeclaration && asterisk) {
throw new UnsupportedOperationException("Empty import cannot have asterisk");
}
this.asterisk = asterisk;
}
/**
* Sets the name this import.
*
* @param name
* the name to set
* @throws UnsupportedOperationException when invoked on an empty import declaration
*/
public void setName(NameExpr name) {
if (isEmptyImportDeclaration) {
throw new UnsupportedOperationException("Empty import cannot have name");
}
this.name = name;
setAsParentNodeOf(this.name);
}
/**
* Sets if this import is static.
*
* @param static_
* <code>true</code> if this import is static
* @throws UnsupportedOperationException when setting true on an empty import declaration
*/
public void setStatic(boolean static_) {
if (isEmptyImportDeclaration && static_) {
throw new UnsupportedOperationException("Empty import cannot be static");
}
this.static_ = static_;
}
}
@@ -1,46 +0,0 @@
package com.github.javaparser.ast;
import java.util.EnumSet;
public enum Modifier {
PUBLIC("public"),
PROTECTED("protected"),
PRIVATE("private"),
ABSTRACT("abstract"),
STATIC("static"),
FINAL("final"),
TRANSIENT("transient"),
VOLATILE("volatile"),
SYNCHRONIZED("synchronized"),
NATIVE("native"),
STRICTFP("strictfp");
String lib;
private Modifier(String lib) {
this.lib = lib;
}
/**
* @return the lib
*/
public String getLib() {
return lib;
}
public EnumSet<Modifier> toEnumSet() {
return EnumSet.of(this);
}
public static AccessSpecifier getAccessSpecifier(EnumSet<Modifier> modifiers) {
if (modifiers.contains(Modifier.PUBLIC)) {
return AccessSpecifier.PUBLIC;
} else if (modifiers.contains(Modifier.PROTECTED)) {
return AccessSpecifier.PROTECTED;
} else if (modifiers.contains(Modifier.PRIVATE)) {
return AccessSpecifier.PRIVATE;
} else {
return AccessSpecifier.DEFAULT;
}
}
}
@@ -1,372 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Position;
import com.github.javaparser.Range;
import com.github.javaparser.ast.comments.BlockComment;
import com.github.javaparser.ast.comments.Comment;
import com.github.javaparser.ast.comments.LineComment;
import com.github.javaparser.ast.visitor.*;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
* 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 Range range;
private Node parentNode;
private List<Node> childrenNodes = new LinkedList<>();
private List<Comment> orphanComments = new LinkedList<>();
/**
* This attribute can store additional information from semantic analysis.
*/
private Object data;
private Comment comment;
public Node() {
this(Range.UNKNOWN);
}
public Node(Range range) {
this.range = range;
}
/**
* 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);
/**
* 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;
}
/**
* The begin position of this node in the source file.
*/
public Position getBegin() {
return range.begin;
}
/**
* The end position of this node in the source file.
*/
public Position getEnd() {
return range.end;
}
/**
* Sets the begin position of this node in the source file.
*/
public void setBegin(Position begin) {
range = range.withBegin(begin);
}
/**
* Sets the end position of this node in the source file.
*/
public void setEnd(Position end) {
range = range.withEnd(end);
}
/**
* @return the range of characters in the source code that this node covers.
*/
public Range getRange() {
return range;
}
/**
* @param range the range of characters in the source code that this node covers.
*/
public void setRange(Range range) {
this.range = range;
}
/**
* 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 comment to be set
*/
public final void setLineComment(String comment) {
setComment(new LineComment(comment));
}
/**
* Use this to store additional information to this node.
*
* @param comment to be set
*/
public final void setBlockComment(String comment) {
setComment(new BlockComment(comment));
}
/**
* Use this to store additional information to this node.
*
* @param data to be set
*/
public final void setData(final Object data) {
this.data = data;
}
/**
* 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;
}
@SuppressWarnings("unchecked")
public <T> T getParentNodeOfType(Class<T> classType) {
Node parent = parentNode;
while (parent != null) {
if (classType.isAssignableFrom(parent.getClass()))
return (T) parent;
parent = parent.parentNode;
}
return null;
}
public List<Node> getChildrenNodes() {
return childrenNodes;
}
public boolean contains(Node other) {
return range.contains(other.range);
}
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 comment preceeds a statement, the one immediately preceding it
* it is associated with the statements, while the others are orphans.
*
* @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<>();
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) {
for (Node current : childNodes) {
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(Position position) {
return range.isAfter(position);
}
public boolean isPositionedBefore(Position position) {
return range.isBefore(position);
}
public boolean hasComment() {
return comment != null;
}
public void tryAddImportToParentCompilationUnit(Class<?> clazz) {
CompilationUnit parentNode = getParentNodeOfType(CompilationUnit.class);
if (parentNode != null) {
parentNode.addImport(clazz);
}
}
/**
* Recursively finds all nodes of a certain type.
*
* @param clazz the type of node to find.
*/
public <N extends Node> List<N> getNodesByType(Class<N> clazz) {
List<N> nodes = new ArrayList<>();
for (Node child : getChildrenNodes()) {
if (clazz.isInstance(child)) {
nodes.add(clazz.cast(child));
}
nodes.addAll(child.getNodesByType(clazz));
}
return nodes;
}
}
@@ -1,127 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.expr.NameExpr;
import com.github.javaparser.utils.Utils;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
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(Range range, List<AnnotationExpr> annotations, NameExpr name) {
super(range);
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 expression of the package.
*
* @return the name of the package
*/
public NameExpr getName() {
return name;
}
/**
* Get full package name.
*/
public String getPackageName() {
return name.toString();
}
/**
* @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);
}
}
@@ -1,56 +0,0 @@
/*
* Copyright (C) 2016 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.type.Type;
import java.util.Collections;
import java.util.List;
import static com.github.javaparser.utils.Utils.ensureNotNull;
public class TypeArguments {
public static final TypeArguments EMPTY = withArguments(Collections.<Type>emptyList());
private final List<Type> typeArguments;
private final boolean usesDiamondOperator;
private TypeArguments(List<Type> typeArguments, boolean usesDiamondOperator) {
this.typeArguments = ensureNotNull(typeArguments);
this.usesDiamondOperator = usesDiamondOperator;
}
public List<Type> getTypeArguments() {
return typeArguments;
}
public boolean isUsingDiamondOperator() {
return usesDiamondOperator;
}
public static TypeArguments withDiamondOperator() {
return new TypeArguments(Collections.<Type>emptyList(), true);
}
public static TypeArguments withArguments(List<Type> typeArguments) {
return new TypeArguments(typeArguments, false);
}
}
@@ -1,136 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.utils.Utils.ensureNotNull;
import java.util.List;
import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.nodeTypes.NodeWithName;
import com.github.javaparser.ast.type.ClassOrInterfaceType;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
/**
* <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 NodeWithName<TypeParameter> {
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(Range range, final String name, final List<ClassOrInterfaceType> typeBound) {
super(range);
setName(name);
setTypeBound(typeBound);
}
public TypeParameter(Range range, String name, List<ClassOrInterfaceType> typeBound, List<AnnotationExpr> annotations) {
this(range, name, typeBound);
setTypeBound(typeBound);
setAnnotations(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
*/
@Override
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
*/
@Override
public TypeParameter setName(final String name) {
this.name = name;
return this;
}
/**
* 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;
setAsParentNodeOf(this.annotations);
}
}
@@ -1,65 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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 java.util.EnumSet;
import com.github.javaparser.Range;
import com.github.javaparser.ast.Modifier;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
/**
* @author Julio Vilmar Gesser
*/
public final class AnnotationDeclaration extends TypeDeclaration<AnnotationDeclaration> {
public AnnotationDeclaration() {
}
public AnnotationDeclaration(EnumSet<Modifier> modifiers, String name) {
super(modifiers, name);
}
public AnnotationDeclaration(EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, String name,
List<BodyDeclaration<?>> members) {
super(annotations, modifiers, name, members);
}
public AnnotationDeclaration(Range range, EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, String name,
List<BodyDeclaration<?>> members) {
super(range, 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);
}
}
@@ -1,149 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.EnumSet;
import java.util.List;
import com.github.javaparser.Range;
import com.github.javaparser.ast.Modifier;
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.nodeTypes.NodeWithJavaDoc;
import com.github.javaparser.ast.nodeTypes.NodeWithModifiers;
import com.github.javaparser.ast.nodeTypes.NodeWithName;
import com.github.javaparser.ast.nodeTypes.NodeWithType;
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 AnnotationMemberDeclaration extends BodyDeclaration<AnnotationMemberDeclaration>
implements NodeWithJavaDoc<AnnotationMemberDeclaration>, NodeWithName<AnnotationMemberDeclaration>,
NodeWithType<AnnotationMemberDeclaration>, NodeWithModifiers<AnnotationMemberDeclaration> {
private EnumSet<Modifier> modifiers = EnumSet.noneOf(Modifier.class);
private Type type;
private String name;
private Expression defaultValue;
public AnnotationMemberDeclaration() {
}
public AnnotationMemberDeclaration(EnumSet<Modifier> modifiers, Type type, String name, Expression defaultValue) {
setModifiers(modifiers);
setType(type);
setName(name);
setDefaultValue(defaultValue);
}
public AnnotationMemberDeclaration(EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, Type type, String name,
Expression defaultValue) {
super(annotations);
setModifiers(modifiers);
setType(type);
setName(name);
setDefaultValue(defaultValue);
}
public AnnotationMemberDeclaration(Range range, EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, Type type,
String name, Expression defaultValue) {
super(range, 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 Modifier
* @return modifiers
*/
@Override
public EnumSet<Modifier> getModifiers() {
return modifiers;
}
@Override
public String getName() {
return name;
}
@Override
public Type getType() {
return type;
}
public void setDefaultValue(Expression defaultValue) {
this.defaultValue = defaultValue;
setAsParentNodeOf(defaultValue);
}
@Override
public AnnotationMemberDeclaration setModifiers(EnumSet<Modifier> modifiers) {
this.modifiers = modifiers;
return this;
}
@Override
public AnnotationMemberDeclaration setName(String name) {
this.name = name;
return this;
}
@Override
public AnnotationMemberDeclaration setType(Type type) {
this.type = type;
setAsParentNodeOf(type);
return this;
}
@Override
public JavadocComment getJavaDoc() {
if (getComment() instanceof JavadocComment) {
return (JavadocComment) getComment();
}
return null;
}
}
@@ -1,133 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.utils.Utils.ensureNotNull;
import java.util.EnumSet;
import java.util.List;
import com.github.javaparser.Range;
import com.github.javaparser.ast.Modifier;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations;
import com.github.javaparser.ast.nodeTypes.NodeWithModifiers;
import com.github.javaparser.ast.nodeTypes.NodeWithName;
public abstract class BaseParameter<T>
extends Node
implements NodeWithAnnotations<T>, NodeWithName<T>, NodeWithModifiers<T> {
private EnumSet<Modifier> modifiers = EnumSet.noneOf(Modifier.class);
private List<AnnotationExpr> annotations;
private VariableDeclaratorId id;
public BaseParameter() {
}
public BaseParameter(VariableDeclaratorId id) {
setId(id);
}
public BaseParameter(EnumSet<Modifier> modifiers, VariableDeclaratorId id) {
setModifiers(modifiers);
setId(id);
}
public BaseParameter(EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, VariableDeclaratorId id) {
setModifiers(modifiers);
setAnnotations(annotations);
setId(id);
}
public BaseParameter(final Range range, EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, VariableDeclaratorId id) {
super(range);
setModifiers(modifiers);
setAnnotations(annotations);
setId(id);
}
/**
* @return the list returned could be immutable (in that case it will be empty)
*/
@Override
public List<AnnotationExpr> getAnnotations() {
annotations = ensureNotNull(annotations);
return annotations;
}
public VariableDeclaratorId getId() {
return id;
}
@Override
public String getName() {
return getId().getName();
}
@SuppressWarnings("unchecked")
@Override
public T setName(String name) {
if (id != null)
id.setName(name);
else
id = new VariableDeclaratorId(name);
return (T) this;
}
/**
* Return the modifiers of this parameter declaration.
*
* @see Modifier
* @return modifiers
*/
@Override
public EnumSet<Modifier> 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
*/
@Override
@SuppressWarnings("unchecked")
public T setAnnotations(List<AnnotationExpr> annotations) {
this.annotations = annotations;
setAsParentNodeOf(this.annotations);
return (T) this;
}
public void setId(VariableDeclaratorId id) {
this.id = id;
setAsParentNodeOf(this.id);
}
@Override
@SuppressWarnings("unchecked")
public T setModifiers(EnumSet<Modifier> modifiers) {
this.modifiers = modifiers;
return (T) this;
}
}
@@ -1,69 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.utils.Utils;
import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations;
/**
* @author Julio Vilmar Gesser
*/
public abstract class BodyDeclaration<T> extends Node implements NodeWithAnnotations<T> {
private List<AnnotationExpr> annotations;
public BodyDeclaration() {
}
public BodyDeclaration(List<AnnotationExpr> annotations) {
setAnnotations(annotations);
}
public BodyDeclaration(Range range, List<AnnotationExpr> annotations) {
super(range);
setAnnotations(annotations);
}
@Override
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
*/
@SuppressWarnings("unchecked")
@Override
public final T setAnnotations(List<AnnotationExpr> annotations) {
this.annotations = annotations;
setAsParentNodeOf(this.annotations);
return (T) this;
}
}
@@ -1,200 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.utils.Utils.ensureNotNull;
import java.util.EnumSet;
import java.util.List;
import com.github.javaparser.Range;
import com.github.javaparser.ast.Modifier;
import com.github.javaparser.ast.TypeParameter;
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;
/**
* @author Julio Vilmar Gesser
*/
public final class ClassOrInterfaceDeclaration extends TypeDeclaration<ClassOrInterfaceDeclaration> {
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 EnumSet<Modifier> modifiers, final boolean isInterface,
final String name) {
super(modifiers, name);
setInterface(isInterface);
}
public ClassOrInterfaceDeclaration(final EnumSet<Modifier> 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(Range range, final EnumSet<Modifier> 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(range, 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);
}
/**
* Add an extends to this class or interface and automatically add the import
*
* @param clazz the class to extand from
* @return this, the {@link ClassOrInterfaceDeclaration}
*/
public ClassOrInterfaceDeclaration addExtends(Class<?> clazz) {
tryAddImportToParentCompilationUnit(clazz);
return addExtends(clazz.getSimpleName());
}
/**
* Add an extends to this class or interface
*
* @param name the name of the type to extends from
* @return this, the {@link ClassOrInterfaceDeclaration}
*/
public ClassOrInterfaceDeclaration addExtends(String name) {
ClassOrInterfaceType classOrInterfaceType = new ClassOrInterfaceType(name);
getExtends().add(classOrInterfaceType);
classOrInterfaceType.setParentNode(this);
return this;
}
/**
* Add an implements to this class or interface
*
* @param name the name of the type to extends from
* @return this, the {@link ClassOrInterfaceDeclaration}
*/
public ClassOrInterfaceDeclaration addImplements(String name) {
ClassOrInterfaceType classOrInterfaceType = new ClassOrInterfaceType(name);
getImplements().add(classOrInterfaceType);
classOrInterfaceType.setParentNode(this);
return this;
}
/**
* Add an implements to this class or interface and automatically add the import
*
* @param clazz the type to implements from
* @return this, the {@link ClassOrInterfaceDeclaration}
*/
public ClassOrInterfaceDeclaration addImplements(Class<?> clazz) {
tryAddImportToParentCompilationUnit(clazz);
return addImplements(clazz.getSimpleName());
}
}
@@ -1,261 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.utils.Utils.ensureNotNull;
import java.util.EnumSet;
import java.util.List;
import com.github.javaparser.Range;
import com.github.javaparser.ast.AccessSpecifier;
import com.github.javaparser.ast.Modifier;
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.nodeTypes.NodeWithBlockStmt;
import com.github.javaparser.ast.nodeTypes.NodeWithDeclaration;
import com.github.javaparser.ast.nodeTypes.NodeWithJavaDoc;
import com.github.javaparser.ast.nodeTypes.NodeWithModifiers;
import com.github.javaparser.ast.nodeTypes.NodeWithName;
import com.github.javaparser.ast.nodeTypes.NodeWithParameters;
import com.github.javaparser.ast.nodeTypes.NodeWithThrowable;
import com.github.javaparser.ast.stmt.BlockStmt;
import com.github.javaparser.ast.type.ReferenceType;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
/**
* @author Julio Vilmar Gesser
*/
public final class ConstructorDeclaration extends BodyDeclaration<ConstructorDeclaration>
implements NodeWithJavaDoc<ConstructorDeclaration>, NodeWithDeclaration,
NodeWithName<ConstructorDeclaration>, NodeWithModifiers<ConstructorDeclaration>,
NodeWithParameters<ConstructorDeclaration>, NodeWithThrowable<ConstructorDeclaration>,
NodeWithBlockStmt<ConstructorDeclaration> {
private EnumSet<Modifier> modifiers = EnumSet.noneOf(Modifier.class);
private List<TypeParameter> typeParameters;
private NameExpr name;
private List<Parameter> parameters;
private List<ReferenceType> throws_;
private BlockStmt body;
public ConstructorDeclaration() {
}
public ConstructorDeclaration(EnumSet<Modifier> modifiers, String name) {
setModifiers(modifiers);
setName(name);
}
public ConstructorDeclaration(EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations,
List<TypeParameter> typeParameters,
String name, List<Parameter> parameters, List<ReferenceType> throws_,
BlockStmt block) {
super(annotations);
setModifiers(modifiers);
setTypeParameters(typeParameters);
setName(name);
setParameters(parameters);
setThrows(throws_);
setBody(block);
}
public ConstructorDeclaration(Range range, EnumSet<Modifier> modifiers,
List<AnnotationExpr> annotations, List<TypeParameter> typeParameters, String name,
List<Parameter> parameters, List<ReferenceType> throws_, BlockStmt block) {
super(range, annotations);
setModifiers(modifiers);
setTypeParameters(typeParameters);
setName(name);
setParameters(parameters);
setThrows(throws_);
setBody(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);
}
/**
* Return the modifiers of this member declaration.
*
* @see Modifier
* @return modifiers
*/
@Override
public EnumSet<Modifier> getModifiers() {
return modifiers;
}
@Override
public String getName() {
return name == null ? null : name.getName();
}
public NameExpr getNameExpr() {
return name;
}
@Override
public List<Parameter> getParameters() {
parameters = ensureNotNull(parameters);
return parameters;
}
@Override
public List<ReferenceType> getThrows() {
throws_ = ensureNotNull(throws_);
return throws_;
}
public List<TypeParameter> getTypeParameters() {
typeParameters = ensureNotNull(typeParameters);
return typeParameters;
}
@Override
public ConstructorDeclaration setModifiers(EnumSet<Modifier> modifiers) {
this.modifiers = modifiers;
return this;
}
@Override
public ConstructorDeclaration setName(String name) {
setNameExpr(new NameExpr(name));
return this;
}
public ConstructorDeclaration setNameExpr(NameExpr name) {
this.name = name;
setAsParentNodeOf(this.name);
return this;
}
@Override
public ConstructorDeclaration setParameters(List<Parameter> parameters) {
this.parameters = parameters;
setAsParentNodeOf(this.parameters);
return this;
}
@Override
public ConstructorDeclaration setThrows(List<ReferenceType> throws_) {
this.throws_ = throws_;
setAsParentNodeOf(this.throws_);
return this;
}
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) {
StringBuilder sb = new StringBuilder();
if (includingModifiers) {
AccessSpecifier accessSpecifier = Modifier.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 (ReferenceType 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 JavadocComment getJavaDoc() {
if (getComment() instanceof JavadocComment) {
return (JavadocComment) getComment();
}
return null;
}
@Override
public BlockStmt getBody() {
return body;
}
@Override
public ConstructorDeclaration setBody(BlockStmt body) {
this.body = body;
setAsParentNodeOf(body);
return this;
}
}
@@ -1,61 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
import com.github.javaparser.ast.comments.JavadocComment;
import com.github.javaparser.ast.nodeTypes.NodeWithJavaDoc;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
/**
* @author Julio Vilmar Gesser
*/
public final class EmptyMemberDeclaration extends BodyDeclaration<EmptyMemberDeclaration>
implements NodeWithJavaDoc<EmptyMemberDeclaration> {
public EmptyMemberDeclaration() {
super(null);
}
public EmptyMemberDeclaration(Range range) {
super(range, 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 JavadocComment getJavaDoc() {
if(getComment() instanceof JavadocComment){
return (JavadocComment) getComment();
}
return null;
}
}
@@ -1,53 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.EnumSet;
import com.github.javaparser.Range;
import com.github.javaparser.ast.Modifier;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
/**
* @author Julio Vilmar Gesser
*/
public final class EmptyTypeDeclaration extends TypeDeclaration<EmptyTypeDeclaration> {
public EmptyTypeDeclaration() {
super(null, EnumSet.noneOf(Modifier.class), null, null);
}
public EmptyTypeDeclaration(Range range) {
super(range, null, EnumSet.noneOf(Modifier.class), null, 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);
}
}
@@ -1,126 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.utils.Utils.ensureNotNull;
import java.util.List;
import com.github.javaparser.Range;
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.expr.NameExpr;
import com.github.javaparser.ast.nodeTypes.NodeWithJavaDoc;
import com.github.javaparser.ast.nodeTypes.NodeWithName;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
/**
* @author Julio Vilmar Gesser
*/
public final class EnumConstantDeclaration extends BodyDeclaration<EnumConstantDeclaration>
implements NodeWithJavaDoc<EnumConstantDeclaration>, NodeWithName<EnumConstantDeclaration> {
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(Range range, List<AnnotationExpr> annotations, String name, List<Expression> args,
List<BodyDeclaration<?>> classBody) {
super(range, 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;
}
@Override
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);
}
@Override
public EnumConstantDeclaration setName(String name) {
this.name = name;
return this;
}
@Override
public JavadocComment getJavaDoc() {
if(getComment() instanceof JavadocComment){
return (JavadocComment) getComment();
}
return null;
}
public EnumConstantDeclaration addArgument(String valueExpr) {
getArgs().add(NameExpr.create(valueExpr));
return this;
}
}
@@ -1,132 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.utils.Utils.ensureNotNull;
import java.util.EnumSet;
import java.util.List;
import com.github.javaparser.Range;
import com.github.javaparser.ast.Modifier;
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;
/**
* @author Julio Vilmar Gesser
*/
public final class EnumDeclaration extends TypeDeclaration<EnumDeclaration> {
private List<ClassOrInterfaceType> implementsList;
private List<EnumConstantDeclaration> entries;
public EnumDeclaration() {
}
public EnumDeclaration(EnumSet<Modifier> modifiers, String name) {
super(modifiers, name);
}
public EnumDeclaration(EnumSet<Modifier> 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(Range range, EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, String name,
List<ClassOrInterfaceType> implementsList, List<EnumConstantDeclaration> entries,
List<BodyDeclaration<?>> members) {
super(range, 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 EnumDeclaration setEntries(List<EnumConstantDeclaration> entries) {
this.entries = entries;
setAsParentNodeOf(this.entries);
return this;
}
public EnumDeclaration setImplements(List<ClassOrInterfaceType> implementsList) {
this.implementsList = implementsList;
setAsParentNodeOf(this.implementsList);
return this;
}
/**
* Add an implements to this enum
*
* @param name the name of the type to extends from
* @return this, the {@link EnumDeclaration}
*/
public EnumDeclaration addImplements(String name) {
ClassOrInterfaceType classOrInterfaceType = new ClassOrInterfaceType(name);
getImplements().add(classOrInterfaceType);
classOrInterfaceType.setParentNode(this);
return this;
}
/**
* Add an implements to this enum and automatically add the import
*
* @param clazz the type to implements from
* @return this, the {@link EnumDeclaration}
*/
public EnumDeclaration addImplements(Class<?> clazz) {
tryAddImportToParentCompilationUnit(clazz);
return addImplements(clazz.getSimpleName());
}
public EnumConstantDeclaration addEnumConstant(String name) {
EnumConstantDeclaration enumConstant = new EnumConstantDeclaration(name);
getEntries().add(enumConstant);
enumConstant.setParentNode(this);
return enumConstant;
}
}
@@ -1,251 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.ast.Modifier.*;
import static com.github.javaparser.ast.type.VoidType.*;
import static com.github.javaparser.utils.Utils.ensureNotNull;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import com.github.javaparser.Range;
import com.github.javaparser.ast.Modifier;
import com.github.javaparser.ast.comments.JavadocComment;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.expr.AssignExpr;
import com.github.javaparser.ast.expr.AssignExpr.Operator;
import com.github.javaparser.ast.expr.NameExpr;
import com.github.javaparser.ast.nodeTypes.NodeWithJavaDoc;
import com.github.javaparser.ast.nodeTypes.NodeWithModifiers;
import com.github.javaparser.ast.nodeTypes.NodeWithType;
import com.github.javaparser.ast.stmt.BlockStmt;
import com.github.javaparser.ast.stmt.ReturnStmt;
import com.github.javaparser.ast.type.Type;
import com.github.javaparser.ast.type.VoidType;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
/**
* @author Julio Vilmar Gesser
*/
public final class FieldDeclaration extends BodyDeclaration<FieldDeclaration>
implements NodeWithJavaDoc<FieldDeclaration>, NodeWithType<FieldDeclaration>,
NodeWithModifiers<FieldDeclaration> {
private EnumSet<Modifier> modifiers = EnumSet.noneOf(Modifier.class);
private Type type;
private List<VariableDeclarator> variables;
public FieldDeclaration() {
}
public FieldDeclaration(EnumSet<Modifier> modifiers, Type type, VariableDeclarator variable) {
setModifiers(modifiers);
setType(type);
List<VariableDeclarator> aux = new ArrayList<>();
aux.add(variable);
setVariables(aux);
}
public FieldDeclaration(EnumSet<Modifier> modifiers, Type type, List<VariableDeclarator> variables) {
setModifiers(modifiers);
setType(type);
setVariables(variables);
}
public FieldDeclaration(EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, Type type,
List<VariableDeclarator> variables) {
super(annotations);
setModifiers(modifiers);
setType(type);
setVariables(variables);
}
public FieldDeclaration(Range range, EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, Type type,
List<VariableDeclarator> variables) {
super(range, annotations);
setModifiers(modifiers);
setType(type);
setVariables(variables);
}
/**
* Creates a {@link FieldDeclaration}.
*
* @param modifiers
* modifiers
* @param type
* type
* @param variable
* variable declarator
* @return instance of {@link FieldDeclaration}
*/
public static FieldDeclaration create(EnumSet<Modifier> modifiers, Type type,
VariableDeclarator variable) {
List<VariableDeclarator> variables = new ArrayList<>();
variables.add(variable);
return new FieldDeclaration(modifiers, type, variables);
}
/**
* Creates a {@link FieldDeclaration}.
*
* @param modifiers
* modifiers
* @param type
* type
* @param name
* field name
* @return instance of {@link FieldDeclaration}
*/
public static FieldDeclaration create(EnumSet<Modifier> modifiers, Type type, String name) {
VariableDeclaratorId id = new VariableDeclaratorId(name);
VariableDeclarator variable = new VariableDeclarator(id);
return create(modifiers, type, variable);
}
@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 Modifier
* @return modifiers
*/
@Override
public EnumSet<Modifier> getModifiers() {
return modifiers;
}
@Override
public Type getType() {
return type;
}
public List<VariableDeclarator> getVariables() {
variables = ensureNotNull(variables);
return variables;
}
@Override
public FieldDeclaration setModifiers(EnumSet<Modifier> modifiers) {
this.modifiers = modifiers;
return this;
}
@Override
public FieldDeclaration setType(Type type) {
this.type = type;
setAsParentNodeOf(this.type);
return this;
}
public void setVariables(List<VariableDeclarator> variables) {
this.variables = variables;
setAsParentNodeOf(this.variables);
}
@Override
public JavadocComment getJavaDoc() {
if (getComment() instanceof JavadocComment) {
return (JavadocComment) getComment();
}
return null;
}
/**
* Create a getter for this field, <b>will only work if this field declares only 1 identifier and if this field is
* already added to a ClassOrInterfaceDeclaration</b>
*
* @return the {@link MethodDeclaration} created
* @throws IllegalStateException if there is more than 1 variable identifier or if this field isn't attached to a
* class or enum
*/
public MethodDeclaration createGetter() {
if (getVariables().size() != 1)
throw new IllegalStateException("You can use this only when the field declares only 1 variable name");
ClassOrInterfaceDeclaration parentClass = getParentNodeOfType(ClassOrInterfaceDeclaration.class);
EnumDeclaration parentEnum = getParentNodeOfType(EnumDeclaration.class);
if ((parentClass == null && parentEnum == null) || (parentClass != null && parentClass.isInterface()))
throw new IllegalStateException(
"You can use this only when the field is attached to a class or an enum");
String fieldName = getVariables().get(0).getId().getName();
String fieldNameUpper = fieldName.toUpperCase().substring(0, 1) + fieldName.substring(1, fieldName.length());
final MethodDeclaration getter;
if (parentClass != null)
getter = parentClass.addMethod("get" + fieldNameUpper, PUBLIC);
else
getter = parentEnum.addMethod("get" + fieldNameUpper, PUBLIC);
getter.setType(getType());
BlockStmt blockStmt = new BlockStmt();
getter.setBody(blockStmt);
blockStmt.addStatement(new ReturnStmt(NameExpr.create(fieldName)));
return getter;
}
/**
* Create a setter for this field, <b>will only work if this field declares only 1 identifier and if this field is
* already added to a ClassOrInterfaceDeclaration</b>
*
* @return the {@link MethodDeclaration} created
* @throws IllegalStateException if there is more than 1 variable identifier or if this field isn't attached to a
* class or enum
*/
public MethodDeclaration createSetter() {
if (getVariables().size() != 1)
throw new IllegalStateException("You can use this only when the field declares only 1 variable name");
ClassOrInterfaceDeclaration parentClass = getParentNodeOfType(ClassOrInterfaceDeclaration.class);
EnumDeclaration parentEnum = getParentNodeOfType(EnumDeclaration.class);
if ((parentClass == null && parentEnum == null) || (parentClass != null && parentClass.isInterface()))
throw new IllegalStateException(
"You can use this only when the field is attached to a class or an enum");
String fieldName = getVariables().get(0).getId().getName();
String fieldNameUpper = fieldName.toUpperCase().substring(0, 1) + fieldName.substring(1, fieldName.length());
final MethodDeclaration setter;
if (parentClass != null)
setter = parentClass.addMethod("set" + fieldNameUpper, PUBLIC);
else
setter = parentEnum.addMethod("set" + fieldNameUpper, PUBLIC);
setter.setType(VOID_TYPE);
setter.getParameters().add(new Parameter(getType(), new VariableDeclaratorId(fieldName)));
BlockStmt blockStmt2 = new BlockStmt();
setter.setBody(blockStmt2);
blockStmt2.addStatement(new AssignExpr(new NameExpr("this." + fieldName), new NameExpr(fieldName), Operator.assign));
return setter;
}
}
@@ -1,90 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
import com.github.javaparser.ast.comments.JavadocComment;
import com.github.javaparser.ast.nodeTypes.NodeWithJavaDoc;
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<InitializerDeclaration>
implements NodeWithJavaDoc<InitializerDeclaration> {
private boolean isStatic;
private BlockStmt block;
public InitializerDeclaration() {
}
public InitializerDeclaration(boolean isStatic, BlockStmt block) {
super(null);
setStatic(isStatic);
setBlock(block);
}
public InitializerDeclaration(Range range, boolean isStatic, BlockStmt block) {
super(range, 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 JavadocComment getJavaDoc() {
if(getComment() instanceof JavadocComment){
return (JavadocComment) getComment();
}
return null;
}
}
@@ -1,338 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.utils.Utils.ensureNotNull;
import java.util.EnumSet;
import java.util.List;
import com.github.javaparser.Range;
import com.github.javaparser.ast.AccessSpecifier;
import com.github.javaparser.ast.Modifier;
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.nodeTypes.NodeWithBlockStmt;
import com.github.javaparser.ast.nodeTypes.NodeWithDeclaration;
import com.github.javaparser.ast.nodeTypes.NodeWithJavaDoc;
import com.github.javaparser.ast.nodeTypes.NodeWithModifiers;
import com.github.javaparser.ast.nodeTypes.NodeWithName;
import com.github.javaparser.ast.nodeTypes.NodeWithParameters;
import com.github.javaparser.ast.nodeTypes.NodeWithThrowable;
import com.github.javaparser.ast.nodeTypes.NodeWithType;
import com.github.javaparser.ast.stmt.BlockStmt;
import com.github.javaparser.ast.type.ReferenceType;
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 MethodDeclaration extends BodyDeclaration<MethodDeclaration>
implements NodeWithJavaDoc<MethodDeclaration>, NodeWithDeclaration, NodeWithName<MethodDeclaration>,
NodeWithType<MethodDeclaration>,
NodeWithModifiers<MethodDeclaration>, NodeWithParameters<MethodDeclaration>,
NodeWithThrowable<MethodDeclaration>, NodeWithBlockStmt<MethodDeclaration> {
private EnumSet<Modifier> modifiers = EnumSet.noneOf(Modifier.class);
private List<TypeParameter> typeParameters;
private Type type;
private NameExpr name;
private List<Parameter> parameters;
private int arrayCount;
private List<ReferenceType> throws_;
private BlockStmt body;
private boolean isDefault = false;
public MethodDeclaration() {
}
public MethodDeclaration(final EnumSet<Modifier> modifiers, final Type type, final String name) {
setModifiers(modifiers);
setType(type);
setName(name);
}
public MethodDeclaration(final EnumSet<Modifier> modifiers, final Type type, final String name,
final List<Parameter> parameters) {
setModifiers(modifiers);
setType(type);
setName(name);
setParameters(parameters);
}
public MethodDeclaration(final EnumSet<Modifier> modifiers, final List<AnnotationExpr> annotations,
final List<TypeParameter> typeParameters, final Type type, final String name,
final List<Parameter> parameters, final int arrayCount, final List<ReferenceType> throws_,
final BlockStmt body) {
super(annotations);
setModifiers(modifiers);
setTypeParameters(typeParameters);
setType(type);
setName(name);
setParameters(parameters);
setArrayCount(arrayCount);
setThrows(throws_);
setBody(body);
}
public MethodDeclaration(Range range,
final EnumSet<Modifier> modifiers, final List<AnnotationExpr> annotations,
final List<TypeParameter> typeParameters, final Type type, final String name,
final List<Parameter> parameters, final int arrayCount, final List<ReferenceType> throws_,
final BlockStmt body) {
super(range, annotations);
setModifiers(modifiers);
setTypeParameters(typeParameters);
setType(type);
setName(name);
setParameters(parameters);
setArrayCount(arrayCount);
setThrows(throws_);
setBody(body);
}
@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;
}
@Override
public BlockStmt getBody() {
return body;
}
/**
* Return the modifiers of this member declaration.
*
* @see Modifier
* @return modifiers
*/
@Override
public EnumSet<Modifier> getModifiers() {
return modifiers;
}
@Override
public String getName() {
return name.getName();
}
public NameExpr getNameExpr() {
return name;
}
@Override
public List<Parameter> getParameters() {
parameters = ensureNotNull(parameters);
return parameters;
}
@Override
public List<ReferenceType> getThrows() {
throws_ = ensureNotNull(throws_);
return throws_;
}
@Override
public Type getType() {
return type;
}
public List<TypeParameter> getTypeParameters() {
typeParameters = ensureNotNull(typeParameters);
return typeParameters;
}
public void setArrayCount(final int arrayCount) {
this.arrayCount = arrayCount;
}
@Override
public MethodDeclaration setBody(final BlockStmt body) {
this.body = body;
setAsParentNodeOf(this.body);
return this;
}
@Override
public MethodDeclaration setModifiers(final EnumSet<Modifier> modifiers) {
this.modifiers = modifiers;
return this;
}
@Override
public MethodDeclaration setName(final String name) {
setNameExpr(new NameExpr(name));
return this;
}
public MethodDeclaration setNameExpr(final NameExpr name) {
this.name = name;
setAsParentNodeOf(this.name);
return this;
}
@Override
public MethodDeclaration setParameters(final List<Parameter> parameters) {
this.parameters = parameters;
setAsParentNodeOf(this.parameters);
return this;
}
@Override
public MethodDeclaration setThrows(final List<ReferenceType> throws_) {
this.throws_ = throws_;
setAsParentNodeOf(this.throws_);
return this;
}
@Override
public MethodDeclaration setType(final Type type) {
this.type = type;
setAsParentNodeOf(this.type);
return this;
}
public MethodDeclaration setTypeParameters(final List<TypeParameter> typeParameters) {
this.typeParameters = typeParameters;
setAsParentNodeOf(typeParameters);
return this;
}
public boolean isDefault() {
return isDefault;
}
public MethodDeclaration setDefault(boolean isDefault) {
this.isDefault = isDefault;
return this;
}
@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) {
StringBuilder sb = new StringBuilder();
if (includingModifiers) {
AccessSpecifier accessSpecifier = Modifier.getAccessSpecifier(getModifiers());
sb.append(accessSpecifier.getCodeRepresenation());
sb.append(accessSpecifier == AccessSpecifier.DEFAULT ? "" : " ");
if (getModifiers().contains(Modifier.STATIC)) {
sb.append("static ");
}
if (getModifiers().contains(Modifier.ABSTRACT)) {
sb.append("abstract ");
}
if (getModifiers().contains(Modifier.FINAL)) {
sb.append("final ");
}
if (getModifiers().contains(Modifier.NATIVE)) {
sb.append("native ");
}
if (getModifiers().contains(Modifier.SYNCHRONIZED)) {
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 (ReferenceType thr : getThrows()) {
if (firstThrow) {
firstThrow = false;
sb.append(" throws ");
} else {
sb.append(", ");
}
sb.append(thr.toStringWithoutComments());
}
}
return sb.toString();
}
@Override
public JavadocComment getJavaDoc() {
if (getComment() instanceof JavadocComment) {
return (JavadocComment) getComment();
}
return null;
}
}
@@ -1,67 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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 java.util.EnumSet;
import com.github.javaparser.Range;
import com.github.javaparser.ast.Modifier;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.type.UnionType;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
public class MultiTypeParameter extends BaseParameter<MultiTypeParameter> {
private UnionType type;
public MultiTypeParameter() {}
public MultiTypeParameter(EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, UnionType type, VariableDeclaratorId id) {
super(modifiers, annotations, id);
this.type = type;
}
public MultiTypeParameter(Range range, EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, UnionType type, VariableDeclaratorId id) {
super(range, modifiers, annotations, id);
this.type = 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 UnionType getType() {
return type;
}
public void setType(UnionType type) {
this.type = type;
}
}
@@ -1,105 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.EnumSet;
import java.util.List;
import com.github.javaparser.Range;
import com.github.javaparser.ast.Modifier;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.nodeTypes.NodeWithType;
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 Parameter extends BaseParameter<Parameter> implements NodeWithType<Parameter> {
private Type type;
private boolean isVarArgs;
public Parameter() {
}
public Parameter(Type type, VariableDeclaratorId id) {
super(id);
setType(type);
}
/**
* 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 create(Type type, String name) {
return new Parameter(type, new VariableDeclaratorId(name));
}
public Parameter(EnumSet<Modifier> modifiers, Type type, VariableDeclaratorId id) {
super(modifiers, id);
setType(type);
}
public Parameter(final Range range, EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, Type type,
boolean isVarArgs, VariableDeclaratorId id) {
super(range, 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);
}
@Override
public Type getType() {
return type;
}
public boolean isVarArgs() {
return isVarArgs;
}
@Override
public Parameter setType(Type type) {
this.type = type;
setAsParentNodeOf(this.type);
return this;
}
public void setVarArgs(boolean isVarArgs) {
this.isVarArgs = isVarArgs;
}
}
@@ -1,160 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.utils.Utils.ensureNotNull;
import static com.github.javaparser.utils.Utils.isNullOrEmpty;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import com.github.javaparser.Range;
import com.github.javaparser.ast.Modifier;
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.nodeTypes.NodeWithJavaDoc;
import com.github.javaparser.ast.nodeTypes.NodeWithMembers;
import com.github.javaparser.ast.nodeTypes.NodeWithModifiers;
import com.github.javaparser.ast.nodeTypes.NodeWithName;
/**
* @author Julio Vilmar Gesser
*/
public abstract class TypeDeclaration<T> extends BodyDeclaration<T>
implements NodeWithName<T>, NodeWithJavaDoc<T>, NodeWithModifiers<T>, NodeWithMembers<T> {
private NameExpr name;
private EnumSet<Modifier> modifiers = EnumSet.noneOf(Modifier.class);
private List<BodyDeclaration<?>> members;
public TypeDeclaration() {
}
public TypeDeclaration(EnumSet<Modifier> modifiers, String name) {
setName(name);
setModifiers(modifiers);
}
public TypeDeclaration(List<AnnotationExpr> annotations,
EnumSet<Modifier> modifiers, String name,
List<BodyDeclaration<?>> members) {
super(annotations);
setName(name);
setModifiers(modifiers);
setMembers(members);
}
public TypeDeclaration(Range range, List<AnnotationExpr> annotations,
EnumSet<Modifier> modifiers, String name,
List<BodyDeclaration<?>> members) {
super(range, annotations);
setName(name);
setModifiers(modifiers);
setMembers(members);
}
/**
* Adds the given declaration to the specified type. The list of members
* will be initialized if it is <code>null</code>.
*
* @param decl
* member declaration
*/
public TypeDeclaration<T> addMember(BodyDeclaration<?> decl) {
List<BodyDeclaration<?>> members = getMembers();
if (isNullOrEmpty(members)) {
members = new ArrayList<>();
setMembers(members);
}
members.add(decl);
decl.setParentNode(this);
return this;
}
@Override
public List<BodyDeclaration<?>> getMembers() {
members = ensureNotNull(members);
return members;
}
/**
* Return the modifiers of this type declaration.
*
* @see Modifier
* @return modifiers
*/
@Override
public final EnumSet<Modifier> getModifiers() {
return modifiers;
}
@Override
public final String getName() {
return name.getName();
}
@SuppressWarnings("unchecked")
@Override
public T setMembers(List<BodyDeclaration<?>> members) {
this.members = members;
setAsParentNodeOf(this.members);
return (T) this;
}
@SuppressWarnings("unchecked")
@Override
public T setModifiers(EnumSet<Modifier> modifiers) {
this.modifiers = modifiers;
return (T) this;
}
@Override
@SuppressWarnings("unchecked")
public T setName(String name) {
setNameExpr(new NameExpr(name));
return (T) this;
}
@SuppressWarnings("unchecked")
public T setNameExpr(NameExpr nameExpr) {
this.name = nameExpr;
setAsParentNodeOf(this.name);
return (T) this;
}
public final NameExpr getNameExpr() {
return name;
}
@Override
public JavadocComment getJavaDoc() {
if(getComment() instanceof JavadocComment){
return (JavadocComment) getComment();
}
return null;
}
}
@@ -1,90 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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(Range range, VariableDeclaratorId id, Expression init) {
super(range);
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);
}
}
@@ -1,81 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.nodeTypes.NodeWithName;
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 NodeWithName<VariableDeclaratorId> {
private String name;
private int arrayCount;
public VariableDeclaratorId() {
}
public VariableDeclaratorId(String name) {
setName(name);
}
public VariableDeclaratorId(Range range, String name, int arrayCount) {
super(range);
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;
}
@Override
public String getName() {
return name;
}
public void setArrayCount(int arrayCount) {
this.arrayCount = arrayCount;
}
@Override
public VariableDeclaratorId setName(String name) {
this.name = name;
return this;
}
}
@@ -1,59 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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 "/&#42;" and
* "&#42;/".
*
* @author Julio Vilmar Gesser
*/
public final class BlockComment extends Comment {
public BlockComment() {
}
public BlockComment(String content) {
super(content);
}
public BlockComment(Range range, String content) {
super(range, 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);
}
}
@@ -1,108 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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(Range range, String content) {
super(range);
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 = null;
return;
}
if (commentedNode==this) {
throw new IllegalArgumentException();
}
if (commentedNode instanceof Comment) {
throw new IllegalArgumentException();
}
this.commentedNode = commentedNode;
}
public boolean isOrphan()
{
return this.commentedNode == null;
}
}
@@ -1,104 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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 tolerate a difference of one element in the end column:
// it depends how \r and \n are calculated...
if ( c.getBegin().line==comment.getBegin().line &&
c.getBegin().column==comment.getBegin().column &&
c.getEnd().line==comment.getEnd().line &&
Math.abs(c.getEnd().column-comment.getEnd().column)<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;
}
}
@@ -1,223 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.util.*;
import static com.github.javaparser.Position.pos;
import static com.github.javaparser.Range.range;
/**
* 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 {
return parse(new StringReader(source));
}
public CommentsCollection parse(final InputStream in, final String charsetName) throws IOException {
return parse(new InputStreamReader(in, charsetName));
}
/**
* Track the internal state of the parser, remembering the last characters observed.
*/
private static class ParserState {
private Deque<Character> prevTwoChars = new LinkedList<Character>();
/**
* Is the last character the one expected?
*/
boolean isLastChar(char expectedChar) {
return !prevTwoChars.isEmpty() && prevTwoChars.peekLast().equals(expectedChar);
}
/**
* Is the character before the last one the same as expectedChar?
*/
public boolean isSecondToLastChar(char expectedChar) {
return !prevTwoChars.isEmpty() && prevTwoChars.peekFirst().equals(expectedChar);
}
/**
* Record a new character. It will be the last one. The character that was the last one will
* become the second to last one.
*/
public void update(char c) {
if (prevTwoChars.size() == 2) {
prevTwoChars.remove();
}
prevTwoChars.add(c);
}
/**
* Remove all the characters observed.
*/
public void reset() {
while (!prevTwoChars.isEmpty()) {
prevTwoChars.removeFirst();
}
}
}
/**
* Collects all comments in a piece of Java source.
*/
public CommentsCollection parse(final Reader in) throws IOException {
boolean lastWasASlashR = false;
BufferedReader br = new BufferedReader(in);
CommentsCollection comments = new CommentsCollection();
int r;
ParserState parserState = new ParserState();
State state = State.CODE;
LineComment currentLineComment = null;
BlockComment currentBlockComment = null;
StringBuilder 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 (parserState.isLastChar('/') && c == '/') {
currentLineComment = new LineComment();
currentLineComment.setBegin(pos(currLine, currCol - 1));
state = State.IN_LINE_COMMENT;
currentContent = new StringBuilder();
} else if (parserState.isLastChar('/') && c == '*') {
currentBlockComment = new BlockComment();
currentBlockComment.setBegin(pos(currLine, currCol - 1));
state = State.IN_BLOCK_COMMENT;
currentContent = new StringBuilder();
} 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.setEnd(pos(currLine, currCol));
comments.addComment(currentLineComment);
state = State.CODE;
} else {
currentContent.append(c);
}
break;
case IN_BLOCK_COMMENT:
// '/*/' is not a valid block comment: it starts the block comment but it does not close it
// However this sequence can be contained inside a comment and in that case it close the comment
// For example:
// /* blah blah /*/
// At the previous line we had a valid block comment
if (parserState.isLastChar('*') && c=='/' && (!parserState.isSecondToLastChar('/') || currentContent.length() > 0)){
// 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.setRange(range(pos(currentBlockComment.getBegin().line, currentBlockComment.getBegin().column), pos(currLine, currCol+1)));
comments.addComment(javadocComment);
} else {
currentBlockComment.setContent(content);
currentBlockComment.setEnd(pos(currLine, currCol+1));
comments.addComment(currentBlockComment);
}
state = State.CODE;
} else {
currentContent.append(c == '\r' ? System.getProperty("line.separator") : c);
}
break;
case IN_STRING:
if (!parserState.isLastChar('\\') && c == '"') {
state = State.CODE;
}
break;
case IN_CHAR:
if (!parserState.isLastChar('\\') && 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;
}
// ok we have two slashes in a row inside a string
// we want to replace them with... anything else, to not confuse
// the parser
if (state==State.IN_STRING && parserState.isLastChar('\\') && c == '\\') {
parserState.reset();
} else {
parserState.update(c);
}
}
if (state==State.IN_LINE_COMMENT){
currentLineComment.setContent(currentContent.toString());
currentLineComment.setEnd(pos(currLine, currCol));
comments.addComment(currentLineComment);
}
return comments;
}
}
@@ -1,53 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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(Range range, String content) {
super(range, 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);
}
}
@@ -1,64 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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(Range range, String content) {
super(range, 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);
}
@Override
public boolean isLineComment()
{
return true;
}
}
@@ -1,47 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
/**
* @author Julio Vilmar Gesser
*/
public abstract class AnnotationExpr extends Expression {
protected NameExpr name;
public AnnotationExpr() {}
public AnnotationExpr(Range range) {
super(range);
}
public NameExpr getName() {
return name;
}
public void setName(NameExpr name) {
this.name = name;
setAsParentNodeOf(name);
}
}
@@ -1,78 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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(Range range, Expression name, Expression index) {
super(range);
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);
}
}
@@ -1,147 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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 java.util.List;
import com.github.javaparser.Range;
import com.github.javaparser.ast.nodeTypes.NodeWithArrays;
import com.github.javaparser.ast.nodeTypes.NodeWithType;
import com.github.javaparser.ast.type.Type;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
import static com.github.javaparser.utils.Utils.ensureNotNull;
/**
* @author Julio Vilmar Gesser
*/
public final class ArrayCreationExpr extends Expression implements NodeWithType<ArrayCreationExpr>, NodeWithArrays<ArrayCreationExpr> {
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(Range range, Type type, int arrayCount, ArrayInitializerExpr initializer) {
super(range);
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(Range range, Type type, List<Expression> dimensions, int arrayCount) {
super(range);
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);
}
@Override
public int getArrayCount() {
return arrayCount;
}
public List<Expression> getDimensions() {
dimensions = ensureNotNull(dimensions);
return dimensions;
}
public ArrayInitializerExpr getInitializer() {
return initializer;
}
@Override
public Type getType() {
return type;
}
@Override
public ArrayCreationExpr setArrayCount(int arrayCount) {
this.arrayCount = arrayCount;
return this;
}
public void setDimensions(List<Expression> dimensions) {
this.dimensions = dimensions;
setAsParentNodeOf(this.dimensions);
}
public void setInitializer(ArrayInitializerExpr initializer) {
this.initializer = initializer;
setAsParentNodeOf(this.initializer);
}
@Override
public ArrayCreationExpr setType(Type type) {
this.type = type;
setAsParentNodeOf(this.type);
return this;
}
@Override
public List<List<AnnotationExpr>> getArraysAnnotations() {
arraysAnnotations = ensureNotNull(arraysAnnotations);
return arraysAnnotations;
}
@Override
public ArrayCreationExpr setArraysAnnotations(
List<List<AnnotationExpr>> arraysAnnotations) {
this.arraysAnnotations = arraysAnnotations;
return this;
}
}
@@ -1,70 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
import java.util.List;
import static com.github.javaparser.utils.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(Range range, List<Expression> values) {
super(range);
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);
}
}
@@ -1,105 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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 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(Range range, Expression target, Expression value, Operator op) {
super(range);
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);
}
}
@@ -1,112 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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 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(Range range, Expression left, Expression right, Operator op) {
super(range);
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);
}
}
@@ -1,64 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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(Range range, boolean value) {
super(range);
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;
}
}
@@ -1,83 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
import com.github.javaparser.ast.nodeTypes.NodeWithType;
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 implements NodeWithType<CastExpr> {
private Type type;
private Expression expr;
public CastExpr() {
}
public CastExpr(Type type, Expression expr) {
setType(type);
setExpr(expr);
}
public CastExpr(Range range, Type type, Expression expr) {
super(range);
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;
}
@Override
public Type getType() {
return type;
}
public void setExpr(Expression expr) {
this.expr = expr;
setAsParentNodeOf(this.expr);
}
@Override
public CastExpr setType(Type type) {
this.type = type;
setAsParentNodeOf(this.type);
return this;
}
}
@@ -1,61 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
import com.github.javaparser.utils.Utils;
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(Range range, String value) {
super(range, value);
}
/**
* Utility method that creates a new StringLiteralExpr. Escapes EOL characters.
*/
public static CharLiteralExpr escape(String string) {
return new CharLiteralExpr(Utils.escapeEndOfLines(string));
}
@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);
}
}
@@ -1,75 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
import com.github.javaparser.ast.nodeTypes.NodeWithType;
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 implements NodeWithType<ClassExpr> {
private Type type;
public ClassExpr() {
}
public ClassExpr(Type type) {
setType(type);
}
public ClassExpr(Range range, Type type) {
super(range);
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);
}
@Override
public Type getType() {
return type;
}
@Override
public ClassExpr setType(Type type) {
this.type = type;
setAsParentNodeOf(this.type);
return this;
}
}
@@ -1,91 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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(Range range, Expression condition, Expression thenExpr, Expression elseExpr) {
super(range);
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);
}
}
@@ -1,51 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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 Range range, final String value) {
super(range, 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);
}
}
@@ -1,63 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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 Range range, final Expression inner) {
super(range);
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);
}
}
@@ -1,39 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
import com.github.javaparser.ast.Node;
/**
* @author Julio Vilmar Gesser
*/
public abstract class Expression extends Node {
public Expression() {
}
public Expression(Range range) {
super(range);
}
}
@@ -1,102 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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.utils.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 Range range, final Expression scope, final List<Type> typeArgs, final String field) {
super(range);
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) {
setFieldExpr(new NameExpr(field));
}
public void setFieldExpr(NameExpr field) {
this.field = field;
setAsParentNodeOf(this.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);
}
}
@@ -1,81 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
import com.github.javaparser.ast.nodeTypes.NodeWithType;
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 implements NodeWithType<InstanceOfExpr> {
private Expression expr;
private Type type;
public InstanceOfExpr() {
}
public InstanceOfExpr(final Expression expr, final Type type) {
setExpr(expr);
setType(type);
}
public InstanceOfExpr(final Range range, final Expression expr, final Type type) {
super(range);
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;
}
@Override
public Type getType() {
return type;
}
public void setExpr(final Expression expr) {
this.expr = expr;
setAsParentNodeOf(this.expr);
}
@Override
public InstanceOfExpr setType(final Type type) {
this.type = type;
setAsParentNodeOf(this.type);
return this;
}
}
@@ -1,61 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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 Range range, final String value) {
super(range, 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);
}
}
@@ -1,49 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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 Range range) {
super(range, 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);
}
}
@@ -1,96 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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.utils.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(Range range, List<Parameter> parameters, Statement body,
boolean parametersEnclosed) {
super(range);
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;
}
}
@@ -1,37 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
/**
* @author Julio Vilmar Gesser
*/
public abstract class LiteralExpr extends Expression {
public LiteralExpr() {
}
public LiteralExpr(Range range) {
super(range);
}
}
@@ -1,62 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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 Range range, final String value) {
super(range, 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');
}
}
@@ -1,49 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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 Range range) {
super(range, 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);
}
}
@@ -1,53 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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 Range range, final NameExpr name) {
super(range);
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);
}
}
@@ -1,80 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.nodeTypes.NodeWithName;
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 NodeWithName<MemberValuePair> {
private String name;
private Expression value;
public MemberValuePair() {
}
public MemberValuePair(final String name, final Expression value) {
setName(name);
setValue(value);
}
public MemberValuePair(final Range range, final String name, final Expression value) {
super(range);
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);
}
@Override
public String getName() {
return name;
}
public Expression getValue() {
return value;
}
@Override
public MemberValuePair setName(final String name) {
this.name = name;
return this;
}
public void setValue(final Expression value) {
this.value = value;
setAsParentNodeOf(this.value);
}
}
@@ -1,141 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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.utils.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 Range range, final Expression scope, final List<Type> typeArgs, final String name, final List<Expression> args) {
super(range);
setScope(scope);
setTypeArgs(typeArgs);
setName(name);
setArgs(args);
}
/**
* Adds the given argument to the method call. The list of arguments will be
* initialized if it is <code>null</code>.
*
* @param arg
* argument value
*/
public MethodCallExpr addArgument(Expression arg) {
List<Expression> args = getArgs();
if (isNullOrEmpty(args)) {
args = new ArrayList<>();
setArgs(args);
}
args.add(arg);
arg.setParentNode(this);
return this;
}
@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) {
setNameExpr(new NameExpr(name));
}
public void setNameExpr(NameExpr name) {
this.name = name;
setAsParentNodeOf(this.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);
}
}
@@ -1,94 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
import com.github.javaparser.ast.TypeArguments;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
/**
* 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 TypeArguments typeArguments;
private String identifier;
public MethodReferenceExpr() {
}
public MethodReferenceExpr(Range range, Expression scope,
TypeArguments typeArguments, String identifier) {
super(range);
setIdentifier(identifier);
setScope(scope);
setTypeArguments(typeArguments);
}
@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 TypeArguments getTypeArguments() {
return typeArguments;
}
public void setTypeArguments(TypeArguments typeArguments) {
this.typeArguments = typeArguments;
}
public String getIdentifier() {
return identifier;
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
}
@@ -1,85 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
import com.github.javaparser.ast.nodeTypes.NodeWithName;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
/**
* @author Julio Vilmar Gesser
*/
public class NameExpr extends Expression implements NodeWithName<NameExpr> {
private String name;
public NameExpr() {
}
public NameExpr(final String name) {
this.name = name;
}
public NameExpr(Range range, final String name) {
super(range);
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);
}
@Override
public final String getName() {
return name;
}
@Override
public NameExpr setName(final String name) {
this.name = name;
return this;
}
/**
* 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 create(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;
}
}
@@ -1,93 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.utils.Utils.ensureNotNull;
import java.util.List;
import com.github.javaparser.Range;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
/**
* @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 Range range, final NameExpr name, final List<MemberValuePair> pairs) {
super(range);
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);
}
/**
* adds a pair to this annotation
*
* @return this, the {@link NormalAnnotationExpr}
*/
public NormalAnnotationExpr addPair(String key, String value) {
return addPair(key, NameExpr.create(value));
}
/**
* adds a pair to this annotation
*
* @return this, the {@link NormalAnnotationExpr}
*/
public NormalAnnotationExpr addPair(String key, NameExpr value) {
MemberValuePair memberValuePair = new MemberValuePair(key, value);
getPairs().add(memberValuePair);
memberValuePair.setParentNode(this);
return this;
}
}
@@ -1,47 +0,0 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2016 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.Range;
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 Range range) {
super(range);
}
@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);
}
}

Some files were not shown because too many files have changed in this diff Show More