当前位置: 首页>>代码示例>>Java>>正文


Java LightVirtualFile类代码示例

本文整理汇总了Java中com.intellij.testFramework.LightVirtualFile的典型用法代码示例。如果您正苦于以下问题:Java LightVirtualFile类的具体用法?Java LightVirtualFile怎么用?Java LightVirtualFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LightVirtualFile类属于com.intellij.testFramework包,在下文中一共展示了LightVirtualFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFindInCommentsProperlyWorksWithOffsets

import com.intellij.testFramework.LightVirtualFile; //导入依赖的package包/类
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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:FindManagerTest.java

示例2: testFindExceptComments

import com.intellij.testFramework.LightVirtualFile; //导入依赖的package包/类
public void testFindExceptComments() {
  FindModel findModel = FindManagerTestUtils.configureFindModel("done");

  String prefix = "/*";
  String text = prefix + "done*/done";

  findModel.setSearchContext(FindModel.SearchContext.EXCEPT_COMMENTS);
  LightVirtualFile file = new LightVirtualFile("A.java", text);

  FindResult findResult = myFindManager.findString(text, prefix.length(), findModel, file);
  assertTrue(findResult.isStringFound());
  assertTrue(findResult.getStartOffset() > prefix.length());

  findModel.setRegularExpressions(true);
  findResult = myFindManager.findString(text, prefix.length(), findModel, file);
  assertTrue(findResult.isStringFound());
  assertTrue(findResult.getStartOffset() > prefix.length());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:FindManagerTest.java

示例3: testFindExceptLiterals

import com.intellij.testFramework.LightVirtualFile; //导入依赖的package包/类
public void testFindExceptLiterals() {
  FindModel findModel = FindManagerTestUtils.configureFindModel("done");

  String prefix = "\"";
  String text = prefix + "done\"done";

  findModel.setSearchContext(FindModel.SearchContext.EXCEPT_STRING_LITERALS);
  LightVirtualFile file = new LightVirtualFile("A.java", text);

  FindResult findResult = myFindManager.findString(text, prefix.length(), findModel, file);
  assertTrue(findResult.isStringFound());
  assertTrue(findResult.getStartOffset() > prefix.length());

  findModel.setRegularExpressions(true);
  findResult = myFindManager.findString(text, prefix.length(), findModel, file);
  assertTrue(findResult.isStringFound());
  assertTrue(findResult.getStartOffset() > prefix.length());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:FindManagerTest.java

示例4: calcBaseLanguage

import com.intellij.testFramework.LightVirtualFile; //导入依赖的package包/类
private static Language calcBaseLanguage(@NotNull VirtualFile file, @NotNull Project project, @NotNull final FileType fileType) {
  if (file instanceof LightVirtualFile) {
    final Language language = ((LightVirtualFile)file).getLanguage();
    if (language != null) {
      return language;
    }
  }

  if (fileType.isBinary()) return Language.ANY;
  if (isTooLargeForIntelligence(file)) return PlainTextLanguage.INSTANCE;

  if (fileType instanceof LanguageFileType) {
    return LanguageSubstitutors.INSTANCE.substituteLanguage(((LanguageFileType)fileType).getLanguage(), file, project);
  }

  return PlainTextLanguage.INSTANCE;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:SingleRootFileViewProvider.java

示例5: isInProject

import com.intellij.testFramework.LightVirtualFile; //导入依赖的package包/类
@Override
public boolean isInProject(@NotNull PsiElement element) {
  if (element instanceof PsiDirectoryContainer) {
    PsiDirectory[] dirs = ((PsiDirectoryContainer)element).getDirectories();
    for (PsiDirectory dir : dirs) {
      if (!isInProject(dir)) return false;
    }
    return true;
  }

  PsiFile file = element.getContainingFile();
  VirtualFile virtualFile = null;
  if (file != null) {
    virtualFile = file.getViewProvider().getVirtualFile();
  }
  else if (element instanceof PsiFileSystemItem) {
    virtualFile = ((PsiFileSystemItem)element).getVirtualFile();
  }
  if (file != null && file.isPhysical() && virtualFile instanceof LightVirtualFile) return true;

  if (virtualFile != null) {
    return myFileIndex.isInContent(virtualFile);
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:PsiManagerImpl.java

示例6: createFileFromText

import com.intellij.testFramework.LightVirtualFile; //导入依赖的package包/类
@Override
@NotNull
public PsiFile createFileFromText(@NotNull String name,
                                  @NotNull FileType fileType,
                                  @NotNull CharSequence text,
                                  long modificationStamp,
                                  final boolean eventSystemEnabled,
                                  boolean markAsCopy) {
  final LightVirtualFile virtualFile = new LightVirtualFile(name, fileType, text, modificationStamp);
  if(fileType instanceof LanguageFileType){
    final Language language =
        LanguageSubstitutors.INSTANCE.substituteLanguage(((LanguageFileType)fileType).getLanguage(), virtualFile, myManager.getProject());
    final PsiFile file = trySetupPsiForFile(virtualFile, language, eventSystemEnabled, markAsCopy);
    if (file != null) return file;
  }
  final SingleRootFileViewProvider singleRootFileViewProvider =
    new SingleRootFileViewProvider(myManager, virtualFile, eventSystemEnabled);
  final PsiPlainTextFileImpl plainTextFile = new PsiPlainTextFileImpl(singleRootFileViewProvider);
  if(markAsCopy) CodeEditUtil.setNodeGenerated(plainTextFile.getNode(), true);
  return plainTextFile;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PsiFileFactoryImpl.java

示例7: trySetupPsiForFile

import com.intellij.testFramework.LightVirtualFile; //导入依赖的package包/类
@Nullable
public PsiFile trySetupPsiForFile(@NotNull LightVirtualFile virtualFile,
                                  @NotNull Language language,
                                  final boolean physical, final boolean markAsCopy) {
  final FileViewProviderFactory factory = LanguageFileViewProviders.INSTANCE.forLanguage(language);
  FileViewProvider viewProvider = factory != null ? factory.createFileViewProvider(virtualFile, language, myManager, physical) : null;
  if (viewProvider == null) viewProvider = new SingleRootFileViewProvider(myManager, virtualFile, physical);

  language = viewProvider.getBaseLanguage();
  final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(language);
  if (parserDefinition != null) {
    final PsiFile psiFile = viewProvider.getPsi(language);
    if (psiFile != null) {
      if (markAsCopy) {
        if (psiFile.getNode() == null) {
          throw new AssertionError("No node for file " + psiFile + "; language=" + language);
        }
        markGenerated(psiFile);
      }
      return psiFile;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:PsiFileFactoryImpl.java

示例8: shouldBeInstalled

import com.intellij.testFramework.LightVirtualFile; //导入依赖的package包/类
private boolean shouldBeInstalled(@Nullable final VirtualFile virtualFile) {
  if (isDisabled()) return false;

  if (virtualFile == null || virtualFile instanceof LightVirtualFile) return false;
  if (!virtualFile.isInLocalFileSystem()) return false;
  final FileStatusManager statusManager = FileStatusManager.getInstance(myProject);
  if (statusManager == null) return false;
  final AbstractVcs activeVcs = myVcsManager.getVcsFor(virtualFile);
  if (activeVcs == null) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("shouldBeInstalled: for file " + virtualFile.getPath() + " failed: no active VCS");
    }
    return false;
  }
  final FileStatus status = statusManager.getStatus(virtualFile);
  if (status == FileStatus.NOT_CHANGED || status == FileStatus.ADDED || status == FileStatus.UNKNOWN || status == FileStatus.IGNORED) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("shouldBeInstalled: for file " + virtualFile.getPath() + " skipped: status=" + status);
    }
    return false;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:LineStatusTrackerManager.java

示例9: GutteredLanguageConsole

import com.intellij.testFramework.LightVirtualFile; //导入依赖的package包/类
public GutteredLanguageConsole(@NotNull String title,
                               @NotNull Project project,
                               @NotNull Language language,
                               @Nullable GutterContentProvider gutterContentProvider,
                               @Nullable final PairFunction<VirtualFile, Project, PsiFile> psiFileFactory) {
  super(new Helper(project, new LightVirtualFile(title, language, "")) {
    @NotNull
    @Override
    public PsiFile getFile() {
      return psiFileFactory == null ? super.getFile() : psiFileFactory.fun(virtualFile, project);
    }

  });

  this.gutterContentProvider = gutterContentProvider == null ? new BasicGutterContentProvider() : gutterContentProvider;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:LanguageConsoleBuilder.java

示例10: createFromText

import com.intellij.testFramework.LightVirtualFile; //导入依赖的package包/类
protected PsiFile createFromText(final Language language, CharSequence text, PsiManager manager) {
  @NonNls
  final LightVirtualFile virtualFile = new LightVirtualFile("foo", createTemplateFakeFileType(language), text, LocalTimeCounter.currentTime());

  FileViewProvider viewProvider = new SingleRootFileViewProvider(manager, virtualFile, false) {
    @Override
    @NotNull
    public Language getBaseLanguage() {
      return language;
    }
  };

  // Since we're already inside a template language PSI that was built regardless of the file size (for whatever reason), 
  // there should also be no file size checks for template data files.
  SingleRootFileViewProvider.doNotCheckFileSizeLimit(virtualFile);

  return viewProvider.getPsi(language);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:TemplateDataElementType.java

示例11: findInjectionHost

import com.intellij.testFramework.LightVirtualFile; //导入依赖的package包/类
@Nullable
public static PsiLanguageInjectionHost findInjectionHost(@Nullable PsiElement psi) {
  if (psi == null) return null;
  PsiFile containingFile = psi.getContainingFile().getOriginalFile();              // * formatting
  PsiElement fileContext = containingFile.getContext();                            // * quick-edit-handler
  if (fileContext instanceof PsiLanguageInjectionHost) return (PsiLanguageInjectionHost)fileContext;
  Place shreds = getShreds(containingFile.getViewProvider()); // * injection-registrar
  if (shreds == null) {
    VirtualFile virtualFile = PsiUtilCore.getVirtualFile(containingFile);
    if (virtualFile instanceof LightVirtualFile) {
      virtualFile = ((LightVirtualFile)virtualFile).getOriginalFile();             // * dynamic files-from-text
    }
    if (virtualFile instanceof VirtualFileWindow) {
      shreds = getShreds(((VirtualFileWindow)virtualFile).getDocumentWindow());
    }
  }
  return shreds != null ? shreds.getHostPointer().getElement() : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:InjectedLanguageUtil.java

示例12: createHighlighter

import com.intellij.testFramework.LightVirtualFile; //导入依赖的package包/类
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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:FileTemplateConfigurable.java

示例13: CommandConsole

import com.intellij.testFramework.LightVirtualFile; //导入依赖的package包/类
/**
 * @param module                     module console runs on
 * @param title                      console title
 * @param commandsAndDefaultExecutor List of commands (to be injected into {@link CommandLineFile}) if any
 *                                   and executor to be used when user executes unknown command.
 *                                   Both may be null. Execution is passed to command if command exist, passed to default executor
 *                                   otherwise. With out of commands default executor will always be used.
 *                                   With out of executor, no execution would be possible at all.
 */
private CommandConsole(@NotNull final Module module,
                       @NotNull final String title,
                       @Nullable final Pair<List<Command>, CommandExecutor> commandsAndDefaultExecutor) {
  super(new Helper(module.getProject(), new LightVirtualFile(title, CommandLineLanguage.INSTANCE, "")) {
    @Override
    public void setupEditor(@NotNull EditorEx editor) {
      super.setupEditor(editor);
      // We do not need spaces here, because it leads to PY-15557
      EditorSettings editorSettings = editor.getSettings();
      editorSettings.setAdditionalLinesCount(0);
      editorSettings.setAdditionalColumnsCount(0);
    }
  });
  myCommandsAndDefaultExecutor = commandsAndDefaultExecutor;
  myModule = module;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:CommandConsole.java

示例14: testCodeCell

import com.intellij.testFramework.LightVirtualFile; //导入依赖的package包/类
public void testCodeCell() throws IOException {
  final String fileName = "testData/code.ipynb";
  final String fileText = getFileText(fileName);
  final IpnbFile ipnbFile = IpnbParser.parseIpnbFile(fileText, new LightVirtualFile());
  assertNotNull(ipnbFile);
  final List<IpnbCell> cells = ipnbFile.getCells();
  assertEquals(1, cells.size());
  final IpnbCell cell = cells.get(0);
  assertTrue(cell instanceof IpnbCodeCell);
  final List<IpnbOutputCell> outputs = ((IpnbCodeCell)cell).getCellOutputs();
  assertEquals(0, outputs.size());
  final List<String> source = ((IpnbCodeCell)cell).getSource();
  final String joined = StringUtil.join(source, "");
  assertEquals("e = x + 2*y", joined);
  final String language = ((IpnbCodeCell)cell).getLanguage();
  assertEquals("python", language);
  final Integer number = ((IpnbCodeCell)cell).getPromptNumber();
  assertEquals(new Integer(4), number);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:JsonParserTest.java

示例15: testOutputs

import com.intellij.testFramework.LightVirtualFile; //导入依赖的package包/类
public void testOutputs() throws IOException {
  final String fileName = "testData/outputs.ipynb";
  final String fileText = getFileText(fileName);
  final IpnbFile ipnbFile = IpnbParser.parseIpnbFile(fileText, new LightVirtualFile());
  assertNotNull(ipnbFile);
  final List<IpnbCell> cells = ipnbFile.getCells();
  assertEquals(1, cells.size());
  final IpnbCell cell = cells.get(0);
  assertTrue(cell instanceof IpnbCodeCell);
  final List<IpnbOutputCell> outputs = ((IpnbCodeCell)cell).getCellOutputs();
  assertEquals(1, outputs.size());
  final IpnbOutputCell output = outputs.get(0);
  final List<String> text = output.getText();
  assertNotNull(text);
  final String joined = StringUtil.join(text, "");
  assertEquals("\"Add(Symbol('x'), Mul(Integer(2), Symbol('y')))\"", joined);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JsonParserTest.java


注:本文中的com.intellij.testFramework.LightVirtualFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。