Package org.aspectj.bridge

Examples of org.aspectj.bridge.IMessage


  // IMessage msg = MessageUtil.warn(msgString, getSourceLocation());
  // weaver.getWorld().getMessageHandler().handleMessage(msg);
  // }

  private void signalError(String msgString, BcelClassWeaver weaver) {
    IMessage msg = MessageUtil.error(msgString, getSourceLocation());
    weaver.getWorld().getMessageHandler().handleMessage(msg);
  }
View Full Code Here


                // check for "just quit -- message printed already"
                if (((AbortException)t).isSilent()) {
                    t = null;
                    break;
                }
                IMessage m = ((AbortException) t).getIMessage();
                if (null == m) {
                    break;
                } else {
                    Throwable tt = m.getThrown();
                    if (null != tt) {
                        t = tt;  
                    } else {
                        break;
                    }
View Full Code Here

            NewConstructorTypeMunger nctm = (NewConstructorTypeMunger) element.getMunger();
            itdMatch = declA.matches(nctm.getSignature(), world);
          }
        }
        if (!itdMatch) {
          IMessage message = null;
          if (isDeclareAtField) {
            message = new Message("The field '" + declA.getSignaturePattern().toString() + "' does not exist",
                declA.getSourceLocation(), true);
          } else {
            message = new Message("The method '" + declA.getSignaturePattern().toString() + "' does not exist",
View Full Code Here

  private boolean openOutputStream(File outJar) {
    try {
      OutputStream os = FileUtil.makeOutputStream(buildConfig.getOutputJar());
      zos = new JarOutputStream(os, getWeaver().getManifest(true));
    } catch (IOException ex) {
      IMessage message = new Message("Unable to open outjar " + outJar.getPath() + "(" + ex.getMessage() + ")",
          new SourceLocation(outJar, 0), true);
      handler.handleMessage(message);
      return false;
    }
    return true;
View Full Code Here

          buildConfig.getCompilationResultDestinationManager().reportFileRemove(outJar.getPath(),
              CompilationResultDestinationManager.FILETYPE_OUTJAR);
        }
      }
    } catch (IOException ex) {
      IMessage message = new Message("Unable to write outjar " + outJar.getPath() + "(" + ex.getMessage() + ")",
          new SourceLocation(outJar, 0), true);
      handler.handleMessage(message);
    }
  }
View Full Code Here

   * @param srcloc the src of the directory entry, for use when creating a warning message
   * @throws IOException if something goes wrong creating the new zip entry
   */
  private void writeDirectory(String directory, File srcloc) throws IOException {
    if (state.hasResource(directory)) {
      IMessage msg = new Message("duplicate resource: '" + directory + "'", IMessage.WARNING, null, new SourceLocation(
          srcloc, 0));
      handler.handleMessage(msg);
      return;
    }
    if (zos != null) {
View Full Code Here

    // Nothing to do if not writing to a zip file
  }

  private void writeResource(String filename, byte[] content, File srcLocation) throws IOException {
    if (state.hasResource(filename)) {
      IMessage msg = new Message("duplicate resource: '" + filename + "'", IMessage.WARNING, null, new SourceLocation(
          srcLocation, 0));
      handler.handleMessage(msg);
      return;
    }
    if (filename.equals(buildConfig.getOutxmlName())) {
      ignoreOutxml = true;
      IMessage msg = new Message("-outxml/-outxmlfile option ignored because resource already exists: '" + filename + "'",
          IMessage.WARNING, null, new SourceLocation(srcLocation, 0));
      handler.handleMessage(msg);
    }
    if (zos != null) {
      ZipEntry newEntry = new ZipEntry(filename); // ??? get compression scheme right
      zos.putNextEntry(newEntry);
      zos.write(content);
      zos.closeEntry();
    } else {
      File destDir = buildConfig.getOutputDir();
      if (buildConfig.getCompilationResultDestinationManager() != null) {
        destDir = buildConfig.getCompilationResultDestinationManager().getOutputLocationForResource(srcLocation);
      }
      try {
        File outputLocation = new File(destDir, filename);
        OutputStream fos = FileUtil.makeOutputStream(outputLocation);
        fos.write(content);
        fos.close();
        if (buildConfig.getCompilationResultDestinationManager() != null) {
          buildConfig.getCompilationResultDestinationManager().reportFileWrite(outputLocation.getPath(),
              CompilationResultDestinationManager.FILETYPE_RESOURCE);
        }
      } catch (FileNotFoundException fnfe) {
        IMessage msg = new Message("unable to copy resource to output folder: '" + filename + "' - reason: "
            + fnfe.getMessage(), IMessage.ERROR, null, new SourceLocation(srcLocation, 0));
        handler.handleMessage(msg);
      }
    }
    state.recordResource(filename, srcLocation);
View Full Code Here

    }

    for (Iterator i = buildConfig.getAspectpath().iterator(); i.hasNext();) {
      File f = (File) i.next();
      if (!f.exists()) {
        IMessage message = new Message("invalid aspectpath entry: " + f.getName(), null, true);
        handler.handleMessage(message);
      } else {
        bcelWeaver.addLibraryJarFile(f);
      }
    }

    // String lintMode = buildConfig.getLintMode();

    File outputDir = buildConfig.getOutputDir();
    if (outputDir == null && buildConfig.getCompilationResultDestinationManager() != null) {
      // send all output from injars and inpath to the default output location
      // (will also later send the manifest there too)
      outputDir = buildConfig.getCompilationResultDestinationManager().getDefaultOutputLocation();
    }
    // ??? incremental issues
    for (File inJar : buildConfig.getInJars()) {
      List<UnwovenClassFile> unwovenClasses = bcelWeaver.addJarFile(inJar, outputDir, false);
      state.recordBinarySource(inJar.getPath(), unwovenClasses);
    }

    for (File inPathElement : buildConfig.getInpath()) {
      if (!inPathElement.isDirectory()) {
        // its a jar file on the inpath
        // the weaver method can actually handle dirs, but we don't call it, see next block
        List<UnwovenClassFile> unwovenClasses = bcelWeaver.addJarFile(inPathElement, outputDir, true);
        state.recordBinarySource(inPathElement.getPath(), unwovenClasses);
      } else {
        // add each class file in an in-dir individually, this gives us the best error reporting
        // (they are like 'source' files then), and enables a cleaner incremental treatment of
        // class file changes in indirs.
        File[] binSrcs = FileUtil.listFiles(inPathElement, binarySourceFilter);
        for (int j = 0; j < binSrcs.length; j++) {
          UnwovenClassFile ucf = bcelWeaver.addClassFile(binSrcs[j], inPathElement, outputDir);
          List<UnwovenClassFile> ucfl = new ArrayList<UnwovenClassFile>();
          ucfl.add(ucf);
          state.recordBinarySource(binSrcs[j].getPath(), ucfl);
        }
      }
    }

    bcelWeaver.setReweavableMode(buildConfig.isXNotReweavable());

    // check for org.aspectj.runtime.JoinPoint
    ResolvedType joinPoint = bcelWorld.resolve("org.aspectj.lang.JoinPoint");
    if (joinPoint.isMissing()) {
      IMessage message = new Message(
          "classpath error: unable to find org.aspectj.lang.JoinPoint (check that aspectjrt.jar is in your classpath)",
          null, true);
      handler.handleMessage(message);
    }
  }
