Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ protected void validate(Element element, AnnotationElements validatedElements, I

validatorHelper.enclosingElementHasAndroidAnnotation(element, validatedElements, valid);

validatorHelper.enclosingElementIsNotAbstractIfNotAbstract(element, valid);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ public void isStatic(Element element, IsValid valid) {
}
}

public void enclosingElementIsNotAbstractIfNotAbstract(Element element, IsValid valid) {
if (!annotationHelper.isAbstract(element) && annotationHelper.isAbstract(element.getEnclosingElement())) {
valid.invalidate();
annotationHelper.printAnnotationError(element, "%s cannot be used on a non-abstract inner element whose outer element is abstract");
}
}

public void enclosingElementHasEBeanAnnotation(Element element, AnnotationElements validatedElements, IsValid valid) {
Element enclosingElement = element.getEnclosingElement();
hasClassAnnotation(element, enclosingElement, validatedElements, EBean.class, valid);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright (C) 2010-2015 eBusiness Information, Excilys Group
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.androidannotations.innerclasses;

import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.EBean;

import android.app.Activity;

@EActivity
public abstract class AbstractActivityWithAbstractInnerClass extends Activity {

@EBean
static abstract class InnerClass {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (C) 2010-2015 eBusiness Information, Excilys Group
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.androidannotations.innerclasses;

import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.EBean;

import android.app.Activity;

@EActivity
public abstract class AbstractActivityWithNonAbstractInnerClass extends Activity {

@EBean
public static class InnerClass {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright (C) 2010-2015 eBusiness Information, Excilys Group
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.androidannotations.innerclasses;

import org.androidannotations.AndroidAnnotationProcessor;
import org.androidannotations.utils.AAProcessorTestHelper;
import org.junit.Before;
import org.junit.Test;

public class InnerClassTest extends AAProcessorTestHelper {

@Before
public void setUp() {
addManifestProcessorParameter(InnerClassTest.class);
addProcessor(AndroidAnnotationProcessor.class);
}

@Test
public void testNonAbstractInnerClassWithAbstractOuterClassDoesNotCompile() {
assertCompilationError(compileFiles(AbstractActivityWithNonAbstractInnerClass.class));
}

@Test
public void testAbstractInnerClassWithAbstractOuterClassDoesCompile() {
assertCompilationSuccessful(compileFiles(AbstractActivityWithAbstractInnerClass.class));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--

Copyright (C) 2010-2015 eBusiness Information, Excilys Group

Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed To in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.

-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.androidannotations.testprocessor"
android:versionCode="1"
android:versionName="1.0" >

<application>
</application>

</manifest>