List of usage examples for com.intellij.openapi.fileTypes StdFileTypes XHTML
LanguageFileType XHTML
To view the source code for com.intellij.openapi.fileTypes StdFileTypes XHTML.
Click Source Link
From source file:com.google.cloud.tools.intellij.debugger.CloudLineBreakpointType.java
License:Apache License
/** * We can only place a cloud breakpoint on a line if: 1) Its normally ok to do so with a java * breakpoint. 2) The selected run config is a {@link CloudDebugRunConfiguration}. *///from w ww . j av a 2 s.c o m @Override public final boolean canPutAt(@NotNull final VirtualFile file, final int line, @NotNull Project project) { RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project); if (runManager.getSelectedConfiguration() == null || !(runManager.getSelectedConfiguration() .getConfiguration() instanceof CloudDebugRunConfiguration)) { return false; } // Most of this code is reused from java linebreakpoint. final PsiFile psiFile = PsiManager.getInstance(project).findFile(file); if (psiFile == null || psiFile.getVirtualFile().getFileType() == StdFileTypes.XHTML) { return false; } if (!StdFileTypes.CLASS.equals(psiFile.getFileType()) && !DebuggerUtils.isBreakpointAware(psiFile)) { return false; } final Document document = FileDocumentManager.getInstance().getDocument(file); final Ref<Class<? extends CloudLineBreakpointType>> result = Ref.create(); assert document != null; XDebuggerUtil.getInstance().iterateLine(project, document, line, new Processor<PsiElement>() { @Override public boolean process(PsiElement element) { // avoid comments if ((element instanceof PsiWhiteSpace) || (PsiTreeUtil.getParentOfType(element, PsiComment.class, false) != null)) { return true; } PsiElement parent = element; while (element != null) { // skip modifiers if (element instanceof PsiModifierList) { element = element.getParent(); continue; } final int offset = element.getTextOffset(); if (offset >= 0) { if (document.getLineNumber(offset) != line) { break; } } parent = element; element = element.getParent(); } if (parent instanceof PsiMethod) { if (parent.getTextRange().getEndOffset() >= document.getLineEndOffset(line)) { PsiCodeBlock body = ((PsiMethod) parent).getBody(); if (body != null) { PsiStatement[] statements = body.getStatements(); if (statements.length > 0 && document.getLineNumber(statements[0].getTextOffset()) == line) { result.set(CloudLineBreakpointType.class); } } } } else { result.set(CloudLineBreakpointType.class); } return true; } }); UsageTrackerProvider.getInstance().trackEvent(GctTracking.CLOUD_DEBUGGER_CREATE_BREAKPOINT).ping(); return result.get() == getClass(); }
From source file:com.google.gct.idea.debugger.CloudLineBreakpointType.java
License:Apache License
/** * We can only place a cloud breakpoint on a line if: 1) Its normally ok to do so with a java breakpoint. 2) The * selected run config is a {@link CloudDebugRunConfiguration}. *//*from w w w.j a v a 2 s. com*/ @Override public final boolean canPutAt(@NotNull final VirtualFile file, final int line, @NotNull Project project) { RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project); if (runManager.getSelectedConfiguration() == null || !(runManager.getSelectedConfiguration() .getConfiguration() instanceof CloudDebugRunConfiguration)) { return false; } // Most of this code is reused from java linebreakpoint. final PsiFile psiFile = PsiManager.getInstance(project).findFile(file); if (psiFile == null || psiFile.getVirtualFile().getFileType() == StdFileTypes.XHTML) { return false; } if (!StdFileTypes.CLASS.equals(psiFile.getFileType()) && !DebuggerUtils.isBreakpointAware(psiFile)) { return false; } final Document document = FileDocumentManager.getInstance().getDocument(file); final Ref<Class<? extends CloudLineBreakpointType>> result = Ref.create(); assert document != null; XDebuggerUtil.getInstance().iterateLine(project, document, line, new Processor<PsiElement>() { @Override public boolean process(PsiElement element) { // avoid comments if ((element instanceof PsiWhiteSpace) || (PsiTreeUtil.getParentOfType(element, PsiComment.class, false) != null)) { return true; } PsiElement parent = element; while (element != null) { // skip modifiers if (element instanceof PsiModifierList) { element = element.getParent(); continue; } final int offset = element.getTextOffset(); if (offset >= 0) { if (document.getLineNumber(offset) != line) { break; } } parent = element; element = element.getParent(); } if (parent instanceof PsiMethod) { if (parent.getTextRange().getEndOffset() >= document.getLineEndOffset(line)) { PsiCodeBlock body = ((PsiMethod) parent).getBody(); if (body != null) { PsiStatement[] statements = body.getStatements(); if (statements.length > 0 && document.getLineNumber(statements[0].getTextOffset()) == line) { result.set(CloudLineBreakpointType.class); } } } } else { result.set(CloudLineBreakpointType.class); } return true; } }); return result.get() == getClass(); }
From source file:ru.artlebedev.idea.plugins.parser.zencoding.ZenCodingTemplate.java
License:Apache License
private static boolean isHtml(CustomTemplateCallback callback) { FileType type = callback.getFileType(); return type == StdFileTypes.HTML || type == StdFileTypes.XHTML; }