Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
4658ec0f
Unverified
Commit
4658ec0f
authored
Apr 04, 2018
by
Konstantin Scheglov
Committed by
GitHub
Apr 04, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract checking IntelliJ packages into a helper and use for Android Studio. (#16198)
parent
48478b59
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
164 additions
and
63 deletions
+164
-63
android_studio.dart
packages/flutter_tools/lib/src/android/android_studio.dart
+21
-0
android_studio_validator.dart
...utter_tools/lib/src/android/android_studio_validator.dart
+8
-0
doctor.dart
packages/flutter_tools/lib/src/doctor.dart
+7
-63
intellij.dart
packages/flutter_tools/lib/src/intellij/intellij.dart
+71
-0
intellij_test.dart
packages/flutter_tools/test/intellij/intellij_test.dart
+57
-0
No files found.
packages/flutter_tools/lib/src/android/android_studio.dart
View file @
4658ec0f
...
...
@@ -38,6 +38,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
final
Version
version
;
final
String
configured
;
String
_pluginsPath
;
String
_javaPath
;
bool
_isValid
=
false
;
final
List
<
String
>
_validationMessages
=
<
String
>[];
...
...
@@ -81,6 +82,26 @@ class AndroidStudio implements Comparable<AndroidStudio> {
bool
get
isValid
=>
_isValid
;
String
get
pluginsPath
{
if
(
_pluginsPath
==
null
)
{
final
int
major
=
version
.
major
;
final
int
minor
=
version
.
minor
;
if
(
platform
.
isMacOS
)
{
_pluginsPath
=
fs
.
path
.
join
(
homeDirPath
,
'Library'
,
'Application Support'
,
'AndroidStudio
$major
.
$minor
'
);
}
else
{
_pluginsPath
=
fs
.
path
.
join
(
homeDirPath
,
'.AndroidStudio
$major
.
$minor
'
,
'config'
,
'plugins'
);
}
}
return
_pluginsPath
;
}
List
<
String
>
get
validationMessages
=>
_validationMessages
;
@override
...
...
packages/flutter_tools/lib/src/android/android_studio_validator.dart
View file @
4658ec0f
...
...
@@ -7,6 +7,7 @@ import 'dart:async';
import
'../base/version.dart'
;
import
'../doctor.dart'
;
import
'../globals.dart'
;
import
'../intellij/intellij.dart'
;
import
'android_studio.dart'
;
class
AndroidStudioValidator
extends
DoctorValidator
{
...
...
@@ -30,11 +31,18 @@ class AndroidStudioValidator extends DoctorValidator {
Future
<
ValidationResult
>
validate
()
async
{
final
List
<
ValidationMessage
>
messages
=
<
ValidationMessage
>[];
ValidationType
type
=
ValidationType
.
missing
;
final
String
studioVersionText
=
_studio
.
version
==
Version
.
unknown
?
null
:
'version
${_studio.version}
'
;
messages
.
add
(
new
ValidationMessage
(
'Android Studio at
${_studio.directory}
'
));
final
IntelliJPlugins
plugins
=
new
IntelliJPlugins
(
_studio
.
pluginsPath
);
plugins
.
validatePackage
(
messages
,
<
String
>[
'flutter-intellij'
,
'flutter-intellij.jar'
],
'Flutter'
,
minVersion:
IntelliJPlugins
.
kMinFlutterPluginVersion
);
plugins
.
validatePackage
(
messages
,
<
String
>[
'Dart'
],
'Dart'
);
if
(
_studio
.
isValid
)
{
type
=
ValidationType
.
installed
;
messages
.
addAll
(
_studio
.
validationMessages
...
...
packages/flutter_tools/lib/src/doctor.dart
View file @
4658ec0f
...
...
@@ -3,9 +3,6 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:convert'
show
utf8
;
import
'package:archive/archive.dart'
;
import
'android/android_studio_validator.dart'
;
import
'android/android_workflow.dart'
;
...
...
@@ -21,6 +18,7 @@ import 'base/version.dart';
import
'cache.dart'
;
import
'device.dart'
;
import
'globals.dart'
;
import
'intellij/intellij.dart'
;
import
'ios/ios_workflow.dart'
;
import
'ios/plist_utils.dart'
;
import
'version.dart'
;
...
...
@@ -316,7 +314,6 @@ abstract class IntelliJValidator extends DoctorValidator {
};
static
final
Version
kMinIdeaVersion
=
new
Version
(
2017
,
1
,
0
);
static
final
Version
kMinFlutterPluginVersion
=
new
Version
(
16
,
0
,
0
);
static
Iterable
<
DoctorValidator
>
get
installedValidators
{
if
(
platform
.
isLinux
||
platform
.
isWindows
)
...
...
@@ -332,9 +329,10 @@ abstract class IntelliJValidator extends DoctorValidator {
messages
.
add
(
new
ValidationMessage
(
'IntelliJ at
$installPath
'
));
_validatePackage
(
messages
,
<
String
>[
'flutter-intellij'
,
'flutter-intellij.jar'
],
'Flutter'
,
minVersion:
kMinFlutterPluginVersion
);
_validatePackage
(
messages
,
<
String
>[
'Dart'
],
'Dart'
);
final
IntelliJPlugins
plugins
=
new
IntelliJPlugins
(
pluginsPath
);
plugins
.
validatePackage
(
messages
,
<
String
>[
'flutter-intellij'
,
'flutter-intellij.jar'
],
'Flutter'
,
minVersion:
IntelliJPlugins
.
kMinFlutterPluginVersion
);
plugins
.
validatePackage
(
messages
,
<
String
>[
'Dart'
],
'Dart'
);
if
(
_hasIssues
(
messages
))
{
messages
.
add
(
new
ValidationMessage
(
...
...
@@ -371,70 +369,16 @@ abstract class IntelliJValidator extends DoctorValidator {
));
}
}
void
_validatePackage
(
List
<
ValidationMessage
>
messages
,
List
<
String
>
packageNames
,
String
title
,
{
Version
minVersion
})
{
for
(
String
packageName
in
packageNames
)
{
if
(!
hasPackage
(
packageName
))
{
continue
;
}
final
String
versionText
=
_readPackageVersion
(
packageName
);
final
Version
version
=
new
Version
.
parse
(
versionText
);
if
(
version
!=
null
&&
minVersion
!=
null
&&
version
<
minVersion
)
{
messages
.
add
(
new
ValidationMessage
.
error
(
'
$title
plugin version
$versionText
- the recommended minimum version is
$minVersion
'
));
}
else
{
messages
.
add
(
new
ValidationMessage
(
'
$title
plugin
${version != null ? "version $version" : "installed"}
'
));
}
return
;
}
messages
.
add
(
new
ValidationMessage
.
error
(
'
$title
plugin not installed; this adds
$title
specific functionality.'
));
}
String
_readPackageVersion
(
String
packageName
)
{
final
String
jarPath
=
packageName
.
endsWith
(
'.jar'
)
?
fs
.
path
.
join
(
pluginsPath
,
packageName
)
:
fs
.
path
.
join
(
pluginsPath
,
packageName
,
'lib'
,
'
$packageName
.jar'
);
// TODO(danrubel) look for a better way to extract a single 2K file from the zip
// rather than reading the entire file into memory.
try
{
final
Archive
archive
=
new
ZipDecoder
().
decodeBytes
(
fs
.
file
(
jarPath
).
readAsBytesSync
());
final
ArchiveFile
file
=
archive
.
findFile
(
'META-INF/plugin.xml'
);
final
String
content
=
utf8
.
decode
(
file
.
content
);
const
String
versionStartTag
=
'<version>'
;
final
int
start
=
content
.
indexOf
(
versionStartTag
);
final
int
end
=
content
.
indexOf
(
'</version>'
,
start
);
return
content
.
substring
(
start
+
versionStartTag
.
length
,
end
);
}
catch
(
_
)
{
return
null
;
}
}
bool
hasPackage
(
String
packageName
)
{
final
String
packagePath
=
fs
.
path
.
join
(
pluginsPath
,
packageName
);
if
(
packageName
.
endsWith
(
'.jar'
))
return
fs
.
isFileSync
(
packagePath
);
return
fs
.
isDirectorySync
(
packagePath
);
}
}
class
IntelliJValidatorOnLinuxAndWindows
extends
IntelliJValidator
{
IntelliJValidatorOnLinuxAndWindows
(
String
title
,
this
.
version
,
String
installPath
,
this
.
pluginsPath
)
:
super
(
title
,
installPath
);
@override
String
version
;
final
String
version
;
@override
String
pluginsPath
;
final
String
pluginsPath
;
static
Iterable
<
DoctorValidator
>
get
installed
{
final
List
<
DoctorValidator
>
validators
=
<
DoctorValidator
>[];
...
...
packages/flutter_tools/lib/src/intellij/intellij.dart
0 → 100644
View file @
4658ec0f
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:convert'
;
import
'package:archive/archive.dart'
;
import
'../base/file_system.dart'
;
import
'../base/version.dart'
;
import
'../doctor.dart'
;
class
IntelliJPlugins
{
static
final
Version
kMinFlutterPluginVersion
=
new
Version
(
16
,
0
,
0
);
final
String
pluginsPath
;
IntelliJPlugins
(
this
.
pluginsPath
);
void
validatePackage
(
List
<
ValidationMessage
>
messages
,
List
<
String
>
packageNames
,
String
title
,
{
Version
minVersion
})
{
for
(
String
packageName
in
packageNames
)
{
if
(!
_hasPackage
(
packageName
))
{
continue
;
}
final
String
versionText
=
_readPackageVersion
(
packageName
);
final
Version
version
=
new
Version
.
parse
(
versionText
);
if
(
version
!=
null
&&
minVersion
!=
null
&&
version
<
minVersion
)
{
messages
.
add
(
new
ValidationMessage
.
error
(
'
$title
plugin version
$versionText
- the recommended minimum version is
$minVersion
'
));
}
else
{
messages
.
add
(
new
ValidationMessage
(
'
$title
plugin
${version != null ? "version $version" : "installed"}
'
));
}
return
;
}
messages
.
add
(
new
ValidationMessage
.
error
(
'
$title
plugin not installed; this adds
$title
specific functionality.'
));
}
bool
_hasPackage
(
String
packageName
)
{
final
String
packagePath
=
fs
.
path
.
join
(
pluginsPath
,
packageName
);
if
(
packageName
.
endsWith
(
'.jar'
))
return
fs
.
isFileSync
(
packagePath
);
return
fs
.
isDirectorySync
(
packagePath
);
}
String
_readPackageVersion
(
String
packageName
)
{
final
String
jarPath
=
packageName
.
endsWith
(
'.jar'
)
?
fs
.
path
.
join
(
pluginsPath
,
packageName
)
:
fs
.
path
.
join
(
pluginsPath
,
packageName
,
'lib'
,
'
$packageName
.jar'
);
// TODO(danrubel) look for a better way to extract a single 2K file from the zip
// rather than reading the entire file into memory.
try
{
final
Archive
archive
=
new
ZipDecoder
().
decodeBytes
(
fs
.
file
(
jarPath
).
readAsBytesSync
());
final
ArchiveFile
file
=
archive
.
findFile
(
'META-INF/plugin.xml'
);
final
String
content
=
utf8
.
decode
(
file
.
content
);
const
String
versionStartTag
=
'<version>'
;
final
int
start
=
content
.
indexOf
(
versionStartTag
);
final
int
end
=
content
.
indexOf
(
'</version>'
,
start
);
return
content
.
substring
(
start
+
versionStartTag
.
length
,
end
);
}
catch
(
_
)
{
return
null
;
}
}
}
packages/flutter_tools/test/intellij/intellij_test.dart
0 → 100644
View file @
4658ec0f
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/doctor.dart'
;
import
'package:flutter_tools/src/intellij/intellij.dart'
;
import
'package:test/test.dart'
;
import
'../src/context.dart'
;
void
main
(
)
{
group
(
'IntelliJ'
,
()
{
group
(
'plugins'
,
()
{
testUsingContext
(
'found'
,
()
async
{
final
String
pluginsPath
=
fs
.
path
.
join
(
'test'
,
'data'
,
'intellij'
,
'plugins'
);
final
IntelliJPlugins
plugins
=
new
IntelliJPlugins
(
pluginsPath
);
final
List
<
ValidationMessage
>
messages
=
<
ValidationMessage
>[];
plugins
.
validatePackage
(
messages
,
<
String
>[
'flutter-intellij'
,
'flutter-intellij.jar'
],
'Flutter'
,
minVersion:
IntelliJPlugins
.
kMinFlutterPluginVersion
);
plugins
.
validatePackage
(
messages
,
<
String
>[
'Dart'
],
'Dart'
);
ValidationMessage
message
=
messages
.
firstWhere
((
ValidationMessage
m
)
=>
m
.
message
.
startsWith
(
'Dart '
));
expect
(
message
.
message
,
'Dart plugin version 162.2485'
);
message
=
messages
.
firstWhere
(
(
ValidationMessage
m
)
=>
m
.
message
.
startsWith
(
'Flutter '
));
expect
(
message
.
message
,
contains
(
'Flutter plugin version 0.1.3'
));
expect
(
message
.
message
,
contains
(
'recommended minimum version'
));
});
testUsingContext
(
'not found'
,
()
async
{
final
String
pluginsPath
=
fs
.
path
.
join
(
'test'
,
'data'
,
'intellij'
,
'no_plugins'
);
final
IntelliJPlugins
plugins
=
new
IntelliJPlugins
(
pluginsPath
);
final
List
<
ValidationMessage
>
messages
=
<
ValidationMessage
>[];
plugins
.
validatePackage
(
messages
,
<
String
>[
'flutter-intellij'
,
'flutter-intellij.jar'
],
'Flutter'
,
minVersion:
IntelliJPlugins
.
kMinFlutterPluginVersion
);
plugins
.
validatePackage
(
messages
,
<
String
>[
'Dart'
],
'Dart'
);
ValidationMessage
message
=
messages
.
firstWhere
((
ValidationMessage
m
)
=>
m
.
message
.
startsWith
(
'Dart '
));
expect
(
message
.
message
,
contains
(
'Dart plugin not installed'
));
message
=
messages
.
firstWhere
(
(
ValidationMessage
m
)
=>
m
.
message
.
startsWith
(
'Flutter '
));
expect
(
message
.
message
,
contains
(
'Flutter plugin not installed'
));
});
});
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment