Permalink
Browse files

remove constructor when removing type

  • Loading branch information...
1 parent 3185e41 commit ba4f8f6bb0b97bd3f583140de3716a1ffcb8563b @JPMoresmau committed Dec 29, 2012
@@ -11,6 +11,7 @@ Necessary Haskell packages:
Fixes:
- Viewing a package in the browser from the Cabal Packages view the first time could cause a NullPointerException
+ - Removing via quick fix an unused type in import list did not remove constructors
Features:
- Cabal Packages view shows a green tick on installed packages and versions when you display the list of all hackage packages.
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Haskell UI Test Plug-in
Bundle-SymbolicName: net.sf.eclipsefp.haskell.ui.test
-Bundle-Version: 2.4.0
+Bundle-Version: 2.4.3
Bundle-Vendor: eclipsefp.sourceforge.net
Require-Bundle: org.junit4,
org.easymock;bundle-version="[2.2.0,3.0.0)",
@@ -50,6 +50,19 @@ public void testRemoveSimple(){
}
@Test
+ public void testRemoveConstructor(){
+ TestDocument td=new TestDocument( "module TestSimpleRemove where"+PlatformUtil.NL+"import Data.Sequence (Seq(..), singleton, empty)"+PlatformUtil.NL );
+ Location loc=new Location( "TestSimpleRemove.hs",2,0,2,44);
+ ImportDef def=new ImportDef( "Data.Sequence", loc, false, false, null );
+ AnImport ai=new AnImport( def, false );
+ CompletionProposal cp=ai.removeItem( td, "Seq" , "remove" );
+ assertNotNull( cp );
+ cp.apply( td );
+ assertEquals("module TestSimpleRemove where"+PlatformUtil.NL+"import Data.Sequence (singleton, empty)"+PlatformUtil.NL,td.get());
+
+ }
+
+ @Test
public void testRemoveLast(){
TestDocument td=new TestDocument( "module TestSimpleRemove where"+PlatformUtil.NL+"import Data.Sequence (Seq)"+PlatformUtil.NL );
Location loc=new Location( "TestSimpleRemove.hs",2,0,2,26);
@@ -482,6 +482,16 @@ public CompletionProposal removeItem(final IDocument doc, final Collection<Strin
} else {
ix--; // remove preceding comma if we're at end
}
+ } else if (newContents.charAt( end )=='('){ // remove constructor list
+ while (end<newContents.length() && newContents.charAt( end )!=')'){
+ end++;
+ }
+ if (newContents.charAt( end )==')'){
+ end++;
+ }
+ trimmed=trimRemovedImport( newContents, thisItemIx, ix, end );
+ ix=trimmed[0];
+ end=trimmed[1];
}
newContents=newContents.substring( 0,ix )+newContents.substring( end );

0 comments on commit ba4f8f6

Please sign in to comment.