コード例 #1
0
  @Nullable
  protected DaemonCodeAnalyzerStatus getDaemonCodeAnalyzerStatus(
      boolean fillErrorsCount, SeverityRegistrar severityRegistrar) {
    if (myFile == null
        || myProject.isDisposed()
        || !myDaemonCodeAnalyzer.isHighlightingAvailable(myFile)) return null;

    List<String> noInspectionRoots = new ArrayList<String>();
    List<String> noHighlightingRoots = new ArrayList<String>();
    FileViewProvider provider = myFile.getViewProvider();
    Set<Language> languages = provider.getLanguages();
    for (Language language : languages) {
      PsiFile root = provider.getPsi(language);
      if (!HighlightLevelUtil.shouldHighlight(root)) {
        noHighlightingRoots.add(language.getID());
      } else if (!HighlightLevelUtil.shouldInspect(root)) {
        noInspectionRoots.add(language.getID());
      }
    }
    DaemonCodeAnalyzerStatus status = new DaemonCodeAnalyzerStatus();
    status.noInspectionRoots =
        noInspectionRoots.isEmpty() ? null : ArrayUtil.toStringArray(noInspectionRoots);
    status.noHighlightingRoots =
        noHighlightingRoots.isEmpty() ? null : ArrayUtil.toStringArray(noHighlightingRoots);

    status.errorCount = errorCount.clone();
    status.rootsNumber = languages.size();
    fillDaemonCodeAnalyzerErrorsStatus(status, fillErrorsCount, severityRegistrar);
    List<TextEditorHighlightingPass> passes =
        myDaemonCodeAnalyzer.getPassesToShowProgressFor(myDocument);
    status.passStati =
        passes.isEmpty()
            ? Collections.<ProgressableTextEditorHighlightingPass>emptyList()
            : new ArrayList<ProgressableTextEditorHighlightingPass>(passes.size());
    //noinspection ForLoopReplaceableByForEach
    for (int i = 0; i < passes.size(); i++) {
      TextEditorHighlightingPass tepass = passes.get(i);
      if (!(tepass instanceof ProgressableTextEditorHighlightingPass)) continue;
      ProgressableTextEditorHighlightingPass pass = (ProgressableTextEditorHighlightingPass) tepass;

      if (pass.getProgress() < 0) continue;
      status.passStati.add(pass);
    }
    status.errorAnalyzingFinished = myDaemonCodeAnalyzer.isAllAnalysisFinished(myFile);
    status.enabled = myDaemonCodeAnalyzer.isUpdateByTimerEnabled();

    return status;
  }
コード例 #2
0
 public String[] knownNamespaces() {
   final PsiElement parentElement = getParent();
   BidirectionalMap<String, String> map = initNamespaceMaps(parentElement);
   Set<String> known = Collections.emptySet();
   if (map != null) {
     known = new HashSet<String>(map.values());
   }
   if (parentElement instanceof XmlTag) {
     if (known.isEmpty()) return ((XmlTag) parentElement).knownNamespaces();
     ContainerUtil.addAll(known, ((XmlTag) parentElement).knownNamespaces());
   } else {
     XmlExtension xmlExtension = XmlExtension.getExtensionByElement(this);
     if (xmlExtension != null) {
       final XmlFile xmlFile = xmlExtension.getContainingFile(this);
       if (xmlFile != null) {
         final XmlTag rootTag = xmlFile.getRootTag();
         if (rootTag != null && rootTag != this) {
           if (known.isEmpty()) return rootTag.knownNamespaces();
           ContainerUtil.addAll(known, rootTag.knownNamespaces());
         }
       }
     }
   }
   return ArrayUtil.toStringArray(known);
 }
