Skip to content
This repository has been archived by the owner on Dec 23, 2022. It is now read-only.

Commit

Permalink
api211 fixes (#54)
Browse files Browse the repository at this point in the history
* Initial fixes for 211
  • Loading branch information
jvolkman authored Feb 4, 2021
1 parent 99ae0e9 commit 9a0f8cd
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

- name: Install bazelisk
run: |
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.3.0/bazelisk-linux-amd64"
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.7.4/bazelisk-linux-amd64"
mkdir -p "${GITHUB_WORKSPACE}/bin/"
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
Expand Down
30 changes: 15 additions & 15 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external")

# The plugin api for IntelliJ UE.
http_archive(
name = "idea_ue_2020_3",
name = "idea_ue_2021_1",
build_file = "@//build_support/external:BUILD.idea_ue",
sha256 = "c118402cbe57dc03aab4165d836fa4a4ac286c1c11639a0e708a0ad60cab7888",
strip_prefix = "idea-IU-203.3645.34",
url = "https://download-cf.jetbrains.com/idea/ideaIU-203.3645.34.tar.gz",
sha256 = "fdca0791d42d044f29e6aaa32c06ada13c687ed9e95cc59b5b2fb2f83767ca97",
strip_prefix = "idea-IU-211.4961.33",
url = "https://download-cf.jetbrains.com/idea/ideaIU-211.4961.33.tar.gz",
)

# Python plugin for IntelliJ UE. Required at compile-time for python-specific features.
http_archive(
name = "python_2020_3",
name = "python_2021_1",
build_file = "@//build_support/external:BUILD.idea_python",
sha256 = "63f114062bd729a63f20801dc887a3ad924e6ebd4aedfe14316930053d0fb17a",
url = "https://plugins.jetbrains.com/files/631/97630/python-203.3645.40.zip",
sha256 = "05f8d2cf5e2833f2814eb0c11717cc9e674f504bf5e8dcbc1d81e0b330c81b8e",
url = "https://plugins.jetbrains.com/files/631/108977/python-211.4961.33.zip",
)

# Go plugin for IntelliJ UE. Required at compile-time for Bazel integration.
http_archive(
name = "go_2020_3",
name = "go_2021_1",
build_file = "@//build_support/external:BUILD.idea_go",
sha256 = "d9e65ab957b6c9160fef3c67cd268097ef87ebdf154e379b7a021058ce821f94",
url = "https://plugins.jetbrains.com/files/9568/97460/go-203.3645.34.zip",
sha256 = "5b130bdbfc4f15689638df8bdb7eb51e88791b2fce2f461ea78ca9ee888533b6",
url = "https://plugins.jetbrains.com/files/9568/108830/go-211.4961.30.zip",
)

# jflex for IDEA
Expand All @@ -51,8 +51,8 @@ http_file(
http_archive(
name = "grammar_kit",
build_file = "//build_support/external:BUILD.grammar_kit",
sha256 = "9cfc31d090de5c68ff6e3fd265615168ec1d28a95984c6d96cb0ebabaab08562",
url = "https://github.com/JetBrains/Grammar-Kit/releases/download/2020.1/grammar-kit-2020.1.zip",
sha256 = "d7fe9ec0a4ca0ceee5bbc26c6699e829762f6229981eac9f466bbd1342a55376",
url = "https://github.com/JetBrains/Grammar-Kit/releases/download/2020.3.1/grammar-kit-2020.3.1.zip",
)

jvm_maven_import_external(
Expand Down Expand Up @@ -81,9 +81,9 @@ jvm_maven_import_external(

http_archive(
name = "com_google_protobuf",
sha256 = "71030a04aedf9f612d2991c1c552317038c3c5a2b578ac4745267a45e7037c29",
strip_prefix = "protobuf-3.12.3",
url = "https://github.com/protocolbuffers/protobuf/archive/v3.12.3.tar.gz",
sha256 = "d0f5f605d0d656007ce6c8b5a82df3037e1d8fe8b121ed42e536f569dec16113",
strip_prefix = "protobuf-3.14.0",
url = "https://github.com/protocolbuffers/protobuf/archive/v3.14.0.tar.gz",
)
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()
Expand Down
8 changes: 4 additions & 4 deletions build_support/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ package(default_visibility = ["//visibility:public"])
#
alias(
name = "intellij_sdk",
actual = "@idea_ue_2020_3//:plugin_sdk"
actual = "@idea_ue_2021_1//:plugin_sdk"
)

alias(
name = "_java_support_internal",
actual = "@idea_ue_2020_3//:java_support"
actual = "@idea_ue_2021_1//:java_support"
)

alias(
name = "_go_support_internal",
actual = "@go_2020_3//:plugin_sdk"
actual = "@go_2021_1//:plugin_sdk"
)

alias(
name = "_python_support_internal",
actual = "@python_2020_3//:plugin_sdk"
actual = "@python_2021_1//:plugin_sdk"
)

#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void testManagerTracksProjectRootsChanges() {
assertTrue(projectDir.mkdirs());

VirtualFile projectFile = createTestProjectStructure(projectDir.getPath());
Project project = PlatformTestUtil.loadAndOpenProject(projectFile.toNioPath());
Project project = PlatformTestUtil.loadAndOpenProject(projectFile.toNioPath(), getTestRootDisposable());
disposeOnTearDown(project);
Module module1 = doCreateRealModuleIn("module1", project, EmptyModuleType.getInstance());
Module module2 = doCreateRealModuleIn("module2", project, EmptyModuleType.getInstance());
Expand Down Expand Up @@ -168,7 +168,7 @@ public void testExtensionConfiguratorsTakePrecedence() {
assertTrue(projectDir.mkdirs());

VirtualFile projectFile = createTestProjectStructure(projectDir.getPath());
Project project = PlatformTestUtil.loadAndOpenProject(projectFile.toNioPath());
Project project = PlatformTestUtil.loadAndOpenProject(projectFile.toNioPath(), getTestRootDisposable());
disposeOnTearDown(project);
Module module = doCreateRealModuleIn("module", project, EmptyModuleType.getInstance());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void testMessageNonQualified() {
assertEquals("user.proto", notNull(usageInfo.getFile()).getName());
assertEquals(fileUser.getText().indexOf("M1 user = 777;"), usageInfo.getNavigationOffset());
assertEquals(2, notNull(usageInfo.getRangeInElement()).getLength());
assertSameElements(describeUsagesTypes(usageInfos), PbUsageTypeProvider.FIELD_DECLARATION);
assertSameElements(describeUsageTypeNames(usageInfos), PbUsageTypeProvider.fieldDeclaration().toString());
}

public void testNestedMessagePreventsToplevelUsage() {
Expand Down Expand Up @@ -107,7 +107,7 @@ public void testEnumNonQualified() {
UsageInfo usageInfo = notNull(ContainerUtil.getFirstItem(usageInfos));
assertEquals("user.proto", notNull(usageInfo.getFile()).getName());
assertEquals(fileUser.getText().indexOf("E1 user = 777;"), usageInfo.getNavigationOffset());
assertSameElements(describeUsagesTypes(usageInfos), PbUsageTypeProvider.FIELD_DECLARATION);
assertSameElements(describeUsageTypeNames(usageInfos), PbUsageTypeProvider.fieldDeclaration().toString());
}

public void testFullyQualified() {
Expand Down Expand Up @@ -148,11 +148,11 @@ public void testFullyQualified() {
assertEquals(204, fileDef.getText().indexOf("Foo {}"));
assertEquals(84, fileUser.getText().indexOf("Foo.Bar Foo = 777;"));
assertSameElements(
describeUsagesTypes(usageInfos),
PbUsageTypeProvider.FIELD_DECLARATION,
PbUsageTypeProvider.SERVICE_TYPE,
PbUsageTypeProvider.EXTEND_DEFINITION,
PbUsageTypeProvider.FIELD_DECLARATION);
describeUsageTypeNames(usageInfos),
PbUsageTypeProvider.fieldDeclaration().toString(),
PbUsageTypeProvider.serviceType().toString(),
PbUsageTypeProvider.extendDefinition().toString(),
PbUsageTypeProvider.fieldDeclaration().toString());
}

public void testMessageNamedMessage() {
Expand Down Expand Up @@ -193,7 +193,7 @@ public void testFieldAsCustomOption() {
UsageInfo usageInfo = notNull(ContainerUtil.getFirstItem(usageInfos));
assertEquals("user.proto", notNull(usageInfo.getFile()).getName());
assertEquals(fileUser.getText().indexOf("moo) = true;"), usageInfo.getNavigationOffset());
assertSameElements(describeUsagesTypes(usageInfos), PbUsageTypeProvider.OPTION_EXPRESSION);
assertSameElements(describeUsageTypeNames(usageInfos), PbUsageTypeProvider.optionExpression().toString());
}

public void testPackageName() {
Expand All @@ -216,7 +216,7 @@ public void testPackageName() {
UsageInfo usageInfo = notNull(ContainerUtil.getFirstItem(usageInfos));
assertEquals("user.proto", notNull(usageInfo.getFile()).getName());
assertEquals(fileUser.getText().indexOf("abc.xyz.M1 f1 = 1;"), usageInfo.getNavigationOffset());
assertSameElements(describeUsagesTypes(usageInfos), PbUsageTypeProvider.FIELD_DECLARATION);
assertSameElements(describeUsageTypeNames(usageInfos), PbUsageTypeProvider.fieldDeclaration().toString());
}

private PsiFile createFile(String filename, String... fileContents) {
Expand Down Expand Up @@ -248,13 +248,13 @@ private static Collection<String> describeUsages(Collection<UsageInfo> usageInfo
.collect(Collectors.toList());
}

private static Collection<UsageType> describeUsagesTypes(Collection<UsageInfo> usageInfos) {
private static Collection<String> describeUsageTypeNames(Collection<UsageInfo> usageInfos) {
return usageInfos
.stream()
.map(
usageInfo -> {
UsageType usageType = USAGE_TYPE_PROVIDER.getUsageType(usageInfo.getElement());
return usageType != null ? usageType : UsageType.UNCLASSIFIED;
return usageType != null ? usageType.toString() : UsageType.UNCLASSIFIED.toString();
})
.collect(Collectors.toList());
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ genrule(
set -e
WORK=`pwd`
SKEL=`echo $(SRCS) | tr ' ' '\n' | grep 'skeleton' | tr '\n' ' '`
GRAMMARS=`echo $(SRCS) | tr ' ' '\n' | grep '\.flex$$' | tr '\n' ' '`
GRAMMARS=`echo $(SRCS) | tr ' ' '\n' | grep '\\.flex$$' | tr '\n' ' '`
mkdir $(@D)/gen
$(location //build_support:idea_jflex) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,40 @@
*/
public class PbUsageTypeProvider implements UsageTypeProvider {

static final UsageType EXTEND_DEFINITION =
new UsageType(() -> PbLangBundle.message("usage.extend.type.reference"));
static final UsageType FIELD_DECLARATION =
new UsageType(() -> PbLangBundle.message("usage.field.type.reference"));
static final UsageType OPTION_EXPRESSION =
new UsageType(() -> PbLangBundle.message("usage.option.expr.reference"));
static final UsageType SERVICE_TYPE =
new UsageType(() -> PbLangBundle.message("usage.service.type.reference"));
public static UsageType fieldDeclaration() {
return new UsageType(() -> PbLangBundle.message("usage.field.type.reference"));
}

public static UsageType extendDefinition() {
return new UsageType(() -> PbLangBundle.message("usage.extend.type.reference"));
}

public static UsageType serviceType() {
return new UsageType(() -> PbLangBundle.message("usage.service.type.reference"));
}

public static UsageType optionExpression() {
return new UsageType(() -> PbLangBundle.message("usage.option.expr.reference"));
}

@Nullable
@Override
public UsageType getUsageType(PsiElement element) {
PbTypeName typeParent = PsiTreeUtil.getParentOfType(element, PbTypeName.class);
if (typeParent != null) {
if (PsiTreeUtil.getParentOfType(typeParent, PbField.class) != null) {
return FIELD_DECLARATION;
return fieldDeclaration();
}
PbDefinition owner = PsiTreeUtil.getParentOfType(typeParent, PbDefinition.class);
if (owner instanceof PbExtendDefinition) {
return EXTEND_DEFINITION;
return extendDefinition();
}
if (owner instanceof PbServiceDefinition) {
return SERVICE_TYPE;
return serviceType();
}
}
if (PsiTreeUtil.getParentOfType(element, PbOptionExpression.class) != null) {
return OPTION_EXPRESSION;
return optionExpression();
}
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package(default_visibility = ["//visibility:private"])
licenses(["notice"]) # Apache License 2.0

# Standalone plugin version.
PROTO_PLUGIN_VERSION = "2.2.0"
PROTO_PLUGIN_VERSION = "2.3.0"

java_library(
name = "combined_lib",
Expand Down
5 changes: 5 additions & 0 deletions plugin/changelog.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<h4><a href="https://github.com/jvolkman/intellij-protobuf-editor/releases/tag/v2.3.0">2.3.0</a></h4>
<ul>
<li>Support for the 2021.1 platform</li>
</ul>

<h4><a href="https://github.com/jvolkman/intellij-protobuf-editor/releases/tag/v2.2.0">2.2.0</a></h4>
<ul>
<li>Support for the 2020.3 platform</li>
Expand Down

0 comments on commit 9a0f8cd

Please sign in to comment.