當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。