public KeywordCompletionContributor() { extend(CompletionType.BASIC, psiElement().inFile(StandardPatterns.instanceOf(AppleScriptFile.class)), new CompletionProvider<CompletionParameters>() { @Override protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { PsiFile file = completionParameters.getOriginalFile(); if (!(file instanceof AppleScriptFile)) return; PsiElement position = completionParameters.getPosition(); if (position instanceof PsiComment) return; ASTNode node = position.getNode(); if (node.getElementType() == AppleScriptTypes.STRING_LITERAL) return; for (IElementType kwElem : AppleScriptTokenTypesSets.KEYWORDS.getTypes()) { completionResultSet.addElement(LookupElementBuilder .create(kwElem.toString().toLowerCase().replaceAll("_", " ")).bold() .withTypeText("keyword", true)); } } }); }
@Override public Result postProcessEnter( @NotNull PsiFile file, @NotNull Editor editor, @NotNull DataContext dataContext) { if (file.getFileType() != SoyFileType.INSTANCE) { return Result.Continue; } int caretOffset = editor.getCaretModel().getOffset(); PsiElement element = file.findElementAt(caretOffset); Document document = editor.getDocument(); int lineNumber = document.getLineNumber(caretOffset) - 1; int lineStartOffset = document.getLineStartOffset(lineNumber); String lineTextBeforeCaret = document.getText(new TextRange(lineStartOffset, caretOffset)); if (element instanceof PsiComment && element.getTextOffset() < caretOffset) { handleEnterInComment(element, file, editor); } else if (lineTextBeforeCaret.startsWith("/*")) { insertText(file, editor, " * \n ", 3); } return Result.Continue; }
@Nullable @Contract(pure = true) public static boolean prevElementIsUserRightsMacros(@NotNull final PsiElement element) { Validate.notNull(element); final Class[] skipClasses = {ImpexValueLine.class, PsiComment.class, PsiWhiteSpace.class}; PsiElement prevElement = PsiTreeUtil.skipSiblingsBackward(element, skipClasses); while (null != prevElement) { if (isHeaderLine(prevElement)) { return false; } if (isUserRightsMacros(prevElement)) { return true; } prevElement = PsiTreeUtil.skipSiblingsBackward(prevElement, skipClasses); } return false; }
protected void scanFile() { PsiElement first = getFile().getFirstChild(); // PropertiesList PsiElement last = first; PsiElement next = first; while (next != null) { if (next instanceof PsiComment || next instanceof PsiWhiteSpace) { next = getNextSibling(next); } else { break; } last = next; } if (first != null) { checkComments(first, last, true); } }
@Override public boolean satisfiedBy(PsiElement element) { if (!(element instanceof PsiComment)) { return false; } if (element instanceof PsiDocComment) { return false; } final PsiComment comment = (PsiComment) element; final IElementType type = comment.getTokenType(); if (!GroovyTokenTypes.mML_COMMENT.equals(type)) { return false; } final PsiElement sibling = PsiTreeUtil.nextLeaf(comment); if(sibling == null) { return true; } if (!(isWhitespace(sibling))) { return false; } final String whitespaceText = sibling.getText(); return whitespaceText.indexOf((int) '\n') >= 0 || whitespaceText.indexOf((int) '\r') >= 0; }
private boolean shouldSkip(boolean classLevel, PsiElement psi) { if (psi instanceof PsiComment) { PsiElement prev = psi.getPrevSibling(); if (prev != null) { if (!classLevel || !PsiUtil.isNewLine(prev) || !fieldGroupEnded(psi)) { return true; } } } if (psi.getParent() instanceof GrLabeledStatement) { if (psi instanceof GrLiteral && GrStringUtil.isStringLiteral((GrLiteral)psi) //skip string comments at the beginning of spock table || !(psi instanceof GrStatement)) { return true; } } return false; }
/** * @return the nearest ancestor {@link SQFStatement} that contains the given element, or null if not in a {@link SQFStatement} * @throws IllegalArgumentException when element is a PsiComment or when it is not in an SQFFile */ @Nullable public static SQFStatement getStatementForElement(@NotNull PsiElement element) { if (element instanceof PsiComment) { throw new IllegalArgumentException("element is a comment"); } if (element.getContainingFile() == null || !(element.getContainingFile() instanceof SQFFile)) { throw new IllegalArgumentException("element isn't in an SQFFile"); } while (!(element instanceof SQFStatement)) { element = element.getParent(); if (element == null) { return null; } } return (SQFStatement) element; }
/** * Used for debugging. Will return the statement the given element is contained in. * If the element is a PsiComment, <PsiComment> will be returned. Otherwise, the element's ancestor statement * text will be returned with all newlines replaced with spaces. * <p> * If the element has no parent or no {@link SQFStatement} parent, <No Statement Parent> will be returned * * @return the text, or <PsiComment> if element is a PsiComment */ @NotNull public static String debug_getStatementTextForElement(@NotNull PsiElement element) { if (element instanceof PsiComment) { return "<PsiComment>"; } if (element.getContainingFile() == null || !(element.getContainingFile() instanceof SQFFile)) { throw new IllegalArgumentException("element isn't in an SQFFile"); } while (!(element instanceof SQFStatement)) { element = element.getParent(); if (element == null) { return "<No Statement Parent>"; } } return element.getText().replaceAll("\n", " "); }
private boolean isEmpty(@NotNull GrOpenBlock body) { final GrStatement[] statements = body.getStatements(); if (statements.length != 0) return false; if (myCountCommentsAsContent) { final PsiElement brace = body.getLBrace(); if (brace != null) { final PsiElement next = PsiUtil.skipWhitespaces(brace.getNextSibling(), true); if (next instanceof PsiComment) { return false; } } } return true; }
static ProblemDescriptor checkFileHeader(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean onTheFly) { TIntObjectHashMap<String> offsetToProperty = new TIntObjectHashMap<String>(); FileTemplate defaultTemplate = FileTemplateManager.getInstance(file.getProject()).getDefaultTemplate(FileTemplateManager.FILE_HEADER_TEMPLATE_NAME); Pattern pattern = getTemplatePattern(defaultTemplate, file.getProject(), offsetToProperty); Matcher matcher = pattern.matcher(file.getViewProvider().getContents()); if (!matcher.matches()) { return null; } PsiComment element = PsiTreeUtil.findElementOfClassAtRange(file, matcher.start(1), matcher.end(1), PsiComment.class); if (element == null) { return null; } LocalQuickFix[] fixes = createQuickFix(matcher, offsetToProperty, file.getProject()); String description = InspectionsBundle.message("default.file.template.description"); return manager.createProblemDescriptor(element, description, onTheFly, fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); }
private static boolean nlsAfter(@Nullable PsiElement element) { if (element == null) return false; PsiElement sibling = element; while (true) { sibling = PsiTreeUtil.nextLeaf(sibling); if (sibling == null) { return true; //eof } final String text = sibling.getText(); if (text.contains("\n")) { return text.charAt(CharArrayUtil.shiftForward(text, 0, " \t")) == '\n'; } if (!(sibling instanceof PsiComment) && !StringUtil.isEmptyOrSpaces(text) && !text.equals(";")) { return false; } } }
@Nullable private static UsageType getUsageType(PsiElement element, @NotNull UsageTarget[] targets) { if (element == null) return null; if (PsiTreeUtil.getParentOfType(element, PsiComment.class, false) != null) { return UsageType.COMMENT_USAGE; } UsageTypeProvider[] providers = Extensions.getExtensions(UsageTypeProvider.EP_NAME); for(UsageTypeProvider provider: providers) { UsageType usageType; if (provider instanceof UsageTypeProviderEx) { usageType = ((UsageTypeProviderEx) provider).getUsageType(element, targets); } else { usageType = provider.getUsageType(element); } if (usageType != null) { return usageType; } } return null; }
@Nullable public static PsiElement getStatementToolSuppressedIn(@NotNull PsiElement place, @NotNull String toolId, @NotNull Class<? extends PsiElement> statementClass, @NotNull Pattern suppressInLineCommentPattern) { PsiElement statement = PsiTreeUtil.getNonStrictParentOfType(place, statementClass); if (statement != null) { PsiElement prev = PsiTreeUtil.skipSiblingsBackward(statement, PsiWhiteSpace.class); if (prev instanceof PsiComment) { String text = prev.getText(); Matcher matcher = suppressInLineCommentPattern.matcher(text); if (matcher.matches() && isInspectionToolIdMentioned(matcher.group(1), toolId)) { return prev; } } } return null; }
/** * Check if comment can be recognized as section start/end * @return true for section comment, false otherwise */ public boolean processComment(@NotNull PsiComment comment) { final TextRange range = comment.getTextRange(); final TextRange expandedRange = myDocument == null ? range : ArrangementUtil.expandToLineIfPossible(range, myDocument); final TextRange sectionTextRange = new TextRange(expandedRange.getStartOffset(), expandedRange.getEndOffset()); final String commentText = comment.getText().trim(); final ArrangementSectionRule openSectionRule = isSectionStartComment(mySettings, commentText); if (openSectionRule != null) { mySectionEntryProducer.consume(new ArrangementSectionEntryTemplate(comment, START_SECTION, sectionTextRange, commentText)); myOpenedSections.push(openSectionRule); return true; } if (!myOpenedSections.isEmpty()) { final ArrangementSectionRule lastSection = myOpenedSections.peek(); if (lastSection.getEndComment() != null && StringUtil.equals(commentText, lastSection.getEndComment())) { mySectionEntryProducer.consume(new ArrangementSectionEntryTemplate(comment, END_SECTION, sectionTextRange, commentText)); myOpenedSections.pop(); return true; } } return false; }
public static PsiElement copySpacesAndCommentsBefore(PsiElement elementToReplace, PsiElement[] patternElements, String replacementToMake, PsiElement elementParent) { int i = 0; while (true) { // if it goes out of bounds then deep error happens if (!(patternElements[i] instanceof PsiComment || patternElements[i] instanceof PsiWhiteSpace)) { break; } ++i; if (patternElements.length == i) { break; } } if (patternElements.length == i) { Logger logger = Logger.getInstance(StructuralSearchProfile.class.getName()); logger.error("Unexpected replacement structure:" + replacementToMake); } if (i != 0) { elementParent.addRangeBefore(patternElements[0], patternElements[i - 1], elementToReplace); } return patternElements[i]; }
@Nullable private static GroovyPsiElement getElementToMove(GroovyFileBase file, int offset) { offset = CharArrayUtil.shiftForward(file.getText(), offset, " \t"); PsiElement element = file.findElementAt(offset); final GrDocComment docComment = PsiTreeUtil.getParentOfType(element, GrDocComment.class); if (docComment != null) { final GrDocCommentOwner owner = docComment.getOwner(); if (owner != null) { element = owner; } } if (element instanceof PsiComment) { element = PsiTreeUtil.nextVisibleLeaf(element); } return (GroovyPsiElement)PsiTreeUtil.findFirstParent(element, new Condition<PsiElement>() { @Override public boolean value(PsiElement element11) { return isMoveable(element11); } }); }
@NotNull private List<Block> getBlocksStartingNewLine() { NewLineBlocksIterator newLineBlocksIterator = new NewLineBlocksIterator(myRootBlock, myDocument); List<Block> newLineBlocks = new ArrayList<Block>(); int currentLine = 0; while (newLineBlocksIterator.hasNext() && currentLine < MAX_NEW_LINE_BLOCKS_TO_PROCESS) { Block next = newLineBlocksIterator.next(); if (next instanceof ASTBlock && ((ASTBlock)next).getNode() instanceof PsiComment) { continue; } newLineBlocks.add(next); currentLine++; } return newLineBlocks; }
@Nullable protected String getIdValue(final PsiElement element) { if (element instanceof XmlTag) { final XmlTag tag = (XmlTag)element; String s = tag.getAttributeValue(IdReferenceProvider.ID_ATTR_NAME); if (!myIdAttrsOnly) { if (s == null) s = tag.getAttributeValue(IdReferenceProvider.NAME_ATTR_NAME); if (s == null) s = tag.getAttributeValue(IdReferenceProvider.STYLE_ID_ATTR_NAME); } return s != null ? s: getImplicitIdRefValue(tag); } else if (element instanceof PsiComment) { return getImplicitIdValue((PsiComment) element); } return null; }
private void scanCommentsInFile(final Project project, final VirtualFile vFile) { if (!vFile.isDirectory() && vFile.getFileType() instanceof LanguageFileType) { ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile); if (psiFile == null) return; for (PsiFile root : psiFile.getViewProvider().getAllFiles()) { root.accept(new PsiRecursiveElementWalkingVisitor() { @Override public void visitComment(PsiComment comment) { commentFound(vFile, comment.getText()); } }); } } }); } }
public SimpleDuplicatesFinder(@NotNull final PsiElement statement1, @NotNull final PsiElement statement2, AbstractVariableData[] variableData, Collection<String> variables) { myOutputVariables = variables; myParameters = new HashSet<String>(); for (AbstractVariableData data : variableData) { myParameters.add(data.getOriginalName()); } myPattern = new ArrayList<PsiElement>(); PsiElement sibling = statement1; do { myPattern.add(sibling); if (sibling == statement2) break; sibling = PsiTreeUtil.skipSiblingsForward(sibling, PsiWhiteSpace.class, PsiComment.class); } while (sibling != null); }
@Nullable protected SimpleMatch isDuplicateFragment(@NotNull final PsiElement candidate) { if (!canReplace(myReplacement, candidate)) return null; for (PsiElement pattern : myPattern) { if (PsiTreeUtil.isAncestor(pattern, candidate, false)) return null; } PsiElement sibling = candidate; final ArrayList<PsiElement> candidates = new ArrayList<PsiElement>(); for (int i = 0; i != myPattern.size(); ++i) { if (sibling == null) return null; candidates.add(sibling); sibling = PsiTreeUtil.skipSiblingsForward(sibling, PsiWhiteSpace.class, PsiComment.class); } if (myPattern.size() != candidates.size()) return null; if (candidates.size() <= 0) return null; final SimpleMatch match = new SimpleMatch(candidates.get(0), candidates.get(candidates.size() - 1)); for (int i = 0; i < myPattern.size(); i++) { if (!matchPattern(myPattern.get(i), candidates.get(i), match)) return null; } return match; }
private FormatterTag getFormatterTag(@NotNull PsiComment comment) { CharSequence nodeChars = comment.getNode().getChars(); if (mySettings.FORMATTER_TAGS_ACCEPT_REGEXP) { Pattern onPattern = mySettings.getFormatterOnPattern(); Pattern offPattern = mySettings.getFormatterOffPattern(); if (onPattern != null && onPattern.matcher(nodeChars).find()) return FormatterTag.ON; if (offPattern != null && offPattern.matcher(nodeChars).find()) return FormatterTag.OFF; } else { for (int i = 0; i < nodeChars.length(); i++) { if (isFormatterTagAt(nodeChars, i, mySettings.FORMATTER_ON_TAG)) return FormatterTag.ON; if (isFormatterTagAt(nodeChars, i, mySettings.FORMATTER_OFF_TAG)) return FormatterTag.OFF; } } return FormatterTag.NONE; }
public static boolean isIgnoredNode(PsiElement element) { // ex. "var i = 0" in AS: empty JSAttributeList should be skipped /*if (element.getText().length() == 0) { return true; }*/ if (element instanceof PsiWhiteSpace || element instanceof PsiErrorElement || element instanceof PsiComment) { return true; } if (!(element instanceof LeafElement)) { return false; } if (CharArrayUtil.containsOnlyWhiteSpaces(element.getText())) { return true; } EquivalenceDescriptorProvider descriptorProvider = EquivalenceDescriptorProvider.getInstance(element); if (descriptorProvider == null) { return false; } final IElementType elementType = ((LeafElement)element).getElementType(); return descriptorProvider.getIgnoredTokens().contains(elementType); }
@Nullable private static String getTypeComment(@NotNull PyTargetExpression target) { final PsiElement commentContainer = PsiTreeUtil.getParentOfType(target, PyAssignmentStatement.class, PyWithStatement.class, PyForPart.class); if (commentContainer != null) { final PsiComment comment = getSameLineTrailingCommentChild(commentContainer); if (comment != null) { final String text = comment.getText(); final Matcher m = TYPE_COMMENT_PATTERN.matcher(text); if (m.matches()) { return m.group(1); } } } return null; }
@Nullable private static PsiComment getSameLineTrailingCommentChild(@NotNull PsiElement element) { PsiElement child = element.getFirstChild(); while (true) { if (child == null) { return null; } if (child instanceof PsiComment) { return (PsiComment)child; } if (child.getText().contains("\n")) { return null; } child = child.getNextSibling(); } }
private static boolean isStringLiteralPart(@NotNull PsiElement element, @Nullable PsiElement context) { if (element == context || element instanceof PyStringLiteralExpression || element instanceof PsiComment) { return true; } else if (element instanceof PyParenthesizedExpression) { final PyExpression contained = ((PyParenthesizedExpression)element).getContainedExpression(); return contained != null && isStringLiteralPart(contained, context); } else if (element instanceof PyBinaryExpression) { final PyBinaryExpression expr = (PyBinaryExpression)element; final PyExpression left = expr.getLeftExpression(); final PyExpression right = expr.getRightExpression(); if (expr.isOperator("+")) { return isStringLiteralPart(left, context) || right != null && isStringLiteralPart(right, context); } else if (expr.isOperator("%")) { return right != context && isStringLiteralPart(left, context); } return false; } else if (element instanceof PyCallExpression) { final PyExpression qualifier = getFormatCallQualifier((PyCallExpression)element); return qualifier != null && isStringLiteralPart(qualifier, context); } return false; }
@NotNull @Override protected InspectionGadgetsFix[] buildFixes(Object... infos) { final boolean suppressionIdPresent = ((Boolean)infos[1]).booleanValue(); if (infos[0] instanceof PsiAnnotation) { final PsiAnnotation annotation = (PsiAnnotation)infos[0]; return suppressionIdPresent ? new InspectionGadgetsFix[]{new DelegatingFix(new RemoveAnnotationQuickFix(annotation, null)), new AllowSuppressionsFix()} : new InspectionGadgetsFix[]{new DelegatingFix(new RemoveAnnotationQuickFix(annotation, null))}; } else if (infos[0] instanceof PsiComment) { return suppressionIdPresent ? new InspectionGadgetsFix[]{new RemoveSuppressCommentFix(), new AllowSuppressionsFix()} : new InspectionGadgetsFix[]{new RemoveSuppressCommentFix()}; } return InspectionGadgetsFix.EMPTY_ARRAY; }
@Override public boolean canPutAt(@NotNull final VirtualFile file, final int line, @NotNull final Project project) { final Ref<Boolean> stoppable = Ref.create(false); final Document document = FileDocumentManager.getInstance().getDocument(file); if (document != null) { if (file.getFileType() == PythonFileType.INSTANCE || isPythonScratch(file)) { XDebuggerUtil.getInstance().iterateLine(project, document, line, new Processor<PsiElement>() { @Override public boolean process(PsiElement psiElement) { if (psiElement instanceof PsiWhiteSpace || psiElement instanceof PsiComment) return true; if (psiElement.getNode() != null && notStoppableElementType(psiElement.getNode().getElementType())) return true; // Python debugger seems to be able to stop on pretty much everything stoppable.set(true); return false; } }); if (PyDebugSupportUtils.isContinuationLine(document, line - 1)) { stoppable.set(false); } } } return stoppable.get(); }
private static boolean isSuppressedForElement(@NotNull PyElement stmt, @NotNull String suppressId) { PsiElement prevSibling = stmt.getPrevSibling(); if (prevSibling == null) { final PsiElement parent = stmt.getParent(); if (parent != null) { prevSibling = parent.getPrevSibling(); } } while (prevSibling instanceof PsiComment || prevSibling instanceof PsiWhiteSpace) { if (prevSibling instanceof PsiComment && isSuppressedInComment(prevSibling.getText().substring(1).trim(), suppressId)) { return true; } prevSibling = prevSibling.getPrevSibling(); } return false; }
public boolean satisfiedBy(PsiElement element) { if (!(element instanceof PsiComment)) { return false; } if (element instanceof PsiDocComment) { return false; } final PsiComment comment = (PsiComment)element; final IElementType type = comment.getTokenType(); if (!JavaTokenType.C_STYLE_COMMENT.equals(type)) { return false; } final PsiElement sibling = PsiTreeUtil.nextLeaf(comment); if (!(sibling instanceof PsiWhiteSpace)) { return false; } final String whitespaceText = sibling.getText(); return whitespaceText.indexOf((int)'\n') >= 0 || whitespaceText.indexOf((int)'\r') >= 0; }
@Nullable private static Couple<PsiElement> getStatementsRange(final PsiElement element1, final PsiElement element2) { final PsiElement parent = PsiTreeUtil.findCommonParent(element1, element2); if (parent == null) { return null; } final PyElement statementList = PyPsiUtils.getStatementList(parent); if (statementList == null) { return null; } final PsiElement statement1 = PyPsiUtils.getParentRightBefore(element1, statementList); final PsiElement statement2 = PyPsiUtils.getParentRightBefore(element2, statementList); if (statement1 == null || statement2 == null){ return null; } // return elements if they are really first and last elements of statements if (element1 == PsiTreeUtil.getDeepestFirst(statement1) && element2 == PyPsiUtils.getPrevSignificantLeaf(PsiTreeUtil.getDeepestLast(statement2), !(element2 instanceof PsiComment))) { return Couple.of(statement1, statement2); } return null; }
@Override public String generateDoc(PsiElement element, @Nullable PsiElement originalElement) { if (element instanceof PsiModuleName) { element = element.getParent(); PsiElement previousElement = element == null ? null : PsiTreeUtil.prevVisibleLeaf(element); if (previousElement instanceof PsiComment) { StringBuilder sb = new StringBuilder(); sb.append(previousElement.getText()); return sb.toString(); } } return super.generateDoc(element, originalElement); }
@Nullable public static PsiElement getFirstMeaningChild(PsiElement element) { PsiElement first = element.getFirstChild(); return first instanceof PsiWhiteSpace || first instanceof PsiComment ? getNextMeaningSibling(first) : first; }
@Nullable public static PsiElement getLastMeaningChild(PsiElement element) { PsiElement last = element.getLastChild(); return last instanceof PsiWhiteSpace || last instanceof PsiComment ? getPrevMeaningSibling(last) : last; }
@Nullable private static String getDocCommentForEnclosingTag(PsiElement element) { PsiElement parentTag = PsiTreeUtil.findFirstParent(element, TagElement.class::isInstance); return PsiTreeUtil.getChildrenOfTypeAsList(parentTag, PsiComment.class) .stream() .filter(SoyDocumentationProvider::isDocComment) .findFirst() .map(PsiElement::getText) .orElse(null); }
int findFirstImportIndex(PsiFile file){ PsiElement[] children = file.getChildren(); for (PsiElement aChildren : children) { if (aChildren instanceof PsiWhiteSpace) { continue; } if (aChildren instanceof PsiComment) { continue; } return aChildren.getTextRange().getStartOffset(); } return 0; }
/** * @param node Tree node * @return true if node is incomplete */ public boolean isIncomplete(@NotNull final ASTNode node) { if (node.getElementType() instanceof ILazyParseableElementType) return false; ASTNode lastChild = node.getLastChildNode(); while (lastChild != null && !(lastChild.getElementType() instanceof ILazyParseableElementType) && (lastChild.getPsi() instanceof PsiWhiteSpace || lastChild.getPsi() instanceof PsiComment)) { lastChild = lastChild.getTreePrev(); } return lastChild != null && (lastChild.getPsi() instanceof PsiErrorElement || isIncomplete(lastChild)); }
@Override public Result charTyped(char c, final Project project, final Editor editor, final PsiFile file) { if (! (file instanceof LuaPsiFile)) return Result.CONTINUE; if (c != ')' && c != '(') return Result.CONTINUE; Document document = editor.getDocument(); int caretOffset = editor.getCaretModel().getOffset(); PsiDocumentManager.getInstance(file.getProject()).commitDocument(document); PsiElement e = file.findElementAt(caretOffset-1); if (!(e instanceof PsiComment)) { PsiElement e1 = file.findElementAt(caretOffset); // PsiElement e2 = file.findElementAt(caretOffset+1); // This handles the case where we are already inside parens. // for example a(b,c function(|) where | is the cursor if (c == '(' && e1 != null && e1.getText().equals(")")) { e = e1; c = ')'; } if (c == ')' && e != null && e.getContext() instanceof LuaFunctionDefinition) { document.insertString(e.getTextOffset() + 1, preserveParen ? " end)" : " end"); return Result.STOP; } } return super.charTyped(c, project, editor, file); }
@NotNull @Override public PsiComment createCommentFromText(@NotNull String s, PsiElement parent) { LuaPsiFile file = createDummyFile(s); return (PsiComment) file.getChildren()[0]; }
@Override public PsiElement getChangeHighlightingDirtyScopeFor(@NotNull PsiElement changedElement) { // rehighlight everything when inspection suppress comment changed if (changedElement.getLanguage() instanceof XMLLanguage && changedElement instanceof PsiComment && changedElement.getText().contains(DefaultXmlSuppressionProvider.SUPPRESS_MARK)) { return changedElement.getContainingFile(); } return null; }