use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class FileTemplateConfigurable method createHighlighter.
private EditorHighlighter createHighlighter() {
if (myTemplate != null && myVelocityFileType != FileTypes.UNKNOWN) {
return EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, new LightVirtualFile("aaa." + myTemplate.getExtension() + ".ft"));
}
FileType fileType = null;
if (myTemplate != null) {
fileType = FileTypeManager.getInstance().getFileTypeByExtension(myTemplate.getExtension());
}
if (fileType == null) {
fileType = FileTypes.PLAIN_TEXT;
}
SyntaxHighlighter originalHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, null, null);
if (originalHighlighter == null) {
originalHighlighter = new PlainSyntaxHighlighter();
}
final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
LayeredLexerEditorHighlighter highlighter = new LayeredLexerEditorHighlighter(new TemplateHighlighter(), scheme);
highlighter.registerLayer(FileTemplateTokenType.TEXT, new LayerDescriptor(originalHighlighter, ""));
return highlighter;
}
use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class PsiCodeFragmentImpl method clone.
@Override
protected PsiCodeFragmentImpl clone() {
final PsiCodeFragmentImpl clone = (PsiCodeFragmentImpl) cloneImpl((FileElement) calcTreeElement().clone());
clone.myPhysical = false;
clone.myOriginalFile = this;
clone.myPseudoImports = new LinkedHashMap<>(myPseudoImports);
FileManager fileManager = ((PsiManagerEx) getManager()).getFileManager();
SingleRootFileViewProvider cloneViewProvider = (SingleRootFileViewProvider) fileManager.createFileViewProvider(new LightVirtualFile(getName(), getLanguage(), getText()), false);
cloneViewProvider.forceCachedPsi(clone);
clone.myViewProvider = cloneViewProvider;
return clone;
}
use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class PsiNameValuePairImpl method getDetachedValue.
@Override
@Nullable
public PsiAnnotationMemberValue getDetachedValue() {
PsiNameValuePairStub stub = getStub();
if (stub != null) {
String text = stub.getValue();
PsiAnnotationMemberValue result = SoftReference.dereference(myDetachedValue);
if (result == null) {
PsiAnnotation anno = JavaPsiFacade.getElementFactory(getProject()).createAnnotationFromText("@F(" + text + ")", this);
((LightVirtualFile) anno.getContainingFile().getViewProvider().getVirtualFile()).setWritable(false);
myDetachedValue = new SoftReference<>(result = anno.findAttributeValue(null));
}
return result;
}
return getValue();
}
use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class FindManagerTest method testFindInCommentsProperlyWorksWithOffsets.
public void testFindInCommentsProperlyWorksWithOffsets() {
FindModel findModel = FindManagerTestUtils.configureFindModel("done");
String prefix = "/*";
String text = prefix + "done*/";
findModel.setSearchContext(FindModel.SearchContext.IN_COMMENTS);
LightVirtualFile file = new LightVirtualFile("A.java", text);
FindResult findResult = myFindManager.findString(text, prefix.length(), findModel, file);
assertTrue(findResult.isStringFound());
findModel.setRegularExpressions(true);
findResult = myFindManager.findString(text, prefix.length(), findModel, file);
assertTrue(findResult.isStringFound());
}
use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class DiffUtil method createEditorHighlighter.
@Nullable
private static EditorHighlighter createEditorHighlighter(@Nullable Project project, @NotNull DocumentContent content) {
FileType type = content.getContentType();
VirtualFile file = content.getHighlightFile();
Language language = content.getUserData(DiffUserDataKeys.LANGUAGE);
EditorHighlighterFactory highlighterFactory = EditorHighlighterFactory.getInstance();
if (language != null) {
SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(language, project, file);
return highlighterFactory.createEditorHighlighter(syntaxHighlighter, EditorColorsManager.getInstance().getGlobalScheme());
}
if (file != null && file.isValid()) {
if ((type == null || type == PlainTextFileType.INSTANCE) || file.getFileType() == type || file instanceof LightVirtualFile) {
return highlighterFactory.createEditorHighlighter(project, file);
}
}
if (type != null) {
return highlighterFactory.createEditorHighlighter(project, type);
}
return null;
}
Aggregations