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 @@ -18,6 +18,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;

Expand All @@ -36,7 +37,7 @@ public void putRootAnnotatedElements(String annotationName, Set<? extends Elemen
public void putAncestorAnnotatedElement(String annotationName, Element annotatedElement, TypeElement rootTypeElement) {
Set<AnnotatedAndRootElements> set = ancestorAnnotatedElementsByAnnotation.get(annotationName);
if (set == null) {
set = new HashSet<>();
set = new LinkedHashSet<>();
ancestorAnnotatedElementsByAnnotation.put(annotationName, set);
}
set.add(new AnnotatedAndRootElements(annotatedElement, rootTypeElement));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.androidannotations.internal.model;

import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

Expand Down Expand Up @@ -71,7 +72,7 @@ private Set<TypeElement> findRootTypeElements(Set<? extends Element> rootElement

private void extractAncestorsAnnotations(AnnotationElementsHolder extractedModel, Set<String> annotationTypesToCheck, Set<TypeElement> rootTypeElements) {
for (TypeElement rootTypeElement : rootTypeElements) {
Set<TypeElement> ancestors = new HashSet<>();
Set<TypeElement> ancestors = new LinkedHashSet<>();
addAncestorsElements(ancestors, rootTypeElement);
if (!ancestors.isEmpty()) {

Expand Down Expand Up @@ -121,8 +122,8 @@ private void addAncestorsElements(Set<TypeElement> elements, TypeElement typeEle
DeclaredType ancestorDeclaredType = (DeclaredType) ancestorTypeMirror;
Element ancestorElement = ancestorDeclaredType.asElement();
if (ancestorElement instanceof TypeElement) {
elements.add((TypeElement) ancestorElement);
addAncestorsElements(elements, (TypeElement) ancestorElement);
elements.add((TypeElement) ancestorElement);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.androidannotations.internal.process;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

Expand Down Expand Up @@ -58,7 +58,7 @@ public AnnotationElements validate(AnnotationElements extractedModel, Annotation

Set<? extends Element> annotatedElements = extractedModel.getRootAnnotatedElements(annotationName);

Set<Element> validatedAnnotatedElements = new HashSet<>();
Set<Element> validatedAnnotatedElements = new LinkedHashSet<>();

validatingHolder.putRootAnnotatedElements(annotationName, validatedAnnotatedElements);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* 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.menu;

import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsMenuItem;

import android.view.MenuItem;

@EActivity
public class OptionsMenuItemSubActivity extends OptionsMenuItemActivity {
@OptionsMenuItem
MenuItem menu1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* 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.menu;

import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsMenuItem;

import android.view.MenuItem;

@EActivity
public class OptionsMenuItemSubSubActivity extends OptionsMenuItemSubActivity {
@OptionsMenuItem
MenuItem menu2;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* 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.menu;

import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsMenuItem;

import android.view.MenuItem;

@EActivity
public class OptionsMenuItemSubSubSubActivity extends
OptionsMenuItemSubSubActivity {
@OptionsMenuItem
MenuItem menu3;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,22 @@ public void testWhenFieldNameCouldConflictWithParameterName() throws IOException
assertCompilationSuccessful(result);
}

@Test
public void testDeeplyInheritedMenuNotBreakOrder() throws IOException {
CompileResult result = compileFiles(OptionsMenuItemSubSubSubActivity.class);
assertCompilationSuccessful(result);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this test sufficient? You should check actually the code is in order, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. You are right. I fixed the test case.

// CHECKSTYLE:OFF
String[] codeFragment = { //
" @Override", //
" public boolean onCreateOptionsMenu(Menu menu) {", //
" MenuInflater menuInflater = getMenuInflater();", //
" this.menu = menu.findItem(R.id.menu);", //
" this.menu1 = menu.findItem(R.id.menu1);", //
" this.menu2 = menu.findItem(R.id.menu2);", //
" this.menu3 = menu.findItem(R.id.menu3);", //
" return super.onCreateOptionsMenu(menu);", //
" }",};
// CHECKSTYLE:ON
assertGeneratedClassContains(toGeneratedFile(OptionsMenuItemSubSubSubActivity.class), codeFragment);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
public class R {
public static final class id {
public static final int menu = 0x7f06000a;
public static final int menu1 = 0x7f06000b;
public static final int menu2 = 0x7f06000c;
public static final int menu3 = 0x7f06000d;
}
}