Logo Search packages:      
Sourcecode: aspectj version File versions  Download package

boolean org::aspectj::ajdt::internal::compiler::WeaverMessageHandler::handleMessage ( IMessage  message  )  throws AbortException [inline]

Handle message, by reporting and/or throwing an AbortException.

Parameters:
message the IMessage to handle - never null
Returns:
true if this message was handled by this handler
Exceptions:
IllegalArgumentException if message is null
AbortException depending on handler logic.

Implements org::aspectj::bridge::IMessageHandler.

Definition at line 57 of file WeaverMessageHandler.java.

References org::aspectj::bridge::ISourceLocation::getSourceFile(), org::aspectj::bridge::SourceLocation::getSourceFile(), and org::aspectj::bridge::IMessageHandler::handleMessage().

                                                                           {
            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();
            // Stick more info in supplementary message info
            if (message.getDetails() != null) {
                  details.append(message.getDetails());
            }
            // Remember if this message was due to a deow
            if (message.getDeclared()) {
                  details.append("[deow=true]");
            }
            if (message instanceof LintMessage) {
                  String lintMessageName = ((LintMessage) message).getLintKind();
                  details.append("[Xlint:").append(lintMessageName).append("]");
            }
            if (details.length() != 0) {
                  problem.setSupplementaryMessageInfo(details.toString());
            }
            compiler.problemReporter.record(problem, problemSource, referenceContext);
            return true;
      }


Generated by  Doxygen 1.6.0   Back to index