Skip to content

Build for 2021.3 EAP #5841

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

Closed
wants to merge 25 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/presubmit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [AF.3.1, AS.211, 2021.2]
version: [AF.3.1, AS.211, 2021.2, 2021.3]
steps:
- name: checkout
uses: actions/checkout@v2
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ lib/jxbrowser/*
!lib/java-string-similarity-2.0.0.jar
material-design-icons/
out/
packages
pubspec.lock
releases/
resources/jxbrowser/jxbrowser.properties
Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ dependencies {
}

sourceSets {
test.resources.srcDirs = [
"flutter-idea/testData"
]
}

//noinspection GroovyAssignabilityCheck
Expand Down
3 changes: 2 additions & 1 deletion docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ project in IntelliJ, then delete .idea/modules.xml. You may need to delete other
files in ~/Library/Application Support/Caches/JetBrains/<IDE>/. Look in `conversion`
and `external_build_systrm`. It may take some experimentation. When the project
is opened in IntelliJ, ensure that there are `flutter-idea` and `flutter-studio`
modules in the project structure.
modules in the project structure. Also make sure the project sdk is set to a
JDK-equivalent, not a JRE-equivalent.

To re-open the project as an IntelliJ (not Gradle) project, close it in IntelliJ,
then restore .idea/modules.xml and delete .idea/gradle.xml. Again, you may need to
Expand Down
1 change: 0 additions & 1 deletion flutter-idea/testData

This file was deleted.

File renamed without changes.
Binary file not shown.
3,553 changes: 3,553 additions & 0 deletions flutter-idea/testData/sdk/packages/flutter/lib/src/cupertino/icons.dart

Large diffs are not rendered by default.

22,131 changes: 22,131 additions & 0 deletions flutter-idea/testData/sdk/packages/flutter/lib/src/material/icons.dart

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion product-matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"channel": "stable",
"comments": "IntelliJ 2021.1, Android Studio 2021.1.1 Beta",
"name": "Bumblebee",
"isUnitTestTarget": "true",
"version": "AS.211",
"ideaProduct": "android-studio",
"ideaVersion": "2021.1.1.8",
Expand Down Expand Up @@ -49,6 +48,19 @@
"dartPluginVersion": "212.5486",
"sinceBuild": "212.5284.40",
"untilBuild": "212.5284.40"
},
{
"channel": "stable",
"comments": "IntelliJ 2021.3 EAP",
"name": "IntelliJ 2021.3 EAP",
"version": "2021.3",
"isUnitTestTarget": "true",
"ideaProduct": "ideaIC",
"ideaVersion": "213.5281.15",
"baseVersion": "213.5281.15",
"dartPluginVersion": "213.5281.15",
"sinceBuild": "213.5281.15",
"untilBuild": "213.*"
}
]
}
2 changes: 1 addition & 1 deletion resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<category>Custom Languages</category>
<version>SNAPSHOT</version>
<idea-version since-build="203.6682.168" until-build="211.7727"/>
<idea-version since-build="203.6682.168" until-build="213.*"/>

<depends>com.intellij.modules.platform</depends>
<depends>com.intellij.modules.lang</depends>
Expand Down
19 changes: 17 additions & 2 deletions src/io/flutter/editor/FlutterCompletionContributor.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
package io.flutter.editor;

import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.util.ui.ColorIcon;
import com.intellij.util.ui.EmptyIcon;
import com.jetbrains.lang.dart.ide.completion.DartCompletionExtension;
import com.jetbrains.lang.dart.ide.completion.DartServerCompletionContributor;
import io.flutter.sdk.FlutterSdk;
import org.apache.commons.lang.StringUtils;
import org.dartlang.analysis.server.protocol.CompletionSuggestion;
import org.dartlang.analysis.server.protocol.Element;
Expand Down Expand Up @@ -60,12 +62,12 @@ else if (Objects.equals(declaringType, "CupertinoColors")) {
}
}
else if (Objects.equals(declaringType, "Icons")) {
final Icon icon = FlutterIconLineMarkerProvider.getMaterialIconByName(project, name);
final Icon icon = FlutterIconLineMarkerProvider.getMaterialIconByName(project, getSdkHomePath(project), name);
// If we have no icon, show an empty node (which is preferable to the default "IconData" text).
return icon != null ? icon : EMPTY_ICON;
}
else if (Objects.equals(declaringType, "CupertinoIcons")) {
final Icon icon = FlutterIconLineMarkerProvider.getCupertinoIconByName(project, name);
final Icon icon = FlutterIconLineMarkerProvider.getCupertinoIconByName(project, getSdkHomePath(project), name);
// If we have no icon, show an empty node (which is preferable to the default "IconData" text).
return icon != null ? icon : EMPTY_ICON;
}
Expand All @@ -75,4 +77,17 @@ else if (Objects.equals(declaringType, "CupertinoIcons")) {

return null;
}

@NotNull
private static String getSdkHomePath(@NotNull Project project) {
final FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
if (sdk == null) {
assert ApplicationManager.getApplication() != null;
if (ApplicationManager.getApplication().isUnitTestMode()) {
return "testData/sdk";
}
throw new NullPointerException("Flutter SDK not found");
}
return sdk.getHomePath();
}
}
29 changes: 13 additions & 16 deletions src/io/flutter/editor/FlutterIconLineMarkerProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.jetbrains.yaml.psi.YamlRecursivePsiElementVisitor;

import javax.swing.*;
import java.io.FileNotFoundException;
import java.util.*;

import static io.flutter.dart.DartPsiUtil.*;
Expand Down Expand Up @@ -75,28 +76,24 @@ public static void initialize() {
}

@Nullable
public static Icon getCupertinoIconByName(@Nullable Project project, @NotNull String iconName) {
public static Icon getCupertinoIconByName(@Nullable Project project, @NotNull String sdkHomePath, @NotNull String iconName) {
if (project == null) return null;
final FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
if (sdk == null) return null;
final IconInfo iconDef =
findStandardDefinition("CupertinoIcons", iconName, project, sdk.getHomePath() + BuiltInPaths.get("CupertinoIcons"), sdk);
findStandardDefinition("CupertinoIcons", iconName, project, sdkHomePath + BuiltInPaths.get("CupertinoIcons"), sdkHomePath);
if (iconDef == null) return null;
final String path = FlutterSdkUtil.getPathToCupertinoIconsPackage(project);
// <pub_cache>/hosted/pub.dartlang.org/cupertino_icons-v.m.n/assets/CupertinoIcons.ttf
return findStandardIconFromDef(iconName, iconDef, path + CupertinoRelativeAssetPath);
}

@Nullable
public static Icon getMaterialIconByName(@Nullable Project project, @NotNull String iconName) {
public static Icon getMaterialIconByName(@Nullable Project project, @NotNull String sdkHomePath, @NotNull String iconName) {
if (project == null) return null;
final FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
if (sdk == null) return null;
final IconInfo iconDef =
findStandardDefinition("Icons", iconName, project, sdk.getHomePath() + BuiltInPaths.get("Icons"), sdk);
findStandardDefinition("Icons", iconName, project, sdkHomePath + BuiltInPaths.get("Icons"), sdkHomePath);
if (iconDef == null) return null;
// <flutter-sdk>/bin/cache/artifacts/material_fonts/MaterialIcons-Regular.otf
return findStandardIconFromDef(iconName, iconDef, sdk.getHomePath() + MaterialRelativeAssetPath);
return findStandardIconFromDef(iconName, iconDef, sdkHomePath + MaterialRelativeAssetPath);
}

@Nullable
Expand Down Expand Up @@ -198,10 +195,10 @@ else if (parentNode.getElementType() == DartTokenTypes.SIMPLE_TYPE) {
final String selector = AstBufferUtil.getTextSkippingWhitespaceComments(selectorNode.getNode());
final Icon icon;
if (name.equals("Icons")) {
icon = getMaterialIconByName(element.getProject(), selector);
icon = getMaterialIconByName(element.getProject(), sdk.getHomePath(), selector);
}
else if (name.equals("CupertinoIcons")) {
icon = getCupertinoIconByName(element.getProject(), selector);
icon = getCupertinoIconByName(element.getProject(), sdk.getHomePath(), selector);
}
else {
// Note: I want to keep this code until I'm sure we won't use pubspec.yaml.
Expand Down Expand Up @@ -254,12 +251,12 @@ private static IconInfo findStandardDefinition(@NotNull String className,
@NotNull String iconName,
@NotNull Project project,
@Nullable String path,
@NotNull FlutterSdk sdk) {
@NotNull String sdkHomePath) {
if (path != null) {
return findDefinition(className, iconName, project, path);
}
assert Objects.requireNonNull(ApplicationManager.getApplication()).isUnitTestMode();
return findDefinition(className, iconName, project, sdk.getHomePath() + BuiltInPaths.get(className));
return findDefinition(className, iconName, project, sdkHomePath + BuiltInPaths.get(className));
}

@Nullable
Expand Down Expand Up @@ -313,10 +310,10 @@ private static IconInfo findDefinition(@NotNull String className,
@NotNull String path) {
assert LocalFileSystem.getInstance() != null;
final VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByPath(path);
if (virtualFile == null) return null;
if (virtualFile == null) throw new Error("FILE NOT FOUND: " + path);//return null;
final PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
if (psiFile == null) {
return null;
throw new Error("CANNOT CREATE PSI FILE");//return null;
}
final IconInfoVisitor visitor = new IconInfoVisitor(iconName);
psiFile.accept(visitor);
Expand All @@ -327,7 +324,7 @@ private static IconInfo findDefinition(@NotNull String className,
private static Icon findIconFromDef(@NotNull String iconClassName, @NotNull IconInfo iconDef, @NotNull String path) {
assert LocalFileSystem.getInstance() != null;
final VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByPath(path);
if (virtualFile == null) return null;
if (virtualFile == null) throw new Error("FILE NOT FOUND: " + path);//return null;
VirtualFile parent = virtualFile;
while (parent != null && !parent.getName().equals("lib")) {
parent = parent.getParent();
Expand Down
5 changes: 5 additions & 0 deletions src/io/flutter/sdk/FlutterSdkUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ public static String guessFlutterSdkFromPackagesFile(@NotNull Module module) {

@Nullable
public static String getPathToCupertinoIconsPackage(@NotNull Project project) {
//noinspection ConstantConditions
if (ApplicationManager.getApplication().isUnitTestMode()) {
// TODO(messick): Configure the test framework to have proper pub data so we don't need this.
return "testData/sdk";
}
final JsonArray packages = getPackagesFromPackageConfig(PubRoots.forProject(project));
for (int i = 0; i < packages.size(); i++) {
final JsonObject pack = packages.get(i).getAsJsonObject();
Expand Down
4 changes: 4 additions & 0 deletions src/io/flutter/utils/UIUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public static ColorKey getEditorNotificationBackgroundColor() {
return EditorColors.GUTTER_BACKGROUND;
}

/**
* Unstable API warning: only use this in the deprecated inspector.
* @return best-guess for the current project based on the top-most window.
*/
@Nullable
public static Project findVisibleProject() {
final WindowManager wm = WindowManager.getInstance();
Expand Down
1 change: 1 addition & 0 deletions testData
26 changes: 14 additions & 12 deletions testSrc/unit/io/flutter/editor/FlutterIconLineMarkerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import io.flutter.sdk.FlutterSdk;
import org.junit.Test;

import java.io.IOException;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand All @@ -27,17 +29,17 @@ private FlutterSdk getSdk() {
return mockSdk;
}

//@Test
public void xtestLocatesIconsReference() throws Exception {
@Test
public void testLocatesIconsReference() throws Exception {
final PsiElement testIdentifier = setUpDartElement("main() { Icons.access_alarm; }", "Icons", LeafPsiElement.class);
final LineMarkerInfo<?> marker = new FlutterIconLineMarkerProvider().getLineMarkerInfo(testIdentifier, getSdk());
assertNotNull(marker);
final DartReferenceExpression element = DartSyntax.findEnclosingReferenceExpression(testIdentifier);
assertNotNull(element);
}

//@Test
public void xtestLocatesIconCtor() throws Exception {
@Test
public void testLocatesIconCtor() throws Exception {
final PsiElement testIdentifier =
setUpDartElement("main() { IconData(0xe190, fontFamily: 'MaterialIcons'); }", "IconData", LeafPsiElement.class);
final LineMarkerInfo<?> marker = new FlutterIconLineMarkerProvider().getLineMarkerInfo(testIdentifier, getSdk());
Expand All @@ -46,8 +48,8 @@ public void xtestLocatesIconCtor() throws Exception {
assertNotNull(element);
}

//@Test
public void xtestLocatesCupertinoIconCtor() throws Exception {
@Test
public void testLocatesCupertinoIconCtor() throws Exception {
final PsiElement testIdentifier =
setUpDartElement("main() { IconData(0xe190, fontFamily: 'CupertinoIcons'); }", "IconData", LeafPsiElement.class);
final LineMarkerInfo<?> marker = new FlutterIconLineMarkerProvider().getLineMarkerInfo(testIdentifier, getSdk());
Expand All @@ -56,8 +58,8 @@ public void xtestLocatesCupertinoIconCtor() throws Exception {
assertNotNull(element);
}

//@Test
public void xtestLocatesConstIconCtor() throws Exception {
@Test
public void testLocatesConstIconCtor() throws Exception {
final PsiElement testIdentifier =
setUpDartElement("main() { const IconData(0xe190, fontFamily: 'MaterialIcons'); }", "IconData", LeafPsiElement.class);
final LineMarkerInfo<?> marker = new FlutterIconLineMarkerProvider().getLineMarkerInfo(testIdentifier, getSdk());
Expand All @@ -66,17 +68,17 @@ public void xtestLocatesConstIconCtor() throws Exception {
assertNotNull(element);
}

//@Test
public void xtestLocatesCupertinoIconsReference() throws Exception {
@Test
public void testLocatesCupertinoIconsReference() throws Exception {
final PsiElement testIdentifier = setUpDartElement("main() { CupertinoIcons.book; }", "CupertinoIcons", LeafPsiElement.class);
final LineMarkerInfo<?> marker = new FlutterIconLineMarkerProvider().getLineMarkerInfo(testIdentifier, getSdk());
assertNotNull(marker);
final DartReferenceExpression element = DartSyntax.findEnclosingReferenceExpression(testIdentifier);
assertNotNull(element);
}

//@Test
public void xtestLocatesCupertinoIconsReferenceWithComment() throws Exception {
@Test
public void testLocatesCupertinoIconsReferenceWithComment() throws Exception {
final PsiElement testIdentifier =
setUpDartElement("main() { CupertinoIcons . /* a book */ book; }", "CupertinoIcons", LeafPsiElement.class);
final LineMarkerInfo<?> marker = new FlutterIconLineMarkerProvider().getLineMarkerInfo(testIdentifier, getSdk());
Expand Down
5 changes: 5 additions & 0 deletions tool/github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ elif [ "CHECK_BOT" = "$BOT" ] ; then

elif [ "UNIT_TEST_BOT" = "$BOT" ] ; then

echo `pwd`
echo "ls -lR"
ls -lR > dir-list.txt
cat dir-list.txt

# Run unit tests.
./bin/plugin test

Expand Down
1 change: 1 addition & 0 deletions tool/kokoro/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ setup() {
export FLUTTER_KEYSTORE_ID=74840
export FLUTTER_KEYSTORE_NAME=flutter-intellij-plugin-auth-token
export FLUTTER_KEYSTORE_JXBROWSER_KEY_NAME=flutter-intellij-plugin-jxbrowser-license-key
export NO_FS_ROOTS_ACCESS_CHECK=true

(cd tool/plugin; echo "pub get `pwd`"; pub get --no-precompile)
./gradlew --version
Expand Down
6 changes: 6 additions & 0 deletions tool/kokoro/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
source ./tool/kokoro/setup.sh
setup

curl https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_osx-x64_bin.tar.gz > ../java.tar.gz
(cd ..; tar fx java.tar.gz)
export JAVA_HOME=`pwd`/../jdk-11.0.2.jdk/Contents/Home
export PATH=$PATH:$JAVA_HOME/bin
echo "JAVA_HOME=$JAVA_HOME"

(cd testData/sample_tests; echo "pub get `pwd`"; pub get --no-precompile)

echo "kokoro test start"
Expand Down
14 changes: 14 additions & 0 deletions tool/plugin/lib/edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ void checkAndClearAppliedEditCommands() {
// TODO(messick): Remove edits for AS 4.2 when confident they won't be needed again.
List<EditCommand> editCommands = [
EditAndroidModuleLibraryManager(),

Subst(
path: 'build.gradle',
initial: 'localPath "\${project.rootDir.absolutePath}/artifacts/\$ide"',
replacement: 'type = "IC"\n version = "213.5281-EAP-CANDIDATE-SNAPSHOT"',
version: '2021.3',
),
Subst(
path: 'flutter-idea/build.gradle',
initial: 'localPath "\${project.rootDir.absolutePath}/artifacts/\$ide"',
replacement: 'type = "IC"\n version = "213.5281-EAP-CANDIDATE-SNAPSHOT"',
version: '2021.3',
),

Subst(
path: 'src/io/flutter/vmService/frame/DartVmServiceValue.java',
initial: ',() -> computeCollectionChildren(instanceRef, offset + count, node)',
Expand Down
3 changes: 3 additions & 0 deletions tool/plugin/test/plugin_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ void main() {
'android-studio',
'ideaIC',
'android-studio',
'ideaIC',
]));
});
});
Expand All @@ -63,6 +64,7 @@ void main() {
'android-studio',
'ideaIC',
'android-studio',
'ideaIC',
]));
});
});
Expand All @@ -79,6 +81,7 @@ void main() {
'android-studio',
'ideaIC',
'android-studio',
'ideaIC',
]));
});
});
Expand Down