Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

pass document to location calculation

  • Loading branch information...
commit cfbede894faa7475ee0048db6fcb4372737fc619 1 parent 1b7dd32
@JPMoresmau authored
Showing with 77 additions and 47 deletions.
  1. +1 −0  docs/releasenotes/net.sf.eclipsefp.haskell_2.5.6.txt
  2. +2 −2 net.sf.eclipsefp.haskell-feature/feature.xml
  3. +1 −1  net.sf.eclipsefp.haskell.buildwrapper/META-INF/MANIFEST.MF
  4. +17 −12 net.sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/BWFacade.java
  5. +6 −5 net.sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/JobFacade.java
  6. +12 −12 net.sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/types/Location.java
  7. +31 −8 net.sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/types/Note.java
  8. +1 −1  net.sf.eclipsefp.haskell.ghccompiler/META-INF/MANIFEST.MF
  9. +1 −1  net.sf.eclipsefp.haskell.ghccompiler/src/net/sf/eclipsefp/haskell/ghccompiler/core/GhcOutputProcessor.java
  10. +2 −2 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/editors/haskell/HaskellEditor.java
  11. +1 −1  net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/editors/haskell/imports/AnImport.java
  12. +1 −1  ...f.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/editors/haskell/imports/ImportsManager.java
  13. +1 −1  ...p.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/views/projectexplorer/HaskellResourceExtensionCP.java
