Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
f43bfbca
Commit
f43bfbca
authored
6 years ago
by
AMalykh
Browse files
Options
Download
Email Patches
Plain Diff
PY-33254: Regex->contains.
parent
7ea1981f
Branches unavailable
Tags unavailable
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/src/com/jetbrains/python/codeInsight/completion/pathFilters/DefaultPyPathFilter.java
+14
-4
...deInsight/completion/pathFilters/DefaultPyPathFilter.java
with
14 additions
and
4 deletions
+14
-4
python/src/com/jetbrains/python/codeInsight/completion/pathFilters/DefaultPyPathFilter.java
+
14
-
4
View file @
f43bfbca
...
...
@@ -35,8 +35,11 @@ public final class DefaultPyPathFilter implements PyPathFilter {
"open"
));
/** For functions with names complying thus pattern every string will be treated as a candidate for path. */
private
static
final
Pattern
FUNCTION_NAME_PATTERN
=
Pattern
.
compile
(
"((file)|(path))"
);
/** For functions with names contaning these strings every string will be treated as a candidate for path. */
private
static
final
String
[]
FUNCTION_NAME_PATTERN
=
new
String
[]
{
"path"
,
"file"
};
@Override
public
boolean
test
(
@NotNull
final
PyStringLiteralExpression
expr
)
{
...
...
@@ -55,11 +58,18 @@ public final class DefaultPyPathFilter implements PyPathFilter {
Optional
<
PyCallExpression
>
call
=
getAncestorByBackwardPath
(
expr
,
PyCallExpression
.
class
,
PyArgumentList
.
class
);
return
call
.
map
(
c
->
c
.
getCallee
()
!=
null
&&
DEFAULT_FUNCTIONS_TO_CHECK
.
contains
(
c
.
getCallee
().
getName
())
||
(
c
.
getCallee
().
getName
()
!=
null
&&
FUNCTION_NAME_PATTERN
.
matcher
(
c
.
getCallee
().
getName
())
.
matches
()
))
.
map
(
c
->
c
.
getCallee
()
!=
null
&&
DEFAULT_FUNCTIONS_TO_CHECK
.
contains
(
c
.
getCallee
().
getName
())
||
(
c
.
getCallee
().
getName
()
!=
null
&&
isProbablyFileAwaitingFunction
(
c
.
getCallee
().
getName
())))
.
orElse
(
false
);
}
public
static
boolean
isProbablyFileAwaitingFunction
(
@NotNull
final
String
name
)
{
for
(
String
s
:
FUNCTION_NAME_PATTERN
)
{
if
(
name
.
contains
(
s
))
return
true
;
}
return
false
;
}
/**
* Gets ancestor in the end of chain el -> ancestors[0] -> ancestors[1] -> ... -> ancestors[n] -> topmostAncestor,
* where class of ancestor[i] should correspond to class reversedAncestorsClasses[n - i]. If somewhere the chain breaks (there is no
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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
Menu
Projects
Groups
Snippets
Help