use of com.cedricziel.idea.typo3.domain.TYPO3ServiceDefinition in project idea-php-typo3-plugin by cedricziel.
the class GeneralUtilityServiceTypeProvider method getBySignature.
@Override
public Collection<? extends PhpNamedElement> getBySignature(String expression, Set<String> visited, int depth, Project project) {
Collection<PhpNamedElement> phpNamedElementCollections = new ArrayList<>();
PhpIndex phpIndex = PhpIndex.getInstance(project);
CoreServiceParser serviceParser = new CoreServiceParser();
serviceParser.collect(project);
List<TYPO3ServiceDefinition> resolvedServices = serviceParser.resolve(project, expression);
if (resolvedServices == null || resolvedServices.isEmpty()) {
return phpNamedElementCollections;
}
resolvedServices.forEach(serviceDefinition -> {
Collection<PhpClass> classesByFQN = phpIndex.getClassesByFQN(serviceDefinition.getClassName());
phpNamedElementCollections.addAll(classesByFQN);
});
return phpNamedElementCollections;
}
use of com.cedricziel.idea.typo3.domain.TYPO3ServiceDefinition in project idea-php-typo3-plugin by cedricziel.
the class CoreServiceDefinitionParserVisitor method visitServiceCreation.
private void visitServiceCreation(PsiElement element) {
MethodReference methodReference = (MethodReference) element;
// A service definition should contain at least 4 arguments
if (methodReference.getParameters().length < 4) {
return;
}
// Extension name
PsiElement extensionNameParam = methodReference.getParameters()[0];
// Service name
PsiElement serviceNameParam = methodReference.getParameters()[1];
// Implementing Class (may be short name)
PsiElement classNameParam = methodReference.getParameters()[2];
// Array parameters
PsiElement optionsArrayParam = methodReference.getParameters()[3];
String serviceId;
if (serviceNameParam instanceof StringLiteralExpression) {
StringLiteralExpression name = (StringLiteralExpression) serviceNameParam;
serviceId = name.getContents();
} else {
serviceId = serviceNameParam.getText();
}
ArrayList<TYPO3ServiceDefinition> serviceMap;
if (!map.containsKey(serviceId)) {
serviceMap = new ArrayList<>();
map.put(serviceId, serviceMap);
}
serviceMap = map.get(serviceId);
TYPO3ServiceDefinition serviceDefinition = new TYPO3ServiceDefinition(serviceId);
serviceDefinition.setExtensionName(extensionNameParam.getText());
if (classNameParam instanceof ClassConstantReference) {
PhpExpression classReference = ((ClassConstantReference) classNameParam).getClassReference();
if (classReference instanceof PhpReference) {
serviceDefinition.setClass(((PhpReference) classReference).getFQN());
PhpReference ref = (PhpReference) classReference;
serviceDefinition.setSignature(ref.getSignature());
}
if (optionsArrayParam instanceof ArrayCreationExpression) {
ArrayCreationExpression arrayExpression = (ArrayCreationExpression) optionsArrayParam;
mapOptionsArrayParam(serviceDefinition, arrayExpression.getHashElements());
}
serviceMap.add(serviceDefinition);
}
map.put(serviceId, serviceMap);
}
Aggregations