Skip to content

Commit e283800

Browse files
eng, prepare release 0.21.1 (#2957)
1 parent d105853 commit e283800

File tree

60 files changed

+5611
-440
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+5611
-440
lines changed

core

Submodule core updated 276 files

customization-base/src/main/java/com/azure/autorest/customization/implementation/ls/EclipseLanguageServerFacade.java

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,9 @@ public EclipseLanguageServerFacade(String pathToLanguageServerPlugin, Logger log
5353
if (javaVersion < 17) {
5454
// JAR to start v1.12.0
5555
command.add("./plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar");
56-
} else if (javaVersion < 21) {
57-
// JAR to start v1.29.0
58-
command.add("./plugins/org.eclipse.equinox.launcher_1.6.500.v20230717-2134.jar");
5956
} else {
60-
// JAR to start v1.31.0
61-
command.add("./plugins/org.eclipse.equinox.launcher_1.6.700.v20231214-2017.jar");
57+
// JAR to start v1.39.0
58+
command.add("./plugins/org.eclipse.equinox.launcher_1.6.900.v20240613-2009.jar");
6259
}
6360

6461
command.add("--add-modules=ALL-SYSTEM");
@@ -76,8 +73,7 @@ public EclipseLanguageServerFacade(String pathToLanguageServerPlugin, Logger log
7673
}
7774

7875
logger.info("Starting Eclipse JDT language server at {}", languageServerPath);
79-
server = new ProcessBuilder(command)
80-
.redirectOutput(ProcessBuilder.Redirect.PIPE)
76+
server = new ProcessBuilder(command).redirectOutput(ProcessBuilder.Redirect.PIPE)
8177
.redirectInput(ProcessBuilder.Redirect.PIPE)
8278
.redirectErrorStream(true)
8379
.directory(languageServerPath.toFile())
@@ -96,23 +92,16 @@ private static Path getLanguageServerDirectory(int javaVersion, Logger logger) t
9692
if (javaVersion < 17) {
9793
// Eclipse JDT language server version 1.12.0 is the last version that supports Java 11, which is
9894
// autorest.java's baseline.
99-
downloadUrl = URI.create(DOWNLOAD_BASE_URL + "1.12.0/jdt-language-server-1.12.0-202206011637.tar.gz")
100-
.toURL();
95+
downloadUrl
96+
= URI.create(DOWNLOAD_BASE_URL + "1.12.0/jdt-language-server-1.12.0-202206011637.tar.gz").toURL();
10197
languageServerPath = autorestLanguageServer.resolve("1.12.0");
102-
} else if (javaVersion < 21) {
103-
// Eclipse JDT language server version 1.29.0 is the latest version that supports Java 17.
104-
// In the future this else statement may need to be replaced with an else if as newer versions of
105-
// Eclipse JDT language server may baseline on Java 21 (or later).
106-
downloadUrl = URI.create(DOWNLOAD_BASE_URL + "1.29.0/jdt-language-server-1.29.0-202310261436.tar.gz")
107-
.toURL();
108-
languageServerPath = autorestLanguageServer.resolve("1.29.0");
10998
} else {
110-
// Eclipse JDT language server version 1.31.0 is the latest version that supports Java 21.
99+
// Eclipse JDT language server version 1.39.0 is the latest version that supports Java 17.
111100
// In the future this else statement may need to be replaced with an else if as newer versions of
112-
// Eclipse JDT language server may baseline on Java 25 (or later).
113-
downloadUrl = URI.create(DOWNLOAD_BASE_URL + "1.31.0/jdt-language-server-1.31.0-202401111522.tar.gz")
114-
.toURL();
115-
languageServerPath = autorestLanguageServer.resolve("1.31.0");
101+
// Eclipse JDT language server may baseline on Java 21 (or later).
102+
downloadUrl
103+
= URI.create(DOWNLOAD_BASE_URL + "1.39.0/jdt-language-server-1.39.0-202408291433.tar.gz").toURL();
104+
languageServerPath = autorestLanguageServer.resolve("1.39.0");
116105
}
117106

118107
Path languageServer = languageServerPath.resolve("jdt-language-server");

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@autorest/java",
3-
"version": "4.1.37",
3+
"version": "4.1.38",
44
"description": "The Java extension for classic generators in AutoRest.",
55
"scripts": {
66
"autorest": "autorest",

protocol-sdk-integration-tests/.vscode/eclipse-format-azure-sdk-for-java.xml

Lines changed: 401 additions & 0 deletions
Large diffs are not rendered by default.

protocol-sdk-integration-tests/eng/code-quality-reports/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22

33
This module defines/configures the rules for code quality analysis tools such as checkstyle and spotbugs.
44
For more information refer to [Checkstyle](https://checkstyle.org/) and [Spotbugs](https://spotbugs.github.io/).
5+
6+
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Feng%2Fcode-quality-reports%2FREADME.png)

protocol-sdk-integration-tests/eng/code-quality-reports/pom.xml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<!-- Copyright (c) Microsoft Corporation. All rights reserved.
2-
Licensed under the MIT License. -->
1+
<!-- Copyright (c) Microsoft Corporation. All rights reserved.
2+
Licensed under the MIT License. -->
33
<project xmlns="http://maven.apache.org/POM/4.0.0"
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
@@ -31,6 +31,15 @@
3131
</scm>
3232

3333
<dependencies>
34+
35+
<!-- Transient Direct Dependency until bump to Java 11 baseline -->
36+
<!-- Necessary because com.puppycrawl.tools:checkstyle:10+ requires Java 11 -->
37+
<dependency>
38+
<groupId>com.google.guava</groupId>
39+
<artifactId>guava</artifactId>
40+
<version>33.1.0-jre</version> <!-- {x-version-update;com.google.guava:guava;external_dependency} -->
41+
</dependency>
42+
3443
<dependency>
3544
<groupId>com.puppycrawl.tools</groupId>
3645
<artifactId>checkstyle</artifactId>
@@ -109,17 +118,17 @@
109118
<plugin>
110119
<groupId>org.apache.maven.plugins</groupId>
111120
<artifactId>maven-site-plugin</artifactId>
112-
<version>3.7.1</version> <!-- {x-version-update;org.apache.maven.plugins:maven-site-plugin;external_dependency} -->
121+
<version>3.12.1</version> <!-- {x-version-update;org.apache.maven.plugins:maven-site-plugin;external_dependency} -->
113122
</plugin>
114123
<plugin>
115124
<groupId>org.apache.maven.plugins</groupId>
116125
<artifactId>maven-project-info-reports-plugin</artifactId>
117-
<version>3.0.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-project-info-reports-plugin;external_dependency} -->
126+
<version>3.5.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-project-info-reports-plugin;external_dependency} -->
118127
</plugin>
119128
<plugin>
120129
<groupId>org.apache.maven.plugins</groupId>
121130
<artifactId>maven-surefire-plugin</artifactId>
122-
<version>3.1.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-surefire-plugin;external_dependency} -->
131+
<version>3.2.5</version> <!-- {x-version-update;org.apache.maven.plugins:maven-surefire-plugin;external_dependency} -->
123132
</plugin>
124133
</plugins>
125134
</build>
Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,30 @@
1010
import com.puppycrawl.tools.checkstyle.utils.CheckUtil;
1111
import com.puppycrawl.tools.checkstyle.utils.ScopeUtil;
1212

