org.eclipse.jdt.core.compiler.CategorizedProblem Java Examples

The following examples show how to use org.eclipse.jdt.core.compiler.CategorizedProblem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CompilationResult.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Answer the problems (errors and warnings) encountered during compilation.
 *
 * This is not a compiler internal API - it has side-effects !
 * It is intended to be used only once all problems have been detected,
 * and makes sure the problems slot as the exact size of the number of
 * problems.
 */
public CategorizedProblem[] getProblems() {
	// Re-adjust the size of the problems if necessary.
	if (this.problems != null) {
		if (this.problemCount != this.problems.length) {
			System.arraycopy(this.problems, 0, (this.problems = new CategorizedProblem[this.problemCount]), 0, this.problemCount);
		}

		if (this.maxProblemPerUnit > 0 && this.problemCount > this.maxProblemPerUnit){
			quickPrioritize(this.problems, 0, this.problemCount - 1);
			this.problemCount = this.maxProblemPerUnit;
			System.arraycopy(this.problems, 0, (this.problems = new CategorizedProblem[this.problemCount]), 0, this.problemCount);
		}

		// Stable sort problems per source positions.
		Arrays.sort(this.problems, 0, this.problems.length, CompilationResult.PROBLEM_COMPARATOR);
		//quickSort(problems, 0, problems.length-1);
	}
	return this.problems;
}
 
Example #2
Source File: ProblemHandler.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public CategorizedProblem createProblem(
		char[] fileName,
		int problemId,
		String[] problemArguments,
		int elaborationId,
		String[] messageArguments,
		int severity,
		int problemStartPosition,
		int problemEndPosition,
		int lineNumber,
		int columnNumber) {
	return this.problemFactory.createProblem(
		fileName,
		problemId,
		problemArguments,
		elaborationId,
		messageArguments,
		severity,
		problemStartPosition,
		problemEndPosition,
		lineNumber,
		columnNumber);
}
 
Example #3
Source File: EclipseAstProblemView.java    From EasyMPermission with MIT License 6 votes vote down vote up
/**
 * Adds a problem to the provided CompilationResult object so that it will show up
 * in the Problems/Warnings view.
 */
public static void addProblemToCompilationResult(char[] fileNameArray, CompilationResult result,
		boolean isWarning, String message, int sourceStart, int sourceEnd) {
	if (result == null) return;
	if (fileNameArray == null) fileNameArray = "(unknown).java".toCharArray();
	int lineNumber = 0;
	int columnNumber = 1;
	int[] lineEnds = null;
	lineNumber = sourceStart >= 0
			? Util.getLineNumber(sourceStart, lineEnds = result.getLineSeparatorPositions(), 0, lineEnds.length-1)
			: 0;
	columnNumber = sourceStart >= 0
			? Util.searchColumnNumber(result.getLineSeparatorPositions(), lineNumber,sourceStart)
			: 0;
	
	CategorizedProblem ecProblem = new LombokProblem(
			fileNameArray, message, 0, new String[0],
			isWarning ? ProblemSeverities.Warning : ProblemSeverities.Error,
			sourceStart, sourceEnd, lineNumber, columnNumber);
	result.record(ecProblem, null);
}
 
Example #4
Source File: Compiler.java    From APDE with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void loggingExtraProblems(Main currentMain) {
	// Unknown whether or not this is actually necessary
	ArrayList<CategorizedProblem> problems = compiler.getExtraProblems();
	if (problems != null) {
		for (CategorizedProblem problem : problems) {
			handleProblem(problem);
			
			// These counters are necessary for ECJ to function properly
			if (problem.isError()) {
				currentMain.globalErrorsCount++;
			}  else {
				currentMain.globalWarningsCount++;
			}
		}
	}
}
 
Example #5
Source File: RemoteServiceValidatorTest.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
public void testDependentTypeIsNotSyncInterface() throws JavaModelException {
  JavaProjectUtilities.createCompilationUnit(javaProject,
      "com.google.TestService",
      "package com.google;\npublic interface TestService { void foo(); }\n");

  ICompilationUnit asyncInterface = JavaProjectUtilities.createCompilationUnit(
      javaProject,
      "com.google.TestServiceAsync",
      "package com.google;\nimport com.google.gwt.user.client.rpc.AsyncCallback;\npublic interface TestServiceAsync { void foo(AsyncCallback foo); }\n");

  RemoteServiceValidator rsv = new RemoteServiceValidator();
  ValidationResult validationResults;

  ASTNode asyncAst = newAST(asyncInterface);

  // Test that no errors are reported on the "Async" interface since the sync
  // interface does not extend RemoteService
  validationResults = rsv.validate(asyncAst);
  assertProblemsEqual(Collections.<CategorizedProblem> emptyList(),
      validationResults.getProblems());
  assertEquals(Arrays.asList("com.google.TestService"),
      validationResults.getTypeDependencies());
}
 
Example #6
Source File: AsynchronousInterfaceValidator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected List<CategorizedProblem> doValidateMethodOnDependentInterface(
    IMethodBinding methodBinding, TypeDeclaration changedInterface,
    ITypeBinding dependentInterfaceBinding) {
  String[] parameters = RemoteServiceUtilities.computeAsyncParameterTypes(methodBinding);
  String methodName = methodBinding.getName();
  if (Bindings.findMethodInHierarchy(changedInterface.resolveBinding(),
      methodName, parameters) == null) {
    CategorizedProblem problem = RemoteServiceProblemFactory.newMissingAsyncMethodOnAsync(
        methodBinding, changedInterface);
    if (problem != null) {
      return Collections.singletonList(problem);
    }
  }

  return Collections.emptyList();
}
 
Example #7
Source File: ReconcileWorkingCopyOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Report working copy problems to a given requestor.
 *
 * @param workingCopy
 * @param problemRequestor
 */
private void reportProblems(CompilationUnit workingCopy, IProblemRequestor problemRequestor) {
	try {
		problemRequestor.beginReporting();
		for (Iterator iteraror = this.problems.values().iterator(); iteraror.hasNext();) {
			CategorizedProblem[] categorizedProblems = (CategorizedProblem[]) iteraror.next();
			if (categorizedProblems == null) continue;
			for (int i = 0, length = categorizedProblems.length; i < length; i++) {
				CategorizedProblem problem = categorizedProblems[i];
				if (JavaModelManager.VERBOSE){
					System.out.println("PROBLEM FOUND while reconciling : " + problem.getMessage());//$NON-NLS-1$
				}
				if (this.progressMonitor != null && this.progressMonitor.isCanceled()) break;
				problemRequestor.acceptProblem(problem);
			}
		}
	} finally {
		problemRequestor.endReporting();
	}
}
 
Example #8
Source File: CompilationResult.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public void record(CategorizedProblem newProblem, ReferenceContext referenceContext, boolean mandatoryError) {
	//new Exception("VERBOSE PROBLEM REPORTING").printStackTrace();
	if(newProblem.getID() == IProblem.Task) {
		recordTask(newProblem);
		return;
	}
	if (this.problemCount == 0) {
		this.problems = new CategorizedProblem[5];
	} else if (this.problemCount == this.problems.length) {
		System.arraycopy(this.problems, 0, (this.problems = new CategorizedProblem[this.problemCount * 2]), 0, this.problemCount);
	}
	this.problems[this.problemCount++] = newProblem;
	if (referenceContext != null){
		if (this.problemsMap == null) this.problemsMap = new HashMap(5);
		if (this.firstErrors == null) this.firstErrors = new HashSet(5);
		if (newProblem.isError() && !referenceContext.hasErrors()) this.firstErrors.add(newProblem);
		this.problemsMap.put(newProblem, referenceContext);
	}
	if (newProblem.isError()) {
		this.numberOfErrors++;
		if (mandatoryError) this.hasMandatoryErrors = true;
		if ((newProblem.getID() & IProblem.Syntax) != 0) {
			this.hasSyntaxError = true;
		}
	}
}
 
Example #9
Source File: SynchronousInterfaceValidator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected List<CategorizedProblem> doValidateMethodOnDependentInterface(
    IMethodBinding dependentMethodBinding, TypeDeclaration changedInterface,
    ITypeBinding dependentTypeBinding) {
  String[] parameters = RemoteServiceUtilities.computeSyncParameterTypes(dependentMethodBinding);
  if (Bindings.findMethodInHierarchy(changedInterface.resolveBinding(),
      dependentMethodBinding.getName(), parameters) == null) {
    CategorizedProblem problem1 = RemoteServiceProblemFactory.newMissingSyncMethodOnSync(
        changedInterface, dependentMethodBinding);
    if (problem1 != null) {
      return Collections.singletonList(problem1);
    }
  }

  return Collections.emptyList();
}
 
Example #10
Source File: RequestorWrapper.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @see ICodeSnippetRequestor
 */
