use of org.eclipse.core.resources.IMarker in project ow by vtst.
the class ErrorManagerGeneratingProblemMarkers method println.
@Override
public void println(CheckLevel level, JSError error) {
IResource file = getResource(error.sourceName);
if (file == null)
return;
try {
IMarker marker = file.createMarker(getMarkerType());
marker.setAttribute(IMarker.SEVERITY, checkLevelToSeverity(level));
marker.setAttribute(IMarker.MESSAGE, error.description);
marker.setAttribute(IMarker.LINE_NUMBER, error.lineNumber);
marker.setAttribute(IMarker.LOCATION, error.sourceName);
// error.getCharno() for the char number in the line
} catch (CoreException e) {
e.printStackTrace();
}
}
use of org.eclipse.core.resources.IMarker in project KaiZen-OpenAPI-Editor by RepreZen.
the class JsonQuickAssistProcessor method computeQuickAssistProposals.
@Override
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
List<IMarker> markers;
try {
markers = getMarkersFor(invocationContext.getSourceViewer(), invocationContext.getOffset());
} catch (BadLocationException e) {
errorMessage = e.getMessage();
return new ICompletionProposal[0];
}
List<ICompletionProposal> result = Lists.newArrayList();
for (IMarker marker : markers) {
for (IMarkerResolution markerResolution : quickFixer.getResolutions(marker)) {
result.add(new MarkerResolutionProposal(marker, markerResolution, invocationContext.getSourceViewer()));
}
}
return result.toArray(new ICompletionProposal[0]);
}
use of org.eclipse.core.resources.IMarker in project tdi-studio-se by Talend.
the class Problems method addRoutineFile.
/**
*
* ggu Comment method "addRoutineFile".
*
*
*/
public static List<Information> addRoutineFile(IFile file, ProblemType type, String label, String version, boolean... fromJob) {
if (file == null || !file.exists()) {
return Collections.emptyList();
}
String uniName = null;
List<Information> informations = new ArrayList<Information>();
try {
IMarker[] markers = file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
Problems.clearAllComliationError(label);
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) {
Information information = PropertiesFactory.eINSTANCE.createInformation();
information.setText(message);
informations.add(information);
ProblemStatus status = null;
switch(severity) {
case IMarker.SEVERITY_ERROR:
status = ProblemStatus.ERROR;
information.setLevel(InformationLevel.ERROR_LITERAL);
IPath location = file.getLocation();
if (location != null) {
String path = location.toString();
uniName = setErrorMark(path, lineNr);
}
break;
case IMarker.SEVERITY_WARNING:
status = ProblemStatus.WARNING;
information.setLevel(InformationLevel.WARN_LITERAL);
break;
case IMarker.SEVERITY_INFO:
status = ProblemStatus.INFO;
information.setLevel(InformationLevel.INFO_LITERAL);
break;
default:
break;
}
if (status != null) {
if (status != ProblemStatus.ERROR) {
continue;
}
if ("".equals(uniName) || uniName == null) {
//$NON-NLS-1$
//$NON-NLS-1$
uniName = "uniName";
}
add(status, marker, label, message, lineNr, uniName, start, end, type, version);
}
}
}
if (fromJob.length > 0 && fromJob[0]) {
addErrorMark();
}
} catch (org.eclipse.core.runtime.CoreException e) {
ExceptionHandler.process(e);
}
return informations;
}
use of org.eclipse.core.resources.IMarker in project tdi-studio-se by Talend.
the class Problems method addJobRoutineFile.
public static List<Information> addJobRoutineFile(IFile file, ProblemType type, Item item, boolean... fromJob) {
if (file == null || !file.exists()) {
return Collections.emptyList();
}
String uniName = null;
List<Information> informations = new ArrayList<Information>();
try {
Set<IMarker> fullMarker = new HashSet<IMarker>();
IMarker[] markers = file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
if (markers != null) {
fullMarker.addAll(Arrays.asList(markers));
}
// remove old
Problems.clearAllComliationError(item.getProperty().getLabel());
for (IMarker marker : fullMarker) {
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) {
Information information = PropertiesFactory.eINSTANCE.createInformation();
information.setText(message);
informations.add(information);
ProblemStatus status = null;
switch(severity) {
case IMarker.SEVERITY_ERROR:
status = ProblemStatus.ERROR;
information.setLevel(InformationLevel.ERROR_LITERAL);
IPath location = file.getLocation();
if (location != null) {
String path = location.toString();
uniName = setErrorMark(path, lineNr);
}
break;
case IMarker.SEVERITY_WARNING:
status = ProblemStatus.WARNING;
information.setLevel(InformationLevel.WARN_LITERAL);
break;
case IMarker.SEVERITY_INFO:
status = ProblemStatus.INFO;
information.setLevel(InformationLevel.INFO_LITERAL);
break;
default:
break;
}
if (status != null) {
if (status != ProblemStatus.ERROR) {
continue;
}
if ("".equals(uniName) || uniName == null) {
//$NON-NLS-1$
//$NON-NLS-1$
uniName = "uniName";
}
add(status, marker, item, message, lineNr, uniName, start, end, type);
}
}
}
// TalendProcessJavaProject.buildModules for buildWholeCodeProject (about line 324)
if (!buildWholeProject) {
addAll(computeCompilationUnit(file, type, item));
}
if (fromJob.length > 0 && fromJob[0]) {
addErrorMark();
}
} catch (org.eclipse.core.runtime.CoreException e) {
ExceptionHandler.process(e);
}
return informations;
}
use of org.eclipse.core.resources.IMarker in project tdi-studio-se by Talend.
the class JobErrorsChecker method checkLastGenerationHasCompilationError.
public static void checkLastGenerationHasCompilationError(boolean updateProblemsView) throws ProcessorException {
if (updateProblemsView && CommonsPlugin.isHeadless()) {
updateProblemsView = false;
}
boolean hasError = false;
boolean isJob = true;
Item item = null;
final IProxyRepositoryFactory proxyRepositoryFactory = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
Integer line = null;
String errorMessage = null;
try {
for (JobInfo jobInfo : LastGenerationInfo.getInstance().getLastGeneratedjobs()) {
if (jobInfo.isTestContainer()) {
continue;
}
item = null;
List<IRepositoryViewObject> allVersions = proxyRepositoryFactory.getAllVersion(jobInfo.getJobId());
for (IRepositoryViewObject repositoryObject2 : allVersions) {
Property property2 = repositoryObject2.getProperty();
if (jobInfo.getJobVersion().equals(property2.getVersion())) {
item = property2.getItem();
break;
}
}
if (item == null) {
continue;
}
IFile file = synchronizer.getFile(item);
if (file == null) {
return;
}
// check other java files related to the job . example : spark job will generate several java file for
// one job
final IResource[] members = file.getParent().members();
for (IResource member : members) {
if (member instanceof IFile && "java".equals(member.getFileExtension())) {
IMarker[] markers = ((IFile) member).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:
hasError = true;
line = lineNr;
errorMessage = message;
break;
default:
break;
}
}
}
}
}
if (updateProblemsView) {
Problems.addRoutineFile(file, ProblemType.JOB, item.getProperty().getLabel(), item.getProperty().getVersion(), true);
}
if (hasError) {
break;
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
if (hasError && item != null) {
if (isJob) {
throw new ProcessorException(//$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_errors") + " " + '\n' + Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) + //$NON-NLS-1$
'\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + //$NON-NLS-1$
'\n' + Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage + //$NON-NLS-1$
'\n' + //$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_error_jvmmessage"));
} else {
throw new ProcessorException(//$NON-NLS-1$
Messages.getString("CamelJobErrorsChecker_compile_errors") + " " + '\n' + Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) + //$NON-NLS-1$
'\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + //$NON-NLS-1$
'\n' + Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage + //$NON-NLS-1$
'\n' + //$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_error_jvmmessage"));
}
}
// if no error for job, check codes.
checkRoutinesCompilationError();
}
Aggregations