Skip to content
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

compatibility with 2021.1 #324

Merged
merged 3 commits into from
Jul 8, 2021
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
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
root = true

[*.java]
indent_size = 2
indent_style = space
32 changes: 22 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
buildscript {
repositories {
mavenCentral()
maven {
url 'https://www.jetbrains.com/intellij-repository/releases'
}
}
}

plugins {
id "org.jetbrains.intellij" version "0.4.1"
id 'org.jetbrains.intellij' version '0.7.2'
id 'jacoco'
id 'com.github.kt3k.coveralls' version '2.7.1'
id "com.diffplug.gradle.spotless" version "3.15.0"
Expand All @@ -19,7 +22,8 @@ intellij {
plugins 'yaml' //Bundled plugin dependencies
pluginName 'intellij-swagger'
updateSinceUntilBuild false
version '2018.3'
version '2021.1'
plugins = ['com.intellij.java', 'org.jetbrains.plugins.yaml']
}

group 'org.zalando.intellij'
Expand All @@ -30,17 +34,20 @@ sourceCompatibility = 1.8

repositories {
mavenCentral()
maven {
url 'https://www.jetbrains.com/intellij-repository/releases'
}
}

dependencies {
compile 'commons-io:commons-io:2.5'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.google.guava:guava:19.0'
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.7.4'
compile 'com.fasterxml.jackson.core:jackson-core:2.7.5'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.7.5'
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile 'org.mockito:mockito-all:1.10.19'
implementation 'commons-io:commons-io:2.5'
implementation 'com.google.code.gson:gson:2.6.2'
implementation 'com.google.guava:guava:19.0'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.7.4'
implementation 'com.fasterxml.jackson.core:jackson-core:2.7.5'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.7.5'
testImplementation group: 'junit', name: 'junit', version: '4.11'
testImplementation group: 'org.mockito', name: 'mockito-core', version: '2.1.0'
}

jacocoTestReport {
Expand All @@ -55,3 +62,8 @@ spotless {
googleJavaFormat('1.6')
}
}

publishPlugin {
channels 'beta'
token = System.getenv("JETBRAINS_HUB_TOKEN")
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Tue Jan 22 20:30:01 EET 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
72 changes: 42 additions & 30 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
warn () {
echo "$*"
}

die ( ) {
die () {
echo
echo "$*"
echo
Expand All @@ -30,6 +48,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
Expand All @@ -40,26 +59,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

# Determine the Java command to use to start the JVM.
Expand All @@ -85,7 +89,7 @@ location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
Expand Down Expand Up @@ -150,11 +154,19 @@ if $cygwin ; then
esac
fi

# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
APP_ARGS=$(save "$@")

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
exec "$JAVACMD" "$@"
12 changes: 3 additions & 9 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

Expand Down Expand Up @@ -49,7 +49,6 @@ goto fail
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
Expand All @@ -60,11 +59,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line
Expand Down
19 changes: 9 additions & 10 deletions release.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
#!/usr/bin/env bash
set -eux

if [ -z "$1" ]
then
echo "Missing version for master branch"
exit 1
fi

if [ -z "$2" ]
export $(grep -v '^\#' .env)
if [ -z "$JETBRAINS_HUB_TOKEN" ]
then
echo "Missing version for 162.x branch"
echo "Please put JETBRAINS_HUB_TOKEN in .env: JETBRAINS_HUB_TOKEN=<token>"
exit 1
fi

NEW_VERSION=$1

sed -i "s/<version>.*<\/version>/<version>$NEW_VERSION<\/version>/g" src/main/resources/META-INF/plugin.xml

git checkout master
./gradlew updateVersion -Pversion=$1
./gradlew buildPlugin -Pversion=$1
./gradlew publishPlugin -Pversion=$NEW_VERSION -x buildSearchableOptions
git add src/main/resources/META-INF/plugin.xml
git commit -m "Bump version"

git checkout 162.x
./gradlew updateVersion -Pversion=$2
./gradlew buildPlugin -Pversion=$2
git add src/main/resources/META-INF/plugin.xml
git commit -m "Bump version"
git checkout master
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.zalando.intellij.swagger;

import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.vfs.VirtualFile;
Expand All @@ -9,19 +10,11 @@

public class SwaggerJsonCatalogExclusion implements JsonSchemaCatalogExclusion {

private final IndexFacade indexFacade;
private final ProjectManager projectManager;

public SwaggerJsonCatalogExclusion(
final IndexFacade indexFacade, final ProjectManager projectManager) {
this.indexFacade = indexFacade;
this.projectManager = projectManager;
}

@Override
public boolean isExcluded(@NotNull VirtualFile file) {
final Project[] openProjects = projectManager.getOpenProjects();
final Project[] openProjects = ServiceManager.getService(ProjectManager.class).getOpenProjects();

IndexFacade indexFacade = ServiceManager.getService(IndexFacade.class);
if (openProjects.length > 0 && indexFacade.isIndexReady(openProjects[0])) {
return indexFacade.isMainSpecFile(file, openProjects[0]);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.zalando.intellij.swagger.documentation.openapi;

import java.util.Optional;
import java.util.stream.Stream;

import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import java.util.Optional;
import java.util.stream.Stream;
import org.jetbrains.annotations.Nullable;
import org.zalando.intellij.swagger.documentation.ApiDocumentProvider;
import org.zalando.intellij.swagger.file.OpenApiFileType;
Expand All @@ -15,12 +17,6 @@

public class OpenApiDocumentationProvider extends ApiDocumentProvider {

private final OpenApiIndexService openApiIndexService;

public OpenApiDocumentationProvider(final OpenApiIndexService openApiIndexService) {
this.openApiIndexService = openApiIndexService;
}

@Nullable
@Override
public String getQuickNavigateInfo(
Expand All @@ -38,7 +34,7 @@ public String getQuickNavigateInfo(
final Project project = maybeProject.get();

final Optional<OpenApiFileType> maybeFileType =
openApiIndexService.getFileType(project, virtualFile);
ServiceManager.getService(OpenApiIndexService.class).getFileType(project, virtualFile);

return maybeFileType.map(
openApiFileType -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.zalando.intellij.swagger.file;

import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.LocalFileUrl;
import java.io.File;
import java.io.IOException;
import java.net.URI;
Expand All @@ -16,6 +14,10 @@
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Collections;
import java.util.Objects;

import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.LocalFileUrl;
import org.jetbrains.annotations.NotNull;

public class SwaggerUiCreator {
Expand Down Expand Up @@ -58,7 +60,7 @@ private void setSwaggerConfigurationValues(
}

private void copyFromJar(final Path target) throws URISyntaxException, IOException {
URI resource = getClass().getResource("").toURI();
URI resource = Objects.requireNonNull(getClass().getResource(""), "resource").toURI();
FileSystem fileSystem =
FileSystems.newFileSystem(resource, Collections.<String, String>emptyMap());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package org.zalando.intellij.swagger.file.icon;

import javax.swing.*;
import javax.swing.Icon;

import com.intellij.openapi.components.ServiceManager;
import org.zalando.intellij.swagger.index.IndexService;
import org.zalando.intellij.swagger.index.openapi.OpenApiIndexService;

public class OpenApiIconProvider extends SpecIconProvider {

protected OpenApiIconProvider(final OpenApiIndexService openApiIndexService) {
super(openApiIndexService);
}

@Override
protected Icon getIcon() {
return Icons.OPEN_API_ICON;
}

@Override
protected IndexService getIndexService() {
return ServiceManager.getService(OpenApiIndexService.class);
}
}
Loading