View
1  docs/releasenotes/net.sf.eclipsefp.haskell_2.5.6.txt
@@ -14,6 +14,7 @@ Fixes:
Features:
- Enable task tags in Happy and Alex editors (https://sourceforge.net/p/eclipsefp/backlog/150/)
+ - More precise marker locations on errors/warnings
Internal:
View
4 net.sf.eclipsefp.haskell-feature/feature.xml
@@ -109,7 +109,7 @@ available at http://www.eclipse.org/legal/epl-v10.html.
id="net.sf.eclipsefp.haskell.ghccompiler"
download-size="0"
install-size="0"
- version="2.5.0"
+ version="2.5.6.qualifier"
unpack="false"/>
<plugin
@@ -158,7 +158,7 @@ available at http://www.eclipse.org/legal/epl-v10.html.
id="net.sf.eclipsefp.haskell.buildwrapper"
download-size="0"
install-size="0"
- version="2.5.5.qualifier"
+ version="2.5.6.qualifier"
unpack="false"/>
<plugin
View
2  net.sf.eclipsefp.haskell.buildwrapper/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %bundleName
Bundle-SymbolicName: net.sf.eclipsefp.haskell.buildwrapper;singleton:=true
-Bundle-Version: 2.5.5.qualifier
+Bundle-Version: 2.5.6.qualifier
Bundle-Activator: net.sf.eclipsefp.haskell.buildwrapper.BuildWrapperPlugin
Bundle-Vendor: %bundleVendor
Bundle-Localization: plugin
View
29 ...sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/BWFacade.java
@@ -56,6 +56,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.text.IDocument;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -258,7 +259,7 @@ public boolean parseBuildResult(JSONArray arr){
}
JSONArray notes=arr.optJSONArray(1);
- return parseNotes(notes,ress,null);
+ return parseNotes(notes,ress,null,null);
}
return true;
}
@@ -285,7 +286,7 @@ private void addEditorStanza(IFile file,List<String> command){
* @param file the file to build the temp contents
* @return the names in scope or null if the build failed
*/
- public Collection<NameDef> build1(IFile file){
+ public Collection<NameDef> build1(IFile file,IDocument d){
//BuildFlagInfo i=getBuildFlags(file);
String path=file.getProjectRelativePath().toOSString();
LinkedList<String> command=new LinkedList<String>();
@@ -305,8 +306,9 @@ private void addEditorStanza(IFile file,List<String> command){
BuildWrapperPlugin.deleteProblems(file);
JSONArray notes=arr.optJSONArray(1);
//notes.putAll(i.getNotes());
-
- parseNotes(notes,ress,null);
+ Map<IResource,IDocument> m=new HashMap<>();
+ m.put(file, d);
+ parseNotes(notes,ress,m,null);
JSONArray names=arr.optJSONArray(0);
if(names!=null){
Collection<NameDef> ret=new ArrayList<NameDef>();
@@ -339,7 +341,7 @@ private void addEditorStanza(IFile file,List<String> command){
}
}
- public Collection<NameDef> build1LongRunning(IFile file,boolean end){
+ public Collection<NameDef> build1LongRunning(IFile file,IDocument d,boolean end){
//BuildFlagInfo i=getBuildFlags(file);
//BuildWrapperPlugin.logInfo("build1LongRunning");
@@ -441,8 +443,9 @@ private void addEditorStanza(IFile file,List<String> command){
BuildWrapperPlugin.deleteProblems(file);
JSONArray notes=arr.optJSONArray(1);
//notes.putAll(i.getNotes());
-
- parseNotes(notes,ress,null);
+ Map<IResource,IDocument> m=new HashMap<>();
+ m.put(file, d);
+ parseNotes(notes,ress,m,null);
JSONArray names=arr.optJSONArray(0);
if(names!=null){
Collection<NameDef> ret=new ArrayList<NameDef>();
@@ -788,7 +791,7 @@ public boolean write(IFile file,File tgt,String contents){
return packageDB;
}
- public OutlineResult outline(IFile file){
+ public OutlineResult outline(IFile file,IDocument d){
String path=file.getProjectRelativePath().toOSString();
OutlineResult or=outlines.get(path);
@@ -827,7 +830,9 @@ public OutlineResult outline(IFile file){
JSONArray notes=arr.optJSONArray(1);
//notes.putAll(i.getNotes());
List<Note> ns=new ArrayList<Note>();
- boolean b=parseNotes(notes,null,ns);
+ Map<IResource,IDocument> m=new HashMap<>();
+ m.put(file, d);
+ boolean b=parseNotes(notes,null,m,ns);
or.setNotes(ns);
or.setBuildOK(b);
}
@@ -1112,7 +1117,7 @@ public void clean(boolean everything){
}
private boolean parseNotes(JSONArray notes){
- return parseNotes(notes,null,null);
+ return parseNotes(notes,null,null,null);
}
private boolean isOK(JSONArray notes){
@@ -1133,7 +1138,7 @@ private boolean isOK(JSONArray notes){
return true;
}
- private boolean parseNotes(JSONArray notes,Set<IResource> ress,Collection<Note> collect){
+ private boolean parseNotes(JSONArray notes,Set<IResource> ress,Map<IResource,IDocument> m,Collection<Note> collect){
boolean buildOK=true;
if (notes!=null){
try {
@@ -1176,7 +1181,7 @@ private boolean parseNotes(JSONArray notes,Set<IResource> ress,Collection<Note>
BuildWrapperPlugin.deleteProblems(res);
}
try {
- n.applyAsMarker(res);
+ n.applyAsMarker(res,m!=null?m.get(res):null);
} catch (CoreException ce){
BuildWrapperPlugin.logError(BWText.process_apply_note_error, ce);
}
View
11 ...f.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/JobFacade.java
@@ -33,6 +33,7 @@
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.osgi.util.NLS;
import org.json.JSONArray;
@@ -282,7 +283,7 @@ public void synchronize(final boolean force) {
realFacade.getSynchronizeJobQueue().addJob(getSynchronizeJob(force,true));
}
- public void outline(final IFile f,final OutlineHandler handler){
+ public void outline(final IFile f,final IDocument d,final OutlineHandler handler){
final String jobNamePrefix = NLS.bind(BWText.outline_job_name, getProject().getName());
Job buildJob = new Job (jobNamePrefix) {
@@ -290,7 +291,7 @@ public void outline(final IFile f,final OutlineHandler handler){
protected IStatus run(IProgressMonitor monitor) {
try {
monitor.beginTask(jobNamePrefix, IProgressMonitor.UNKNOWN);
- OutlineResult or=realFacade.outline(f);
+ OutlineResult or=realFacade.outline(f,d);
if(!monitor.isCanceled()){
handler.handleOutline(or);
}
@@ -312,7 +313,7 @@ protected IStatus run(IProgressMonitor monitor) {
* @param handler
* @param ndhandler
*/
- public void updateFromEditor(final IFile file,final OutlineHandler handler,final NameDefHandler ndhandler,final boolean sync1,final boolean end){
+ public void updateFromEditor(final IFile file,final IDocument d,final OutlineHandler handler,final NameDefHandler ndhandler,final boolean sync1,final boolean end){
final String jobNamePrefix = NLS.bind(BWText.editor_job_name, getProject().getName());
/*
@@ -335,13 +336,13 @@ protected IStatus run(IProgressMonitor monitor) {
}
long t1=System.currentTimeMillis();
if (handler!=null){
- OutlineResult or=realFacade.outline(file);
+ OutlineResult or=realFacade.outline(file,d);
handler.handleOutline(or); // avoid removing all outline on error
}
long t3=System.currentTimeMillis();
- Collection<NameDef> ns=realFacade.build1LongRunning(file,end);
+ Collection<NameDef> ns=realFacade.build1LongRunning(file,d,end);
long t35=System.currentTimeMillis();
if (ndhandler!=null){
ndhandler.handleNameDefs(ns);
View
24 ...ipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/types/Location.java
@@ -318,18 +318,18 @@ public IFile getIFile(IProject p){
int line= Math.min(getStartLine(),maxLines);
final Map<Object,Object> attributes=new HashMap<Object,Object>();
MarkerUtilities.setLineNumber(attributes, line);
- if (getStartLine()==getEndLine()){
- int start=getStartColumn();
- int end=getEndColumn();
- // if we have startColumn==endColumn we could take end+1
- // BUT if end goes over the document size, or start is zero, or if Eclipse feels like it, the marker is not shown on the document
- // so it's better to just show the line without more info
- if (end>start){
- MarkerUtilities.setCharStart(attributes, start);
- // exclusive
- MarkerUtilities.setCharEnd(attributes, end-1);
- }
- }
+// if (getStartLine()==getEndLine()){
+// int start=getStartColumn();
+// int end=getEndColumn();
+// // if we have startColumn==endColumn we could take end+1
+// // BUT if end goes over the document size, or start is zero, or if Eclipse feels like it, the marker is not shown on the document
+// // so it's better to just show the line without more info
+// if (end>start){
+// MarkerUtilities.setCharStart(attributes, start);
+// // exclusive
+// MarkerUtilities.setCharEnd(attributes, end-1);
+// }
+// }
return attributes;
}
View
39 ....eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/types/Note.java
@@ -8,6 +8,10 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ui.editors.text.TextFileDocumentProvider;
+import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.MarkerUtilities;
import org.json.JSONException;
import org.json.JSONObject;
@@ -67,11 +71,11 @@ public String getAdditionalInfo() {
return additionalInfo;
}
- public void applyAsMarker(IResource resource) throws CoreException {
- applyAsMarker(resource,Integer.MAX_VALUE);
+ public void applyAsMarker(IResource resource,IDocument doc) throws CoreException {
+ applyAsMarker(resource,doc,Integer.MAX_VALUE);
}
- public void applyAsMarker(IResource resource,int maxLines) throws CoreException {
+ public void applyAsMarker(IResource resource,IDocument doc,int maxLines) throws CoreException {
if (resource != null && resource.isAccessible()) {
/**
* this causes scheduling rule issues sometimes
@@ -93,12 +97,12 @@ public void applyAsMarker(IResource resource,int maxLines) throws CoreException
}
String msg= message + (additionalInfo != null ? "\n" + additionalInfo : "");
- addMarker(resource, severity, maxLines, msg);
+ addMarker(resource,doc, severity, maxLines, msg);
}
}
- private void addMarker(final IResource resource, int severity, int maxLines, String msg) throws CoreException {
+ private void addMarker(final IResource resource,IDocument doc, int severity, int maxLines, String msg) throws CoreException {
int line= Math.min(location.getStartLine(),maxLines);
int start=location.getStartColumn();
// duplicate
@@ -110,18 +114,37 @@ private void addMarker(final IResource resource, int severity, int maxLines, Str
)
return;
}
+ Map<Object,Object> attributes=null;
+ if (doc==null){
+ IDocumentProvider prov=new TextFileDocumentProvider();
+ try {
+ prov.connect( resource );
+ doc=prov.getDocument( resource );
+ try {
+ attributes=location.getMarkerProperties(doc);
+ } finally {
+ prov.disconnect( resource );
+ }
+ } catch (Exception ce){
+ BuildWrapperPlugin.log(IStatus.ERROR,ce.getLocalizedMessage(), ce );
+ }
+ } else {
+ attributes=location.getMarkerProperties(doc);
+ }
- final Map<Object,Object> attributes=location.getMarkerProperties(maxLines);
+ if (attributes==null){
+ attributes=location.getMarkerProperties(maxLines);
+ }
attributes.put(IMarker.SEVERITY, severity);
attributes.put(IMarker.MESSAGE,msg);
-
+ final Map<Object,Object> attributesf=attributes;
/**
* this locks the workspace, so fire a new thread
*/
new Thread(new Runnable(){
public void run() {
try {
- MarkerUtilities.createMarker(resource, attributes, BuildWrapperPlugin.PROBLEM_MARKER_ID);
+ MarkerUtilities.createMarker(resource, attributesf, BuildWrapperPlugin.PROBLEM_MARKER_ID);
} catch (CoreException ex){
BuildWrapperPlugin.logError(BWText.process_apply_note_error, ex);
}
View
2  net.sf.eclipsefp.haskell.ghccompiler/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-Name: %bundleName
Bundle-SymbolicName: net.sf.eclipsefp.haskell.ghccompiler;singleton:=true
-Bundle-Version: 2.5.0
+Bundle-Version: 2.5.6.qualifier
Bundle-Activator: net.sf.eclipsefp.haskell.ghccompiler.GhcCompilerPlugin
Bundle-Vendor: %bundleVendor
Bundle-Localization: plugin
View
2  ...haskell.ghccompiler/src/net/sf/eclipsefp/haskell/ghccompiler/core/GhcOutputProcessor.java
@@ -46,7 +46,7 @@ public void compiling( final String fileName, final int number, final int total
public void message( final Note note ) {
IFile file = findFile( note.getLocation().getFileName() );
try {
- note.applyAsMarker( file );
+ note.applyAsMarker( file ,null);
} catch( CoreException ex ) {
GhcCompilerPlugin.log( UITexts.error_applyMarkers, IStatus.WARNING, ex );
}
View
4 ...fp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/editors/haskell/HaskellEditor.java
@@ -504,7 +504,7 @@ public void run() {
}*/
JobFacade jf=BuildWrapperPlugin.getJobFacade( file.getProject() );
if (jf!=null){
- jf.updateFromEditor( file, null, null, true, true );
+ jf.updateFromEditor( file,getDocument(), null, null, true, true );
}
}
@@ -706,7 +706,7 @@ public void synchronize(){
needWrite=true;
}*/
//needWrite?getDocument():null
- jf.updateFromEditor( file, outlineHandler,this,false,false );
+ jf.updateFromEditor( file,getDocument(), outlineHandler,this,false,false );
/*if (!isDirty()){ // now we've written and not dirty
needWrite=false;
}*/
View
2  ...haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/editors/haskell/imports/AnImport.java
@@ -256,7 +256,7 @@ private void addDeclaration(final HashMap<String, FileDocumented> r, final Strin
if (file!=null){
BWFacade f=BuildWrapperPlugin.getFacade( file.getProject() );
if (f!=null){
- OutlineResult or=f.outline( file );
+ OutlineResult or=f.outline( file ,null);
return getDeclarationsFromOutlineResult( file, or,visited );
}
}
View
2  ...l.ui/src/net/sf/eclipsefp/haskell/ui/internal/editors/haskell/imports/ImportsManager.java
@@ -76,7 +76,7 @@ public void reset(){
if (or==null){
BWFacade f=BuildWrapperPlugin.getFacade( file.getProject() );
if (f!=null){
- or=f.outline( file );
+ or=f.outline( file ,doc);
}
}
View
2  ...et/sf/eclipsefp/haskell/ui/internal/views/projectexplorer/HaskellResourceExtensionCP.java
@@ -76,7 +76,7 @@
if( FileUtil.hasHaskellExtension( f ) && ResourceUtil.isInHaskellProject( f )) {
BWFacade si = BuildWrapperPlugin.getFacade( f.getProject() );//ScionPlugin.getScionInstance( f );
if (si != null) {
- List<OutlineDef> outlineDefs = si.outline( f ).getOutlineDefs();
+ List<OutlineDef> outlineDefs = si.outline( f,null ).getOutlineDefs();
//OutlineCP cp = new OutlineCP();
//cp.inputChanged( null, null, outlineDefs );
for( OutlineDef def : outlineDefs ) {
Please sign in to comment.
Something went wrong with that request. Please try again.