Skip to content

Commit

Permalink
Trigger auto-popup for constant arg completion
Browse files Browse the repository at this point in the history
  • Loading branch information
klesun committed Feb 13, 2019
1 parent 8749680 commit 460a802
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private static Opt<T2<String, Integer>> assertBuiltInFuncArg(PsiElement caretLea
.cst(ConstantReferenceImpl.class) // IntellijIdeaRulezzz
.fop(cst -> opt(cst.getParent()))
.map(lst -> Tls.cast(BinaryExpressionImpl.class, lst) // doStuff(A | B)
.map(bin -> bin.getParent()).def(lst))
.fop(bin -> opt(bin.getParent())).def(lst))
.cst(ParameterList.class)
.fop(cst -> opt(cst.getParent()))
.cst(FunctionReferenceImpl.class)
Expand Down Expand Up @@ -84,4 +84,28 @@ protected void addCompletions(@NotNull CompletionParameters parameters, Processi

suggestions.fch(result::addElement);
}

public static boolean invokeAutoPopup(@NotNull PsiElement position, char typeChar)
{
if (typeChar == ' ') {
if (position.getText().equals(",")) {
return opt(position.getParent())
.cst(ParameterList.class)
.fop(cst -> opt(cst.getParent()))
.cst(FunctionReferenceImpl.class)
.any(call -> !"".equals(opt(call.getName()).def("")));
} else if (position.getText().equals("|")) {
return opt(position.getParent())
.fop(lst -> Tls.cast(BinaryExpressionImpl.class, lst))
.fop(cst -> opt(cst.getParent()))
.cst(ParameterList.class)
.fop(cst -> opt(cst.getParent()))
.cst(FunctionReferenceImpl.class)
.any(call -> !"".equals(opt(call.getName()).def("")));
}
} else if (typeChar == '(') {
return position.getParent() instanceof ConstantReferenceImpl;
}
return false;
}
}
4 changes: 2 additions & 2 deletions src/org/klesun/deep_assoc_completion/entry/DeepAssocCbtr.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ public boolean invokeAutoPopup(@NotNull PsiElement position, char typeChar) {
.map(par -> par.getLastChild())
.flt(lst -> lst.isEquivalentTo(position))
.uni(var -> true, () -> false);
// } else if (typeChar == ',' || typeChar == ' ') {
// return ArgCstPvdr.assertBuiltInFuncArgFromLeaf(position).has();
} else if (ArgCstPvdr.invokeAutoPopup(position, typeChar)) {
return true;
} else {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ function __construct(array $options = array())

pcntl_signal();
file_put_contents('text.txt', 'abababa', );
json_encode(['a' => 5, 'b' => 6], JSON_PRETTY_PRINT | i);
json_encode(['a' => 5, 'b' => 6], JSON_PRETTY_PRINT | );
file_put_contents('text.txt', 'abababa', '');

preg_match('/asd/', 'asd', $matches, '');
Expand Down

0 comments on commit 460a802

Please sign in to comment.