Java Code Examples for

The following examples show how to use . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public static GlobalSearchScope includedFilesUnionScope(PsiFile source) {
    List<VirtualFile> scopes = Lists.newLinkedList();

    Set<PsiFile> includedFiles = findIncludedFiles(source, true, true);
    for (PsiFile file : includedFiles) {

    return GlobalSearchScope.filesScope(source.getProject(), scopes);
Example 2
Source Project: BashSupport   File:    License: Apache License 2.0 5 votes vote down vote up
public static GlobalSearchScope varDefSearchScope(BashVar reference, boolean withIncludedFiles) {
    PsiFile referenceFile = BashPsiUtils.findFileContext(reference);
    if (!withIncludedFiles) {
        return GlobalSearchScope.fileScope(referenceFile.getProject(), referenceFile.getVirtualFile());

    Set<VirtualFile> result = Sets.newLinkedHashSet();

    int referenceFileOffset = BashPsiUtils.getFileTextOffset(reference);
    BashFunctionDef referenceFunctionContainer = BashPsiUtils.findNextVarDefFunctionDefScope(reference);

    for (BashIncludeCommand command : BashPsiUtils.findIncludeCommands(referenceFile, null)) {
        boolean includeIsInFunction = BashPsiUtils.findNextVarDefFunctionDefScope(command) != null;

        //either one of var or include command is in a function or the var is used after the include command
        if (referenceFunctionContainer != null || includeIsInFunction || (referenceFileOffset > BashPsiUtils.getFileTextEndOffset(command))) {
            BashFileReference fileReference = command.getFileReference();
            PsiFile includedFile = fileReference != null ? fileReference.findReferencedFile() : null;
            if (includedFile != null) {

                //also, add all files included in the valid include command's file
                for (PsiFile file : BashPsiUtils.findIncludedFiles(includedFile, true)) {

    return GlobalSearchScope.filesScope(referenceFile.getProject(), result);