public void acceptProblem(CategorizedProblem problem, char[] fragmentSource, int fragmentKind) {
	try {
		IMarker marker = ResourcesPlugin.getWorkspace().getRoot().createMarker(IJavaModelMarker.TRANSIENT_PROBLEM);
		marker.setAttribute(IJavaModelMarker.ID, problem.getID());
		marker.setAttribute(IMarker.CHAR_START, problem.getSourceStart());
		marker.setAttribute(IMarker.CHAR_END, problem.getSourceEnd() + 1);
		marker.setAttribute(IMarker.LINE_NUMBER, problem.getSourceLineNumber());
		//marker.setAttribute(IMarker.LOCATION, "#" + problem.getSourceLineNumber());
		marker.setAttribute(IMarker.MESSAGE, problem.getMessage());
		marker.setAttribute(IMarker.SEVERITY, (problem.isWarning() ? IMarker.SEVERITY_WARNING : IMarker.SEVERITY_ERROR));
		marker.setAttribute(IMarker.SOURCE_ID, JavaBuilder.SOURCE_ID);
		this.requestor.acceptProblem(marker, new String(fragmentSource), fragmentKind);
	} catch (CoreException e) {
		e.printStackTrace();
	}
}
 
Example #11
Source File: Compiler.java    From APDE with GNU General Public License v2.0 6 votes vote down vote up
@Override
public int logProblems(CategorizedProblem[] problems, char[] unitSource, Main currentMain) {
	int localErrorCount = 0;
	
	for (CategorizedProblem problem : problems) {
		if (problem != null) {
			handleProblem(problem);
			
			// These counters are necessary for ECJ to function properly
			if (problem.isError()) {
				localErrorCount++;
				currentMain.globalErrorsCount++;
			} else if (problem.getID() == IProblem.Task) {
				currentMain.globalTasksCount++;
			} else {
				currentMain.globalWarningsCount++;
			}
		}
	}
	
	return localErrorCount;
}
 
Example #12
Source File: CompilationUnitDeclaration.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public boolean isSuppressed(CategorizedProblem problem) {
	if (this.suppressWarningsCount == 0) return false;
	int irritant = ProblemReporter.getIrritant(problem.getID());
	if (irritant == 0) return false;
	int start = problem.getSourceStart();
	int end = problem.getSourceEnd();
	nextSuppress: for (int iSuppress = 0, suppressCount = this.suppressWarningsCount; iSuppress < suppressCount; iSuppress++) {
		long position = this.suppressWarningScopePositions[iSuppress];
		int startSuppress = (int) (position >>> 32);
		int endSuppress = (int) position;
		if (start < startSuppress) continue nextSuppress;
		if (end > endSuppress) continue nextSuppress;
		if (this.suppressWarningIrritants[iSuppress].isSet(irritant))
			return true;
	}
	return false;
}
 
