-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/3465 support for java variants #3797
Changes from 6 commits
a0b0dcf
f75dd2c
00d9911
63ee9f1
0c4c810
bb181bf
87122ed
ec58043
bb95588
941a8de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,24 @@ | |
<span><img class="mx-1" src="~/icons/go-original.svg" width="40" alt="@Model.Review.Language"></span> | ||
break; | ||
case "java": | ||
<span><img class="mx-1" src="~/icons/java-original.svg" width="40" alt="@Model.Review.Language"></span> | ||
if(@Model.Review.Variant != null) | ||
{ | ||
switch(@Model.Review.Variant.ToLower()) | ||
{ | ||
case "spring": | ||
<span><img class="mx-1" src="~/icons/java-spring-original.svg" width="40" alt="@Model.Review.Language @Model.Review.Variant"></span> | ||
break; | ||
case "android": | ||
<span><img class="mx-1" src="~/icons/java-android-original.svg" width="40" alt="@Model.Review.Language @Model.Review.Variant"></span> | ||
break; | ||
default: | ||
<span><img class="mx-1" src="~/icons/java-original.svg" width="40" alt="@Model.Review.Language"></span> | ||
break; | ||
} | ||
} else | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
{ | ||
<span><img class="mx-1" src="~/icons/java-original.svg" width="40" alt="@Model.Review.Language"></span> | ||
} | ||
break; | ||
case "swift": | ||
<span><img class="mx-1" src="~/icons/swift-original.svg" width="40" alt="@Model.Review.Language"></span> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,24 @@ | |
<img class="mx-1" src="~/icons/go-original.svg" alt="@review.Language"> | ||
break; | ||
case "java": | ||
<img class="mx-1" src="~/icons/java-original.svg" alt="@review.Language"> | ||
if(@review.Variant != null) | ||
{ | ||
switch(@review.Variant.ToLower()) | ||
{ | ||
case "spring": | ||
<img class="mx-1" src="~/icons/java-spring-original.svg" alt="@review.Language @review.Variant"> | ||
break; | ||
case "android": | ||
<img class="mx-1" src="~/icons/java-android-original.svg" alt="@review.Language @review.Variant"> | ||
break; | ||
default: | ||
<img class="mx-1" src="~/icons/java-original.svg" alt="@review.Language"> | ||
break; | ||
} | ||
} else | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As much as it pains me (as a Java engineer), the C# expectation here is to put the closing brace and the |
||
{ | ||
<img class="mx-1" src="~/icons/java-original.svg" alt="@review.Language"> | ||
} | ||
break; | ||
case "swift": | ||
<img class="mx-1" src="~/icons/swift-original.svg" alt="@review.Language"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
import com.azure.tools.apiview.processor.model.APIListing; | ||
import com.azure.tools.apiview.processor.model.Diagnostic; | ||
import com.azure.tools.apiview.processor.model.DiagnosticKind; | ||
import com.azure.tools.apiview.processor.model.LanguageVariant; | ||
import com.azure.tools.apiview.processor.model.Token; | ||
import com.azure.tools.apiview.processor.model.maven.Pom; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
@@ -157,6 +158,15 @@ private static void processJavaSourcesJar(File inputFile, APIListing apiListing) | |
apiListing.setLanguage("Java"); | ||
apiListing.setMavenPom(reviewProperties.getMavenPom()); | ||
|
||
if(packageName.contains("spring")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: let's use Just to add a bit more context here, we use groupId to differentiate between Spring, Android and Java Azure libraries.
Artifact Ids can be any of the hundreds of Azure service names and there's a chance that they may contain terms like "spring" and are not related to the Spring framework. |
||
apiListing.setVariant(LanguageVariant.SPRING); | ||
} else if(packageName.contains("android")) { | ||
apiListing.setVariant(LanguageVariant.ANDROID); | ||
} else { | ||
apiListing.setVariant(LanguageVariant.DEFAULT); | ||
} | ||
System.out.println(" Using '" + apiListing.getVariant() + "' for the language variant"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eventually we will want a smarter way of discerning this, but it should do for now |
||
|
||
final Analyser analyser = new JavaASTAnalyser(inputFile, apiListing); | ||
|
||
// Read all files within the jar file so that we can create a list of files to analyse | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,9 @@ public class APIListing { | |
@JsonProperty("Language") | ||
private String language; | ||
|
||
@JsonProperty("Variant") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Let's name the property |
||
private LanguageVariant variant; | ||
|
||
@JsonProperty("PackageName") | ||
private String packageName; | ||
|
||
|
@@ -91,6 +94,14 @@ public void setLanguage(final String language) { | |
this.language = language; | ||
} | ||
|
||
public LanguageVariant getVariant() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
return variant; | ||
} | ||
|
||
public void setVariant(final LanguageVariant variant) { | ||
this.variant = variant; | ||
} | ||
|
||
public String getPackageName() { | ||
return packageName; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.azure.tools.apiview.processor.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
public enum LanguageVariant { | ||
DEFAULT("Default"), | ||
SPRING("Spring"), | ||
ANDROID("Android"); | ||
|
||
private final String variantName; | ||
|
||
LanguageVariant(String name) { | ||
this.variantName = name; | ||
} | ||
|
||
@Override | ||
@JsonValue | ||
public String toString() { | ||
return this.variantName; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually I would like to see this change to instead be a single line that uses code along the following lines:
Then move all of the image file references out to CSS, e.g.