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


Java GroovyFile.getVirtualFile方法代码示例

本文整理汇总了Java中org.jetbrains.plugins.groovy.lang.psi.GroovyFile.getVirtualFile方法的典型用法代码示例。如果您正苦于以下问题:Java GroovyFile.getVirtualFile方法的具体用法?Java GroovyFile.getVirtualFile怎么用?Java GroovyFile.getVirtualFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jetbrains.plugins.groovy.lang.psi.GroovyFile的用法示例。


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

示例1: timeToOptimizeImports

import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; //导入方法依赖的package包/类
private boolean timeToOptimizeImports(GroovyFile myFile, Editor editor) {
  if (!CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY) return false;
  if (onTheFly && editor != null) {
    // if we stand inside import statements, do not optimize
    final VirtualFile vfile = myFile.getVirtualFile();
    if (vfile != null && ProjectRootManager.getInstance(myFile.getProject()).getFileIndex().isInSource(vfile)) {
      final GrImportStatement[] imports = myFile.getImportStatements();
      if (imports.length > 0) {
        final int offset = editor.getCaretModel().getOffset();
        if (imports[0].getTextRange().getStartOffset() <= offset && offset <= imports[imports.length - 1].getTextRange().getEndOffset()) {
          return false;
        }
      }
    }
  }

  DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myFile.getProject());
  if (!codeAnalyzer.isHighlightingAvailable(myFile)) return false;

  if (!codeAnalyzer.isErrorAnalyzingFinished(myFile)) return false;
  Document myDocument = PsiDocumentManager.getInstance(myFile.getProject()).getDocument(myFile);
  boolean errors = containsErrorsPreventingOptimize(myFile, myDocument);

  return !errors && DaemonListeners.canChangeFileSilently(myFile);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:GroovyOptimizeImportsFix.java

示例2: getRuntimeScriptName

import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; //导入方法依赖的package包/类
@NotNull
public String getRuntimeScriptName(@NotNull final String originalName, GroovyFile groovyFile) {
  VirtualFile virtualFile = groovyFile.getVirtualFile();
  if (virtualFile == null) return "";

  final Module module = ModuleUtilCore.findModuleForPsiElement(groovyFile);
  if (module == null) {
    return "";
  }

  final File scriptFile = VfsUtilCore.virtualToIoFile(virtualFile);
  final String className = CachedValuesManager.getManager(module.getProject())
    .getCachedValue(module, GRADLE_CLASS_NAME, new ScriptSourceMapCalculator(module), false).get(scriptFile);
  return className == null ? "" : className;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:GradlePositionManager.java

示例3: annotate

import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; //导入方法依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder holder) {
  if (!(psiElement instanceof GroovyFile)) return;

  final GroovyFile groovyFile = (GroovyFile)psiElement;
  if (!GrFileIndexUtil.isGroovySourceFile(groovyFile)) return;
  
  final VirtualFile vfile = groovyFile.getVirtualFile();
  if (!GdslUtil.GDSL_FILTER.value(vfile)) return;
  
  final DslActivationStatus.Status status = GroovyDslFileIndex.getStatus(vfile);
  if (status == ACTIVE) return;

  final String message = status == MODIFIED
                         ? "DSL descriptor file has been changed and isn't currently executed."
                         : "DSL descriptor file has been disabled due to a processing error.";

  final Annotation annotation = holder.createWarningAnnotation(psiElement, message);
  annotation.setFileLevelAnnotation(true);
  if (status == ERROR) {
    final String error = GroovyDslFileIndex.getError(vfile);
    if (error != null) {
      annotation.registerFix(GroovyQuickFixFactory.getInstance().createInvestigateFix(error));
    }
  }
  annotation.registerFix(new ActivateFix(vfile));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:GroovyDslAnnotator.java

示例4: isRenameFileOnClassRenaming

import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; //导入方法依赖的package包/类
private boolean isRenameFileOnClassRenaming() {
  final PsiFile file = getContainingFile();
  if (!(file instanceof GroovyFile)) return false;
  final GroovyFile groovyFile = (GroovyFile)file;
  if (groovyFile.isScript()) return false;
  final String name = getName();
  final VirtualFile vFile = groovyFile.getVirtualFile();
  return vFile != null && name != null && name.equals(vFile.getNameWithoutExtension());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:GrTypeDefinitionImpl.java


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