use of org.eclipse.core.resources.IMarker in project tdi-studio-se by Talend.
the class JobErrorsChecker method checkExportErrors.
public static boolean checkExportErrors(IStructuredSelection selection, boolean isJob) {
if (!selection.isEmpty()) {
final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
Set<String> jobIds = new HashSet<String>();
List<RepositoryNode> nodes = selection.toList();
if (nodes.size() > 1) {
// in case it's a multiple export, only check the status of the latest job to export
for (RepositoryNode node : nodes) {
Item item = node.getObject().getProperty().getItem();
try {
IFile sourceFile = synchronizer.getFile(item);
if (sourceFile == null) {
return false;
}
// check the item has compile error when export job
boolean ret = false;
String message = null;
IMarker[] markers = sourceFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
for (IMarker marker : markers) {
Integer lineNr = (Integer) marker.getAttribute(IMarker.LINE_NUMBER);
message = (String) marker.getAttribute(IMarker.MESSAGE);
Integer severity = (Integer) marker.getAttribute(IMarker.SEVERITY);
Integer start = (Integer) marker.getAttribute(IMarker.CHAR_START);
Integer end = (Integer) marker.getAttribute(IMarker.CHAR_END);
if (lineNr != null && message != null && severity != null && start != null && end != null) {
switch(severity) {
case IMarker.SEVERITY_ERROR:
ret = true;
break;
default:
break;
}
}
}
if (ret) {
if (isJob) {
throw new ProcessorException(//$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_errors") + '\n' + Messages.getString("JobErrorsChecker_compile_error_content", //$NON-NLS-1$
item.getProperty().getLabel()) + '\n' + message);
} else {
throw new ProcessorException(//$NON-NLS-1$
Messages.getString("CamelJobErrorsChecker_compile_errors") + '\n' + Messages.getString("CamelJobErrorsChecker_compile_error_content", //$NON-NLS-1$
item.getProperty().getLabel()) + '\n' + message);
}
}
jobIds.add(item.getProperty().getId());
Problems.addRoutineFile(sourceFile, ProblemType.JOB, item.getProperty().getLabel(), item.getProperty().getVersion(), true);
} catch (Exception e) {
MessageBoxExceptionHandler.process(e);
return true;
}
}
} else {
// if single export (normal case), check compilation status from latest generation.
try {
checkLastGenerationHasCompilationError(true);
} catch (Exception e) {
if (CommonsPlugin.isHeadless()) {
CommonExceptionHandler.process(e);
// trace in command status.
throw new RuntimeException(e);
}
MessageBoxExceptionHandler.process(e);
return true;
}
}
for (RepositoryNode node : nodes) {
Item item = node.getObject().getProperty().getItem();
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
IProcess process = service.getProcessFromItem(item);
if (process instanceof IProcess2) {
((IProcess2) process).checkProcess();
}
}
Problems.refreshProblemTreeView();
List<Problem> errors = Problems.getProblemList().getProblemsBySeverity(ProblemStatus.ERROR);
ErrorDetailTreeBuilder builder = new ErrorDetailTreeBuilder();
List<JobErrorEntry> input = builder.createTreeInput(errors, jobIds);
try {
if (input.size() > 0) {
String label = input.get(0).getLabel();
if (isJob) {
throw new ProcessorException(//$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_errors") + '\n' + //$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_error_content", label));
} else {
throw new ProcessorException(//$NON-NLS-1$
Messages.getString("CamelJobErrorsChecker_compile_errors") + '\n' + //$NON-NLS-1$
Messages.getString("CamelJobErrorsChecker_compile_error_content", label));
}
}
} catch (Exception e) {
MessageBoxExceptionHandler.process(e);
return true;
}
}
return false;
}
use of org.eclipse.core.resources.IMarker in project tdi-studio-se by Talend.
the class JobErrorsChecker method checkRoutinesCompilationError.
private static void checkRoutinesCompilationError() throws ProcessorException {
Set<String> dependentRoutines = LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(LastGenerationInfo.getInstance().getLastMainJob().getJobId(), LastGenerationInfo.getInstance().getLastMainJob().getJobVersion());
// from Problems
List<Problem> errors = Problems.getProblemList().getProblemsBySeverity(ProblemStatus.ERROR);
for (Problem p : errors) {
if (p instanceof TalendProblem) {
TalendProblem talendProblem = (TalendProblem) p;
if (talendProblem.getType() == ProblemType.ROUTINE && dependentRoutines.contains(talendProblem.getJavaUnitName())) {
int line = talendProblem.getLineNumber();
String errorMessage = talendProblem.getDescription();
throw new ProcessorException(Messages.getString("JobErrorsChecker_routines_compile_errors", talendProblem.getJavaUnitName()) + //$NON-NLS-1$
'\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + //$NON-NLS-1$
'\n' + Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + //$NON-NLS-1$
errorMessage);
}
} else {
// for now not to check components errors when building jobs in studio/commandline
// throw new ProcessorException(Messages.getString("JobErrorsChecker_jobDesign_errors", p.getType().getTypeName(), //$NON-NLS-1$
// p.getJobInfo().getJobName(), p.getComponentName(), p.getDescription()));
}
}
// if can't find the routines problem, try to check the file directly(mainly for commandline)
try {
final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
List<IRepositoryViewObject> routinesObjects = factory.getAll(ERepositoryObjectType.ROUTINES, false);
if (routinesObjects != null) {
for (IRepositoryViewObject obj : routinesObjects) {
Property property = obj.getProperty();
if (!dependentRoutines.contains(property.getLabel())) {
continue;
}
Item routinesitem = property.getItem();
IFile routinesFile = synchronizer.getFile(routinesitem);
IMarker[] markers = routinesFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
for (IMarker marker : markers) {
Integer lineNr = (Integer) marker.getAttribute(IMarker.LINE_NUMBER);
String message = (String) marker.getAttribute(IMarker.MESSAGE);
Integer severity = (Integer) marker.getAttribute(IMarker.SEVERITY);
Integer start = (Integer) marker.getAttribute(IMarker.CHAR_START);
Integer end = (Integer) marker.getAttribute(IMarker.CHAR_END);
if (lineNr != null && message != null && severity != null && start != null && end != null) {
switch(severity) {
case IMarker.SEVERITY_ERROR:
throw new ProcessorException(//$NON-NLS-1$
Messages.getString("JobErrorsChecker_routines_compile_errors", property.getLabel()) + '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + lineNr + //$NON-NLS-1$
'\n' + Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + //$NON-NLS-1$
message);
default:
break;
}
}
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
} catch (SystemException e) {
ExceptionHandler.process(e);
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
use of org.eclipse.core.resources.IMarker in project KaiZen-OpenAPI-Editor by RepreZen.
the class JsonEditor method addMarker.
private IMarker addMarker(SwaggerError error, IFile target, IDocument document) {
IMarker marker = null;
try {
marker = target.createMarker(IMarker.PROBLEM);
marker.setAttribute(IMarker.SEVERITY, error.getLevel());
marker.setAttribute(IMarker.MESSAGE, error.getMessage());
marker.setAttribute(IMarker.LINE_NUMBER, error.getLine());
} catch (CoreException e) {
YEditLog.logException(e);
YEditLog.logger.warning("Failed to create marker for syntax error: \n" + e.toString());
}
return marker;
}
use of org.eclipse.core.resources.IMarker in project XobotOS by xamarin.
the class SharpenConversion method createProblemMarker.
protected void createProblemMarker(CompilationUnit ast, ASTNode node, String message, boolean isError) {
if (!createProblemMarkers()) {
return;
}
try {
IMarker marker = _source.getCorrespondingResource().createMarker(Sharpen.PROBLEM_MARKER);
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put(IMarker.MESSAGE, message);
if (node != null) {
attributes.put(IMarker.CHAR_START, new Integer(node.getStartPosition()));
attributes.put(IMarker.CHAR_END, new Integer(node.getStartPosition() + node.getLength()));
attributes.put(IMarker.LINE_NUMBER, ASTUtility.lineNumber(ast, node));
}
attributes.put(IMarker.TRANSIENT, Boolean.TRUE);
attributes.put(IMarker.SEVERITY, isError ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING);
marker.setAttributes(attributes);
} catch (CoreException e) {
e.printStackTrace();
}
}
use of org.eclipse.core.resources.IMarker in project XobotOS by xamarin.
the class SharpenConversion method createProblemMarker.
private void createProblemMarker(IProblem problem) {
if (!createProblemMarkers())
return;
try {
IMarker marker = _source.getCorrespondingResource().createMarker(Sharpen.PROBLEM_MARKER);
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put(IMarker.MESSAGE, problem.getMessage());
if (problem.getSourceLineNumber() > 0) {
attributes.put(IMarker.CHAR_START, new Integer(problem.getSourceStart()));
attributes.put(IMarker.CHAR_END, new Integer(problem.getSourceEnd()));
attributes.put(IMarker.LINE_NUMBER, problem.getSourceLineNumber());
}
attributes.put(IMarker.TRANSIENT, Boolean.TRUE);
attributes.put(IMarker.SEVERITY, problem.isError() ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING);
marker.setAttributes(attributes);
if (problem.isError())
_foundErrors = true;
} catch (CoreException e) {
e.printStackTrace();
}
}
Aggregations