use of org.eclipse.core.resources.IMarker in project applause by applause.
the class ApplauseBuilderParticipant method build.
public void build(final IBuildContext context, IProgressMonitor monitor) throws CoreException {
if (!isEnabled(context)) {
return;
}
final List<IResourceDescription.Delta> deltas = getRelevantDeltas(context);
if (deltas.isEmpty()) {
return;
}
final int numberOfDeltas = deltas.size();
// monitor handling
if (monitor.isCanceled())
throw new OperationCanceledException();
SubMonitor subMonitor = SubMonitor.convert(monitor, numberOfDeltas + 3);
ApplauseEclipseResourceFileSystemAccess2 access = fileSystemAccessProvider.get();
final IProject builtProject = context.getBuiltProject();
access.setProject(builtProject);
final Map<String, OutputConfiguration> outputConfigurations = getOutputConfigurations(context);
refreshOutputFolders(context, outputConfigurations, subMonitor.newChild(1));
access.setOutputConfigurations(outputConfigurations);
if (context.getBuildType() == BuildType.CLEAN || context.getBuildType() == BuildType.RECOVERY) {
SubMonitor cleanMonitor = SubMonitor.convert(subMonitor.newChild(1), outputConfigurations.size());
for (OutputConfiguration config : outputConfigurations.values()) {
cleanOutput(context, config, cleanMonitor.newChild(1));
}
if (context.getBuildType() == BuildType.CLEAN)
return;
}
Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers = getGeneratorMarkers(builtProject, outputConfigurations.values());
for (int i = 0; i < numberOfDeltas; i++) {
final IResourceDescription.Delta delta = deltas.get(i);
// monitor handling
if (subMonitor.isCanceled())
throw new OperationCanceledException();
subMonitor.subTask("Compiling " + delta.getUri().lastSegment() + " (" + i + " of " + numberOfDeltas + ")");
access.setMonitor(subMonitor.newChild(1));
final String uri = delta.getUri().toString();
final Set<IFile> derivedResources = newLinkedHashSet();
for (OutputConfiguration config : outputConfigurations.values()) {
if (config.isCleanUpDerivedResources()) {
Iterable<IMarker> markers = generatorMarkers.get(config);
for (IMarker marker : markers) {
String source = derivedResourceMarkers.getSource(marker);
if (source != null && source.equals(uri))
derivedResources.add((IFile) marker.getResource());
}
}
}
access.setPostProcessor(new ApplauseEclipseResourceFileSystemAccess2.IFileCallback() {
public boolean beforeFileDeletion(IFile file) {
derivedResources.remove(file);
context.needRebuild();
return true;
}
public void afterFileUpdate(IFile file) {
handleFileAccess(file);
}
public void afterFileCreation(IFile file) {
handleFileAccess(file);
}
protected void handleFileAccess(IFile file) {
try {
derivedResources.remove(file);
derivedResourceMarkers.installMarker(file, uri);
context.needRebuild();
} catch (CoreException e) {
throw new RuntimeException(e);
}
}
});
if (delta.getNew() != null) {
try {
handleChangedContents(delta, context, access);
} catch (OperationCanceledException e) {
throw e;
} catch (Exception e) {
logger.error("Error during compilation of '" + delta.getUri() + "'.", e);
}
}
access.flushSourceTraces();
SubMonitor deleteMonitor = SubMonitor.convert(subMonitor.newChild(1), derivedResources.size());
for (IFile iFile : newLinkedHashSet(derivedResources)) {
IMarker marker = derivedResourceMarkers.findDerivedResourceMarker(iFile, uri);
if (marker != null)
marker.delete();
if (derivedResourceMarkers.findDerivedResourceMarkers(iFile).length == 0) {
access.deleteFile(iFile, deleteMonitor);
context.needRebuild();
}
}
}
}
use of org.eclipse.core.resources.IMarker in project bndtools by bndtools.
the class ProjectBuildPage method loadMarkers.
private void loadMarkers(IMarker[] markers) {
for (IMarker marker : markers) {
int severity = marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
String message = marker.getAttribute(IMarker.MESSAGE, "");
messageSeverityMap.put(message, severity);
generateFixes(message, marker);
problemSeverity = Math.max(problemSeverity, severity);
}
}
use of org.eclipse.core.resources.IMarker in project bndtools by bndtools.
the class BndMarkerAnnotationHover method getHoverInfo.
public String getHoverInfo(ISourceViewer sourceViewer, int lineNum) {
@SuppressWarnings("rawtypes") Iterator iter = sourceViewer.getAnnotationModel().getAnnotationIterator();
while (iter.hasNext()) {
Object annotation = iter.next();
if (annotation instanceof MarkerAnnotation) {
IMarker marker = ((MarkerAnnotation) annotation).getMarker();
int markerLine = marker.getAttribute(IMarker.LINE_NUMBER, 0);
// Hover line is zero-based and marker line is one-based. FML.
if (markerLine == lineNum + 1) {
return marker.getAttribute(IMarker.MESSAGE, null);
}
}
}
return null;
}
use of org.eclipse.core.resources.IMarker in project bndtools by bndtools.
the class PackageInfoBaselineQuickFixProcessor method getCorrections.
@Override
public IJavaCompletionProposal[] getCorrections(IInvocationContext context, IProblemLocation[] locations) throws CoreException {
ICompilationUnit compUnit = context.getCompilationUnit();
IResource resource = compUnit.getResource();
IMarker[] markers = resource.findMarkers(BndtoolsConstants.MARKER_JAVA_BASELINE, false, 1);
for (IProblemLocation location : locations) {
for (IMarker marker : markers) {
int markerStart = marker.getAttribute(IMarker.CHAR_START, -1);
int markerEnd = marker.getAttribute(IMarker.CHAR_END, -1);
int markerLength = markerEnd - markerStart;
if (location.getOffset() <= markerStart && markerStart < location.getOffset() + location.getLength()) {
String newVersion = marker.getAttribute("suggestedVersion", null);
if (newVersion != null) {
StringBuilder quotedVersion = new StringBuilder(newVersion.trim());
if (quotedVersion.charAt(0) != '"')
quotedVersion.insert(0, '"');
if (quotedVersion.charAt(quotedVersion.length() - 1) != '"')
quotedVersion.append('"');
CompilationUnitChange change = new CompilationUnitChange("Change package-info.java", compUnit);
change.setEdit(new ReplaceEdit(markerStart, markerLength, quotedVersion.toString()));
return new IJavaCompletionProposal[] { new ChangeCorrectionProposal("Change package version to " + newVersion, change, 1000) };
}
}
}
}
return null;
}
use of org.eclipse.core.resources.IMarker in project bndtools by bndtools.
the class PackageInfoEditor method updateTitleIcon.
void updateTitleIcon() {
IResource resource = ResourceUtil.getResource(getEditorInput());
if (resource == null)
return;
int severity = IMarker.SEVERITY_INFO;
try {
IMarker[] markers = resource.findMarkers(BndtoolsConstants.MARKER_BND_PROBLEM, true, 0);
if (markers != null) {
for (IMarker marker : markers) severity = Math.max(severity, marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO));
}
} catch (CoreException e) {
LOGGER.logError("Error updating packageinfo editor title icon", e);
}
if (severity >= IMarker.SEVERITY_ERROR) {
titleImage = imgTitleError;
} else if (severity >= IMarker.SEVERITY_WARNING) {
titleImage = imgTitleWarning;
} else {
titleImage = imgTitleBase;
}
firePropertyChange(PROP_TITLE);
}
Aggregations