コード例 #3
0
  private boolean performCompilation(
      List<String> args,
      StringWriter out,
      StringWriter err,
      Map<String, List<String>> outputs,
      CompileContext context,
      ModuleChunk chunk) {
    try {
      Class<?> mainClass = Class.forName(GreclipseMain.class.getName(), true, myGreclipseLoader);
      Constructor<?> constructor =
          mainClass.getConstructor(PrintWriter.class, PrintWriter.class, Map.class, Map.class);
      Method compileMethod = mainClass.getMethod("compile", String[].class);

      HashMap<String, Object> customDefaultOptions = ContainerUtil.newHashMap();
      // without this greclipse won't load AST transformations
      customDefaultOptions.put(
          "org.eclipse.jdt.core.compiler.groovy.groovyClassLoaderPath", getClasspathString(chunk));

      // used by greclipse to cache transform loaders
      // names should be different for production & tests
      customDefaultOptions.put(
          "org.eclipse.jdt.core.compiler.groovy.groovyProjectName",
          chunk.getPresentableShortName());

      Object main =
          constructor.newInstance(
              new PrintWriter(out), new PrintWriter(err), customDefaultOptions, outputs);
      return (Boolean) compileMethod.invoke(main, new Object[] {ArrayUtil.toStringArray(args)});
    } catch (Exception e) {
      context.processMessage(new CompilerMessage(getPresentableName(), e));
      return false;
    }
  }
 public String[] getTemplateNames() {
   final Set<String> names = new LinkedHashSet<String>();
   for (TemplateResource resource : getAllTemplates()) {
     names.add(getTemplateBaseName(resource));
   }
   return ArrayUtil.toStringArray(names);
 }
コード例 #5
0
  @NotNull
  @Override
  public SuggestedNameInfo suggestUniqueVariableName(
      @NotNull final SuggestedNameInfo baseNameInfo,
      PsiElement place,
      boolean ignorePlaceName,
      boolean lookForward) {
    final String[] names = baseNameInfo.names;
    final LinkedHashSet<String> uniqueNames = new LinkedHashSet<String>(names.length);
    for (String name : names) {
      if (ignorePlaceName && place instanceof PsiNamedElement) {
        final String placeName = ((PsiNamedElement) place).getName();
        if (Comparing.strEqual(placeName, name)) {
          uniqueNames.add(name);
          continue;
        }
      }
      uniqueNames.add(suggestUniqueVariableName(name, place, lookForward));
    }

    return new SuggestedNameInfo(ArrayUtil.toStringArray(uniqueNames)) {
      @Override
      public void nameChosen(String name) {
        baseNameInfo.nameChosen(name);
      }
    };
  }
コード例 #6
0
  private static String[] createArgumentsForJsCompiler(
      File outputFile, List<File> sourceFiles, Set<String> libraryFiles) {
    List<String> args = new ArrayList<String>();

    Collections.addAll(args, "-tags", "-verbose", "-version", "-sourcemap");

    String separator = ",";
    String sourceFilesAsString =
        StringUtil.join(
            sourceFiles,
            new Function<File, String>() {
              @Override
              public String fun(File file) {
                return file.getPath();
              }
            },
            separator);

    args.add("-sourceFiles");
    args.add(sourceFilesAsString);

    args.add("-output");
    args.add(outputFile.getPath());

    args.add("-libraryFiles");
    args.add(StringUtil.join(libraryFiles, separator));

    return ArrayUtil.toStringArray(args);
  }
コード例 #7
0
 @Override
 @NotNull
 public String[] getAllMethodNames() {
   Collection<String> keys = StubIndex.getInstance().getAllKeys(GrMethodNameIndex.KEY, myProject);
   keys.addAll(StubIndex.getInstance().getAllKeys(GrAnnotationMethodNameIndex.KEY, myProject));
   return ArrayUtil.toStringArray(keys);
 }
コード例 #8
0
ファイル: FunctionCodegen.java プロジェクト: AlexJuca/kotlin
  @NotNull
  public static String[] getThrownExceptions(
      @NotNull FunctionDescriptor function, @NotNull final JetTypeMapper mapper) {
    AnnotationDescriptor annotation =
        function.getAnnotations().findAnnotation(new FqName("kotlin.throws"));
    if (annotation == null) {
      annotation = function.getAnnotations().findAnnotation(new FqName("kotlin.jvm.Throws"));
    }

    if (annotation == null) return ArrayUtil.EMPTY_STRING_ARRAY;

    Collection<ConstantValue<?>> values = annotation.getAllValueArguments().values();
    if (values.isEmpty()) return ArrayUtil.EMPTY_STRING_ARRAY;

    Object value = values.iterator().next();
    if (!(value instanceof ArrayValue)) return ArrayUtil.EMPTY_STRING_ARRAY;
    ArrayValue arrayValue = (ArrayValue) value;

    List<String> strings =
        ContainerUtil.mapNotNull(
            arrayValue.getValue(),
            new Function<ConstantValue<?>, String>() {
              @Override
              public String fun(ConstantValue<?> constant) {
                if (constant instanceof KClassValue) {
                  KClassValue classValue = (KClassValue) constant;
                  ClassDescriptor classDescriptor =
                      DescriptorUtils.getClassDescriptorForType(classValue.getValue());
                  return mapper.mapClass(classDescriptor).getInternalName();
                }
                return null;
              }
            });
    return ArrayUtil.toStringArray(strings);
  }
コード例 #9
0
 @NotNull
 private Trinity<String[], VirtualFile[], VirtualFile[]> cacheThings() {
   Trinity<String[], VirtualFile[], VirtualFile[]> result;
   if (myList.isEmpty()) {
     result = EMPTY;
   } else {
     VirtualFilePointer[] vf = myList.toArray(new VirtualFilePointer[myList.size()]);
     List<VirtualFile> cachedFiles = new ArrayList<VirtualFile>(vf.length);
     List<String> cachedUrls = new ArrayList<String>(vf.length);
     List<VirtualFile> cachedDirectories = new ArrayList<VirtualFile>(vf.length / 3);
     boolean allFilesAreDirs = true;
     for (VirtualFilePointer v : vf) {
       VirtualFile file = v.getFile();
       String url = v.getUrl();
       cachedUrls.add(url);
       if (file != null) {
         cachedFiles.add(file);
         if (file.isDirectory()) {
           cachedDirectories.add(file);
         } else {
           allFilesAreDirs = false;
         }
       }
     }
     VirtualFile[] directories = VfsUtilCore.toVirtualFileArray(cachedDirectories);
     VirtualFile[] files =
         allFilesAreDirs ? directories : VfsUtilCore.toVirtualFileArray(cachedFiles);
     String[] urlsArray = ArrayUtil.toStringArray(cachedUrls);
     result = Trinity.create(urlsArray, files, directories);
   }
   myCachedThings = result;
   myTimeStampOfCachedThings = myVirtualFilePointerManager.getModificationCount();
   return result;
 }
コード例 #10
0
  public static String[] getUrls(OrderEntry entry) {
    List<String> result = new ArrayList<>();
    RootPolicy<List<String>> policy =
        new RootPolicy<List<String>>() {
          @Override
          public List<String> visitLibraryOrderEntry(
              final LibraryOrderEntry orderEntry, final List<String> value) {
            Collections.addAll(value, orderEntry.getRootUrls(getInstance()));
            return value;
          }

          @Override
          public List<String> visitJdkOrderEntry(
              final JdkOrderEntry orderEntry, final List<String> value) {
            Collections.addAll(value, orderEntry.getRootUrls(getInstance()));
            return value;
          }

          @Override
          public List<String> visitModuleSourceOrderEntry(
              final ModuleSourceOrderEntry orderEntry, final List<String> value) {
            Collections.addAll(
                value,
                orderEntry
                    .getRootModel()
                    .getModuleExtension(JavaModuleExternalPaths.class)
                    .getJavadocUrls());
            return value;
          }
        };
    entry.accept(policy, result);
    return ArrayUtil.toStringArray(result);
  }
コード例 #11
0
 public static String[] removeCommonIndentation(@NotNull final String docstring) {
   // detect common indentation
   String[] lines = LineTokenizer.tokenize(docstring, false);
   boolean isFirst = true;
   int cutWidth = Integer.MAX_VALUE;
   int firstIndentedLine = 0;
   for (String frag : lines) {
     if (frag.length() == 0) continue;
     int padWidth = 0;
     final Matcher matcher = ourSpacesPattern.matcher(frag);
     if (matcher.find()) {
       padWidth = matcher.end();
     }
     if (isFirst) {
       isFirst = false;
       if (padWidth == 0) { // first line may have zero padding
         firstIndentedLine = 1;
         continue;
       }
     }
     if (padWidth < cutWidth) cutWidth = padWidth;
   }
   // remove common indentation
   if (cutWidth > 0 && cutWidth < Integer.MAX_VALUE) {
     for (int i = firstIndentedLine; i < lines.length; i += 1) {
       if (lines[i].length() >= cutWidth) lines[i] = lines[i].substring(cutWidth);
     }
   }
   List<String> result = new ArrayList<String>();
   for (String line : lines) {
     if (line.startsWith(PyConsoleUtil.ORDINARY_PROMPT)) break;
     result.add(line);
   }
   return ArrayUtil.toStringArray(result);
 }
コード例 #12
0
  private String[] suggestVariableNameByType(
      PsiType type, final VariableKind variableKind, boolean correctKeywords) {
    String longTypeName = getLongTypeName(type);
    CodeStyleSettings.TypeToNameMap map = getMapByVariableKind(variableKind);
    if (map != null && longTypeName != null) {
      if (type.equals(PsiType.NULL)) {
        longTypeName = CommonClassNames.JAVA_LANG_OBJECT;
      }
      String name = map.nameByType(longTypeName);
      if (name != null && isIdentifier(name)) {
        return new String[] {name};
      }
    }

    Collection<String> suggestions = new LinkedHashSet<String>();

    suggestNamesForCollectionInheritors(type, variableKind, suggestions, correctKeywords);
    suggestNamesFromGenericParameters(type, variableKind, suggestions, correctKeywords);

    String typeName = normalizeTypeName(getTypeName(type));
    if (typeName != null) {
      ContainerUtil.addAll(
          suggestions,
          getSuggestionsByName(
              typeName, variableKind, type instanceof PsiArrayType, correctKeywords));
    }

    return ArrayUtil.toStringArray(suggestions);
  }
コード例 #13
0
ファイル: ImportHelper.java プロジェクト: jexp/idea2
  @NotNull
  private static String[] collectNamesToImport(
      @NotNull PsiJavaFile file, @NotNull Set<String> namesToImportStaticly) {
    Set<String> names = new THashSet<String>();

    final JspFile jspFile = JspPsiUtil.getJspFile(file);
    collectNamesToImport(names, file, namesToImportStaticly, jspFile);
    if (jspFile != null) {
      PsiFile[] files =
          ArrayUtil.mergeArrays(
              JspSpiUtil.getIncludingFiles(jspFile),
              JspSpiUtil.getIncludedFiles(jspFile),
              PsiFile.class);
      for (PsiFile includingFile : files) {
        final PsiFile javaRoot = includingFile.getViewProvider().getPsi(StdLanguages.JAVA);
        if (javaRoot instanceof PsiJavaFile && file != javaRoot) {
          collectNamesToImport(names, (PsiJavaFile) javaRoot, namesToImportStaticly, jspFile);
        }
      }
    }

    addUnresolvedImportNames(names, file, namesToImportStaticly);

    return ArrayUtil.toStringArray(names);
  }
コード例 #14
0
  public static String[] getParameterString(ExtractInfoHelper helper, boolean useCanonicalText) {
    int i = 0;
    ParameterInfo[] infos = helper.getParameterInfos();
    int number = 0;
    for (ParameterInfo info : infos) {
      if (info.passAsParameter()) number++;
    }
    ArrayList<String> params = new ArrayList<String>();
    for (ParameterInfo info : infos) {
      if (info.passAsParameter()) {
        PsiType paramType = info.getType();
        final PsiPrimitiveType unboxed = PsiPrimitiveType.getUnboxedType(paramType);
        if (unboxed != null) paramType = unboxed;
        String paramTypeText;

        if (paramType == null || paramType.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) {
          paramTypeText = "";
        } else {
          paramTypeText =
              (useCanonicalText ? paramType.getCanonicalText() : paramType.getPresentableText())
                  + " ";
        }
        params.add(paramTypeText + info.getName() + (i < number - 1 ? ", " : ""));
        i++;
      }
    }
    return ArrayUtil.toStringArray(params);
  }
コード例 #15
0
  @NotNull
  public static String[] getCreateProjectCommand(
      @NotNull SymfonyInstallerVersion version,
      @NotNull String installerPath,
      @NotNull String newProjectPath,
      @NotNull String phpPath,
      @Nullable String commandLineOptions) {

    List<String> commands = new ArrayList<>();

    commands.add(phpPath);
    commands.add(installerPath);

    // "php symfony demo"
    if ("demo".equals(version.getVersion())) {
      commands.add("demo");
      commands.add(newProjectPath + "/" + PROJECT_SUB_FOLDER);
    } else {
      commands.add("new");
      commands.add(newProjectPath + "/" + PROJECT_SUB_FOLDER);
      commands.add(version.getVersion());
    }

    if (commandLineOptions != null) {
      commands.add(commandLineOptions);
    }

    return ArrayUtil.toStringArray(commands);
  }
コード例 #16
0
  private NamesByExprInfo suggestVariableNameByExpression(
      PsiExpression expr, VariableKind variableKind, boolean correctKeywords) {

    final LinkedHashSet<String> names = new LinkedHashSet<String>();
    final String[] fromLiterals =
        suggestVariableNameFromLiterals(expr, variableKind, correctKeywords);
    if (fromLiterals != null) {
      ContainerUtil.addAll(names, fromLiterals);
    }

    ContainerUtil.addAll(
        names,
        suggestVariableNameByExpressionOnly(expr, variableKind, correctKeywords, false).names);
    ContainerUtil.addAll(
        names, suggestVariableNameByExpressionPlace(expr, variableKind, correctKeywords).names);

    PsiType type = expr.getType();
    if (type != null) {
      ContainerUtil.addAll(names, suggestVariableNameByType(type, variableKind, correctKeywords));
    }
    ContainerUtil.addAll(
        names,
        suggestVariableNameByExpressionOnly(expr, variableKind, correctKeywords, true).names);

    String[] namesArray = ArrayUtil.toStringArray(names);
    String propertyName =
        suggestVariableNameByExpressionOnly(expr, variableKind, correctKeywords, false).propertyName
                != null
            ? suggestVariableNameByExpressionOnly(expr, variableKind, correctKeywords, false)
                .propertyName
            : suggestVariableNameByExpressionPlace(expr, variableKind, correctKeywords)
                .propertyName;
    return new NamesByExprInfo(propertyName, namesArray);
  }
コード例 #17
0
  private static String[] getSuggestionsByValue(final String stringValue) {
    List<String> result = new ArrayList<String>();
    StringBuffer currentWord = new StringBuffer();

    boolean prevIsUpperCase = false;

    for (int i = 0; i < stringValue.length(); i++) {
      final char c = stringValue.charAt(i);
      if (Character.isUpperCase(c)) {
        if (currentWord.length() > 0 && !prevIsUpperCase) {
          result.add(currentWord.toString());
          currentWord = new StringBuffer();
        }
        currentWord.append(c);
      } else if (Character.isLowerCase(c)) {
        currentWord.append(Character.toUpperCase(c));
      } else if (Character.isJavaIdentifierPart(c) && c != '_') {
        if (Character.isJavaIdentifierStart(c) || currentWord.length() > 0 || !result.isEmpty()) {
          currentWord.append(c);
        }
      } else {
        if (currentWord.length() > 0) {
          result.add(currentWord.toString());
          currentWord = new StringBuffer();
        }
      }

      prevIsUpperCase = Character.isUpperCase(c);
    }

    if (currentWord.length() > 0) {
      result.add(currentWord.toString());
    }
    return ArrayUtil.toStringArray(result);
  }
コード例 #18
0
  public GrInplaceConstantIntroducer(
      GrIntroduceContext context, OccurrencesChooser.ReplaceChoice choice) {
    super(IntroduceConstantHandler.REFACTORING_NAME, choice, context);

    myContext = context;

    myPanel = new GrInplaceIntroduceConstantPanel();

    GrVariable localVar = GrIntroduceHandlerBase.resolveLocalVar(context);
    if (localVar != null) {
      ArrayList<String> result = ContainerUtil.newArrayList(localVar.getName());

      GrExpression initializer = localVar.getInitializerGroovy();
      if (initializer != null) {
        ContainerUtil.addAll(
            result,
            GroovyNameSuggestionUtil.suggestVariableNames(
                initializer, new GroovyInplaceFieldValidator(context), true));
      }
      mySuggestedNames = ArrayUtil.toStringArray(result);
    } else {
      GrExpression expression = context.getExpression();
      assert expression != null;
      mySuggestedNames =
          GroovyNameSuggestionUtil.suggestVariableNames(
              expression, new GroovyInplaceFieldValidator(context), true);
    }
  }
コード例 #19
0
  private void reportNullableReturns(
      DataFlowInstructionVisitor visitor,
      ProblemsHolder holder,
      Set<PsiElement> reportedAnchors,
      @NotNull PsiElement block) {
    final PsiMethod method = getScopeMethod(block);
    if (method == null || NullableStuffInspectionBase.isNullableNotInferred(method, true)) return;

    boolean notNullRequired = NullableNotNullManager.isNotNull(method);
    if (!notNullRequired && !SUGGEST_NULLABLE_ANNOTATIONS) return;

    PsiType returnType = method.getReturnType();
    // no warnings in void lambdas, where the expression is not returned anyway
    if (block instanceof PsiExpression
        && block.getParent() instanceof PsiLambdaExpression
        && returnType == PsiType.VOID) return;

    // no warnings for Void methods, where only null can be possibly returned
    if (returnType == null || returnType.equalsToText(CommonClassNames.JAVA_LANG_VOID)) return;

    for (PsiElement statement : visitor.getProblems(NullabilityProblem.nullableReturn)) {
      assert statement instanceof PsiExpression;
      final PsiExpression expr = (PsiExpression) statement;
      if (!reportedAnchors.add(expr)) continue;

      if (notNullRequired) {
        final String text =
            isNullLiteralExpression(expr)
                ? InspectionsBundle.message("dataflow.message.return.null.from.notnull")
                : InspectionsBundle.message("dataflow.message.return.nullable.from.notnull");
        holder.registerProblem(expr, text);
      } else if (AnnotationUtil.isAnnotatingApplicable(statement)) {
        final NullableNotNullManager manager =
            NullableNotNullManager.getInstance(expr.getProject());
        final String defaultNullable = manager.getDefaultNullable();
        final String presentableNullable = StringUtil.getShortName(defaultNullable);
        final String text =
            isNullLiteralExpression(expr)
                ? InspectionsBundle.message(
                    "dataflow.message.return.null.from.notnullable", presentableNullable)
                : InspectionsBundle.message(
                    "dataflow.message.return.nullable.from.notnullable", presentableNullable);
        final LocalQuickFix[] fixes =
            PsiTreeUtil.getParentOfType(expr, PsiMethod.class, PsiLambdaExpression.class)
                    instanceof PsiLambdaExpression
                ? LocalQuickFix.EMPTY_ARRAY
                : new LocalQuickFix[] {
                  new AnnotateMethodFix(
                      defaultNullable, ArrayUtil.toStringArray(manager.getNotNulls())) {
                    @Override
                    public int shouldAnnotateBaseMethod(
                        PsiMethod method, PsiMethod superMethod, Project project) {
                      return 1;
                    }
                  }
                };
        holder.registerProblem(expr, text, fixes);
      }
    }
  }
コード例 #20
0
  private static boolean packageResources(
      @NotNull AndroidFacet facet, @NotNull CompileContext context) {
    final Module module = facet.getModule();

    try {
      context.processMessage(
          new ProgressMessage(
              AndroidJpsBundle.message(
                  "android.jps.progress.packaging.resources", module.getName())));

      final File manifestFile = AndroidJpsUtil.getManifestFileForCompilationPath(facet);
      if (manifestFile == null) {
        context.processMessage(
            new CompilerMessage(
                BUILDER_NAME,
                BuildMessage.Kind.ERROR,
                AndroidJpsBundle.message(
                    "android.jps.errors.manifest.not.found", module.getName())));
        return false;
      }
      final ArrayList<String> assetsDirPaths = new ArrayList<String>();
      collectAssetDirs(facet, assetsDirPaths);

      final File outputDir =
          AndroidJpsUtil.getOutputDirectoryForPackagedFiles(context.getProjectPaths(), module);
      if (outputDir == null) {
        context.processMessage(
            new CompilerMessage(
                BUILDER_NAME,
                BuildMessage.Kind.ERROR,
                AndroidJpsBundle.message(
                    "android.jps.errors.output.dir.not.specified", module.getName())));
        return false;
      }

      final Pair<AndroidSdk, IAndroidTarget> pair =
          AndroidJpsUtil.getAndroidPlatform(module, context, BUILDER_NAME);
      if (pair == null) {
        return false;
      }
      final IAndroidTarget target = pair.getSecond();

      final String outputFilePath = getPackagedResourcesFile(module, outputDir).getPath();
      final String[] resourceDirPaths =
          AndroidJpsUtil.collectResourceDirsForCompilation(facet, true, context);

      return doPackageResources(
          context,
          manifestFile,
          target,
          resourceDirPaths,
          ArrayUtil.toStringArray(assetsDirPaths),
          outputFilePath,
          AndroidJpsUtil.isReleaseBuild(context));
    } catch (IOException e) {
      AndroidJpsUtil.reportExceptionError(context, null, e, BUILDER_NAME);
      return false;
    }
  }
コード例 #21
0
 private String[] getGroups() {
   ArrayList<String> result = new ArrayList<String>();
   ToolsGroup[] groups = getGroupList();
   for (ToolsGroup group : groups) {
     result.add(group.getName());
   }
   return ArrayUtil.toStringArray(result);
 }
コード例 #22
0
 public String[] getSuperClassNames() {
   final PsiReference[] types = getExtendsList().getReferences();
   List<String> names = new ArrayList<String>(types.length);
   for (PsiReference type : types) {
     names.add(type.getCanonicalText());
   }
   return ArrayUtil.toStringArray(names);
 }
コード例 #23
0
  @Override
  public SuggestedNameInfo suggestVariableName(
      @NotNull final VariableKind kind,
      @Nullable final String propertyName,
      @Nullable final PsiExpression expr,
      @Nullable PsiType type,
      final boolean correctKeywords) {
    LinkedHashSet<String> names = new LinkedHashSet<String>();

    if (expr != null && type == null) {
      type = expr.getType();
    }

    if (propertyName != null) {
      String[] namesByName = getSuggestionsByName(propertyName, kind, false, correctKeywords);
      sortVariableNameSuggestions(namesByName, kind, propertyName, null);
      ContainerUtil.addAll(names, namesByName);
    }

    final NamesByExprInfo namesByExpr;
    if (expr != null) {
      namesByExpr = suggestVariableNameByExpression(expr, kind, correctKeywords);
      if (namesByExpr.propertyName != null) {
        sortVariableNameSuggestions(namesByExpr.names, kind, namesByExpr.propertyName, null);
      }
      ContainerUtil.addAll(names, namesByExpr.names);
    } else {
      namesByExpr = null;
    }

    if (type != null) {
      String[] namesByType = suggestVariableNameByType(type, kind, correctKeywords);
      sortVariableNameSuggestions(namesByType, kind, null, type);
      ContainerUtil.addAll(names, namesByType);
    }

    final String _propertyName;
    if (propertyName != null) {
      _propertyName = propertyName;
    } else {
      _propertyName = namesByExpr != null ? namesByExpr.propertyName : null;
    }

    addNamesFromStatistics(names, kind, _propertyName, type);

    String[] namesArray = ArrayUtil.toStringArray(names);
    sortVariableNameSuggestions(namesArray, kind, _propertyName, type);

    final PsiType _type = type;
    return new SuggestedNameInfo(namesArray) {
      @Override
      public void nameChosen(String name) {
        if (_propertyName != null || _type != null && _type.isValid()) {
          JavaStatisticsManager.incVariableNameUseCount(name, kind, _propertyName, _type);
        }
      }
    };
  }
コード例 #24
0
 @NotNull
 private DetailedLogData loadSomeCommitsOnTaggedBranches(
     @NotNull VirtualFile root, int commitCount, @NotNull Collection<String> unmatchedTags)
     throws VcsException {
   List<String> params = new ArrayList<String>();
   params.add("--max-count=" + commitCount);
   params.addAll(unmatchedTags);
   return GitHistoryUtils.loadMetadata(myProject, root, true, ArrayUtil.toStringArray(params));
 }
 public boolean validate() throws ConfigurationException {
   calcDuplicates();
   if (!duplicateNames.isEmpty()) {
     throw new ConfigurationException(
         "Duplicate names found:" + StringUtil.join(ArrayUtil.toStringArray(duplicateNames), ","),
         "Unable to proceed");
   }
   return super.validate();
 }
 {
   List<String> names = new ArrayList<String>();
   names.add(XmlBundle.message("column.name.edit.external.resource.uri"));
   names.add(XmlBundle.message("column.name.edit.external.resource.location"));
   if (myProject != null) {
     names.add("Project");
   }
   myNames = ArrayUtil.toStringArray(names);
 }
コード例 #27
0
 protected void saveRecent(String path) {
   final List<String> files = new ArrayList<String>(Arrays.asList(getRecentFiles()));
   files.remove(path);
   files.add(0, path);
   while (files.size() > 30) {
     files.remove(files.size() - 1);
   }
   PropertiesComponent.getInstance().setValues(RECENT_FILES_KEY, ArrayUtil.toStringArray(files));
 }
コード例 #28
0
 @Override
 public String[] getUrls(OrderRootType rootType) {
   final Collection<LightFilePointer> pointers = myRoots.get(rootType);
   List<String> urls = new ArrayList<String>();
   for (LightFilePointer pointer : pointers) {
     urls.add(pointer.getUrl());
   }
   return ArrayUtil.toStringArray(urls);
 }
コード例 #29
0
 @Override
 public Object[] getChildElements(Object element) {
   if (element == RootDescriptor.ROOT) {
     return ArrayUtil.toStringArray(myCertificates.keySet());
   } else if (element instanceof String) {
     return ArrayUtil.toObjectArray(myCertificates.get((String) element));
   }
   return ArrayUtil.EMPTY_OBJECT_ARRAY;
 }
コード例 #30
0
  @NotNull
  public static List<VcsCommitMetadata> loadMetadata(
      @NotNull final Project project,
      @NotNull final VirtualFile root,
      int limit,
      @NotNull List<String> parameters)
      throws VcsException {

    final VcsLogObjectsFactory factory = getObjectsFactoryWithDisposeCheck(project);
    if (factory == null) {
      return Collections.emptyList();
    }
    HgVcs hgvcs = HgVcs.getInstance(project);
    assert hgvcs != null;
    HgVersion version = hgvcs.getVersion();
    List<String> templateList = HgBaseLogParser.constructDefaultTemplate(version);
    templateList.add("{desc}");
    String[] templates = ArrayUtil.toStringArray(templateList);
    HgCommandResult result =
        getLogResult(
            project, root, version, limit, parameters, HgChangesetUtil.makeTemplate(templates));
    HgBaseLogParser<VcsCommitMetadata> baseParser =
        new HgBaseLogParser<VcsCommitMetadata>() {

          @Override
          protected VcsCommitMetadata convertDetails(
              @NotNull String rev,
              @NotNull String changeset,
              @NotNull SmartList<HgRevisionNumber> parents,
              @NotNull Date revisionDate,
              @NotNull String author,
              @NotNull String email,
              @NotNull List<String> attributes) {
            String message = parseAdditionalStringAttribute(attributes, MESSAGE_INDEX);
            int subjectIndex = message.indexOf('\n');
            String subject = subjectIndex == -1 ? message : message.substring(0, subjectIndex);
            List<Hash> parentsHash = new SmartList<Hash>();
            for (HgRevisionNumber parent : parents) {
              parentsHash.add(factory.createHash(parent.getChangeset()));
            }
            return factory.createCommitMetadata(
                factory.createHash(changeset),
                parentsHash,
                revisionDate.getTime(),
                root,
                subject,
                author,
                email,
                message,
                author,
                email,
                revisionDate.getTime());
          }
        };
    return getCommitRecords(project, result, baseParser);
  }