use of com.perl5.lang.perl.psi.impl.PerlStringContentElementImpl in project Perl5-IDEA by Camelcade.
the class PerlUnresolvedSubInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new PerlVisitor() {
@Override
public void visitStringContentElement(@NotNull PerlStringContentElementImpl o) {
if (EXPORT_ASSIGNED_STRING_CONTENT.accepts(o)) {
if (!isResolvable(o.getReference())) {
registerProblem(holder, o, PerlBundle.message("perl.inspection.no.exported.entity"));
}
}
}
@Override
public void visitPerlMethod(@NotNull PerlMethod o) {
PerlNamespaceElement namespaceElement = o.getNamespaceElement();
PerlSubNameElement subNameElement = o.getSubNameElement();
// fixme adjust built in checking to the file; Remove second condition after implementing annotations
if (subNameElement == null || namespaceElement != null && namespaceElement.isBuiltin() || subNameElement.isBuiltIn()) {
return;
}
for (PsiReference reference : subNameElement.getReferences()) {
if (isResolvable(reference)) {
return;
}
}
registerProblem(holder, subNameElement, PerlBundle.message("perl.inspection.no.sub.definition"));
}
};
}
use of com.perl5.lang.perl.psi.impl.PerlStringContentElementImpl in project Perl5-IDEA by Camelcade.
the class PerlElementFactory method createStringContent.
public static PerlStringContentElementImpl createStringContent(Project project, String name) {
PerlFileImpl file = createFile(project, "'" + name + "';");
PsiPerlStringSq string = PsiTreeUtil.findChildOfType(file, PsiPerlStringSq.class);
assert string != null;
return (PerlStringContentElementImpl) string.getFirstChild().getNextSibling();
}
use of com.perl5.lang.perl.psi.impl.PerlStringContentElementImpl in project Perl5-IDEA by Camelcade.
the class PerlTemplateContextType method isInContext.
@Override
public boolean isInContext(@NotNull PsiFile psiFile, int fileOffset) {
if (!PsiUtilCore.getLanguageAtOffset(psiFile, fileOffset).isKindOf(PerlLanguage.INSTANCE)) {
return false;
}
PsiElement element = psiFile.findElementAt(fileOffset);
if (element == null) {
element = psiFile.findElementAt(fileOffset - 1);
}
if (element == null) {
return false;
}
IElementType tokenType = PsiUtilCore.getElementType(element);
return !(element instanceof PsiWhiteSpace || element instanceof PerlStringContentElementImpl || element instanceof PsiComment || tokenType == PerlElementTypes.REGEX_TOKEN) && isInContext(element);
}
use of com.perl5.lang.perl.psi.impl.PerlStringContentElementImpl in project Perl5-IDEA by Camelcade.
the class PerlStringCompletionUtil method fillWithHashIndexes.
public static void fillWithHashIndexes(@NotNull final PsiElement element, @NotNull final CompletionResultSet result) {
for (String text : HASH_INDEXES_CACHE) {
addElement(text, result);
}
PsiFile file = element.getContainingFile();
file.accept(new PerlRecursiveVisitor() {
@Override
public void visitStringContentElement(@NotNull PerlStringContentElementImpl o) {
if (o != element && SIMPLE_HASH_INDEX.accepts(o)) {
processStringElement(o);
}
super.visitStringContentElement(o);
}
@Override
public void visitCommaSequenceExpr(@NotNull PsiPerlCommaSequenceExpr o) {
if (o.getParent() instanceof PsiPerlAnonHash) {
PsiElement sequenceElement = o.getFirstChild();
boolean isKey = true;
while (sequenceElement != null) {
ProgressManager.checkCanceled();
IElementType elementType = sequenceElement.getNode().getElementType();
if (isKey && sequenceElement instanceof PerlString) {
for (PerlStringContentElement stringElement : PerlPsiUtil.collectStringElements(sequenceElement)) {
processStringElement(stringElement);
}
} else if (elementType == COMMA || elementType == FAT_COMMA) {
isKey = !isKey;
}
sequenceElement = PerlPsiUtil.getNextSignificantSibling(sequenceElement);
}
}
super.visitCommaSequenceExpr(o);
}
protected void processStringElement(PerlStringContentElement stringContentElement) {
String text = stringContentElement.getText();
if (StringUtil.isNotEmpty(text) && !HASH_INDEXES_CACHE.contains(text) && PerlLexer.IDENTIFIER_PATTERN.matcher(text).matches()) {
HASH_INDEXES_CACHE.add(text);
addElement(text, result);
}
}
});
}
Aggregations