use of com.jetbrains.php.lang.psi.elements.StringLiteralExpression in project idea-php-typo3-plugin by cedricziel.
the class RouteAnnotator 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 (value.isEmpty()) {
return;
}
for (PsiReference psiReference : literalExpression.getReferences()) {
if (psiReference instanceof RouteReference) {
annotateRoute(psiElement, annotationHolder, value);
}
}
}
use of com.jetbrains.php.lang.psi.elements.StringLiteralExpression in project idea-php-typo3-plugin by cedricziel.
the class ClassConstantMatcherInspection method getDeprecatedClassConstants.
private Set<String> getDeprecatedClassConstants(PhpPsiElement element) {
Set<PsiElement> elements = new HashSet<>();
PsiFile[] classConstantMatcherFiles = FilenameIndex.getFilesByName(element.getProject(), "ClassConstantMatcher.php", GlobalSearchScope.allScope(element.getProject()));
for (PsiFile file : classConstantMatcherFiles) {
Collections.addAll(elements, PsiTreeUtil.collectElements(file, el -> PlatformPatterns.psiElement(StringLiteralExpression.class).withParent(PlatformPatterns.psiElement(PhpElementTypes.ARRAY_KEY).withAncestor(4, PlatformPatterns.psiElement(PhpElementTypes.RETURN))).accepts(el)));
}
return elements.stream().map(stringLiteral -> ((StringLiteralExpression) stringLiteral).getContents()).collect(Collectors.toSet());
}
use of com.jetbrains.php.lang.psi.elements.StringLiteralExpression in project idea-php-typo3-plugin by cedricziel.
the class TCAUtil method getAvailableRenderTypes.
public static Set<String> getAvailableRenderTypes(PsiElement element) {
Set<String> renderTypes = new HashSet<>();
Set<PsiElement> elementsFromExtLocalConf = findAvailableRenderTypes(element.getProject());
// add static list of render types
renderTypes.addAll(Arrays.asList(TCA_CORE_RENDER_TYPES));
// add dynamic list of render types from nodeRegistry
for (PsiElement el : elementsFromExtLocalConf) {
if (el instanceof StringLiteralExpression) {
renderTypes.add(((StringLiteralExpression) el).getContents());
}
}
return renderTypes;
}
use of com.jetbrains.php.lang.psi.elements.StringLiteralExpression in project idea-php-typo3-plugin by cedricziel.
the class TYPO3Utility method getTYPO3Version.
@Nullable
public static String getTYPO3Version(@NotNull Project project) {
Constant versionConstant = getVersionConstant(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 CreateMissingTranslationQuickFix method applyFix.
/**
* Called to apply the fix.
*
* @param project {@link Project}
* @param descriptor problem reported by the tool which provided this quick fix action
*/
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
PsiElement psiElement = descriptor.getPsiElement();
if (psiElement instanceof StringLiteralExpression) {
StringLiteralExpression stringElement = (StringLiteralExpression) psiElement;
String contents = stringElement.getContents();
String fileName = TranslationUtil.extractResourceFilenameFromTranslationString(contents);
String key = TranslationUtil.extractTranslationKeyTranslationString(contents);
if (fileName != null) {
PsiElement[] elementsForKey = ResourcePathIndex.findElementsForKey(project, fileName);
if (elementsForKey.length > 0) {
// TranslationUtil.add();
}
}
}
}
Aggregations