Package org.aspectj.bridge

Examples of org.aspectj.bridge.ISourceLocation


        sourceFileName = s.substring(i + 1);
      } else {
        sourceFileName = s;
      }
    }
    ISourceLocation sLoc = new SourceLocation(getBinaryFile(), sl.getLine(), sl.getEndLine(),
        ((sl.getColumn() == 0) ? ISourceLocation.NO_COLUMN : sl.getColumn()), sl.getContext(), sourceFileName);
    return sLoc;
  }
View Full Code Here


  public boolean handleMessage(IMessage message) throws AbortException {
    if (!(message.isError() || message.isWarning()))
      return sink.handleMessage(message);
    // we only care about warnings and errors here...
    ISourceLocation sLoc = message.getSourceLocation();

    // See bug 62073. We should assert that the caller pass the correct primary source location.
    // But for AJ1.2 final we will simply do less processing of the locations if that is not the
    // case (By calling sink.handleMessage()) - this ensures we don't put out bogus source context info.
    if (sLoc instanceof EclipseSourceLocation) {
      EclipseSourceLocation esLoc = (EclipseSourceLocation) sLoc;
      if (currentlyWeaving != null && esLoc.getCompilationResult() != null) {
        if (!currentlyWeaving.equals(((EclipseSourceLocation) sLoc).getCompilationResult()))
          return sink.handleMessage(message);
        // throw new RuntimeException("Primary source location must match the file we are currently processing!");
      }
    }
    // bug 128618 - want to do a similar thing as in bug 62073 above, however
    // we're not an EclipseSourceLocation we're a SourceLocation.
    if (sLoc instanceof SourceLocation) {
      SourceLocation sl = (SourceLocation) sLoc;
      if (currentlyWeaving != null && sl.getSourceFile() != null) {
        if (!String.valueOf(currentlyWeaving.getFileName()).equals(sl.getSourceFile().getAbsolutePath())) {
          return sink.handleMessage(message);
          // throw new RuntimeException("Primary source location must match the file we are currently processing!");
        }
      }
    }

    CompilationResult problemSource = currentlyWeaving;
    if (problemSource == null) {
      // must be a problem found during completeTypeBindings phase of begin to compile
      if (sLoc instanceof EclipseSourceLocation) {
        problemSource = ((EclipseSourceLocation) sLoc).getCompilationResult();
      }
      if (problemSource == null) {
        // XXX this is ok for ajc, will have to do better for AJDT in time...
        return sink.handleMessage(message);
      }
    }
    int startPos = getStartPos(sLoc, problemSource);
    int endPos = getEndPos(sLoc, problemSource);
    int severity = message.isError() ? ProblemSeverities.Error : ProblemSeverities.Warning;
    char[] filename = problemSource.fileName;
    boolean usedBinarySourceFileName = false;
    if (problemSource.isFromBinarySource()) {
      if (sLoc != null) {
        filename = sLoc.getSourceFile().getPath().toCharArray();
        usedBinarySourceFileName = true;
      }
    }
    ReferenceContext referenceContext = findReferenceContextFor(problemSource);
    CategorizedProblem problem = compiler.problemReporter.createProblem(filename, IProblem.Unclassified, new String[0],
        new String[] { message.getMessage() }, severity, startPos, endPos, sLoc != null ? sLoc.getLine() : 0,
        sLoc != null ? sLoc.getColumn() : 0);
    IProblem[] seeAlso = buildSeeAlsoProblems(problem, message.getExtraSourceLocations(), problemSource,
        usedBinarySourceFileName);
    problem.setSeeAlsoProblems(seeAlso);

    StringBuffer details = new StringBuffer();
View Full Code Here

  private IProblem[] buildSeeAlsoProblems(IProblem originalProblem, List sourceLocations, CompilationResult problemSource,
      boolean usedBinarySourceFileName) {
    List ret = new ArrayList();

    for (int i = 0; i < sourceLocations.size(); i++) {
      ISourceLocation loc = (ISourceLocation) sourceLocations.get(i);
      if (loc != null) {
        DefaultProblem dp = new DefaultProblem(loc.getSourceFile().getPath().toCharArray(), "see also", 0, new String[] {},
            ProblemSeverities.Ignore, getStartPos(loc, null), getEndPos(loc, null), loc.getLine(), loc.getColumn());
        ret.add(dp);
      } else {
        System.err.println("About to abort due to null location, dumping state:");
        System.err.println("> Original Problem=" + problemSource.toString());
        throw new RuntimeException(
View Full Code Here

    }
  }

  private static String findOrFakeUpNode(AsmManager model, ResolvedType onType) {
    IHierarchy hierarchy = model.getHierarchy();
    ISourceLocation sourceLocation = onType.getSourceLocation();
    String canonicalFilePath = model.getCanonicalFilePath(sourceLocation.getSourceFile());
    int lineNumber = sourceLocation.getLine();
    // Find the relevant source file node first
    IProgramElement node = hierarchy.findNodeForSourceFile(hierarchy.getRoot(), canonicalFilePath);
    if (node == null) {
      // Does not exist in the model - probably an inpath
      String bpath = onType.getBinaryPath();
View Full Code Here

        sourceFileName = s.substring(i + 1);
      } else {
        sourceFileName = s;
      }
    }
    ISourceLocation sLoc = new SourceLocation(getBinaryFile(aspect), sl.getLine(), sl.getEndLine(),
        ((sl.getColumn() == 0) ? ISourceLocation.NO_COLUMN : sl.getColumn()), sl.getContext(), sourceFileName);
    return sLoc;
  }
View Full Code Here

        ((sl.getColumn() == 0) ? ISourceLocation.NO_COLUMN : sl.getColumn()), sl.getContext(), sourceFileName);
    return sLoc;
  }

  private static ISourceLocation createSourceLocation(String sourcefilename, ResolvedType aspect, ISourceLocation sl) {
    ISourceLocation sLoc = new SourceLocation(getBinaryFile(aspect), sl.getLine(), sl.getEndLine(),
        ((sl.getColumn() == 0) ? ISourceLocation.NO_COLUMN : sl.getColumn()), sl.getContext(), sourcefilename);
    return sLoc;
  }