Example #13
Source File: Compiler.java    From APDE with GNU General Public License v2.0 5 votes vote down vote up
protected ArrayList<CategorizedProblem> getExtraProblems() {
	// This field might not actually be used, but I don't know for sure
	try {
		Field field = Main.class.getField("extraProblems");
		field.setAccessible(true);
		return (ArrayList<CategorizedProblem>) field.get(this);
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
Example #14
Source File: Java50Fix.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static boolean hasFatalError(CompilationUnit compilationUnit) {
	try {
		if (!((ICompilationUnit) compilationUnit.getJavaElement()).isStructureKnown())
			return true;
	} catch (JavaModelException e) {
		JavaPlugin.log(e);
		return true;
	}

	IProblem[] problems= compilationUnit.getProblems();
	for (int i= 0; i < problems.length; i++) {
		if (problems[i].isError()) {
			if (!(problems[i] instanceof CategorizedProblem))
				return true;

			CategorizedProblem categorizedProblem= (CategorizedProblem) problems[i];
			int categoryID= categorizedProblem.getCategoryID();

			if (categoryID == CategorizedProblem.CAT_BUILDPATH)
				return true;
			if (categoryID == CategorizedProblem.CAT_SYNTAX)
				return true;
			if (categoryID == CategorizedProblem.CAT_IMPORT)
				return true;
			if (categoryID == CategorizedProblem.CAT_TYPE)
				return true;
			if (categoryID == CategorizedProblem.CAT_MEMBER)
				return true;
			if (categoryID == CategorizedProblem.CAT_INTERNAL)
				return true;
		}
	}

	return false;
}
 
Example #15
Source File: CompilationResult.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void removeProblem(CategorizedProblem problem) {
	if (this.problemsMap != null) this.problemsMap.remove(problem);
	if (this.firstErrors != null) this.firstErrors.remove(problem);
	if (problem.isError()) {
		this.numberOfErrors--;
	}
	this.problemCount--;
}
 
Example #16
Source File: ValidationResult.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public void addProblem(CategorizedProblem problem) {
  if (problem == null) {
    // This occurs when the problem creation method returns null because the
    // problem's severity is Ignore.
    return;
  }
  problems.add(problem);
}
 
Example #17
Source File: AbstractPairedInterfaceValidator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public List<CategorizedProblem> validate(TypeDeclaration changedInterface,
    ITypeBinding dependentTypeBinding) {
  CompilationUnit compilationUnit = getCompilationUnit(changedInterface);
  if (JavaASTUtils.hasErrors(changedInterface, compilationUnit.getProblems())) {
    /*
     * Don't validate any type that already has errors (we are assuming that
     * it has JDT errors.
     */
    return Collections.emptyList();
  }

  if (dependentTypeBinding == null) {
    return doMissingDependentInterface(changedInterface);
  }

  // Check that for every method on the changed interface, there is a
  // corresponding method on the dependent interface
  List<CategorizedProblem> problems = new ArrayList<CategorizedProblem>();
  for (MethodDeclaration methodDeclaration : changedInterface.getMethods()) {
    List<CategorizedProblem> methodProblems = doValidateMethodOnChangedType(
        methodDeclaration, dependentTypeBinding);
    problems.addAll(methodProblems);
  }

  List<ITypeBinding> superTypeBindings = new ArrayList<ITypeBinding>();
  RemoteServiceUtilities.expandSuperInterfaces(dependentTypeBinding,
      superTypeBindings);

  for (ITypeBinding typeBinding : superTypeBindings) {
    for (IMethodBinding methodBinding : typeBinding.getDeclaredMethods()) {
      List<CategorizedProblem> dependentMethodProblems = doValidateMethodOnDependentInterface(
          methodBinding, changedInterface, typeBinding);
      problems.addAll(dependentMethodProblems);
    }
  }

  return problems;
}
 
Example #18
Source File: CompilationResult.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Answer the tasks (TO-DO, ...) encountered during compilation.
 *
 * This is not a compiler internal API - it has side-effects !
 * It is intended to be used only once all problems have been detected,
 * and makes sure the problems slot as the exact size of the number of
 * problems.
 */
public CategorizedProblem[] getTasks() {
	// Re-adjust the size of the tasks if necessary.
	if (this.tasks != null) {

		if (this.taskCount != this.tasks.length) {
			System.arraycopy(this.tasks, 0, (this.tasks = new CategorizedProblem[this.taskCount]), 0, this.taskCount);
		}
		// Stable sort problems per source positions.
		Arrays.sort(this.tasks, 0, this.tasks.length, CompilationResult.PROBLEM_COMPARATOR);
		//quickSort(tasks, 0, tasks.length-1);
	}
	return this.tasks;
}
 
Example #19
Source File: SynchronousInterfaceValidator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected List<CategorizedProblem> doMissingDependentInterface(
    TypeDeclaration changedInterface) {
  ValidationSuppressionVisitor warningSuppressionVisitor = new ValidationSuppressionVisitor();

  /*
   * BodyDeclaration.modifiers returns a raw type, which can only be an
   * instance of IExtendedModifier. IExtendedModifier is only implemented by
   * the Annotation and Modifier ASTNode subtypes.
   */
  @SuppressWarnings("unchecked")
  List<ASTNode> modifiers = changedInterface.modifiers();
  for (ASTNode modifier : modifiers) {
    modifier.accept(warningSuppressionVisitor);
  }

  if (warningSuppressionVisitor.shouldSuppressValidation()) {
    return Collections.emptyList();
  }

  CategorizedProblem problem = RemoteServiceProblemFactory.newMissingAsyncType(changedInterface);
  if (problem != null) {
    return Collections.singletonList(problem);
  }

  return Collections.emptyList();
}
 
Example #20
Source File: RemoteServiceValidatorTest.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private void assertProblemsEqual(List<? extends CategorizedProblem> expected,
    List<? extends CategorizedProblem> actual) {
  if (expected.size() == actual.size()) {
    for (int i = 0, n = expected.size(); i < n; ++i) {
      if (!equals(expected.get(i), actual.get(i))) {
        failNotEquals(null, expected, actual);
      }
    }
  }
}
 
Example #21
Source File: GroovyCompilationOnScriptExpressionConstraint.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private IStatus evaluateExpression(final IValidationContext context, final EObject eObj) {
    final Expression expression = (Expression) eObj;
    final String scriptText = expression.getContent();
    if (scriptText == null || scriptText.isEmpty()) {
        return context.createSuccessStatus();
    }
    final IJavaProject javaProject = RepositoryManager.getInstance().getCurrentRepository().getJavaProject();
    final GroovySnippetCompiler compiler = new GroovySnippetCompiler((JavaProject) javaProject);
    final CompilationResult result = compiler.compileForErrors(scriptText, null);
    final CategorizedProblem[] problems = result.getErrors();
    if (problems != null && problems.length > 0) {
        final StringBuilder sb = new StringBuilder();
        for (final CategorizedProblem problem : problems) {
            sb.append(problem.getMessage());
            sb.append(", ");
        }
        if (sb.length() > 1) {
            sb.delete(sb.length() - 2, sb.length());
            return context.createFailureStatus(new Object[] { Messages.bind(Messages.groovyCompilationProblem, expression.getName(), sb.toString()) });
        }
    }
    final ModuleNode moduleNode = compiler.compile(scriptText, null);
    final BlockStatement statementBlock = moduleNode.getStatementBlock();
    final ValidationCodeVisitorSupport validationCodeVisitorSupport = new ValidationCodeVisitorSupport(context, expression, moduleNode);
    statementBlock.visit(validationCodeVisitorSupport);
    return validationCodeVisitorSupport.getStatus();
}
 
Example #22
Source File: CompilationResult.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Answer the errors encountered during compilation.
 */
public CategorizedProblem[] getErrors() {
	CategorizedProblem[] reportedProblems = getProblems();
	int errorCount = 0;
	for (int i = 0; i < this.problemCount; i++) {
		if (reportedProblems[i].isError()) errorCount++;
	}
	if (errorCount == this.problemCount) return reportedProblems;
	CategorizedProblem[] errors = new CategorizedProblem[errorCount];
	int index = 0;
	for (int i = 0; i < this.problemCount; i++) {
		if (reportedProblems[i].isError()) errors[index++] = reportedProblems[i];
	}
	return errors;
}
 
Example #23
Source File: IProblemFactory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
CategorizedProblem createProblem(
char[] originatingFileName,
int problemId,
String[] problemArguments,
String[] messageArguments, // shorter versions of the problemArguments
int severity,
int startPosition,
int endPosition,
int lineNumber,
int columnNumber);
 
Example #24
Source File: CompilationUnitDeclaration.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void abort(int abortLevel, CategorizedProblem problem) {
	switch (abortLevel) {
		case AbortType :
			throw new AbortType(this.compilationResult, problem);
		case AbortMethod :
			throw new AbortMethod(this.compilationResult, problem);
		default :
			throw new AbortCompilationUnit(this.compilationResult, problem);
	}
}
 
Example #25
Source File: LambdaExpression.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void abort(int abortLevel, CategorizedProblem problem) {

	switch (abortLevel) {
		case AbortCompilation :
			throw new AbortCompilation(this.compilationResult, problem);
		case AbortCompilationUnit :
			throw new AbortCompilationUnit(this.compilationResult, problem);
		case AbortType :
			throw new AbortType(this.compilationResult, problem);
		default :
			throw new AbortMethod(this.compilationResult, problem);
	}
}
 
Example #26
Source File: CodeSnippetParsingUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private RecordedParsingInformation getRecordedParsingInformation(CompilationResult compilationResult, int[][] commentPositions) {
	int problemsCount = compilationResult.problemCount;
	CategorizedProblem[] problems = null;
	if (problemsCount != 0) {
		final CategorizedProblem[] compilationResultProblems = compilationResult.problems;
		if (compilationResultProblems.length == problemsCount) {
			problems = compilationResultProblems;
		} else {
			System.arraycopy(compilationResultProblems, 0, (problems = new CategorizedProblem[problemsCount]), 0, problemsCount);
		}
	}
	return new RecordedParsingInformation(problems, compilationResult.getLineSeparatorPositions(), commentPositions);
}
 
Example #27
Source File: Main.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param problem
 *            the given problem to log
 * @param unitSource
 *            the given unit source
 */
private void logXmlTask(CategorizedProblem problem, char[] unitSource) {
	this.parameters.put(Logger.PROBLEM_LINE, new Integer(problem.getSourceLineNumber()));
	this.parameters.put(Logger.PROBLEM_SOURCE_START, new Integer(problem.getSourceStart()));
	this.parameters.put(Logger.PROBLEM_SOURCE_END, new Integer(problem.getSourceEnd()));
	String problemOptionKey = getProblemOptionKey(problem.getID());
	if (problemOptionKey != null) {
		this.parameters.put(Logger.PROBLEM_OPTION_KEY, problemOptionKey);
	}
	printTag(Logger.TASK, this.parameters, true, false);
	this.parameters.put(Logger.VALUE, problem.getMessage());
	printTag(Logger.PROBLEM_MESSAGE, this.parameters, true, true);
	extractContext(problem, unitSource);
	endTag(Logger.TASK);
}
 
Example #28
Source File: Main.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param problem
 *            the given problem to log
 * @param unitSource
 *            the given unit source
 */
private void logXmlProblem(CategorizedProblem problem, char[] unitSource) {
	final int sourceStart = problem.getSourceStart();
	final int sourceEnd = problem.getSourceEnd();
	final int id = problem.getID();
	this.parameters.put(Logger.ID, getFieldName(id)); // ID as field name
	this.parameters.put(Logger.PROBLEM_ID, new Integer(id)); // ID as numeric value
	boolean isError = problem.isError();
	int severity = isError ? ProblemSeverities.Error : ProblemSeverities.Warning;
	this.parameters.put(Logger.PROBLEM_SEVERITY, isError ? Logger.ERROR : Logger.WARNING);
	this.parameters.put(Logger.PROBLEM_LINE, new Integer(problem.getSourceLineNumber()));
	this.parameters.put(Logger.PROBLEM_SOURCE_START, new Integer(sourceStart));
	this.parameters.put(Logger.PROBLEM_SOURCE_END, new Integer(sourceEnd));
	String problemOptionKey = getProblemOptionKey(id);
	if (problemOptionKey != null) {
		this.parameters.put(Logger.PROBLEM_OPTION_KEY, problemOptionKey);
	}
	int categoryID = ProblemReporter.getProblemCategory(severity, id);
	this.parameters.put(Logger.PROBLEM_CATEGORY_ID, new Integer(categoryID));
	printTag(Logger.PROBLEM_TAG, this.parameters, true, false);
	this.parameters.put(Logger.VALUE, problem.getMessage());
	printTag(Logger.PROBLEM_MESSAGE, this.parameters, true, true);
	extractContext(problem, unitSource);
	String[] arguments = problem.getArguments();
	final int length = arguments.length;
	if (length != 0) {
		printTag(Logger.PROBLEM_ARGUMENTS, null, true, false);
		for (int i = 0; i < length; i++) {
			this.parameters.put(Logger.PROBLEM_ARGUMENT_VALUE, arguments[i]);
			printTag(Logger.PROBLEM_ARGUMENT, this.parameters, true, true);
		}
		endTag(Logger.PROBLEM_ARGUMENTS);
	}
	endTag(Logger.PROBLEM_TAG);
}
 
Example #29
Source File: Main.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void logXmlExtraProblem(CategorizedProblem problem, int globalErrorCount, int localErrorCount) {
	final int sourceStart = problem.getSourceStart();
	final int sourceEnd = problem.getSourceEnd();
	boolean isError = problem.isError();
	this.parameters.put(Logger.PROBLEM_SEVERITY, isError ? Logger.ERROR : Logger.WARNING);
	this.parameters.put(Logger.PROBLEM_LINE, new Integer(problem.getSourceLineNumber()));
	this.parameters.put(Logger.PROBLEM_SOURCE_START, new Integer(sourceStart));
	this.parameters.put(Logger.PROBLEM_SOURCE_END, new Integer(sourceEnd));
	printTag(Logger.EXTRA_PROBLEM_TAG, this.parameters, true, false);
	this.parameters.put(Logger.VALUE, problem.getMessage());
	printTag(Logger.PROBLEM_MESSAGE, this.parameters, true, true);
	extractContext(problem, null);
	endTag(Logger.EXTRA_PROBLEM_TAG);
}
 
Example #30
Source File: EvaluationResult.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds the given problem to the list of problems of this evaluation result.
 */
void addProblem(CategorizedProblem problem) {
	CategorizedProblem[] existingProblems = this.problems;
	int existingLength = existingProblems.length;
	this.problems = new CategorizedProblem[existingLength + 1];
	System.arraycopy(existingProblems, 0, this.problems, 0, existingLength);
	this.problems[existingLength] = problem;
}