13-
import java.util.Arrays;
1413
import java.util.Collections;
1514
import java.util.HashSet;
1615
import java.util.Set;
17-
import java.util.stream.Collectors;
1816

1917
/**
20-
* Ensure that code is not using words or abbreviations that are blacklisted by this Checkstyle.
21-
* blacklistedWords: the words that have been blacklisted in the checkstyle.xml config file
22-
*
23-
* Prints out a message stating the location and the class, method or variable as well as the list
24-
* blacklisted words.
18+
* Ensure that code is not using words or abbreviations that are deny listed by this Checkstyle. denyListedWords: the
19+
* words that have been denied in the checkstyle.xml config file
20+
* <p>
21+
* Prints out a message stating the location and the class, method or variable as well as the list of deny listed words.
2522
*/
26-
public class BlacklistedWordsCheck extends AbstractCheck {
27-
private final Set<String> blacklistedWords = new HashSet<>();
23+
public class DenyListedWordsCheck extends AbstractCheck {
24+
private final Set<String> denyListedWords = new HashSet<>();
2825

2926
static final String ERROR_MESSAGE = "%s, All Public API Classes, Fields and Methods should follow "
3027
+ "Camelcase standards for the following words: %s.";
3128

3229
/**
3330
* Adds words that Classes, Methods and Variables that should follow Camelcasing standards
34-
* @param blacklistedWords words that should follow normal Camelcasing standards
31+
*
32+
* @param denyListedWords words that should follow normal Camelcasing standards
3533
*/
36-
public final void setBlacklistedWords(String... blacklistedWords) {
37-
if (blacklistedWords != null) {
38-
Collections.addAll(this.blacklistedWords, blacklistedWords);
34+
public final void setDenyListedWords(String... denyListedWords) {
35+
if (denyListedWords != null) {
36+
Collections.addAll(this.denyListedWords, denyListedWords);
3937
}
4038
}
4139

@@ -51,7 +49,7 @@ public int[] getAcceptableTokens() {
5149

5250
@Override
5351
public int[] getRequiredTokens() {
54-
return new int[] {TokenTypes.CLASS_DEF,
52+
return new int[]{TokenTypes.CLASS_DEF,
5553
TokenTypes.METHOD_DEF,
5654
TokenTypes.VARIABLE_DEF};
5755
}
@@ -67,7 +65,7 @@ public void visitToken(DetailAST token) {
6765
}
6866

6967
final String tokenName = token.findFirstToken(TokenTypes.IDENT).getText();
70-
if (!hasBlacklistedWords(tokenName)) {
68+
if (!hasDenyListedWords(tokenName)) {
7169
break;
7270
}
7371

@@ -76,7 +74,7 @@ public void visitToken(DetailAST token) {
7674
break;
7775
}
7876

79-
log(token, String.format(ERROR_MESSAGE, tokenName, String.join(", ", this.blacklistedWords)));
77+
log(token, String.format(ERROR_MESSAGE, tokenName, String.join(", ", this.denyListedWords)));
8078

8179
break;
8280
default:
@@ -100,13 +98,13 @@ private boolean isPublicApi(DetailAST token) {
10098

10199
/**
102100
* Gets the disallowed abbreviation contained in given String.
101+
*
103102
* @param tokenName the given String.
104-
* @return the disallowed abbreviation contained in given String as a
105-
* separate String.
103+
* @return the disallowed abbreviation contained in given String as a separate String.
106104
*/
107-
private boolean hasBlacklistedWords(String tokenName) {
108-
for (String blacklistedWord : blacklistedWords) {
109-
if (tokenName.contains(blacklistedWord)) {
105+
private boolean hasDenyListedWords(String tokenName) {
106+
for (String denyListedWord : denyListedWords) {
107+
if (tokenName.contains(denyListedWord)) {
110108
return true;
111109
}
112110
}

protocol-sdk-integration-tests/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/EnforceFinalFieldsCheck.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55

66
import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
77
import com.puppycrawl.tools.checkstyle.api.DetailAST;
8+
import com.puppycrawl.tools.checkstyle.api.FullIdent;
89
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
10+
import com.puppycrawl.tools.checkstyle.utils.CheckUtil;
911
import com.puppycrawl.tools.checkstyle.utils.TokenUtil;
1012

1113
import java.util.ArrayList;
14+
import java.util.HashMap;
1215
import java.util.HashSet;
1316
import java.util.List;
17+
import java.util.Map;
18+
import java.util.Objects;
1419
import java.util.Set;
1520

1621
/**
@@ -19,7 +24,7 @@
1924
* nonFinalFields: keep an array of non private fields as tokens (to keep line number)
2025
* assignmentsFromConstructor: Save a set of string for each field name that gets its value assigned in constructor
2126
* assignmentsFromMethods: Save a set of strings for each field name that gets updated in any method
22-
*
27+
* <p>
2328
* On finish tree, check what non-final fields get a value only in constructor and nowhere else by looking for
2429
* strings inside nonFinalFields AND assignmentsFromConstructor but NOT in assignmentsFromMethods
2530
*/
@@ -36,6 +41,7 @@ public class EnforceFinalFieldsCheck extends AbstractCheck {
3641
private Set<String> assignmentsFromMethods;
3742
private DetailAST scopeParent = null;
3843
private Set<String> currentScopeParameterSet = null;
44+
private Map<String, DetailAST> variablesInScope = null;
3945
private String currentClassName = null;
4046

4147
@Override
@@ -108,6 +114,7 @@ public void visitToken(DetailAST token) {
108114
case TokenTypes.METHOD_DEF:
109115
case TokenTypes.CTOR_DEF:
110116
scopeParent = token;
117+
variablesInScope = new HashMap<>();
111118
break;
112119
default:
113120
// Checkstyle complains if there's no default block in switch
@@ -122,6 +129,7 @@ public void leaveToken(DetailAST token) {
122129
case TokenTypes.CTOR_DEF:
123130
scopeParent = null;
124131
currentScopeParameterSet = null;
132+
variablesInScope = null;
125133
break;
126134
default:
127135
break;
@@ -160,6 +168,15 @@ private DetailAST getAssignedField(final DetailAST assignationToken) {
160168
token -> token.getText().equals(this.currentClassName)).isPresent()) {
161169
// Case when referencing same class for private static fields
162170
return assignationWithDot.getLastChild();
171+
} else if (assignationWithDot.getFirstChild().getType() == TokenTypes.IDENT) {
172+
// Case where setting a field on a variable.
173+
String variableNameToken = assignationWithDot.getFirstChild().getText();
174+
DetailAST variableDeclaration = variablesInScope.get(variableNameToken);
175+
DetailAST parentScope = getParentScope(assignationToken);
176+
if (variableDeclaration != null && parentScope != null
177+
&& CheckUtil.isBeforeInSource(variableDeclaration, parentScope)) {
178+
return assignationWithDot.getLastChild();
179+
}
163180
}
164181
} else {
165182
final DetailAST variableNameToken = assignationToken.getFirstChild();
@@ -172,6 +189,17 @@ private DetailAST getAssignedField(final DetailAST assignationToken) {
172189
return null;
173190
}
174191

192+
private static DetailAST getParentScope(DetailAST ast) {
193+
DetailAST parent = ast.getParent();
194+
do {
195+
if (parent.getType() == TokenTypes.SLIST) {
196+
return parent;
197+
}
198+
} while ((parent = parent.getParent()) != null);
199+
200+
return null;
201+
}
202+
175203
/*
176204
* Saves a field name to a container depending on the provided type
177205
*/
@@ -197,7 +225,12 @@ private void checkAssignation(final DetailAST assignationToken) {
197225

198226
final DetailAST assignationParent = assignationToken.getParent();
199227
if (assignationParent != null && TokenTypes.VARIABLE_DEF == assignationParent.getType()) {
200-
// Assignation for a variable definition. No need to check this assignation
228+
String variableType = FullIdent.createFullIdentBelow(assignationParent.findFirstToken(TokenTypes.TYPE)).getText();
229+
if (Objects.equals(currentClassName, variableType)) {
230+
// Track variable definitions of the class we're currently in.
231+
variablesInScope.put(assignationParent.findFirstToken(TokenTypes.IDENT).getText(), assignationParent);
232+
}
233+
201234
return;
202235
}
203236

protocol-sdk-integration-tests/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,15 @@
1010
import com.puppycrawl.tools.checkstyle.checks.naming.AccessModifierOption;
1111
import com.puppycrawl.tools.checkstyle.utils.CheckUtil;
1212

13-
import java.util.Arrays;
14-
import java.util.Collections;
1513
import java.util.HashMap;
16-
import java.util.HashSet;
1714
import java.util.Map;
18-
import java.util.Set;
1915

2016
/**
2117
* No external dependency exposed in public API
2218
*/
2319
public class ExternalDependencyExposedCheck extends AbstractCheck {
2420
private static final String EXTERNAL_DEPENDENCY_ERROR =
2521
"Class ''%s'', is a class from external dependency. You should not use it as a %s type.";
26-
private static final Set<String> VALID_DEPENDENCY_SET = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
27-
"java", "com.azure", "reactor", "org.reactivestreams"
28-
)));
2922

3023
private final Map<String, String> simpleClassNameToQualifiedNameMap = new HashMap<>();
3124

@@ -198,7 +191,12 @@ private boolean isValidClassDependency(String typeName) {
198191
}
199192

200193
final String qualifiedName = simpleClassNameToQualifiedNameMap.get(typeName);
201-
return VALID_DEPENDENCY_SET.stream()
202-
.anyMatch(validPackageName -> qualifiedName.startsWith(validPackageName));
194+
195+
return "com.azure.".regionMatches(0, qualifiedName, 0, 10)
196+
|| "io.clientcore.".regionMatches(0, qualifiedName, 0, 14)
197+
|| "java.".regionMatches(0, qualifiedName, 0, 5)
198+
|| "javax.".regionMatches(0, qualifiedName, 0, 6)
199+
|| "reactor.".regionMatches(0, qualifiedName, 0, 8)
200+
|| "org.reactivestreams.".regionMatches(0, qualifiedName, 0, 20);
203201
}
204202
}

0 commit comments

Comments
 (0)