本文整理汇总了Java中com.intellij.psi.FileViewProvider类的典型用法代码示例。如果您正苦于以下问题:Java FileViewProvider类的具体用法?Java FileViewProvider怎么用?Java FileViewProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileViewProvider类属于com.intellij.psi包,在下文中一共展示了FileViewProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processRoot
import com.intellij.psi.FileViewProvider; //导入依赖的package包/类
private void processRoot(final List<InferenceCapable> files, VirtualFile f) {
LuaFileUtil.iterateLuaFilesRecursively(f, new ContentIterator() {
@Override
public boolean processFile(VirtualFile fileOrDir) {
ProgressManager.checkCanceled();
log.debug("process " + fileOrDir.getName());
if (fileOrDir.isDirectory()) return true;
indicator.setText2(fileOrDir.getPresentableName());
final FileViewProvider viewProvider = p.findViewProvider(fileOrDir);
if (viewProvider == null) return true;
final PsiFile psiFile = viewProvider.getPsi(viewProvider.getBaseLanguage());
if (!(psiFile instanceof InferenceCapable)) return true;
indicator.setText2(fileOrDir.getName());
log.debug("forcing inference for: " + fileOrDir.getName());
files.add((InferenceCapable) psiFile);
return true;
}
});
}
示例2: divideInsideAndOutside
import com.intellij.psi.FileViewProvider; //导入依赖的package包/类
public static void divideInsideAndOutside(@NotNull PsiFile file,
int startOffset,
int endOffset,
@NotNull TextRange range,
@NotNull List<PsiElement> inside,
@NotNull List<ProperTextRange> insideRanges,
@NotNull List<PsiElement> outside,
@NotNull List<ProperTextRange> outsideRanges,
boolean includeParents,
@NotNull Condition<PsiFile> filter) {
final FileViewProvider viewProvider = file.getViewProvider();
for (Language language : viewProvider.getLanguages()) {
final PsiFile psiRoot = viewProvider.getPsi(language);
if (filter.value(psiRoot)) {
divideInsideAndOutside(psiRoot, startOffset, endOffset, range, inside, insideRanges, outside, outsideRanges, includeParents);
}
}
}
示例3: getRootBlock
import com.intellij.psi.FileViewProvider; //导入依赖的package包/类
protected Block getRootBlock(PsiElement element, FileViewProvider viewProvider, CodeStyleSettings settings) {
ASTNode node = element.getNode();
if (node == null) {
return createDummyBlock(node);
}
if (viewProvider instanceof TemplateLanguageFileViewProvider) {
final Language dataLanguage = ((TemplateLanguageFileViewProvider)viewProvider).getTemplateDataLanguage();
final FormattingModelBuilder builder = LanguageFormatting.INSTANCE.forLanguage(dataLanguage);
if (builder instanceof DelegatingFormattingModelBuilder && ((DelegatingFormattingModelBuilder)builder).dontFormatMyModel()) {
return createDummyBlock(node);
}
if (builder != null) {
final FormattingModel model = builder.createModel(viewProvider.getPsi(dataLanguage), settings);
List<DataLanguageBlockWrapper> childWrappers = buildChildWrappers(model.getRootBlock());
if (childWrappers.size() == 1) {
childWrappers = buildChildWrappers(childWrappers.get(0).getOriginal());
}
return createTemplateLanguageBlock(node, Wrap.createWrap(WrapType.NONE, false), null,
filterBlocksByRange(childWrappers, node.getTextRange()), settings);
}
}
return createTemplateLanguageBlock(node, Wrap.createWrap(WrapType.NONE, false), null, Collections.<DataLanguageBlockWrapper>emptyList(), settings);
}
示例4: checkFile
import com.intellij.psi.FileViewProvider; //导入依赖的package包/类
@Override
@Nullable
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if (InjectedLanguageManager.getInstance(file.getProject()).isInjectedFragment(file)) return null;
if (!file.isPhysical()) return null;
FileViewProvider viewProvider = file.getViewProvider();
if (viewProvider.getBaseLanguage() != file.getLanguage()) return null;
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) return null;
if (!virtualFile.isInLocalFileSystem()) return null;
CharSequence text = viewProvider.getContents();
Charset charset = LoadTextUtil.extractCharsetFromFileContent(file.getProject(), virtualFile, text);
// no sense in checking transparently decoded file: all characters there are already safely encoded
if (charset instanceof Native2AsciiCharset) return null;
List<ProblemDescriptor> descriptors = new SmartList<ProblemDescriptor>();
boolean ok = checkFileLoadedInWrongEncoding(file, manager, isOnTheFly, virtualFile, charset, descriptors);
if (ok) {
checkIfCharactersWillBeLostAfterSave(file, manager, isOnTheFly, text, charset, descriptors);
}
return descriptors.toArray(new ProblemDescriptor[descriptors.size()]);
}
示例5: doCollectInformation
import com.intellij.psi.FileViewProvider; //导入依赖的package包/类
@Override
public void doCollectInformation(@NotNull ProgressIndicator progress) {
final FileViewProvider viewProvider = myFile.getViewProvider();
final Set<Language> relevantLanguages = viewProvider.getLanguages();
List<LineMarkerInfo> markers = new SmartList<LineMarkerInfo>();
for (Language language : relevantLanguages) {
PsiElement psiRoot = viewProvider.getPsi(language);
if (psiRoot == null || !HighlightingLevelManager.getInstance(myProject).shouldHighlight(psiRoot)) continue;
List<PsiElement> elements = CollectHighlightsUtil.getElementsInRange(psiRoot, myBounds.getStartOffset(), myBounds.getEndOffset());
final List<LineMarkerProvider> providers = LineMarkersPass.getMarkerProviders(language, myProject);
addLineMarkers(elements, providers, markers, progress);
LineMarkersPass.collectLineMarkersForInjected(markers, elements, this, myFile, progress);
}
myMarkers = LineMarkersPass.mergeLineMarkers(markers, myEditor);
}
示例6: update
import com.intellij.psi.FileViewProvider; //导入依赖的package包/类
@Override
public void update(final AnActionEvent e) {
e.getPresentation().setVisible(false);
VirtualFile virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
if (files != null && files.length > 1) {
virtualFile = null;
}
if (virtualFile == null || virtualFile.isDirectory()) return;
Project project = e.getData(CommonDataKeys.PROJECT);
if (project == null) return;
final FileViewProvider provider = PsiManager.getInstance(project).findViewProvider(virtualFile);
if (provider instanceof ConfigurableTemplateLanguageFileViewProvider) {
final TemplateLanguageFileViewProvider viewProvider = (TemplateLanguageFileViewProvider)provider;
e.getPresentation().setText(LangBundle.message("quickfix.change.template.data.language.text", viewProvider.getTemplateDataLanguage().getDisplayName()));
e.getPresentation().setEnabled(true);
e.getPresentation().setVisible(true);
}
}
示例7: compute
import com.intellij.psi.FileViewProvider; //导入依赖的package包/类
@Override
public CachedValueProvider.Result<MultiHostRegistrarImpl> compute(PsiElement element) {
PsiFile hostPsiFile = element.getContainingFile();
if (hostPsiFile == null) return null;
FileViewProvider viewProvider = hostPsiFile.getViewProvider();
final DocumentEx hostDocument = (DocumentEx)viewProvider.getDocument();
if (hostDocument == null) return null;
PsiManager psiManager = viewProvider.getManager();
final Project project = psiManager.getProject();
InjectedLanguageManagerImpl injectedManager = InjectedLanguageManagerImpl.getInstanceImpl(project);
final MultiHostRegistrarImpl result = doCompute(element, injectedManager, project, hostPsiFile);
return CachedValueProvider.Result.create(result, PsiModificationTracker.MODIFICATION_COUNT, hostDocument);
}
示例8: createFileViewProvider
import com.intellij.psi.FileViewProvider; //导入依赖的package包/类
@NotNull
@Override
public FileViewProvider createFileViewProvider(
@NotNull VirtualFile virtualFile,
Language language,
@NotNull PsiManager psiManager,
boolean eventSystemEnabled) {
assert language.isKindOf(SoyLanguage.INSTANCE);
return new SoyFileViewProvider(psiManager, virtualFile, eventSystemEnabled);
}
示例9: createFile
import com.intellij.psi.FileViewProvider; //导入依赖的package包/类
@Override
public PsiFile createFile(FileViewProvider fileViewProvider) {
if (fileViewProvider != null) {
return new MelFile(fileViewProvider);
} else {
throw new RuntimeException("Invalid file viewer null!!!");
}
}
示例10: createFile
import com.intellij.psi.FileViewProvider; //导入依赖的package包/类
@Override
public PsiFile createFile(FileViewProvider viewProvider) {
if (viewProvider != null) {
return new WeaveFile(viewProvider);
} else {
throw new RuntimeException("Invalid file viewer null!!!");
}
}
示例11: autoPopupXmlLookup
import com.intellij.psi.FileViewProvider; //导入依赖的package包/类
public static void autoPopupXmlLookup(final Project project, final Editor editor){
AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, new Condition<PsiFile>() {
@Override
public boolean value(PsiFile file) {
int offset = editor.getCaretModel().getOffset();
PsiElement lastElement = InjectedLanguageUtil.findElementAtNoCommit(file, offset - 1);
if (lastElement instanceof PsiFile) { //the very end of an injected file
lastElement = file.findElementAt(offset - 1);
}
if (lastElement == null || !lastElement.isValid()) return false;
if (doCompleteIfNeeded(offset, file, lastElement)) {
return true;
}
FileViewProvider fileViewProvider = file.getViewProvider();
Language templateDataLanguage;
final PsiElement parent = lastElement.getParent();
if (fileViewProvider instanceof TemplateLanguageFileViewProvider &&
(templateDataLanguage = ((TemplateLanguageFileViewProvider)fileViewProvider).getTemplateDataLanguage()) != parent.getLanguage()) {
lastElement = fileViewProvider.findElementAt(offset - 1, templateDataLanguage);
if (lastElement == null || !lastElement.isValid()) return false;
return doCompleteIfNeeded(offset, file, lastElement);
}
return false;
}
});
}
示例12: createFileViewProvider
import com.intellij.psi.FileViewProvider; //导入依赖的package包/类
@NotNull
@Override
public FileViewProvider createFileViewProvider(@NotNull VirtualFile virtualFile,
Language language,
@NotNull PsiManager psiManager,
boolean eventSystemEnabled){
assert language.isKindOf(RythmLanguage.INSTANCE);
return new RythmFileViewProvider(psiManager, virtualFile, eventSystemEnabled, language);
}
示例13: getLineExtensions
import com.intellij.psi.FileViewProvider; //导入依赖的package包/类
@Override
public Collection<LineExtensionInfo> getLineExtensions(@NotNull Project project, @NotNull VirtualFile file, int lineNumber) {
List<LineExtensionInfo> res = ContainerUtil.newSmartList();
PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
final Document doc = FileDocumentManager.getInstance().getDocument(file);
if (doc != null && lineNumber < doc.getLineCount()) {
PsiFile psiFile = psiDocumentManager.getPsiFile(doc);
if (psiFile != null) {
int offset = doc.getLineStartOffset(lineNumber);
FileViewProvider viewProvider = psiFile.getViewProvider();
PsiElement element = viewProvider.findElementAt(offset);
while (element != null) {
int startOffset = element.getTextRange().getStartOffset();
if (startOffset >= doc.getTextLength()) break;
int startOffsetLine = doc.getLineNumber(startOffset);
if (startOffsetLine < lineNumber) {
element = PsiTreeUtil.nextVisibleLeaf(element);
continue;
}
if (startOffsetLine > lineNumber) break;
try {
element = addExtensions(res, element);
} catch (IndexNotReadyException ignored) { element = null; }
}
}
}
return res;
}
示例14: canHandleElement
import com.intellij.psi.FileViewProvider; //导入依赖的package包/类
@Override
public boolean canHandleElement(@NotNull OpenInBrowserRequest request) {
if (request.getVirtualFile() instanceof HttpVirtualFile) {
return true;
}
// we must use base language because we serve file - not part of file, but the whole file
// handlebars, for example, contains HTML and HBS psi trees, so, regardless of context, we should not handle such file
FileViewProvider viewProvider = request.getFile().getViewProvider();
return viewProvider.isPhysical() &&
!(request.getVirtualFile() instanceof LightVirtualFile) &&
isMyLanguage(viewProvider.getBaseLanguage());
}
示例15: PsiFileBase
import com.intellij.psi.FileViewProvider; //导入依赖的package包/类
protected PsiFileBase(@NotNull FileViewProvider viewProvider, @NotNull Language language) {
super(viewProvider);
myLanguage = findLanguage(language, viewProvider);
final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(myLanguage);
if (parserDefinition == null) {
throw new RuntimeException("PsiFileBase: language.getParserDefinition() returned null for: "+myLanguage);
}
myParserDefinition = parserDefinition;
final IFileElementType nodeType = parserDefinition.getFileNodeType();
assert nodeType.getLanguage() == myLanguage: nodeType.getLanguage() + " != " + myLanguage;
init(nodeType, nodeType);
}