PsiElement psiElement = completionParameters.getOriginalPosition();
if(psiElement == null || !(psiElement.getParent() instanceof MethodReference)) {
return;
}
Symfony2InterfacesUtil symfony2InterfacesUtil = new Symfony2InterfacesUtil();
for(ConstantEnumCompletionProvider enumProvider: CONSTANTS_ENUMS) {
if(enumProvider.getEnumType() == ConstantEnumCompletionProvider.EnumType.PARAMETER) {
attachLookup(completionResultSet, (MethodReference) psiElement.getParent(), symfony2InterfacesUtil, enumProvider);
}
}
}
});
// $test = TEST::HTTP
extend(CompletionType.BASIC, PlatformPatterns.psiElement(), new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
PsiElement psiElement = completionParameters.getOriginalPosition();
if(psiElement == null) {
return;
}
BinaryExpression binaryExpression = PsiTreeUtil.getPrevSiblingOfType(psiElement, BinaryExpression.class);
if(binaryExpression == null) {
return;
}
// OK: $response->getStatusCode() == Response::HTTP_BAD_GATEWAY
// @TODO: error we are complete outside of context: $response->getStatusCode() == Response::HTTP_BAD_GATEWAY || $response->getStatusCode() ==
PsiElement leftOperand = binaryExpression.getLeftOperand();
if(!(leftOperand instanceof MethodReference)) {
return;
}
Symfony2InterfacesUtil symfony2InterfacesUtil = new Symfony2InterfacesUtil();
for(ConstantEnumCompletionProvider enumProvider: CONSTANTS_ENUMS) {
if(enumProvider.getEnumType() == ConstantEnumCompletionProvider.EnumType.RETURN) {
attachLookup(completionResultSet, (MethodReference) leftOperand, symfony2InterfacesUtil, enumProvider);
}
}
}
});
extend(CompletionType.BASIC, PlatformPatterns.psiElement(), new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
PsiElement psiElement = completionParameters.getOriginalPosition();
if(psiElement == null) {
return;
}
BinaryExpression binaryExpression = PsiTreeUtil.getPrevSiblingOfType(psiElement, BinaryExpression.class);
if(binaryExpression == null) {
return;
}
// OK: $response->getStatusCode() == Response::HTTP_BAD_GATEWAY
// @TODO: error we are complete outside of context: $response->getStatusCode() == Response::HTTP_BAD_GATEWAY || $response->getStatusCode() ==
PsiElement leftOperand = binaryExpression.getLeftOperand();
if(!(leftOperand instanceof MethodReference)) {
return;
}
Symfony2InterfacesUtil symfony2InterfacesUtil = new Symfony2InterfacesUtil();
for(ConstantEnumCompletionProvider enumProvider: CONSTANTS_ENUMS) {
if(enumProvider.getEnumType() == ConstantEnumCompletionProvider.EnumType.RETURN) {
attachLookup(completionResultSet, (MethodReference) leftOperand, symfony2InterfacesUtil, enumProvider);
}
}
}
});
// strings
extend(CompletionType.BASIC, PlatformPatterns.psiElement(), new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
PsiElement psiElement = completionParameters.getPosition().getOriginalElement();
if(!(psiElement.getParent() instanceof StringLiteralExpression)) {
return;
}
for(ConstantEnumCompletionProvider enumProvider: CONSTANTS_ENUMS) {
if(enumProvider.getEnumType() == ConstantEnumCompletionProvider.EnumType.PARAMETER && enumProvider.getEnumConstantFilter().getStringValues() != null) {
if(MethodMatcher.getMatchedSignatureWithDepth(psiElement.getParent(), new MethodMatcher.CallToSignature[] {enumProvider.getCallToSignature()}) != null) {
for(String stringValue: enumProvider.getEnumConstantFilter().getStringValues()) {
completionResultSet.addElement(LookupElementBuilder.create(stringValue));
}
}
}
}
}
});
extend(CompletionType.BASIC, PlatformPatterns.psiElement(), new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
PsiElement psiElement = completionParameters.getPosition().getOriginalElement();
if(!(psiElement.getParent() instanceof StringLiteralExpression)) {
return;
}
if(!(psiElement.getParent().getParent() instanceof BinaryExpression)) {
return;
}
BinaryExpression binaryExpression = (BinaryExpression) psiElement.getParent().getParent();
// OK: $response->getStatusCode() == Response::HTTP_BAD_GATEWAY
// @TODO: error we are complete outside of context: $response->getStatusCode() == Response::HTTP_BAD_GATEWAY || $response->getStatusCode() ==
PsiElement leftOperand = binaryExpression.getLeftOperand();
if(!(leftOperand instanceof MethodReference)) {
return;
}
Symfony2InterfacesUtil symfony2InterfacesUtil = new Symfony2InterfacesUtil();
for(ConstantEnumCompletionProvider enumProvider: CONSTANTS_ENUMS) {
if(enumProvider.getEnumType() == ConstantEnumCompletionProvider.EnumType.RETURN && enumProvider.getEnumConstantFilter().getStringValues() != null && symfony2InterfacesUtil.isCallTo((MethodReference) leftOperand, enumProvider.getCallToSignature().getInstance(), enumProvider.getCallToSignature().getMethod())) {
for(String stringValue: enumProvider.getEnumConstantFilter().getStringValues()) {
completionResultSet.addElement(LookupElementBuilder.create(stringValue));
}
}
}