View Full Code Here

    if (!filenode.getKind().equals(IProgramElement.Kind.FILE_JAVA)) {
      return;
    }

    // create the class file node
    ISourceLocation binLocation = getBinarySourceLocation(aspect, aspect.getSourceLocation());
    String f = getBinaryFile(aspect).getName();
    IProgramElement classFileNode = new ProgramElement(model, f, IProgramElement.Kind.FILE, binLocation, 0, null, null);

    // create package ipe if one exists....
    IProgramElement root = model.getHierarchy().getRoot();
View Full Code Here

      // something stopped us making it a lazy tjp
      // can't build tjp lazily, no suitable test...
      int valid = 0;
      for (Iterator<BcelAdvice> iter = badAdvice.iterator(); iter.hasNext();) {
        BcelAdvice element = iter.next();
        ISourceLocation sLoc = element.getSourceLocation();
        if (sLoc != null && sLoc.getLine() > 0) {
          valid++;
        }
      }
      if (valid != 0) {
        ISourceLocation[] badLocs = new ISourceLocation[valid];
        int i = 0;
        for (Iterator<BcelAdvice> iter = badAdvice.iterator(); iter.hasNext();) {
          BcelAdvice element = iter.next();
          ISourceLocation sLoc = element.getSourceLocation();
          if (sLoc != null) {
            badLocs[i++] = sLoc;
          }
        }
        world.getLint().multipleAdviceStoppingLazyTjp
View Full Code Here

    for (int i = 0; i < pointcuts.length; i++) {
      ResolvedMember pointcut = pointcuts[i];
      if (pointcut instanceof ResolvedPointcutDefinition) {
        ResolvedPointcutDefinition rpcd = (ResolvedPointcutDefinition) pointcut;
        Pointcut p = rpcd.getPointcut();
        ISourceLocation sLoc = (p == null ? null : p.getSourceLocation());
        if (sLoc == null) {
          sLoc = rpcd.getSourceLocation();
        }
        ISourceLocation pointcutLocation = (sLoc == null ? null : createSourceLocation(sourcefilename, aspect, sLoc));
        ProgramElement pointcutElement = new ProgramElement(model, pointcut.getName(), IProgramElement.Kind.POINTCUT,
            pointcutLocation, pointcut.getModifiers(), NO_COMMENT, Collections.EMPTY_LIST);
        containingAspect.addChild(pointcutElement);
      }
    }
View Full Code Here

    for (int i = 0; i < children.length; i++) {
      ResolvedMember pcd = children[i];
      if (pcd instanceof ResolvedPointcutDefinition) {
        ResolvedPointcutDefinition rpcd = (ResolvedPointcutDefinition) pcd;
        Pointcut p = rpcd.getPointcut();
        ISourceLocation sLoc = (p == null ? null : p.getSourceLocation());
        if (sLoc == null) {
          sLoc = rpcd.getSourceLocation();
        }
        parent.addChild(new ProgramElement(asm, pcd.getName(), IProgramElement.Kind.POINTCUT, getBinarySourceLocation(
            aspect, sLoc), pcd.getModifiers(), null, Collections.EMPTY_LIST));
View Full Code Here

TOP

Related Classes of org.aspectj.bridge.ISourceLocation

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.