use of com.jetbrains.php.lang.psi.elements.StringLiteralExpression in project idea-php-typo3-plugin by cedricziel.
the class GeneralUtilityServiceTypeProvider method getType.
@Nullable
@Override
public PhpType getType(PsiElement psiElement) {
if (DumbService.getInstance(psiElement.getProject()).isDumb()) {
return null;
}
if (!(psiElement instanceof MethodReference) || !PhpElementsUtil.isMethodWithFirstStringOrFieldReference(psiElement, "makeInstanceService")) {
return null;
}
MethodReference methodReference = (MethodReference) psiElement;
if (methodReference.getParameters().length == 0) {
return null;
}
PsiElement firstParam = methodReference.getParameters()[0];
if (firstParam instanceof StringLiteralExpression) {
StringLiteralExpression ref = (StringLiteralExpression) firstParam;
String serviceId = ref.getContents();
return new PhpType().add("#" + this.getKey() + serviceId);
}
return null;
}
use of com.jetbrains.php.lang.psi.elements.StringLiteralExpression in project idea-php-typo3-plugin by cedricziel.
the class RouteLineMarkerProvider method collectNavigationMarkers.
@Override
protected void collectNavigationMarkers(@NotNull PsiElement element, @NotNull Collection<? super RelatedItemLineMarkerInfo> result) {
if (!(element instanceof StringLiteralExpression)) {
return;
}
StringLiteralExpression literalExpression = (StringLiteralExpression) element;
String value = literalExpression.getContents();
if (value.isEmpty()) {
return;
}
PsiElement methodReference = PsiTreeUtil.getParentOfType(element, MethodReference.class);
if (PhpElementsUtil.isMethodWithFirstStringOrFieldReference(methodReference, "getAjaxUrl") || PhpElementsUtil.isMethodWithFirstStringOrFieldReference(methodReference, "buildUriFromRoute")) {
if (RouteIndex.hasRoute(element.getProject(), value)) {
Collection<RouteStub> routes = RouteIndex.getRoute(element.getProject(), value);
routes.forEach(def -> {
PsiElement[] routeDefinitionElements = RouteHelper.getRouteDefinitionElements(element.getProject(), value);
NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(TYPO3CMSIcons.ROUTE_ICON).setTargets(routeDefinitionElements);
if (def.getPath() != null) {
builder.setTooltipTitle("Path: " + def.getPath());
}
result.add(builder.createLineMarkerInfo(element));
});
}
}
}
use of com.jetbrains.php.lang.psi.elements.StringLiteralExpression in project idea-php-typo3-plugin by cedricziel.
the class TYPO3Utility method getTYPO3Branch.
@Nullable
public static String getTYPO3Branch(@NotNull Project project) {
Constant versionConstant = getBranchVersionConstant(project);
if (versionConstant == null) {
return null;
}
PsiElement value = versionConstant.getValue();
if (value instanceof StringLiteralExpression) {
return ((StringLiteralExpression) value).getContents();
}
return null;
}
use of com.jetbrains.php.lang.psi.elements.StringLiteralExpression in project idea-php-typo3-plugin by cedricziel.
the class TranslationAnnotator method annotate.
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
if (!(psiElement instanceof StringLiteralExpression)) {
return;
}
StringLiteralExpression literalExpression = (StringLiteralExpression) psiElement;
String value = literalExpression.getContents();
if (TranslationUtil.isTranslationKeyString(value) && value.length() > 4 && !(psiElement.getParent() instanceof ConcatenationExpression)) {
annotateTranslationUsage(psiElement, annotationHolder, value);
}
}
Aggregations