com.intellij.psi.impl.source.resolve.FileContextUtil源码实例Demo

类com.intellij.psi.impl.source.resolve.FileContextUtil源码实例Demo

下面列出了com.intellij.psi.impl.source.resolve.FileContextUtil 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: intellij-haxe   文件: HaxeParserWrapper.java
@Override
public ASTNode parse(IElementType t, PsiBuilder b) {
  if (debugging) {
    HaxeDebugTimeLog timeLog = null;

    // The file is attached to the user data. :/  I suspect this was a hack, but it's what we've got available.
    PsiFile file = b.getUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY);

    String description = null != file ? file.getName() : t.toString();
    timeLog = HaxeDebugTimeLog.startNew("HaxeParser " + description, HaxeDebugTimeLog.Since.StartAndPrevious);

    ASTNode node = super.parse(t, b);

    timeLog.stamp("Finished parsing.");
    timeLog.printIfTimeExceeds(20 /* milliseconds */);

    return node;
  }
  return super.parse(t,b);
}
 
源代码2 项目: intellij   文件: BuildParserDefinition.java
@Override
public ASTNode parse(IElementType root, PsiBuilder builder) {
  if (debug.getValue()) {
    System.err.println(builder.getUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY));
  }
  PsiBuilder.Marker rootMarker = builder.mark();
  ParsingContext context = new ParsingContext(builder);
  context.statementParser.parseFileInput();
  rootMarker.done(root);
  return builder.getTreeBuilt();
}
 
源代码3 项目: intellij-latte   文件: GeneratedParserUtilBase.java
public static void initState(ErrorState state, PsiBuilder builder, IElementType root, TokenSet[] extendsSets) {
	state.extendsSets = extendsSets;
	PsiFile file = builder.getUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY);
	state.completionState = file == null? null: file.getUserData(COMPLETION_STATE_KEY);
	Language language = file == null? root.getLanguage() : file.getLanguage();
	state.caseSensitive = language.isCaseSensitive();
	PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(language);
	state.braces = matcher == null ? null : matcher.getPairs();
	if (state.braces != null && state.braces.length == 0) state.braces = null;
}
 
源代码4 项目: intellij-xquery   文件: GeneratedParserUtilBase.java
public static void initState(ErrorState state, PsiBuilder builder, IElementType root, TokenSet[] extendsSets) {
    state.extendsSets = extendsSets;
    PsiFile file = builder.getUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY);
    state.completionState = file == null? null: file.getUserData(COMPLETION_STATE_KEY);
    Language language = file == null? root.getLanguage() : file.getLanguage();
    state.caseSensitive = language.isCaseSensitive();
    PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(language);
    state.braces = matcher == null ? null : matcher.getPairs();
    if (state.braces != null && state.braces.length == 0) state.braces = null;
}
 
源代码5 项目: consulo   文件: ResolveScopeManagerImpl.java
@Override
@Nonnull
public GlobalSearchScope getResolveScope(@Nonnull PsiElement element) {
  ProgressIndicatorProvider.checkCanceled();

  VirtualFile vFile;
  final PsiFile contextFile;
  if (element instanceof PsiDirectory) {
    vFile = ((PsiDirectory)element).getVirtualFile();
    contextFile = null;
  }
  else {
    final PsiFile containingFile = element.getContainingFile();
    if (containingFile instanceof PsiCodeFragment) {
      final GlobalSearchScope forcedScope = ((PsiCodeFragment)containingFile).getForcedResolveScope();
      if (forcedScope != null) {
        return forcedScope;
      }
      final PsiElement context = containingFile.getContext();
      if (context == null) {
        return GlobalSearchScope.allScope(myProject);
      }
      return getResolveScope(context);
    }

    contextFile = containingFile != null ? FileContextUtil.getContextFile(containingFile) : null;
    if (contextFile == null) {
      return GlobalSearchScope.allScope(myProject);
    }
    else if (contextFile instanceof FileResolveScopeProvider) {
      return ((FileResolveScopeProvider)contextFile).getFileResolveScope();
    }
    vFile = contextFile.getOriginalFile().getVirtualFile();
  }
  if (vFile == null || contextFile == null) {
    return GlobalSearchScope.allScope(myProject);
  }

  return myDefaultResolveScopesCache.get(vFile);
}
 
源代码6 项目: consulo   文件: PsiBuilderImpl.java
@Override
public <T> void putUserData(@Nonnull Key<T> key, @Nullable T value) {
  if (key == FileContextUtil.CONTAINING_FILE_KEY) {
    myFile = (PsiFile)value;
  }
  else {
    super.putUserData(key, value);
  }
}
 