View Full Code Here

              }
              if (shouldAddAspectName && !classname.endsWith("$ajcMightHaveAspect")) {
                addAspectName(classname, unitResult.getFileName());
              }
            } catch (IOException ex) {
              IMessage message = EclipseAdapterUtils.makeErrorMessage(new String(unitResult.fileName),
                  CANT_WRITE_RESULT, ex);
              handler.handleMessage(message);
            }

          }
          state.noteNewResult(unitResult);
          unitResult.compiledTypes.clear(); // free up references to AjClassFile instances
        }

        if (unitResult.hasProblems() || unitResult.hasTasks()) {
          IProblem[] problems = unitResult.getAllProblems();
          for (int i = 0; i < problems.length; i++) {
            IMessage message = EclipseAdapterUtils.makeMessage(unitResult.compilationUnit, problems[i], getBcelWorld(),
                progressListener);
            handler.handleMessage(message);
          }
        }

      }

      private String writeDirectoryEntry(CompilationResult unitResult, ClassFile classFile, String filename)
          throws IOException {
        File destinationPath = buildConfig.getOutputDir();
        if (buildConfig.getCompilationResultDestinationManager() != null) {
          destinationPath = buildConfig.getCompilationResultDestinationManager().getOutputLocationForClass(
              new File(new String(unitResult.fileName)));
        }
        String outFile;
        if (destinationPath == null) {
          outFile = new File(filename).getName();
          outFile = new File(extractDestinationPathFromSourceFile(unitResult), outFile).getPath();
        } else {
          outFile = new File(destinationPath, filename).getPath();
        }

        try {
          BufferedOutputStream os = FileUtil.makeOutputStream(new File(outFile));
          os.write(classFile.getBytes());
          os.close();
        } catch (FileNotFoundException fnfe) {
          IMessage msg = new Message("unable to write out class file: '" + filename + "' - reason: " + fnfe.getMessage(),
              IMessage.ERROR, null, new SourceLocation(new File(outFile), 0));
          handler.handleMessage(msg);
        }

        if (buildConfig.getCompilationResultDestinationManager() != null) {
View Full Code Here

    forCompiler.lookupEnvironment = le;

    forCompiler.parser = new Parser(pr, forCompiler.options.parseLiteralExpressionsAsConstants);
    if (getBcelWorld().shouldPipelineCompilation()) {
      IMessage message = MessageUtil.info("Pipelining compilation");
      handler.handleMessage(message);
      return new AjPipeliningCompilerAdapter(forCompiler, batchCompile, getBcelWorld(), getWeaver(), factory,
          getInterimResultRequestor(), progressListener,
          this, // IOutputFilenameProvider
          this, // IBinarySourceProvider
View Full Code Here

TOP

Related Classes of org.aspectj.bridge.IMessage

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.