Skip to content
This repository was archived by the owner on Aug 9, 2022. It is now read-only.

Commit de69fe1

Browse files
authored
September Release (#25)
* fix bug 100961, "[]" removed from all uids which leads to arrays not handle properly (#22) * fix bug 103515, fix inherited methods not added to references (#23) * fix bug 103515, some inherited methods not added to references * update test resource yml
1 parent 7f26c29 commit de69fe1

19 files changed

Lines changed: 906 additions & 19 deletions

src/main/java/com/microsoft/build/YmlFilesBuilder.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,7 @@ List<String> splitUidWithGenericsIntoClassNames(String uid) {
419419
}
420420

421421
MetadataFileItem buildRefItem(String uid) {
422-
uid = RegExUtils.removeAll(uid, "\\[\\]$");
423-
if (!uid.endsWith("*") && uid.contains("<")) {
422+
if (!uid.endsWith("*") && (uid.contains("<") || uid.contains("[]"))) {
424423
return new MetadataFileItem(uid, getJavaSpec(replaceUidAndSplit(uid)));
425424
} else {
426425
List<String> fullNameList = new ArrayList<>();
@@ -439,10 +438,12 @@ MetadataFileItem buildRefItem(String uid) {
439438
}
440439

441440
List<String> replaceUidAndSplit(String uid) {
442-
String retValue= RegExUtils.replaceAll(uid,"\\<","//<//");
443-
retValue = RegExUtils.replaceAll(retValue,"\\>","//>//");
444-
retValue = RegExUtils.replaceAll(retValue,",","//,//");
445-
return Arrays.asList(StringUtils.split(retValue, "//"));
441+
String retValue = RegExUtils.replaceAll(uid, "\\<", "//<//");
442+
retValue = RegExUtils.replaceAll(retValue, "\\>", "//>//");
443+
retValue = RegExUtils.replaceAll(retValue, ",", "//,//");
444+
retValue = RegExUtils.replaceAll(retValue, "\\[\\]", "//[]//");
445+
446+
return Arrays.asList(StringUtils.split(retValue, "//"));
446447
}
447448

448449
List<SpecViewModel> getJavaSpec(List<String> references) {
@@ -451,7 +452,10 @@ List<SpecViewModel> getJavaSpec(List<String> references) {
451452
Optional.ofNullable(references).ifPresent(
452453
ref -> references.forEach(
453454
uid -> {
454-
if(uid.equalsIgnoreCase("<") || uid.equalsIgnoreCase(">") || uid.equalsIgnoreCase(",") )
455+
if (uid.equalsIgnoreCase("<")
456+
|| uid.equalsIgnoreCase(">")
457+
|| uid.equalsIgnoreCase(",")
458+
|| uid.equalsIgnoreCase("[]"))
455459
specList.add(new SpecViewModel(null, uid));
456460
else if (uid != "")
457461
specList.add(new SpecViewModel(uid, uid));

src/main/java/com/microsoft/lookup/ClassLookup.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ void populateContent(TypeElement classElement, String shortNameWithGenericsSuppo
8282
.collect(Collectors.toList()));
8383

8484
addInterfacesToReferencesMap(interfaces, container);
85-
addInheritedMethodsToReferencesMap(container);
86-
}
8785

86+
}
87+
addInheritedMethodsToReferencesMap(container);
8888
container.setContent(result);
8989
}
9090

@@ -122,15 +122,15 @@ List<String> determineNestedSuperclass(TypeElement classElement, ExtendedMetadat
122122
nestedList = result.getSuperclass();
123123
}
124124

125-
TypeMirror supperclass = classElement.getSuperclass();
126-
if (supperclass.getKind() != TypeKind.NONE) {
127-
TypeElement supperClassElement = (TypeElement) environment.getTypeUtils().asElement(supperclass);
125+
TypeMirror superclass = classElement.getSuperclass();
126+
if (superclass.getKind() != TypeKind.NONE) {
127+
TypeElement superClassElement = (TypeElement) environment.getTypeUtils().asElement(superclass);
128128

129-
nestedList.add(supperClassElement.getQualifiedName().toString());
129+
nestedList.add(superClassElement.getQualifiedName().toString());
130130
result.setSuperclass(nestedList);
131-
appendInheritedMethods(supperClassElement, inheritedMethods);
131+
appendInheritedMethods(superClassElement, inheritedMethods);
132132

133-
determineNestedSuperclass(supperClassElement, result, inheritedMethods);
133+
determineNestedSuperclass(superClassElement, result, inheritedMethods);
134134
}
135135
return nestedList;
136136
}
@@ -180,7 +180,7 @@ List<String> determineInheritedMembers(List<ExtendedMetadataFileItem> inheritedM
180180
String key = item.getName();
181181

182182
if (map.containsKey(key) && map.get(key).getNestedLevel() > item.getNestedLevel()) {
183-
// childclass will have smaller than supperclass, we only need the nearest methods inherited with same signature
183+
// child class will have smaller than superclass, we only need the nearest methods inherited with same signature
184184
map.put(key, item);
185185
} else if (!map.containsKey(key)) {
186186
map.put(key, item);

src/test/java/com/microsoft/build/YmlFilesBuilderTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import javax.lang.model.element.TypeElement;
2424
import javax.lang.model.util.Elements;
2525
import jdk.javadoc.doclet.DocletEnvironment;
26+
import org.apache.commons.lang3.RegExUtils;
2627
import org.junit.Before;
2728
import org.junit.Rule;
2829
import org.junit.Test;
@@ -79,16 +80,16 @@ public void addConstructorsInfo() {
7980
@Test
8081
public void buildRefItem() {
8182
buildRefItemAndCheckAssertions("java.lang.Some.String", "java.lang.Some.String", "String");
82-
buildRefItemAndCheckAssertions("java.lang.Some.String[]", "java.lang.Some.String", "String");
83+
buildRefItemAndCheckAssertions("java.lang.Some.String[]", "java.lang.Some.String[]", "String");
8384
}
8485

8586
private void buildRefItemAndCheckAssertions(String initialValue, String expectedUid, String expectedName) {
8687
MetadataFileItem result = ymlFilesBuilder.buildRefItem(initialValue);
8788

8889
assertThat("Wrong uid", result.getUid(), is(expectedUid));
89-
assertThat("Wrong name", result.getSpecForJava().iterator().next().getUid(), is(expectedUid));
90+
assertThat("Wrong name", result.getSpecForJava().iterator().next().getUid(), is(RegExUtils.removeAll(expectedUid, "\\[\\]$")));
9091
assertThat("Wrong name", result.getSpecForJava().iterator().next().getName(), is(expectedName));
91-
assertThat("Wrong fullName", result.getSpecForJava().iterator().next().getFullName(), is(expectedUid));
92+
assertThat("Wrong fullName", result.getSpecForJava().iterator().next().getFullName(), is(RegExUtils.removeAll(expectedUid, "\\[\\]$")));
9293
}
9394

9495
@Test
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.microsoft.samples.offers;
2+
3+
import java.net.URI;
4+
import java.util.List;
5+
6+
/**
7+
* Represents a form of product availability to customer
8+
*/
9+
public class Offer
10+
{
11+
/**
12+
* Initializes a new instance of the Offer class.
13+
*/
14+
public Offer()
15+
{
16+
}
17+
18+
/**
19+
* Gets or sets qualifications required by the Partner in order to purchase the offer for a customer.
20+
*/
21+
private String[] __ResellerQualifications;
22+
23+
public String[] getResellerQualifications()
24+
{
25+
return __ResellerQualifications;
26+
}
27+
28+
public void setResellerQualifications(String[] value)
29+
{
30+
__ResellerQualifications = value;
31+
}
32+
33+
/**
34+
* Gets or sets qualifications required by the customer for the partner to purchase it for the customer.
35+
*/
36+
private String[] __ReselleeQualifications;
37+
38+
public String[] getReselleeQualifications()
39+
{
40+
return __ReselleeQualifications;
41+
}
42+
43+
public void setReselleeQualifications(String[] value)
44+
{
45+
__ReselleeQualifications = value;
46+
}
47+
}

src/test/resources/expected-generated-files/com.microsoft.samples.BasePartnerComponent.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,47 @@ references:
105105
nameWithType: "BasePartnerComponent<TContext>.testInherited"
106106
fullName: "com.microsoft.samples.BasePartnerComponent<TContext>.testInherited"
107107
package: "com.microsoft.samples"
108+
- uid: "java.lang.Object.notify()"
109+
name: "Object.notify()"
110+
nameWithType: "Object.notify()"
111+
fullName: "java.lang.Object.notify()"
112+
- uid: "java.lang.Object.wait()"
113+
name: "Object.wait()"
114+
nameWithType: "Object.wait()"
115+
fullName: "java.lang.Object.wait()"
116+
- uid: "java.lang.Object.finalize()"
117+
name: "Object.finalize()"
118+
nameWithType: "Object.finalize()"
119+
fullName: "java.lang.Object.finalize()"
120+
- uid: "java.lang.Object.clone()"
121+
name: "Object.clone()"
122+
nameWithType: "Object.clone()"
123+
fullName: "java.lang.Object.clone()"
124+
- uid: "java.lang.Object.notifyAll()"
125+
name: "Object.notifyAll()"
126+
nameWithType: "Object.notifyAll()"
127+
fullName: "java.lang.Object.notifyAll()"
128+
- uid: "java.lang.Object.equals(java.lang.Object)"
129+
name: "Object.equals(Object)"
130+
nameWithType: "Object.equals(Object)"
131+
fullName: "java.lang.Object.equals(java.lang.Object)"
132+
- uid: "java.lang.Object.getClass()"
133+
name: "Object.getClass()"
134+
nameWithType: "Object.getClass()"
135+
fullName: "java.lang.Object.getClass()"
136+
- uid: "java.lang.Object.wait(long)"
137+
name: "Object.wait(long)"
138+
nameWithType: "Object.wait(long)"
139+
fullName: "java.lang.Object.wait(long)"
140+
- uid: "java.lang.Object.hashCode()"
141+
name: "Object.hashCode()"
142+
nameWithType: "Object.hashCode()"
143+
fullName: "java.lang.Object.hashCode()"
144+
- uid: "java.lang.Object.wait(long,int)"
145+
name: "Object.wait(long,int)"
146+
nameWithType: "Object.wait(long,int)"
147+
fullName: "java.lang.Object.wait(long,int)"
148+
- uid: "java.lang.Object.toString()"
149+
name: "Object.toString()"
150+
nameWithType: "Object.toString()"
151+
fullName: "java.lang.Object.toString()"

src/test/resources/expected-generated-files/com.microsoft.samples.BasePartnerComponentString.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,58 @@ references:
110110
name: "BasePartnerComponent<String>"
111111
nameWithType: "BasePartnerComponent<String>"
112112
fullName: "com.microsoft.samples.BasePartnerComponent<java.lang.String>"
113+
- uid: "java.lang.Object.notify()"
114+
name: "Object.notify()"
115+
nameWithType: "Object.notify()"
116+
fullName: "java.lang.Object.notify()"
117+
- uid: "java.lang.Object.wait()"
118+
name: "Object.wait()"
119+
nameWithType: "Object.wait()"
120+
fullName: "java.lang.Object.wait()"
121+
- uid: "java.lang.Object.finalize()"
122+
name: "Object.finalize()"
123+
nameWithType: "Object.finalize()"
124+
fullName: "java.lang.Object.finalize()"
125+
- uid: "java.lang.Object.notifyAll()"
126+
name: "Object.notifyAll()"
127+
nameWithType: "Object.notifyAll()"
128+
fullName: "java.lang.Object.notifyAll()"
129+
- uid: "java.lang.Object.clone()"
130+
name: "Object.clone()"
131+
nameWithType: "Object.clone()"
132+
fullName: "java.lang.Object.clone()"
133+
- uid: "com.microsoft.samples.BasePartnerComponent.testBase()"
134+
name: "BasePartnerComponent.testBase()"
135+
nameWithType: "BasePartnerComponent.testBase()"
136+
fullName: "com.microsoft.samples.BasePartnerComponent.testBase()"
137+
- uid: "java.lang.Object.equals(java.lang.Object)"
138+
name: "Object.equals(Object)"
139+
nameWithType: "Object.equals(Object)"
140+
fullName: "java.lang.Object.equals(java.lang.Object)"
141+
- uid: "java.lang.Object.toString()"
142+
name: "Object.toString()"
143+
nameWithType: "Object.toString()"
144+
fullName: "java.lang.Object.toString()"
145+
- uid: "java.lang.Object.getClass()"
146+
name: "Object.getClass()"
147+
nameWithType: "Object.getClass()"
148+
fullName: "java.lang.Object.getClass()"
149+
- uid: "java.lang.Object.wait(long)"
150+
name: "Object.wait(long)"
151+
nameWithType: "Object.wait(long)"
152+
fullName: "java.lang.Object.wait(long)"
153+
- uid: "java.lang.Object.hashCode()"
154+
name: "Object.hashCode()"
155+
nameWithType: "Object.hashCode()"
156+
fullName: "java.lang.Object.hashCode()"
157+
- uid: "com.microsoft.samples.BasePartnerComponent.testInherited()"
158+
name: "BasePartnerComponent.testInherited()"
159+
nameWithType: "BasePartnerComponent.testInherited()"
160+
fullName: "com.microsoft.samples.BasePartnerComponent.testInherited()"
161+
- uid: "java.lang.Object.wait(long,int)"
162+
name: "Object.wait(long,int)"
163+
nameWithType: "Object.wait(long,int)"
164+
fullName: "java.lang.Object.wait(long,int)"
113165
- uid: "com.microsoft.samples.BasePartnerComponent"
114166
name: "BasePartnerComponent"
115167
nameWithType: "BasePartnerComponent"

src/test/resources/expected-generated-files/com.microsoft.samples.KeyValuePair.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,47 @@ references:
121121
nameWithType: "KeyValuePair<K,V>.getValue"
122122
fullName: "com.microsoft.samples.KeyValuePair<K,V>.getValue"
123123
package: "com.microsoft.samples"
124+
- uid: "java.lang.Object.notify()"
125+
name: "Object.notify()"
126+
nameWithType: "Object.notify()"
127+
fullName: "java.lang.Object.notify()"
128+
- uid: "java.lang.Object.wait()"
129+
name: "Object.wait()"
130+
nameWithType: "Object.wait()"
131+
fullName: "java.lang.Object.wait()"
132+
- uid: "java.lang.Object.finalize()"
133+
name: "Object.finalize()"
134+
nameWithType: "Object.finalize()"
135+
fullName: "java.lang.Object.finalize()"
136+
- uid: "java.lang.Object.clone()"
137+
name: "Object.clone()"
138+
nameWithType: "Object.clone()"
139+
fullName: "java.lang.Object.clone()"
140+
- uid: "java.lang.Object.notifyAll()"
141+
name: "Object.notifyAll()"
142+
nameWithType: "Object.notifyAll()"
143+
fullName: "java.lang.Object.notifyAll()"
144+
- uid: "java.lang.Object.equals(java.lang.Object)"
145+
name: "Object.equals(Object)"
146+
nameWithType: "Object.equals(Object)"
147+
fullName: "java.lang.Object.equals(java.lang.Object)"
148+
- uid: "java.lang.Object.getClass()"
149+
name: "Object.getClass()"
150+
nameWithType: "Object.getClass()"
151+
fullName: "java.lang.Object.getClass()"
152+
- uid: "java.lang.Object.wait(long)"
153+
name: "Object.wait(long)"
154+
nameWithType: "Object.wait(long)"
155+
fullName: "java.lang.Object.wait(long)"
156+
- uid: "java.lang.Object.hashCode()"
157+
name: "Object.hashCode()"
158+
nameWithType: "Object.hashCode()"
159+
fullName: "java.lang.Object.hashCode()"
160+
- uid: "java.lang.Object.wait(long,int)"
161+
name: "Object.wait(long,int)"
162+
nameWithType: "Object.wait(long,int)"
163+
fullName: "java.lang.Object.wait(long,int)"
164+
- uid: "java.lang.Object.toString()"
165+
name: "Object.toString()"
166+
nameWithType: "Object.toString()"
167+
fullName: "java.lang.Object.toString()"

src/test/resources/expected-generated-files/com.microsoft.samples.Link.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,50 @@ references:
162162
nameWithType: "Link.setHeaders"
163163
fullName: "com.microsoft.samples.Link.setHeaders"
164164
package: "com.microsoft.samples"
165+
- uid: "java.lang.Object.notify()"
166+
name: "Object.notify()"
167+
nameWithType: "Object.notify()"
168+
fullName: "java.lang.Object.notify()"
169+
- uid: "java.lang.Object.wait()"
170+
name: "Object.wait()"
171+
nameWithType: "Object.wait()"
172+
fullName: "java.lang.Object.wait()"
173+
- uid: "java.lang.Object.finalize()"
174+
name: "Object.finalize()"
175+
nameWithType: "Object.finalize()"
176+
fullName: "java.lang.Object.finalize()"
177+
- uid: "java.lang.Object.clone()"
178+
name: "Object.clone()"
179+
nameWithType: "Object.clone()"
180+
fullName: "java.lang.Object.clone()"
181+
- uid: "java.lang.Object.notifyAll()"
182+
name: "Object.notifyAll()"
183+
nameWithType: "Object.notifyAll()"
184+
fullName: "java.lang.Object.notifyAll()"
185+
- uid: "java.lang.Object.equals(java.lang.Object)"
186+
name: "Object.equals(Object)"
187+
nameWithType: "Object.equals(Object)"
188+
fullName: "java.lang.Object.equals(java.lang.Object)"
189+
- uid: "java.lang.Object.getClass()"
190+
name: "Object.getClass()"
191+
nameWithType: "Object.getClass()"
192+
fullName: "java.lang.Object.getClass()"
193+
- uid: "java.lang.Object.wait(long)"
194+
name: "Object.wait(long)"
195+
nameWithType: "Object.wait(long)"
196+
fullName: "java.lang.Object.wait(long)"
197+
- uid: "java.lang.Object.hashCode()"
198+
name: "Object.hashCode()"
199+
nameWithType: "Object.hashCode()"
200+
fullName: "java.lang.Object.hashCode()"
201+
- uid: "java.lang.Object.wait(long,int)"
202+
name: "Object.wait(long,int)"
203+
nameWithType: "Object.wait(long,int)"
204+
fullName: "java.lang.Object.wait(long,int)"
205+
- uid: "java.lang.Object.toString()"
206+
name: "Object.toString()"
207+
nameWithType: "Object.toString()"
208+
fullName: "java.lang.Object.toString()"
165209
- uid: "com.microsoft.samples.KeyValuePair"
166210
name: "KeyValuePair"
167211
nameWithType: "KeyValuePair"

0 commit comments

Comments
 (0)