예제 #1
0
 public static boolean isVisibleSubPackage(PsiPackage subPackage, PbFile curFile) {
   String qSubPackageName = subPackage.getQualifiedName();
   if (curFile.getPackageName().startsWith(qSubPackageName)) {
     return true;
   }
   PbFile[] importedFiles = getImportedFiles(curFile, true);
   for (PbFile importedFile : importedFiles) {
     if (importedFile.getPackageName().startsWith(qSubPackageName)) {
       return true;
     }
   }
   return false;
 }
예제 #2
0
 public static PbFile[] getImportedFilesByPackageName(PbFile file, @NotNull String packageName) {
   PbImportDef[] importDefs = file.getImportDefinitions();
   ArrayList<PbFile> importFiles = new ArrayList<PbFile>(importDefs.length);
   for (PbImportDef importDef : importDefs) {
     PbFile aliasedFile = importDef.getAliasedFile();
     if (aliasedFile != null && packageName.equals(aliasedFile.getPackageName())) {
       importFiles.add(aliasedFile);
     }
   }
   if (importFiles.size() == 0) {
     return EMPTY_FILE_ARRAY;
   }
   return importFiles.toArray(new PbFile[importFiles.size()]);
 }
예제 #3
0
 public static PbFile[] getImportedFiles(PbFile file, boolean onlyAliased) {
   PbImportDef[] importDefs = file.getImportDefinitions();
   ArrayList<PbFile> importFiles = new ArrayList<PbFile>(importDefs.length);
   for (PbImportDef importDef : importDefs) {
     PbFile aliasedFile = importDef.getAliasedFile();
     if (aliasedFile != null || !onlyAliased) {
       importFiles.add(aliasedFile);
     }
   }
   if (importFiles.size() == 0) {
     return EMPTY_FILE_ARRAY;
   }
   return importFiles.toArray(new PbFile[importFiles.size()]);
 }
예제 #4
0
 public static boolean isSamePackage(PbFile file, PsiPackage psiPackage) {
   return psiPackage.getQualifiedName().equals(file.getPackageName());
 }