aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/javac/handlers/PKG.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/lombok/javac/handlers/PKG.java')
-rw-r--r--src/lombok/javac/handlers/PKG.java23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/lombok/javac/handlers/PKG.java b/src/lombok/javac/handlers/PKG.java
index 615e4c80..25d1a93e 100644
--- a/src/lombok/javac/handlers/PKG.java
+++ b/src/lombok/javac/handlers/PKG.java
@@ -40,7 +40,7 @@ class PKG {
node = node.up();
}
- if ( node.get() instanceof JCClassDecl ) {
+ if ( node != null && node.get() instanceof JCClassDecl ) {
for ( JCTree def : ((JCClassDecl)node.get()).defs ) {
if ( def instanceof JCMethodDecl ) {
if ( ((JCMethodDecl)def).name.contentEquals(methodName) ) {
@@ -55,6 +55,27 @@ class PKG {
return MethodExistsResult.NOT_EXISTS;
}
+ static MethodExistsResult constructorExists(JavacAST.Node node) {
+ while ( node != null && !(node.get() instanceof JCClassDecl) ) {
+ node = node.up();
+ }
+
+ if ( node != null && node.get() instanceof JCClassDecl ) {
+ for ( JCTree def : ((JCClassDecl)node.get()).defs ) {
+ if ( def instanceof JCMethodDecl ) {
+ if ( ((JCMethodDecl)def).name.contentEquals("<init>") ) {
+ if ( (((JCMethodDecl)def).mods.flags & Flags.GENERATEDCONSTR) != 0 ) continue;
+ JavacAST.Node existing = node.getNodeFor(def);
+ if ( existing == null || !existing.isHandled() ) return MethodExistsResult.EXISTS_BY_USER;
+ return MethodExistsResult.EXISTS_BY_LOMBOK;
+ }
+ }
+ }
+ }
+
+ return MethodExistsResult.NOT_EXISTS;
+ }
+
static int toJavacModifier(AccessLevel accessLevel) {
switch ( accessLevel ) {
case MODULE: