Package org.aspectj.bridge

Examples of org.aspectj.bridge.CountingMessageHandler


   * @return null if invalid configuration, corresponding AjBuildConfig otherwise
   */
  public AjBuildConfig generateAjBuildConfig() {
    File configFile = new File(compiler.getId());
    ICompilerConfiguration compilerConfig = compiler.getCompilerConfiguration();
    CountingMessageHandler handler = CountingMessageHandler.makeCountingMessageHandler(msgHandlerAdapter);

    String[] args = null;
    // Retrieve the set of files from either an arg file (@filename) or the compiler configuration
    if (configFile.exists() && configFile.isFile()) {
      args = new String[] { "@" + configFile.getAbsolutePath() };
    } else {
      List l = compilerConfig.getProjectSourceFiles();
      if (l == null) {
        return null;
      }
      List xmlfiles = compilerConfig.getProjectXmlConfigFiles();
      if (xmlfiles != null && !xmlfiles.isEmpty()) {
        args = new String[l.size() + xmlfiles.size() + 1];
        // TODO speedup
        int p = 0;
        for (int i = 0; i < l.size(); i++) {
          args[p++] = (String) l.get(i);
        }
        for (int i = 0; i < xmlfiles.size(); i++) {
          args[p++] = (String) xmlfiles.get(i);
        }
        args[p++] = "-xmlConfigured";
      } else {
        args = (String[]) l.toArray(new String[l.size()]);
      }
    }

    BuildArgParser parser = new BuildArgParser(handler);

    AjBuildConfig config = new AjBuildConfig();

    parser.populateBuildConfig(config, args, false, configFile);

    // Process the CLASSPATH
    String propcp = compilerConfig.getClasspath();
    if (propcp != null && propcp.length() != 0) {
      StringTokenizer st = new StringTokenizer(propcp, File.pathSeparator);
      List configClasspath = config.getClasspath();
      ArrayList toAdd = new ArrayList();
      while (st.hasMoreTokens()) {
        String entry = st.nextToken();
        if (!configClasspath.contains(entry)) {
          toAdd.add(entry);
        }
      }
      if (0 < toAdd.size()) {
        ArrayList both = new ArrayList(configClasspath.size() + toAdd.size());
        both.addAll(configClasspath);
        both.addAll(toAdd);
        config.setClasspath(both);
      }
    }

    // Process the OUTJAR
    if (config.getOutputJar() == null) {
      String outJar = compilerConfig.getOutJar();
      if (outJar != null && outJar.length() != 0) {
        config.setOutputJar(new File(outJar));
      }
    }

    // Process the OUTPUT LOCATION MANAGER
    IOutputLocationManager outputLocationManager = compilerConfig.getOutputLocationManager();
    if (config.getCompilationResultDestinationManager() == null && outputLocationManager != null) {
      config.setCompilationResultDestinationManager(new OutputLocationAdapter(outputLocationManager));
    }

    // Process the INPATH
    mergeInto(config.getInpath(), compilerConfig.getInpath());
    // bug 168840 - calling 'setInPath(..)' creates BinarySourceFiles which
    // are used to see if there have been changes in classes on the inpath
    if (config.getInpath() != null) {
      config.setInPath(config.getInpath());
    }

    // Process the SOURCE PATH RESOURCES
    config.setSourcePathResources(compilerConfig.getSourcePathResources());

    // Process the ASPECTPATH
    mergeInto(config.getAspectpath(), compilerConfig.getAspectPath());

    // Process the JAVA OPTIONS MAP
    Map jom = compilerConfig.getJavaOptionsMap();
    if (jom != null) {
      String version = (String) jom.get(CompilerOptions.OPTION_Compliance);
      if (version != null && (version.equals(CompilerOptions.VERSION_1_5) || version.equals(CompilerOptions.VERSION_1_6))) {
        config.setBehaveInJava5Way(true);
      }
      config.getOptions().set(jom);
    }

    // Process the NON-STANDARD COMPILER OPTIONS
    configureNonStandardOptions(config);

    compilerConfig.configurationRead();

    ISourceLocation location = null;
    if (config.getConfigFile() != null) {
      location = new SourceLocation(config.getConfigFile(), 0);
    }

    String message = parser.getOtherMessages(true);
    if (null != message) {
      IMessage m = new Message(message, IMessage.ERROR, null, location);
      handler.handleMessage(m);
    }

    // always force model generation in AJDE
    config.setGenerateModelMode(true);
    // always be in incremental mode in AJDE
View Full Code Here


    }
    String[] args = (String[]) tokens.toArray(new String[] {});

    // set the non-standard options in an alternate build config
    // (we don't want to lose the settings we already have)
    CountingMessageHandler counter = CountingMessageHandler.makeCountingMessageHandler(msgHandlerAdapter);
    AjBuildConfig altConfig = AjdtCommand.genBuildConfig(args, counter);
    if (counter.hasErrors()) {
      return;
    }
    // copy globals where local is not set
    config.installGlobals(altConfig);
  }
View Full Code Here

TOP

Related Classes of org.aspectj.bridge.CountingMessageHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.