Skip to content

Commit

Permalink
Parse missing type message properly, fixes #166
Browse files Browse the repository at this point in the history
  • Loading branch information
JPMoresmau committed Mar 15, 2014
1 parent 2d97599 commit 0fdca2e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/releasenotes/net.sf.eclipsefp.haskell_2.6.0.txt
Expand Up @@ -17,6 +17,7 @@ Fixes:
- Do not make popups too small (https://sourceforge.net/p/eclipsefp/discussion/371922/thread/2eec0c41/?limit=25#b636)
- LINE Pragmas that do not start the line are handled correctly (https://github.com/JPMoresmau/eclipsefp/issues/161)
- Support Arrow syntax (https://github.com/JPMoresmau/BuildWrapper/issues/23)
- Quick Fix on unknown Type (https://github.com/JPMoresmau/eclipsefp/issues/166)

Features:
- Support benchmark stanzas in cabal files (https://github.com/JPMoresmau/eclipsefp/issues/109)
Expand Down
@@ -1,3 +1,8 @@
/**
* Copyright (c) 2011 by JP Moresmau
* This code is made available under the terms of the Eclipse Public License,
* version 1.0 (EPL). See http://www.eclipse.org/legal/epl-v10.html
*/
package net.sf.eclipsefp.haskell.buildwrapper.types;

/**
Expand Down Expand Up @@ -58,7 +63,8 @@ public interface GhcMessages {
public static String NAKED="naked expression at top level";
public static String INPUT_CASE="parse error on input `case'";

//-fno-warn-unused-do-bind
public static String TYPE_OR_CLASS="type constructor or class";



}
Expand Up @@ -79,5 +79,17 @@ public void testNone(){
assertNull(s.getOutOfScopeQualifier());
}

@Test
public void testType(){
String msg="Not in scope: type constructor or class `Array'";
String msgL=msg.toLowerCase(Locale.ENGLISH);
int ix=msgL.indexOf( GhcMessages.NOT_IN_SCOPE_START);
assertTrue(ix>-1);
ResolutionSuggestion s=new ResolutionSuggestion( msg, ix,msgL );
assertNull(s.getSuggestions());
assertEquals("Array",s.getOutOfScope());
assertEquals("Array",s.getOutOfScopeName());
assertNull(s.getOutOfScopeQualifier());

}
}
Expand Up @@ -7,6 +7,7 @@

import java.util.List;
import java.util.Locale;
import net.sf.eclipsefp.haskell.buildwrapper.types.GhcMessages;

/**
* Encapsulate parsing out of scope messages
Expand Down Expand Up @@ -46,6 +47,10 @@ public ResolutionSuggestion(final String msg,final int ix,String msgL){
}
int end =msgL.length();
outOfScope = msg.substring( start + 1, end ).trim();
// type or class is specified
if (outOfScope.startsWith( GhcMessages.TYPE_OR_CLASS )){
outOfScope=outOfScope.substring( GhcMessages.TYPE_OR_CLASS.length() ).trim();
}
if (outOfScope.startsWith( "`" ) && outOfScope.endsWith( "'" )){
outOfScope=outOfScope.substring( 1,outOfScope.length()-1 );
}
Expand Down

0 comments on commit 0fdca2e

Please sign in to comment.