-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b4555d
commit d42ca93
Showing
27 changed files
with
1,607 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/net.sf.eclipsefp.haskell.style"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> | ||
<classpathentry kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.swt_3.7.1.v3738a.jar"/> | ||
<classpathentry kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.swt.win32.win32.x86_3.7.1.v3738a.jar"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>net.sf.eclipsefp.haskell.style.test</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
82 changes: 82 additions & 0 deletions
82
....eclipsefp.haskell.style.test/src/net/sf/eclipsefp/haskell/style/SHConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/** | ||
* Copyright (c) 2012 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.style; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import net.sf.eclipsefp.haskell.style.stylishhaskell.SHConfiguration; | ||
import net.sf.eclipsefp.haskell.style.stylishhaskell.SHImports.SHImportAlign; | ||
import net.sf.eclipsefp.haskell.style.stylishhaskell.SHPragmas.SHPragmaStyle; | ||
import net.sf.eclipsefp.haskell.style.stylishhaskell.StylishHaskell; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* Tests the Stylish Haskell configuration, especially YAML I/O | ||
* @author JP Moresmau | ||
* | ||
*/ | ||
public class SHConfigurationTest { | ||
|
||
|
||
@Test | ||
public void testDefault(){ | ||
SHConfiguration def=new SHConfiguration(); | ||
assertNull(def.getTabs()); | ||
assertNull(def.getUnicode()); | ||
assertNotNull(def.getImports()); | ||
assertEquals(SHImportAlign.GLOBAL, def.getImports().getAlign()); | ||
assertNotNull(def.getPragmas()); | ||
assertTrue(def.getPragmas().isRemoveRedundant()); | ||
assertEquals(SHPragmaStyle.VERTICAL,def.getPragmas().getStyle()); | ||
assertNotNull(def.getTrailingWhitespace()); | ||
} | ||
|
||
@Test | ||
public void testIODefault() throws IOException{ | ||
SHConfiguration def=new SHConfiguration(); | ||
InputStream is=getClass().getResourceAsStream("stylish-haskell-default.yaml"); | ||
assertNotNull(is); | ||
SHConfiguration defRead=StylishHaskell.load(is); | ||
assertEquals(def,defRead); | ||
ByteArrayOutputStream baos=new ByteArrayOutputStream(); | ||
StylishHaskell.save(defRead, baos); | ||
SHConfiguration defRead2=StylishHaskell.load(new ByteArrayInputStream(baos.toByteArray())); | ||
assertEquals(def,defRead2); | ||
} | ||
|
||
@Test | ||
public void testIOFull() throws IOException{ | ||
InputStream is=getClass().getResourceAsStream("stylish-haskell-full.yaml"); | ||
assertNotNull(is); | ||
SHConfiguration confRead=StylishHaskell.load(is); | ||
assertNotNull(confRead.getTabs()); | ||
assertEquals(4,confRead.getTabs().getSpaces()); | ||
assertNotNull(confRead.getUnicode()); | ||
assertTrue(confRead.getUnicode().isUnicodePragmas()); | ||
|
||
assertNotNull(confRead.getImports()); | ||
assertEquals(SHImportAlign.GROUP, confRead.getImports().getAlign()); | ||
assertNotNull(confRead.getPragmas()); | ||
assertFalse(confRead.getPragmas().isRemoveRedundant()); | ||
assertEquals(SHPragmaStyle.COMPACT,confRead.getPragmas().getStyle()); | ||
assertNotNull(confRead.getTrailingWhitespace()); | ||
|
||
ByteArrayOutputStream baos=new ByteArrayOutputStream(); | ||
StylishHaskell.save(confRead, baos); | ||
SHConfiguration confRead2=StylishHaskell.load(new ByteArrayInputStream(baos.toByteArray())); | ||
assertEquals(confRead,confRead2); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...ipsefp.haskell.style.test/src/net/sf/eclipsefp/haskell/style/stylish-haskell-default.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# stylish-haskell configuration file | ||
# ================================== | ||
# | ||
# The stylish-haskell tool is mainly configured by specifying steps. These steps | ||
# are a list, so they have an order, and one specific step may appear more than | ||
# once (if needed). Each file is processed by these steps in the given order. | ||
steps: | ||
# Convert some ASCII sequences to their Unicode equivalents. This is disabled | ||
# by default. | ||
# - unicode_syntax: | ||
# # In order to make this work, we also need to insert the UnicodeSyntax | ||
# # language pragma. If this flag is set to true, we insert it when it's | ||
# # not already present. You may want to disable it if you configure | ||
# # language extensions using some other method than pragmas. Default: | ||
# # true. | ||
# add_language_pragma: true | ||
|
||
# Import cleanup | ||
- imports: | ||
# There are different ways we can align names and lists. | ||
# | ||
# - global: Align the import names and import list throughout the entire | ||
# file. | ||
# | ||
# - group: Only align the imports per group (a group is formed by adjacent | ||
# import lines). | ||
# | ||
# - none: Do not perform any alignment. | ||
# | ||
# Default: global. | ||
align: global | ||
|
||
# Language pragmas | ||
- language_pragmas: | ||
# We can generate different styles of language pragma lists. | ||
# | ||
# - vertical: Vertical-spaced language pragmas, one per line. | ||
# | ||
# - compact: A more compact style. | ||
# | ||
# Default: vertical. | ||
style: vertical | ||
|
||
# stylish-haskell can detect redundancy of some language pragmas. If this | ||
# is set to true, it will remove those redundant pragmas. Default: true. | ||
remove_redundant: true | ||
|
||
# Replace tabs by spaces. This is disabled by default. | ||
# - tabs: | ||
# # Number of spaces to use for each tab. Default: 8, as specified by the | ||
# # Haskell report. | ||
# spaces: 8 | ||
|
||
# Remove trailing whitespace | ||
- trailing_whitespace: {} |
55 changes: 55 additions & 0 deletions
55
...eclipsefp.haskell.style.test/src/net/sf/eclipsefp/haskell/style/stylish-haskell-full.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# stylish-haskell configuration file | ||
# ================================== | ||
# | ||
# The stylish-haskell tool is mainly configured by specifying steps. These steps | ||
# are a list, so they have an order, and one specific step may appear more than | ||
# once (if needed). Each file is processed by these steps in the given order. | ||
steps: | ||
# Convert some ASCII sequences to their Unicode equivalents. This is disabled | ||
# by default. | ||
- unicode_syntax: | ||
# In order to make this work, we also need to insert the UnicodeSyntax | ||
# language pragma. If this flag is set to true, we insert it when it's | ||
# not already present. You may want to disable it if you configure | ||
# language extensions using some other method than pragmas. Default: | ||
# true. | ||
add_language_pragma: true | ||
|
||
# Import cleanup | ||
- imports: | ||
# There are different ways we can align names and lists. | ||
# | ||
# - global: Align the import names and import list throughout the entire | ||
# file. | ||
# | ||
# - group: Only align the imports per group (a group is formed by adjacent | ||
# import lines). | ||
# | ||
# - none: Do not perform any alignment. | ||
# | ||
# Default: global. | ||
align: group | ||
|
||
# Language pragmas | ||
- language_pragmas: | ||
# We can generate different styles of language pragma lists. | ||
# | ||
# - vertical: Vertical-spaced language pragmas, one per line. | ||
# | ||
# - compact: A more compact style. | ||
# | ||
# Default: vertical. | ||
style: compact | ||
|
||
# stylish-haskell can detect redundancy of some language pragmas. If this | ||
# is set to true, it will remove those redundant pragmas. Default: true. | ||
remove_redundant: false | ||
|
||
# Replace tabs by spaces. This is disabled by default. | ||
- tabs: | ||
# Number of spaces to use for each tab. Default: 8, as specified by the | ||
# Haskell report. | ||
spaces: 4 | ||
|
||
# Remove trailing whitespace | ||
- trailing_whitespace: {} |
66 changes: 66 additions & 0 deletions
66
...askell.style.test/src/net/sf/eclipsefp/haskell/style/ui/SHConfigurationCompositeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Copyright (c) 2012 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.style.ui; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
|
||
import net.sf.eclipsefp.haskell.style.stylishhaskell.SHConfiguration; | ||
import net.sf.eclipsefp.haskell.style.stylishhaskell.StylishHaskell; | ||
import net.sf.eclipsefp.haskell.style.stylishhaskell.ui.SHConfigurationComposite; | ||
|
||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.events.SelectionAdapter; | ||
import org.eclipse.swt.events.SelectionEvent; | ||
import org.eclipse.swt.layout.GridLayout; | ||
import org.eclipse.swt.widgets.Button; | ||
import org.eclipse.swt.widgets.Display; | ||
import org.eclipse.swt.widgets.Shell; | ||
|
||
/** | ||
* test composite | ||
* @author JP Moresmau | ||
* | ||
*/ | ||
public class SHConfigurationCompositeTest { | ||
|
||
/** | ||
* @param args | ||
*/ | ||
public static void main(String[] args) { | ||
Display display=new Display(); | ||
|
||
Shell shell=new Shell(display); | ||
shell.setLayout(new GridLayout(1,true)); | ||
final SHConfigurationComposite comp=new SHConfigurationComposite(shell, SWT.NONE); | ||
comp.setConfiguration(new SHConfiguration()); | ||
Button b=new Button(shell,SWT.PUSH); | ||
b.setText("click"); | ||
b.addSelectionListener(new SelectionAdapter() { | ||
/* (non-Javadoc) | ||
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) | ||
*/ | ||
@Override | ||
public void widgetSelected(SelectionEvent e) { | ||
SHConfiguration conf=comp.getConfiguration(); | ||
ByteArrayOutputStream baos=new ByteArrayOutputStream(); | ||
try { | ||
StylishHaskell.save(conf, baos); | ||
System.out.println(new String(baos.toByteArray())); | ||
} catch (IOException ioe){ | ||
ioe.printStackTrace(); | ||
} | ||
} | ||
}); | ||
shell.open(); | ||
while (!shell.isDisposed ()) { | ||
if (!display.readAndDispatch ()) | ||
display.sleep (); | ||
} | ||
display.dispose (); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# bundle manifest | ||
bundleVendor = The EclipseFP Project | ||
bundleName = Haskell Style and Formatting Utilities | ||
bundleName = Haskell Style and Formatting Utilities | ||
|
||
stylishHaskellPP_name=Stylish Haskell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?eclipse version="3.4"?> | ||
<plugin> | ||
<extension | ||
point="org.eclipse.ui.propertyPages"> | ||
|
||
<page | ||
name="%stylishHaskellPP_name" | ||
class="net.sf.eclipsefp.haskell.style.stylishhaskell.ui.SHConfigurationPP" | ||
id="net.sf.eclipsefp.haskell.style.stylishhaskell.ui.SHConfigurationPP"> | ||
<filter | ||
name="nature" | ||
value="net.sf.eclipsefp.haskell.core.project.HaskellNature"> | ||
</filter> | ||
<filter | ||
name="open" | ||
value="true"> | ||
</filter> | ||
<enabledWhen> | ||
<adapt type="org.eclipse.core.resources.IProject" /> | ||
</enabledWhen> | ||
</page> | ||
</extension> | ||
|
||
</plugin> |
Oops, something went wrong.