Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Combined pull request for several commits #54

Merged
merged 4 commits into from

2 participants

@Oblosys

Can't seem to figure out at the moment how to get these into four separate pull requests, so they're combined into one.

313830f: Shortcut for "New Haskell project" in project-explorer context menu.
Does not always seem to show up though.

796ee57: Fix: null check for delimiter.

9e6e790: Very hacky workaround for loop bug.
When a module includes itself in its export list, getDeclarationsFromFile will loop. This is a nasty hack that should not be merged as is.

1a2fa29: More information + html in type tooltip.
The type/error tooltip can now include full html, rather than just plain or bold text. Unfortunately, from what I've read it's seems pretty tricky to have the height of the tooltip depend on the rendered height of its contents, so now it is has a fixed size. Letting the tooltip size depend on the kind of information we display is also hard, since the tooltip gets its size on creation, and the information is put into it at a later time. I haven't been able to resize the tooltip after the information was set (not sure whether this is even possible without annoying flashes.)

@JPMoresmau JPMoresmau merged commit 242d00c into JPMoresmau:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
3  net.sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/types/Location.java
@@ -131,8 +131,9 @@ public Location(IProject project, String fileName, int startLin, int startCol, i
if (lineTracker != null) {
try {
//System.err.println("Initial span: "+startLine+":"+startColumn+" to "+endLine+":"+endColumn);
+ String delimiter = lineTracker.getLineDelimiter(startLine-1); // apparently this can return null
int lineLength = lineTracker.getLineLength(startLine-1 /*LineTracker is 0 based*/ )
- - lineTracker.getLineDelimiter(startLine-1).length(); // subtract the delimiter length
+ - (delimiter == null ? 0 : delimiter.length()); // subtract the delimiter length
if (startLine==endLine && startColumn==endColumn) { // span is empty
if (startColumn < lineLength) { // not past the last character, so we can extend to the right.
endColumn += 1;
View
4 net.sf.eclipsefp.haskell.ui/plugin.xml
@@ -906,6 +906,10 @@
</or>
</enablement>
</commonWizard>
+ <commonWizard type="new"
+ wizardId="net.sf.eclipsefp.haskell.ui.wizards.NewHaskellProjectWizard">
+ <enablement></enablement>
+ </commonWizard>
</extension>
<extension
point="org.eclipse.ui.ide.markerResolution">
View
47 ...psefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/editors/haskell/HaskellInformationControl.java
@@ -6,6 +6,8 @@
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.AbstractInformationControl;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.util.Geometry;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
@@ -20,9 +22,11 @@
* @author Alejandro Serrano
*
*/
-@Deprecated
public class HaskellInformationControl extends AbstractInformationControl {
+ private static final int HOVER_WIDTH = 600; // size of the tooltip for
+ private static final int HOVER_HEIGHT = 80; // type info and errors/warnings
+
private Browser doc;
private boolean hasContents = false;
@@ -40,16 +44,16 @@ public void setInformation( final String content ) {
protected void createContent( final Composite parent ) {
doc = new Browser( parent, SWT.NONE );
- //doc.setForeground( parent.getForeground() );
- //doc.setBackground( parent.getBackground() );
+ // These have no effect, so we set the colors with css.
+ // Unfortunately, the background remains white, which is sometimes visible when scrolling
doc.setForeground( parent.getDisplay().getSystemColor( SWT.COLOR_INFO_FOREGROUND ) );
- doc.setBackground( parent.getDisplay().getSystemColor( SWT.COLOR_INFO_BACKGROUND ) );
- doc.setFont( JFaceResources.getDialogFont() );
+ doc.setBackground( parent.getDisplay().getSystemColor( SWT.COLOR_YELLOW ) );
+ doc.setFont( JFaceResources.getTextFont() );
}
public void setDocumentation( final String content ) {
hasContents = content.length() > 0;
- doc.setText( content );
+ doc.setText( "<html><body style=\"background-color: #fafbc5; margin:0; padding:0; font-size: 8pt\">"+content+"<body></html>" );
}
/*
@@ -64,6 +68,7 @@ public void setVisible( final boolean visible ) {
/*
* @see IInformationControl#computeSizeHint()
*/
+ /*
@Override
public Point computeSizeHint() {
// see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=117602
@@ -75,6 +80,18 @@ public Point computeSizeHint() {
return getShell().computeSize( widthHint, SWT.DEFAULT, true );
}
+For some reason, the method above causes a very large tooltip to be generated, which is
+briefly visible before it shrinks to its normal size. Unfortunately, this doesn't happen
+on test runs, but only when the plug-in is deployed, making it extremely difficult to debug.
+The problem doesn't seem to occur in Eclipse Juno.
+
+For some other reason, everything works fine if we specify the size with computeSizeConstraints.
+*/
+ @Override
+ public Point computeSizeConstraints(final int widthInChars, final int heightInChars) {
+ return new Point(HOVER_WIDTH,HOVER_HEIGHT);
+ }
+
/*
* @see org.eclipse.jface.text.AbstractInformationControl#computeTrim()
*/
@@ -116,4 +133,22 @@ public void setFocus() {
doc.setFocus();
}
+ // Without this, the hover text disappears immediately on a mouse move.
+ /*
+ * @see org.eclipse.jface.text.IInformationControlExtension5#getInformationPresenterControlCreator()
+ * @since 3.4
+ */
+ @Override
+ public IInformationControlCreator getInformationPresenterControlCreator() {
+ return new IInformationControlCreator() {
+ /*
+ * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ public IInformationControl createInformationControl(final Shell parent) {
+ return new HaskellInformationControl(parent);
+ }
+ };
+ }
+
}
View
48 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/editors/haskell/HaskellTextHover.java
@@ -11,10 +11,10 @@
import net.sf.eclipsefp.haskell.buildwrapper.types.ThingAtPoint;
import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
import net.sf.eclipsefp.haskell.ui.internal.editors.haskell.imports.ImportsManager;
+import net.sf.eclipsefp.haskell.ui.internal.preferences.editor.IEditorPreferenceNames;
import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultInformationControl;
import org.eclipse.jface.text.DefaultTextHover;
import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
@@ -51,11 +51,11 @@ public String getHoverInfo( final ITextViewer textViewer,
final IRegion hoverRegion ) {
// TODO TtC this method does not get called when hovering over a string literal
// which leads to potential problem annotation hovers not appearing
- String hoverInfo = computeProblemInfo( textViewer, hoverRegion,fMarkerAnnotationAccess );
- if (hoverInfo != null) {
- return hoverInfo;
- }
- return computeThingAtPoint( textViewer, hoverRegion,false );
+ String hoverInfo = computeProblemInfo( textViewer, hoverRegion,fMarkerAnnotationAccess);
+ if (hoverInfo != null) {
+ return hoverInfo;
+ }
+ return computeThingAtPoint( textViewer, hoverRegion,false );
}
/* (non-Javadoc)
@@ -64,7 +64,7 @@ public String getHoverInfo( final ITextViewer textViewer,
@Override
public Object getHoverInfo2( final ITextViewer textViewer,
final IRegion hoverRegion) {
- String hoverInfo = computeProblemInfo( textViewer, hoverRegion,fMarkerAnnotationAccess );
+ String hoverInfo = computeProblemInfo( textViewer, hoverRegion,fMarkerAnnotationAccess);
if (hoverInfo != null) {
return hoverInfo;
}
@@ -80,8 +80,8 @@ public IInformationControlCreator getHoverControlCreator() {
@Override
public IInformationControl createInformationControl( final Shell parent ) {
- //return new HaskellInformationControl(parent,editor.getFont());
- return new DefaultInformationControl( parent, false );
+ return new HaskellInformationControl(parent);
+ //return new DefaultInformationControl( parent, false ); // for bold-only tooltips
}
} ;
}
@@ -100,7 +100,9 @@ public static String computeProblemInfo( final ITextViewer textViewer, final IRe
fMarkerAnnotationAccess.isSubtype( type, WARNING_ANNOTATION_TYPE )) {
Position p = annotationModel.getPosition( a );
if (p.overlapsWith( hoverRegion.getOffset(), hoverRegion.getLength() )) {
- return a.getText();
+ return "<div style='font-family: verdana; padding:2px'>" +
+ a.getText() +
+ "</div>";
}
}
}
@@ -123,26 +125,36 @@ protected String computeThingAtPoint( final ITextViewer textViewer, final IRegio
ThingAtPoint tap=f.getThingAtPoint(file,location);
if (tap!=null){
StringBuilder sb=new StringBuilder();
+
+
+ sb.append(html ? "<div style='font-family: monaco; padding:2px'>" : "");
sb.append(tap.getName());
+ String moduleColor = HaskellUIPlugin.getDefault().getPreferenceStore().getString( IEditorPreferenceNames.EDITOR_CON_COLOR );
+
if (tap.getType()!=null){
sb.append(" :: ");
+ sb.append(html ? "<b>" : "");
sb.append(tap.getType());
+ sb.append(html ? "</b>" : "");
}
- if(html){
- sb.insert( 0, "<b>" );
- sb.append( "</b>" );
+ if (tap.getModule()!=null){
+ sb.append(html ? "<br/>" : "\n");
+ sb.append(html ? "<span style='color: grey'>module:</span> <span style='color:rgb("+moduleColor+"); font-weight: bold'>" : "");
+ sb.append(tap.getModule());
+ sb.append(html ? "</span>" : "");
}
+ sb.append(html ? "</div>" : "");
ImportsManager im=editor.getImportsManager();
Documented d=im.getDeclarations().get( tap.getName() );
if (d!=null && d.getDoc()!=null && d.getDoc().length()>0){
- if(html){
- sb.append( "<br/>" );
- } else {
- sb.append("\n");
- }
+ sb.append(html ? "<hr/>" : "\n");
+ sb.append(html ? "<div style='font-family: verdana; padding:2px'>" : "");
sb.append(d.getDoc());
+ sb.append(html ? "</div>" : "");
+
}
+
return sb.toString();
}
//} finally {
View
6 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/editors/haskell/imports/AnImport.java
@@ -270,7 +270,11 @@ private void addDeclaration(final HashMap<String, FileDocumented> r, final Strin
outlineToBrowser( def,null,file,decls );
}
for (ExportDef ed:or.getExportDefs()){
- if (ed.getType().equals( ImportExportType.IEModule )){
+ if (ed.getType().equals( ImportExportType.IEModule )
+ && !file.getName().equals(ed.getName()+".hs") // Hacky workaround for bug that causes a loop when the export list contains the module itself.
+ // This hack can probably still fail in case of hi-boot import cycles,
+ // so it's better to keep track of visited modules.
+ ){
decls.addAll( getDeclarationsFromFile( ed.getName(), file.getProject() ) );
}
}
Something went wrong with that request. Please try again.