源代码7 项目: consulo   文件: GeneratedParserUtilBase.java
public static void initState(ErrorState state, PsiBuilder builder, IElementType root, TokenSet[] extendsSets) {
  state.extendsSets = extendsSets;
  PsiFile file = builder.getUserData(FileContextUtil.CONTAINING_FILE_KEY);
  state.completionState = file == null? null: file.getUserData(COMPLETION_STATE_KEY);
  Language language = file == null? root.getLanguage() : file.getLanguage();
  state.caseSensitive = language.isCaseSensitive();
  PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(language);
  state.braces = matcher == null ? null : matcher.getPairs();
  if (state.braces != null && state.braces.length == 0) state.braces = null;
}
 
源代码8 项目: consulo   文件: InjectedLanguageManagerImpl.java
@Override
public PsiLanguageInjectionHost getInjectionHost(@Nonnull PsiElement injectedElement) {
  final PsiFile file = injectedElement.getContainingFile();
  final VirtualFile virtualFile = file == null ? null : file.getVirtualFile();
  if (virtualFile instanceof VirtualFileWindow) {
    PsiElement host = FileContextUtil.getFileContext(file); // use utility method in case the file's overridden getContext()
    if (host instanceof PsiLanguageInjectionHost) {
      return (PsiLanguageInjectionHost)host;
    }
  }
  return null;
}
 
源代码9 项目: consulo   文件: PlatformPackageUtil.java
@Nullable
public static PsiDirectory getDirectory(@Nullable PsiElement element) {
  if (element == null) return null;
  // handle injection and fragment editor
  PsiFile file = FileContextUtil.getContextFile(element);
  return file == null ? null : file.getContainingDirectory();
}
 
源代码10 项目: Intellij-Dust   文件: GeneratedParserUtilBase.java
private static void initState(IElementType root, PsiBuilder builder, ErrorState state) {
    PsiFile file = builder.getUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY);
    state.completionState = file == null? null: file.getUserData(COMPLETION_STATE_KEY);
    Language language = file == null? root.getLanguage() : file.getLanguage();
    state.caseSensitive = language.isCaseSensitive();
    ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(language);
    if (parserDefinition != null) {
        state.commentTokens = parserDefinition.getCommentTokens();
        state.whitespaceTokens = parserDefinition.getWhitespaceTokens();
    }
    PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(language);
    state.braces = matcher == null ? null : matcher.getPairs();
    if (state.braces != null && state.braces.length == 0) state.braces = null;
}
 
源代码11 项目: consulo   文件: MockPsiFile.java
@Override
public PsiElement getContext() {
  return FileContextUtil.getFileContext(this);
}
 
源代码12 项目: consulo   文件: LiteFixture.java
public static void setContext(final PsiFile psiFile, final PsiElement context) {
  if (context != null) {
    psiFile.putUserData(FileContextUtil.INJECTED_IN_ELEMENT, SmartPointerManager.getInstance(context.getProject()).createSmartPsiElementPointer(context));
  }
}
 
源代码13 项目: consulo   文件: PsiBuilderImpl.java
@Override
@SuppressWarnings("unchecked")
public <T> T getUserData(@Nonnull Key<T> key) {
  return key == FileContextUtil.CONTAINING_FILE_KEY ? (T)myFile : super.getUserData(key);
}
 
源代码14 项目: consulo   文件: PsiFileImpl.java
@Override
public PsiElement getContext() {
  return FileContextUtil.getFileContext(this);
}
 
源代码15 项目: consulo   文件: PsiBinaryFileImpl.java
@Override
public PsiElement getContext() {
  return FileContextUtil.getFileContext(this);
}
 
源代码16 项目: consulo   文件: LightPsiFileImpl.java
@Override
public PsiElement getContext() {
  return FileContextUtil.getFileContext(this);
}
 
源代码17 项目: consulo   文件: InjectionRegistrarImpl.java
private static boolean cacheEverything(@Nonnull Place place, @Nonnull DocumentWindowImpl documentWindow, @Nonnull InjectedFileViewProvider viewProvider, @Nonnull PsiFile psiFile) {
  FileDocumentManagerImpl.registerDocument(documentWindow, viewProvider.getVirtualFile());

  DebugUtil.performPsiModification("MultiHostRegistrar cacheEverything", () -> viewProvider.forceCachedPsi(psiFile));

  SmartPsiElementPointer<PsiLanguageInjectionHost> pointer = ((ShredImpl)place.get(0)).getSmartPointer();
  psiFile.putUserData(FileContextUtil.INJECTED_IN_ELEMENT, pointer);

  keepTreeFromChameleoningBack(psiFile);

  return viewProvider.setShreds(place);
}
 
源代码评论
动弹
沙发等你来抢
 类所在包
 类方法
 同包方法