use of com.intellij.psi.jsp.JspFile in project intellij-community by JetBrains.
the class JspIndexPatternBuilder method getCommentTokenSet.
@Override
public TokenSet getCommentTokenSet(@NotNull final PsiFile file) {
final JspFile jspFile = JspPsiUtil.getJspFile(file);
TokenSet commentTokens = TokenSet.orSet(JavaIndexPatternBuilder.XML_COMMENT_BIT_SET, StdTokenSets.COMMENT_BIT_SET);
final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(jspFile.getViewProvider().getTemplateDataLanguage());
if (parserDefinition != null) {
commentTokens = TokenSet.orSet(commentTokens, parserDefinition.getCommentTokens());
}
return commentTokens;
}
use of com.intellij.psi.jsp.JspFile in project intellij-community by JetBrains.
the class ImportHelper method collectNamesToImport.
@NotNull
private static // returns list of (name, isImportStatic) pairs
Collection<Pair<String, Boolean>> collectNamesToImport(@NotNull PsiJavaFile file, List<PsiElement> comments) {
Set<Pair<String, Boolean>> names = new THashSet<>();
final JspFile jspFile = JspPsiUtil.getJspFile(file);
collectNamesToImport(names, comments, file, jspFile);
if (jspFile != null) {
PsiFile[] files = ArrayUtil.mergeArrays(JspSpiUtil.getIncludingFiles(jspFile), JspSpiUtil.getIncludedFiles(jspFile));
for (PsiFile includingFile : files) {
final PsiFile javaRoot = includingFile.getViewProvider().getPsi(JavaLanguage.INSTANCE);
if (javaRoot instanceof PsiJavaFile && file != javaRoot) {
collectNamesToImport(names, comments, (PsiJavaFile) javaRoot, jspFile);
}
}
}
addUnresolvedImportNames(names, file);
return names;
}
use of com.intellij.psi.jsp.JspFile in project intellij-community by JetBrains.
the class JavaTypedHandler method beforeCharTyped.
@Override
public Result beforeCharTyped(final char c, final Project project, final Editor editor, final PsiFile file, final FileType fileType) {
if (!(file instanceof PsiJavaFile))
return Result.CONTINUE;
if (c == '@') {
autoPopupJavadocLookup(project, editor);
} else if (c == '#' || c == '.') {
autoPopupMemberLookup(project, editor);
}
int offsetBefore = editor.getCaretModel().getOffset();
//important to calculate before inserting charTyped
myJavaLTTyped = '<' == c && !(file instanceof JspFile) && CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET && PsiUtil.isLanguageLevel5OrHigher(file) && isAfterClassLikeIdentifierOrDot(offsetBefore, editor);
if ('>' == c) {
if (!(file instanceof JspFile) && CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET && PsiUtil.isLanguageLevel5OrHigher(file)) {
if (handleJavaGT(editor, JavaTokenType.LT, JavaTokenType.GT, INVALID_INSIDE_REFERENCE))
return Result.STOP;
}
}
if (c == ';') {
if (handleSemicolon(editor, fileType))
return Result.STOP;
}
if (fileType == StdFileTypes.JAVA && c == '{') {
int offset = editor.getCaretModel().getOffset();
if (offset == 0) {
return Result.CONTINUE;
}
HighlighterIterator iterator = ((EditorEx) editor).getHighlighter().createIterator(offset - 1);
while (!iterator.atEnd() && iterator.getTokenType() == TokenType.WHITE_SPACE) {
iterator.retreat();
}
if (iterator.atEnd() || iterator.getTokenType() == JavaTokenType.RBRACKET || iterator.getTokenType() == JavaTokenType.EQ) {
return Result.CONTINUE;
}
Document doc = editor.getDocument();
PsiDocumentManager.getInstance(project).commitDocument(doc);
final PsiElement leaf = file.findElementAt(offset);
if (PsiTreeUtil.getParentOfType(leaf, PsiArrayInitializerExpression.class, false, PsiCodeBlock.class, PsiMember.class) != null) {
return Result.CONTINUE;
}
PsiElement st = leaf != null ? leaf.getParent() : null;
PsiElement prev = offset > 1 ? file.findElementAt(offset - 1) : null;
if (CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET && isRparenth(leaf) && (st instanceof PsiWhileStatement || st instanceof PsiIfStatement) && shouldInsertStatementBody(st, doc, prev)) {
CommandProcessor.getInstance().executeCommand(project, () -> new JavaSmartEnterProcessor().process(project, editor, file), "Insert block statement", null);
return Result.STOP;
}
PsiElement prevLeaf = leaf == null ? null : PsiTreeUtil.prevVisibleLeaf(leaf);
if (PsiUtil.isJavaToken(prevLeaf, JavaTokenType.ARROW) || PsiTreeUtil.getParentOfType(prevLeaf, PsiNewExpression.class, true, PsiCodeBlock.class, PsiMember.class) != null) {
return Result.CONTINUE;
}
if (PsiTreeUtil.getParentOfType(leaf, PsiCodeBlock.class, false, PsiMember.class) != null) {
EditorModificationUtil.insertStringAtCaret(editor, "{");
TypedHandler.indentOpenedBrace(project, editor);
// use case: manually wrapping part of method's code in 'if', 'while', etc
return Result.STOP;
}
}
return Result.CONTINUE;
}
use of com.intellij.psi.jsp.JspFile in project intellij-plugins by JetBrains.
the class OgnlStruts2JspVariableReferencesContributor method process.
@Override
public boolean process(@NotNull PsiElement element, @NotNull PsiFile containingFile, @NotNull Processor<OgnlVariableReference> processor) {
final PsiFile topLevelFile = InjectedLanguageManager.getInstance(containingFile.getProject()).getTopLevelFile(element);
if (!(topLevelFile instanceof JspFile)) {
return true;
}
if (StrutsFacet.getInstance(element) == null) {
return true;
}
final PsiElement selfNavigation = element.getOriginalElement();
for (String name : VAR_NAMES) {
if (!processor.process(new OgnlVariableReference(name, "java.util.Map<String,Object>", ORIGIN_INFO, selfNavigation))) {
return false;
}
}
return true;
}
use of com.intellij.psi.jsp.JspFile in project intellij-plugins by JetBrains.
the class Struts2GraphFileEditorProvider method accept.
public boolean accept(@NotNull final Project project, @NotNull final VirtualFile file) {
if (!file.isValid()) {
return false;
}
final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (!(psiFile instanceof XmlFile)) {
return false;
}
if (psiFile instanceof JspFile) {
return false;
}
if (!StrutsManager.getInstance(project).isStruts2ConfigFile((XmlFile) psiFile)) {
return false;
}
final Module module = ModuleUtilCore.findModuleForFile(file, project);
if (module == null) {
return false;
}
final Set<StrutsFileSet> fileSets = StrutsManager.getInstance(project).getAllConfigFileSets(module);
for (final StrutsFileSet fileSet : fileSets) {
if (fileSet.hasFile(file)) {
return true;
}
}
return false;
}
Aggregations