diff --git a/org.nix.editor/.classpath b/org.nix.editor/.classpath index 02302d3..05aeb7e 100644 --- a/org.nix.editor/.classpath +++ b/org.nix.editor/.classpath @@ -1,9 +1,8 @@ - - + - - + + - + - \ No newline at end of file + diff --git a/org.nix.editor/.externalToolBuilders/Nix build.main.xml.launch b/org.nix.editor/.externalToolBuilders/Nix build.main.xml.launch index f2639a8..c5b51af 100644 --- a/org.nix.editor/.externalToolBuilders/Nix build.main.xml.launch +++ b/org.nix.editor/.externalToolBuilders/Nix build.main.xml.launch @@ -2,25 +2,20 @@ - - - - - - - + + - + - + - + diff --git a/org.nix.editor/.externalToolBuilders/Nix clean-project.xml.launch b/org.nix.editor/.externalToolBuilders/Nix clean-project.xml.launch new file mode 100644 index 0000000..82481b8 --- /dev/null +++ b/org.nix.editor/.externalToolBuilders/Nix clean-project.xml.launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/org.nix.editor/.gitignore b/org.nix.editor/.gitignore new file mode 100644 index 0000000..0ea3117 --- /dev/null +++ b/org.nix.editor/.gitignore @@ -0,0 +1,27 @@ +bin +.cache +include/Nix.def +include/Nix-parenthesize.str +include/Nix-Permissive.def +include/Nix.generated.pp.af +include/Nix.packed.esv +include/Nix.pp.af +include/Nix.rtg +include/Nix.str +include/Nix.tbl +include/nix.rtree +include/nix.ctree +include/nix.ctree.dep +include/nix.jar +include/nix-java.jar +editor/java/trans +editor/*.generated.* +syntax/Nix*.generated.esv +syntax/Nix.generated.pp +syntax/*.sdf +trans/*.pp.generated.str +.settings/org.eclipse.jdt.core.prefs +utils +lib/runtime +lib/*.generated.str +lib-refactoring/*.generated.str diff --git a/org.nix.editor/.project b/org.nix.editor/.project index 613f11d..c027138 100644 --- a/org.nix.editor/.project +++ b/org.nix.editor/.project @@ -1,37 +1,46 @@ - - + - Nix - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/Nix build.main.xml.launch - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - \ No newline at end of file + org.nix.editor + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/Nix build.main.xml.launch + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + clean, + + + LaunchConfigHandle + <project>/.externalToolBuilders/Nix clean-project.xml.launch + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/org.nix.editor/test/COPYING b/org.nix.editor/COPYING similarity index 100% rename from org.nix.editor/test/COPYING rename to org.nix.editor/COPYING diff --git a/org.nix.editor/META-INF/MANIFEST.MF b/org.nix.editor/META-INF/MANIFEST.MF index 0758183..0b8126e 100644 --- a/org.nix.editor/META-INF/MANIFEST.MF +++ b/org.nix.editor/META-INF/MANIFEST.MF @@ -1,23 +1,22 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Nix Plug-in -Bundle-SymbolicName: org.nix.editor;singleton:=true -Bundle-Version: 1.0.3.qualifier -Bundle-Activator: Nix.Activator -Import-Package: org.osgi.framework;version="1.3.0", - org.strategoxt.lang +Bundle-SymbolicName: org.nix.editor; singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: org.nix.editor.Activator +Import-Package: org.osgi.framework;version="1.3.0" Require-Bundle: org.eclipse.core.runtime, - org.eclipse.core.resources, - org.eclipse.imp.runtime, - org.eclipse.ui, - lpg.runtime, - org.eclipse.jface.text, - org.eclipse.ui.editors, - org.eclipse.ui.workbench.texteditor, - org.strategoxt.imp.runtime, - org.spoofax.aterm, - org.spoofax.jsglr, - org.spoofax.interpreter.core, - org.strategoxt.strj -Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Export-Package: Nix + org.eclipse.core.resources, + org.eclipse.imp.runtime, + org.eclipse.ui, + lpg.runtime, + org.eclipse.jface.text, + org.eclipse.ui.editors, + org.eclipse.ui.workbench.texteditor, + org.strategoxt.imp.runtime, + org.spoofax.jsglr, + org.strategoxt.strj +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Bundle-ActivationPolicy: lazy +Export-Package: org.nix.editor +Eclipse-RegisterBuddy: org.strategoxt.imp.runtime diff --git a/org.nix.editor/build.generated.xml b/org.nix.editor/build.generated.xml index bb96cdf..b5f8591 100644 --- a/org.nix.editor/build.generated.xml +++ b/org.nix.editor/build.generated.xml @@ -1,437 +1,774 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + diff --git a/org.nix.editor/build.main.xml b/org.nix.editor/build.main.xml index fd16010..7eaa3b1 100644 --- a/org.nix.editor/build.main.xml +++ b/org.nix.editor/build.main.xml @@ -1,41 +1,45 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + + + - - - \ No newline at end of file + + + + + + + + + + + + + + diff --git a/org.nix.editor/build.properties b/org.nix.editor/build.properties index c5e3389..9079268 100644 --- a/org.nix.editor/build.properties +++ b/org.nix.editor/build.properties @@ -1,8 +1,10 @@ source.. = editor/java/ output.. = bin/ bin.includes = META-INF/,\ - .,\ plugin.xml,\ include/,\ bin/,\ - . + lib/,\ + .,\ + icons/ +bin.excludes = trans/ diff --git a/org.nix.editor/editor/Nix-Builders.esv b/org.nix.editor/editor/Nix-Builders.esv deleted file mode 100644 index 0dc7f86..0000000 --- a/org.nix.editor/editor/Nix-Builders.esv +++ /dev/null @@ -1,17 +0,0 @@ - -module Nix-Builders - -imports Nix-Builders.generated - -builders - - observer : editor-analyze - - provider : include/nix.jar - - builder : "Show abstract syntax" = generate-aterm (openeditor) (realtime) (meta) - builder : "Show decorated abstract syntax" = generate-decorated-ast (openeditor) (realtime) (meta) - builder : "Create missing file" = generate-missing-file (openeditor) (cursor) - builder : "Build attribute" = build-attribute (cursor) - builder : "Build top-level" = build-top-level (cursor) - \ No newline at end of file diff --git a/org.nix.editor/editor/Nix-Builders.generated.esv b/org.nix.editor/editor/Nix-Builders.generated.esv deleted file mode 100644 index e00d843..0000000 --- a/org.nix.editor/editor/Nix-Builders.generated.esv +++ /dev/null @@ -1,40 +0,0 @@ - -module Nix-Builders.generated - -builders - - // Building and analysis is defined in Stratego program or programs: - // - // provider : stratego-program.ctree - // provider : stratego-library.jar - // - // Analysis is carried out by a Stratego rule that can be selected as follows: - // - // observer : analysis-rule - // - // Any dynamic rules set in the analysis may be used by other semantic services, - // such as reference resolving or the builders. - // - // Builders may carry out custom transformations on a file or selection. - // (At run-time, they can be accessed using the toolbar button with the star icon.) - // Builders can be specified as follows: - // - // builder : "Generate Java code" = generate-java (openeditor) (persistent) (realtime) - // - // In this example, the caption "Generate Java code" is used in the build button dropdown menu, - // and the generate-java rule is used to carry out the tranformation. - // Builder definitions can also specify any combination of the following annotations: - // - // (cursor) The builder should always transform the tree node at the cursor. - // (meta) Indicates the builder should only be available to meta-programmers - // (i.e., not when the plugin is deployed to end-users). - // (openeditor) Indicates an editor should be opened with the result. - // (persistent) Indicates that the resulting file should be saved to disk. - // (realtime) Indicates that the resulting editor should be updated in real-time - // as the source file is edited. - // (source) Always apply this builder to the source AST, not to the AST - // after it has been analyzed/desugared by the observer. - // - // The 'on save' handler can be used to generate code as files are saved: - // - // on save : generate-java \ No newline at end of file diff --git a/org.nix.editor/editor/Nix-Colorer.esv b/org.nix.editor/editor/Nix-Colorer.esv index 4d9b0ca..f3cb5c2 100644 --- a/org.nix.editor/editor/Nix-Colorer.esv +++ b/org.nix.editor/editor/Nix-Colorer.esv @@ -3,8 +3,7 @@ module Nix-Colorer imports Nix-Colorer.generated colorer - + _.Arg : _ italic _.ArgDefault : _ italic - _.ArgEllipses : _ italic - \ No newline at end of file + _.ArgEllipsis : _ italic \ No newline at end of file diff --git a/org.nix.editor/editor/Nix-Colorer.generated.esv b/org.nix.editor/editor/Nix-Colorer.generated.esv index eeba986..5885f0e 100644 --- a/org.nix.editor/editor/Nix-Colorer.generated.esv +++ b/org.nix.editor/editor/Nix-Colorer.generated.esv @@ -23,7 +23,7 @@ colorer Default, token-based highlighting number : darkgreen var : 255 0 100 italic operator : 0 0 128 - layout : 100 100 0 italic + layout : 63 127 95 italic colorer System colors diff --git a/org.nix.editor/editor/Nix-Completions.esv b/org.nix.editor/editor/Nix-Completions.esv index 67e969f..6c22d0a 100644 --- a/org.nix.editor/editor/Nix-Completions.esv +++ b/org.nix.editor/editor/Nix-Completions.esv @@ -3,10 +3,14 @@ module Nix-Completions imports Nix-Completions.generated completions - completion proposer : editor-complete + // Semantic (identifier) completion: + + completion proposer : editor-complete + + //completion trigger : "." completion template : "import " completion template : "inherit (" ") " ";" completion template : "inherit " ";" completion template : "fetchurl {\n\turl = " ";\n\tsha256sum = \"\";\n};" - // completion template : " = import " " {\n\t\n};" + // completion template : " = import " " {\n\t\n};" \ No newline at end of file diff --git a/org.nix.editor/editor/Nix-Completions.generated.esv b/org.nix.editor/editor/Nix-Completions.generated.esv index 7cbc153..3a8cf0f 100644 --- a/org.nix.editor/editor/Nix-Completions.generated.esv +++ b/org.nix.editor/editor/Nix-Completions.generated.esv @@ -17,12 +17,17 @@ completions // // completion template: "section " "\n\t" (blank) // - // Finally, you can specify a specific SDF sort for which a completion + // You can specify a specific SDF sort for which a completion // rule should trigger as follows: // - // completion template : Section = + // completion template Section : // "section " <title> "\n\t" (blank) // + // Finally, you can override the prefix of the completion: + // + // completion template Statement : "assignment" = + // <x> " = " <y> (blank) + // // Semantic content completion can be defined as follows: // // completion proposer : completion-function-call diff --git a/org.nix.editor/editor/Nix-Folding.esv b/org.nix.editor/editor/Nix-Folding.esv index d36e5fe..8bcd6be 100644 --- a/org.nix.editor/editor/Nix-Folding.esv +++ b/org.nix.editor/editor/Nix-Folding.esv @@ -3,12 +3,7 @@ module Nix-Folding imports Nix-Folding.generated folding - - // This file can be used for custom folding rules. - // - // See the imported file for a brief introduction and examples. - + _.List _.AttributeSet - _.RecAttributeSet - \ No newline at end of file + _.RecAttributeSet \ No newline at end of file diff --git a/org.nix.editor/editor/Nix-Menus.esv b/org.nix.editor/editor/Nix-Menus.esv new file mode 100644 index 0000000..9b6c6f6 --- /dev/null +++ b/org.nix.editor/editor/Nix-Menus.esv @@ -0,0 +1,35 @@ +module Nix-Menus + +menus + + menu: "Syntax" (openeditor) + + action: "Format" = editor-format (realtime) (source) + action: "Show abstract syntax" = debug-show-aterm (realtime) (meta) (source) + action: "Show analyzed syntax" = debug-show-analyzed (meta) + + menu: "Analysis" (meta) + + action: "Reset and reanalyze" = debug-reanalyze + + submenu: "Show analysis" (openeditor) + action: "Project" = debug-project + action: "Partition" = debug-partition + end + + submenu: "Show index" (openeditor) + action: "Project" = debug-index-project + action: "Project (resolved)" = debug-index-project-resolve + action: "Partition" = debug-index-partition + end + + submenu: "Show tasks" (openeditor) + action: "Project" = debug-task-project + action: "Partition" = debug-task-partition + action: "Selection" = debug-task-selection + end + + menu: "Generation" (openeditor) (realtime) + + action: "Generate Java" = generate-java + diff --git a/org.nix.editor/editor/Nix-Outliner.esv b/org.nix.editor/editor/Nix-Outliner.esv deleted file mode 100644 index fc07990..0000000 --- a/org.nix.editor/editor/Nix-Outliner.esv +++ /dev/null @@ -1,9 +0,0 @@ -module Nix-Outliner - -imports Nix-Outliner.generated - -outliner - - // This file can be used for custom outliner rules. - // - // See the imported file for a brief introduction and examples. \ No newline at end of file diff --git a/org.nix.editor/editor/Nix-Outliner.generated.esv b/org.nix.editor/editor/Nix-Outliner.generated.esv deleted file mode 100644 index bdb249f..0000000 --- a/org.nix.editor/editor/Nix-Outliner.generated.esv +++ /dev/null @@ -1,18 +0,0 @@ -module Nix-Outliner.generated - -outliner Default outliner - - - // Outliner rules indicate which syntactic constructs should be shown in the outline - // and quick outline views, and take one of the following forms: - // - // <sort>.<constructor> - // - // <sort>._ - // - // _.<constructor> - - Bind.Bind - Bind.InheritFrom - Expr.Function - Expr.Function \ No newline at end of file diff --git a/org.nix.editor/editor/Nix-Outliner.str b/org.nix.editor/editor/Nix-Outliner.str new file mode 100644 index 0000000..4bc5e9c --- /dev/null +++ b/org.nix.editor/editor/Nix-Outliner.str @@ -0,0 +1,13 @@ +module editor/Nix-Outliner + +imports + + include/Nix + lib/runtime/editor/outline-library + lib/runtime/editor/origins + editor/Nix-Outliner.generated + +rules + + to-outline-label = fail + diff --git a/org.nix.editor/editor/Nix-Refactorings.esv b/org.nix.editor/editor/Nix-Refactorings.esv new file mode 100644 index 0000000..4fe3324 --- /dev/null +++ b/org.nix.editor/editor/Nix-Refactorings.esv @@ -0,0 +1,24 @@ +module Nix-Refactorings + +imports Nix-Refactorings.generated + +refactorings + + + + // This file can be used for specification of refactorings. + + // + + // See the imported file for a brief introduction and examples. + +refactorings + + + + pretty-print : pp-nix-string + + refactoring ID : "Rename Entity" = rename-refactoring (cursor) + shortcut : Shift + Alt + R + input + identifier : "new name" = "" \ No newline at end of file diff --git a/org.nix.editor/editor/Nix-References.esv b/org.nix.editor/editor/Nix-References.esv index 6fb815e..70bc88a 100644 --- a/org.nix.editor/editor/Nix-References.esv +++ b/org.nix.editor/editor/Nix-References.esv @@ -2,7 +2,6 @@ module Nix-References imports Nix-References.generated - references // This file can be used to specify reference resolving and hover help, and content completion. @@ -11,11 +10,6 @@ references references - + reference _ : editor-resolve - -/* - - hover _ : editor-hover - -*/ \ No newline at end of file + //hover _ : editor-hover \ No newline at end of file diff --git a/org.nix.editor/editor/Nix-Syntax.esv b/org.nix.editor/editor/Nix-Syntax.esv index add351d..37e4543 100644 --- a/org.nix.editor/editor/Nix-Syntax.esv +++ b/org.nix.editor/editor/Nix-Syntax.esv @@ -1,7 +1,9 @@ module Nix-Syntax +imports Nix-Syntax.generated + language - + // Comment constructs: line comment : "#" block comment : "/*" * "*/" diff --git a/org.nix.editor/editor/Nix-Views.esv b/org.nix.editor/editor/Nix-Views.esv new file mode 100644 index 0000000..00d41d7 --- /dev/null +++ b/org.nix.editor/editor/Nix-Views.esv @@ -0,0 +1,8 @@ +module Nix-Views + +views + + outline view: editor-outline (source) + expand to level: 3 + + properties view: editor-properties diff --git a/org.nix.editor/editor/Nix.main.esv b/org.nix.editor/editor/Nix.main.esv index f7778e4..1dd6a4d 100644 --- a/org.nix.editor/editor/Nix.main.esv +++ b/org.nix.editor/editor/Nix.main.esv @@ -1,16 +1,31 @@ module Nix.main -imports Nix-Builders Nix-Colorer Nix-Completions Nix-Folding Nix-Outliner Nix-References Nix-Syntax +imports + Nix-Colorer + Nix-Completions + Nix-Folding + Nix-Menus + Nix-Refactorings + Nix-References + Nix-Syntax + Nix-Views language General properties - - name : Nix - id : Nix - extends : Root - - description : "Spoofax/IMP-generated editor for the Nix language" - url : http://strategoxt.org - - extensions : nix - table : include/Nix.tbl - start symbols : Expr \ No newline at end of file + + name: Nix + id: org.nix.editor + extends: Root + + description: "Spoofax/IMP-generated editor for the Nix language" + url: https://nixos.org/nix/ + + extensions: nix + table: include/Nix.tbl + start symbols: Expr + + provider: include/nix.ctree + provider: include/nix-java.jar + + observer: editor-analyze (multifile) + + on save: editor-save diff --git a/org.nix.editor/editor/java/Nix/Activator.java b/org.nix.editor/editor/java/org/nix/editor/Activator.java similarity index 97% rename from org.nix.editor/editor/java/Nix/Activator.java rename to org.nix.editor/editor/java/org/nix/editor/Activator.java index 8587299..67ae0e4 100644 --- a/org.nix.editor/editor/java/Nix/Activator.java +++ b/org.nix.editor/editor/java/org/nix/editor/Activator.java @@ -1,4 +1,4 @@ -package Nix; +package org.nix.editor; import org.eclipse.imp.preferences.PreferencesService; import org.eclipse.imp.runtime.PluginBase; diff --git a/org.nix.editor/editor/java/org/nix/editor/NixParseController.java b/org.nix.editor/editor/java/org/nix/editor/NixParseController.java new file mode 100644 index 0000000..21e1c1d --- /dev/null +++ b/org.nix.editor/editor/java/org/nix/editor/NixParseController.java @@ -0,0 +1,4 @@ +package org.nix.editor; + +public class NixParseController extends NixParseControllerGenerated +{ } \ No newline at end of file diff --git a/org.nix.editor/editor/java/Nix/NixParseController.java b/org.nix.editor/editor/java/org/nix/editor/NixParseControllerGenerated.java similarity index 71% rename from org.nix.editor/editor/java/Nix/NixParseController.java rename to org.nix.editor/editor/java/org/nix/editor/NixParseControllerGenerated.java index 38c1c95..a230e14 100644 --- a/org.nix.editor/editor/java/Nix/NixParseController.java +++ b/org.nix.editor/editor/java/org/nix/editor/NixParseControllerGenerated.java @@ -1,7 +1,10 @@ -package Nix; +package org.nix.editor; import java.io.InputStream; import java.io.IOException; +import java.io.File; +import java.io.FileInputStream; +import org.eclipse.core.runtime.Path; import org.eclipse.imp.parser.IParseController; import org.strategoxt.imp.runtime.Environment; import org.strategoxt.imp.runtime.dynamicloading.BadDescriptorException; @@ -9,7 +12,7 @@ import org.strategoxt.imp.runtime.dynamicloading.DescriptorFactory; import org.strategoxt.imp.runtime.dynamicloading.DynamicParseController; -public class NixParseController extends DynamicParseController +public class NixParseControllerGenerated extends DynamicParseController { public static final String LANGUAGE = new String("Nix"); @@ -30,18 +33,34 @@ public static synchronized Descriptor getDescriptor() return descriptor; } - private static void createDescriptor() + protected static synchronized void setDescriptor(Descriptor descriptor) + { + NixParseControllerGenerated.descriptor = descriptor; + } + + protected static void createDescriptor() { try { - InputStream descriptorStream = NixParseController.class.getResourceAsStream(DESCRIPTOR); - InputStream table = NixParseController.class.getResourceAsStream(TABLE); + InputStream descriptorStream = NixParseControllerGenerated.class.getResourceAsStream(DESCRIPTOR); + InputStream table = NixParseControllerGenerated.class.getResourceAsStream(TABLE); + boolean filesystem = false; + if(descriptorStream == null && new File("./" + DESCRIPTOR).exists()) + { + descriptorStream = new FileInputStream("./" + DESCRIPTOR); + filesystem = true; + } + if(table == null && new File("./" + TABLE).exists()) + { + table = new FileInputStream("./" + TABLE); + filesystem = true; + } if(descriptorStream == null) throw new BadDescriptorException("Could not load descriptor file from " + DESCRIPTOR + " (not found in plugin: " + getPluginLocation() + ")"); if(table == null) throw new BadDescriptorException("Could not load parse table from " + TABLE + " (not found in plugin: " + getPluginLocation() + ")"); - descriptor = DescriptorFactory.load(descriptorStream, table, null); - descriptor.setAttachmentProvider(NixParseController.class); + descriptor = DescriptorFactory.load(descriptorStream, table, filesystem ? Path.fromPortableString("./") : null); + descriptor.setAttachmentProvider(NixParseControllerGenerated.class); } catch(BadDescriptorException exc) { diff --git a/org.nix.editor/editor/java/Nix/NixValidator.java b/org.nix.editor/editor/java/org/nix/editor/NixValidator.java similarity index 92% rename from org.nix.editor/editor/java/Nix/NixValidator.java rename to org.nix.editor/editor/java/org/nix/editor/NixValidator.java index be1f479..a5f0e5c 100644 --- a/org.nix.editor/editor/java/Nix/NixValidator.java +++ b/org.nix.editor/editor/java/org/nix/editor/NixValidator.java @@ -1,4 +1,4 @@ -package Nix; +package org.nix.editor; import org.strategoxt.imp.runtime.dynamicloading.Descriptor; import org.strategoxt.imp.runtime.services.MetaFileLanguageValidator; diff --git a/org.nix.editor/editor/java/org/nix/editor/strategies/InteropRegisterer.java b/org.nix.editor/editor/java/org/nix/editor/strategies/InteropRegisterer.java new file mode 100644 index 0000000..db8653b --- /dev/null +++ b/org.nix.editor/editor/java/org/nix/editor/strategies/InteropRegisterer.java @@ -0,0 +1,14 @@ +package org.nix.editor.strategies; + +import org.strategoxt.lang.JavaInteropRegisterer; +import org.strategoxt.lang.Strategy; + +/** + * Helper class for {@link java_strategy_0_0}. + */ +public class InteropRegisterer extends JavaInteropRegisterer { + + public InteropRegisterer() { + super(new Strategy[] { java_strategy_0_0.instance }); + } +} diff --git a/org.nix.editor/editor/java/org/nix/editor/strategies/Main.java b/org.nix.editor/editor/java/org/nix/editor/strategies/Main.java new file mode 100644 index 0000000..867602f --- /dev/null +++ b/org.nix.editor/editor/java/org/nix/editor/strategies/Main.java @@ -0,0 +1,11 @@ +package org.nix.editor.strategies; + +import org.strategoxt.lang.Context; + +public class Main { + + public static void init(Context context) { + // Called when the editor is being initialized + } + +} diff --git a/org.nix.editor/editor/java/org/nix/editor/strategies/java_strategy_0_0.java b/org.nix.editor/editor/java/org/nix/editor/strategies/java_strategy_0_0.java new file mode 100644 index 0000000..9b51280 --- /dev/null +++ b/org.nix.editor/editor/java/org/nix/editor/strategies/java_strategy_0_0.java @@ -0,0 +1,32 @@ +package org.nix.editor.strategies; + +import org.spoofax.interpreter.terms.IStrategoTerm; +import org.spoofax.interpreter.terms.ITermFactory; +import org.strategoxt.lang.Context; +import org.strategoxt.lang.Strategy; + +/** + * Example Java strategy implementation. + * + * This strategy can be used by editor services and can be called + * in Stratego modules by declaring it as an external strategy + * as follows: + * + * <code> + * external java-strategy(|) + * </code> + * + * @see InteropRegisterer This class registers java_strategy_0_0 for use. + */ +public class java_strategy_0_0 extends Strategy { + + public static java_strategy_0_0 instance = new java_strategy_0_0(); + + @Override + public IStrategoTerm invoke(Context context, IStrategoTerm current) { + context.getIOAgent().printError("Input for java-strategy: " + current); + ITermFactory factory = context.getFactory(); + return factory.makeString("Regards from java-strategy"); + } + +} diff --git a/org.nix.editor/lib/editor-common.generated.str b/org.nix.editor/lib/editor-common.generated.str index ea78c86..421bb42 100644 --- a/org.nix.editor/lib/editor-common.generated.str +++ b/org.nix.editor/lib/editor-common.generated.str @@ -32,6 +32,8 @@ strategies ast2abox(|[<import-term(include/Nix.generated.pp.af)>, <import-term(include/Nix.pp.af)>]); box2text-string(|100) + + language = !"Nix" strategies @@ -125,11 +127,21 @@ strategies origin-term = prim("SSL_EXT_origin_term", <id>) origin-text = prim("SSL_EXT_origin_text", <id>) + origin-offset = prim("SSL_EXT_origin_offset", <id>) origin-location = prim("SSL_EXT_origin_location", <id>) origin-line = origin-location => (<id>, _, _, _) origin-column = origin-location => (_, <id>, _, _) + origin-file = prim("SSL_EXT_origin_file", <id>) origin-strip = prim("SSL_EXT_origin_strip", <id>) origin-equal(|t) = prim("SSL_EXT_origin_equal", <id>, t) + + origin-language-description = + prim("SSL_EXT_languagedescription", <id>) + + origin-language = + origin-file; + origin-language-description; + Fst origin-surrounding-comments = prim("SSL_EXT_origin_surrounding_comments", "Nix", <id>) @@ -143,8 +155,15 @@ strategies ['*' | c*] -> <ltrim(' ' + '\t' + '\n' + '\r')> c* origin-track-forced(s) = - !Some(<id>); all(s); ?Some(<id>) + ![<id>]; all(s); ?[<id>] + origin-relative-path: + trm -> rel-path + where + full-path := <origin-file> trm; + len-project-prefix := <project-path; string-length; inc>; + rel-path := <string-as-chars(drop(|len-project-prefix))> full-path + strategies desugar-position(desugar|ast): @@ -167,14 +186,16 @@ strategies !position => []; t' := <s> t + position-of-term(is-term): + _#(t*) -> <position-of-term(is-term|0)> t* + where + not(is-term) + position-of-term(is-term): t -> [] where is-term - position-of-term(is-term): - _#(t*) -> <position-of-term(is-term|0)> t* - position-of-term(is-term|start-index): [t | t*] -> position where @@ -203,23 +224,13 @@ strategies subterm-at(|index): _#(t*) -> <index(|<inc> index)> t* - + signature constructors COMPLETION : String -> Term NOCONTEXT : Term -> Term MARKER : Term - - // Below are copies of the signatures of the terms used in example - // trans/nix.str file. These definitions should also be automatically - // generated in the imported include/Nix.str module. However, - // to ensure that the example transformation doesn't break when the - // syntax is changed, we also hard-coded them here. - - Module : ID * List(Entity) -> Module - Entity : ID * List(Property) -> Entity - Property : ID * Type -> Property - Type : ID -> Type + True : Term strategies @@ -233,6 +244,10 @@ strategies queue-analysis = (is-list; list-loop(queue-analysis)) <+ prim("SSL_EXT_queue_analysis") + + // Gets the number of background analyses for currenct project and language. + // Current term: ignored + analysis-count = prim("SSL_EXT_queue_analysis_count") // Set the total number of work units to complete. Can be called multiple times. // Current term: number of work units (int). diff --git a/org.nix.editor/plugin.xml b/org.nix.editor/plugin.xml index cde4ba0..0dd6c8c 100644 --- a/org.nix.editor/plugin.xml +++ b/org.nix.editor/plugin.xml @@ -1,12 +1,24 @@ -<?xml version="1.0" encoding="UTF-8" ?> +<?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.0"?> - <plugin> - <extension point="org.eclipse.imp.runtime.languageDescription"> - <language extensions="nix" description="Nix" language="Nix" derivedFrom="DynamicRoot" validator="Nix.NixValidator" validatorClass="Nix.NixValidator"></language> - </extension> - <extension id="Nix.parser" name="Nix Parser" point="org.eclipse.imp.runtime.parser"> - <parser class="Nix.NixParseController" language="Nix"> - </parser> - </extension> - </plugin> \ No newline at end of file + <extension + point="org.eclipse.imp.runtime.languageDescription"> + <language + extensions="nix" + description="Nix" + language="Nix" + derivedFrom="DynamicRoot" + validator="org.nix.editor.NixValidator" + validatorClass="org.nix.editor.NixValidator" + ></language> + </extension> + <extension + id="org.nix.editor.parser" + name="Nix Parser" + point="org.eclipse.imp.runtime.parser"> + <parser + class="org.nix.editor.NixParseController" + language="Nix"> + </parser> + </extension> +</plugin> diff --git a/org.nix.editor/svn-commit.tmp b/org.nix.editor/svn-commit.tmp deleted file mode 100644 index 65ec52f..0000000 --- a/org.nix.editor/svn-commit.tmp +++ /dev/null @@ -1,4 +0,0 @@ -initial import ---This line, and those below, will be ignored-- - -A Nix diff --git a/org.nix.editor/syntax/Nix.sdf b/org.nix.editor/syntax/Nix.sdf index 357baae..726f357 100644 --- a/org.nix.editor/syntax/Nix.sdf +++ b/org.nix.editor/syntax/Nix.sdf @@ -1,5 +1,4 @@ %% Grammar for the Nix language -%% By default, based on an example "entities" syntax module Nix exports diff --git a/org.nix.editor/syntax/temp.sdf b/org.nix.editor/syntax/temp.sdf deleted file mode 100644 index c013105..0000000 --- a/org.nix.editor/syntax/temp.sdf +++ /dev/null @@ -1,39 +0,0 @@ - Expr Expr -> Expr {cons("Call"), left} - "let" "{" Bind* "}" -> Expr {cons("LetRec")} - "{" Bind* "}" -> Expr {cons("Attrs")} - - Id "=" Expr ";" -> Bind {cons("Bind")} - "inherit" ("(" Expr ")")? Id* ";" -> Bind {cons("Inherit")} - - "[" ExprList "]" -> Expr {cons("List")} - -> ExprList {cons("ExprNil")} - Expr ExprList -> ExprList {cons("ExprCons")} - - Expr "." Id -> Expr {cons("Select")} - - - "if" Expr "then" Expr "else" Expr -> Expr {cons("If")} - - - context-free priorities - - Expr "." Id -> Expr - > Expr ExprList -> ExprList - > Expr Expr -> Expr - > Expr "~" Expr -> Expr - > Expr "?" Id -> Expr - > Expr "++" Expr -> Expr - > Expr "+" Expr -> Expr - > "!" Expr -> Expr - > Expr "//" Expr -> Expr - > { Expr "==" Expr -> Expr - Expr "!=" Expr -> Expr - } - > Expr "&&" Expr -> Expr - > Expr "||" Expr -> Expr - > Expr "->" Expr -> Expr - > "if" Expr "then" Expr "else" Expr -> Expr - > "assert" Expr ";" Expr -> Expr - > "with" Expr ";" Expr -> Expr - > Id ":" Expr -> Expr - > "{" {Formal ","}* "}" ":" Expr -> Expr diff --git a/org.nix.editor/test/STABLE b/org.nix.editor/test/STABLE deleted file mode 100644 index c227083..0000000 --- a/org.nix.editor/test/STABLE +++ /dev/null @@ -1 +0,0 @@ -0 \ No newline at end of file diff --git a/org.nix.editor/test/VERSION b/org.nix.editor/test/VERSION deleted file mode 100644 index c64601b..0000000 --- a/org.nix.editor/test/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.14 \ No newline at end of file diff --git a/org.nix.editor/test/a b/org.nix.editor/test/a deleted file mode 100644 index bf7c9fe..0000000 --- a/org.nix.editor/test/a +++ /dev/null @@ -1 +0,0 @@ -f: '' ${f} '' diff --git a/org.nix.editor/test/default.nix b/org.nix.editor/test/default.nix index 9d5764a..1cb3483 100644 --- a/org.nix.editor/test/default.nix +++ b/org.nix.editor/test/default.nix @@ -1 +1 @@ -import ./pkgs/top-level/all-packages.nix +import ./pkgs/top-level/all-packages.nix \ No newline at end of file diff --git a/org.nix.editor/test/log b/org.nix.editor/test/log deleted file mode 100644 index 418e6e9..0000000 --- a/org.nix.editor/test/log +++ /dev/null @@ -1,151 +0,0 @@ -[ sglri | error ] ./pkgs/lib/strings.nix: character '\' unexpected at line 83, column 49 -[ sglri | error ] escape = list : string : -[ sglri | error ] stringAsChars (c: if lib.elem c list then "\\${c}" else c) string; -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/development/libraries/webkit/src-info-for-default.nix: character '\' unexpected at line 3, column 53 -[ sglri | error ] downloadPage = "http://nightly.webkit.org/"; -[ sglri | error ] versionExtractorSedScript = "s/.*-(r[0-9]+)[.].*/\\1/"; -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/development/libraries/java/saxon/default8.nix: character '\' unexpected at line 18, column 46 -[ sglri | error ] export JAVA_HOME=${jre} -[ sglri | error ] exec ${jre}/bin/java -jar $out/saxon8.jar \"\\$@\" -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/development/libraries/libixp_for_wmii/default.nix: character '\' unexpected at line 7, column 47 -[ sglri | error ] export LDFLAGS\=$(echo \$NIX_LDFLAGS | sed -e 's/-rpath/-L/g') -[ sglri | error ] sed -i -e \"s%^PREFIX.*%PREFIX=\$out%\" \\ -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/development/libraries/wxGTK-2.8/default.nix: character '}' unexpected at line 3, column 1 -[ sglri | error ] , mesa, compat24 ? false, compat26 ? true, unicode ? true, -[ sglri | error ] }: -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/development/tools/misc/ctags/wrapped.nix: character '\' unexpected at line 41, column 39 -[ sglri | error ] "--langmap=ActionScript:.as" -[ sglri | error ] "--regex-ActionScript=/function[ \\t]+([A-Za-z0-9_]+)[ \\t]*\\(/\1/f,function,functions/" -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/development/compilers/fpc/default.nix: character '@' unexpected at line 20, column 41 -[ sglri | error ] if system == "i686-linux" || system == "x86_64-linux" then '' -[ sglri | error ] sed -e "s@'/lib/ld-linux[^']*'@'''@" -i fpcsrc/compiler/systems/t_linux.pas -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/development/compilers/sbcl/src-info-for-default.nix: character '\' unexpected at line 6, column 53 -[ sglri | error ] sourceRegexp = "source[.-].*tar"; -[ sglri | error ] versionExtractorSedScript = "s/.*-([0-9.rc]+)-.*/\\1/"; -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/development/compilers/qi/9.1.nix: character '\' unexpected at line 25, column 75 -[ sglri | error ] shift -[ sglri | error ] clisp -M '\$out'/share/Qi-9.1/lispinit.mem \$arg1 \"\$@\"\\n' > \$out/bin/qi -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/development/compilers/ghc/6.8.2.nix: character '\' unexpected at line 32, column 18 -[ sglri | error ] # still requires a hack for ncurses -[ sglri | error ] sed -i \"s|^\\\(ld-options.*$\\\)|\\\1 -L${ncurses}/lib|\" libraries/readline/readline.buildinfo.in -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/development/compilers/ghc/6.4.2-binary.nix: character '\' unexpected at line 34, column 32 -[ sglri | error ] postBuild = if stdenv.isLinux then " -[ sglri | error ] find . -type f -perm +100 \\ -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/servers/http/4store/src-info-for-default.nix: character '\' unexpected at line 5, column 54 -[ sglri | error ] choiceCommand = "tail -n 1"; -[ sglri | error ] versionExtractorSedScript = "s@.*-(v[0-9.]+)[.].*@\\1@"; -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/servers/x11/xorg/default.nix: character ';' unexpected at line 18, column 19 -[ sglri | error ] buildInputs = [pkgconfig ]; -[ sglri | error ] })) // {inherit ;}; -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/build-support/builder-defs/builder-defs.nix: character '\' unexpected at line 68, column 45 -[ sglri | error ] nestingLevel=\$((\$nestingLevel + 1)) -[ sglri | error ] echo -en \"\\e[\$1p\" -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/build-support/builder-defs/template-auto-callable.nix: character '(' unexpected at line 2, column 3 -[ sglri | error ] x@{builderDefsPackage -[ sglri | error ] (abort "Specify dependencies") -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/build-support/builder-defs/template-composing-builder.nix: character ';' unexpected at line 11, column 46 -[ sglri | error ] rec { -[ sglri | error ] src = /* Here a fetchurl expression goes */; -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/build-support/builder-defs/template-bdp-uud.nix: character '(' unexpected at line 21, column 25 -[ sglri | error ] maintainers = [ -[ sglri | error ] a.lib.maintainers.(abort "Specify maintainer") -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/desktops/gnome-2.28/default.nix: '1 ambiguous subsentences found': input sentence -[ sglri | error ] ./pkgs/os-specific/linux/syslinux/default.nix: character '\' unexpected at line 17, column 45 -[ sglri | error ] if test \"$system\" = x86_64-linux; then -[ sglri | error ] substituteInPlace memdisk/Makefile \\ -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/os-specific/linux/atheros/0.9.3.3.nix: character ';' unexpected at line 17, column 29 -[ sglri | error ] sha256 = "11xpx5g9w7ilagvj60prc3s8a3x0n5n4mr0b7nh0lxwrbjdgjjfg"; -[ sglri | error ] } else "")*/; -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/os-specific/linux/upstart/jobcontrol.nix: character '\' unexpected at line 9, column 53 -[ sglri | error ] shift -[ sglri | error ] controlscript=\$(egrep exec\\|respawn \$file | tail | sed -e s/^\\\\s\\\\+//g | sed -e s/\\\\s\\\\+/\\ /g | cut -f 2 -d \\ ) -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/os-specific/windows/wxMSW-2.8/default.nix: character '}' unexpected at line 2, column 1 -[ sglri | error ] { stdenv, fetchurl, compat24 ? false, compat26 ? true, unicode ? true, -[ sglri | error ] }: -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/applications/editors/jedit/default.nix: character '\' unexpected at line 13, column 17 -[ sglri | error ] buildPhase = " -[ sglri | error ] sed -i 's/\\<SplashScreen\\>/org.gjt.sp.jedit.gui.SplashScreen/g' org/gjt/sp/jedit/GUIUtilities.java -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/applications/editors/jedit/wrapper.nix: character '\' unexpected at line 14, column 28 -[ sglri | error ] #!/bin/sh -[ sglri | error ] exec $java -jar $jeditjar \\$* -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/applications/window-managers/wmii/default.nix: character '\' unexpected at line 22, column 47 -[ sglri | error ] export LDFLAGS\=$(echo \$NIX_LDFLAGS | sed -e 's/-rpath/-L/g') -[ sglri | error ] sed -i -e \"s%^PREFIX.*%PREFIX=\$out%\" \\ -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/applications/window-managers/wmii31/default.nix: character '\' unexpected at line 17, column 47 -[ sglri | error ] export LDFLAGS\=$(echo \$NIX_LDFLAGS | sed -e 's/-rpath/-L/g') -[ sglri | error ] sed -i -e \"s%^PREFIX.*%PREFIX=\$out%\" \\ -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/applications/office/openoffice/get-go-src.nix: character '/' unexpected at line 30, column 41 -[ sglri | error ] makesh = '' -[ sglri | error ] sed -i -e '/-x $WG/d' -e "s/WGET='''/WGET='echo XXX'/" download -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/applications/graphics/xara/default.nix: character '\' unexpected at line 26, column 21 -[ sglri | error ] LD_LIBRARY_PATH=\$freetype/lib:\$libpng/lib:\$libjpeg/lib:\$libxml2/lib: -[ sglri | error ] \$out/lib/XaraLX \"\\$@\" -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/applications/graphics/graphicsmagick/default.nix: '1 ambiguous subsentences found': input sentence -[ sglri | error ] ./pkgs/applications/graphics/graphicsmagick/1.3.7.nix: '1 ambiguous subsentences found': input sentence -[ sglri | error ] ./pkgs/applications/virtualization/virtualbox/default.nix: character '\' unexpected at line 19, column 67 -[ sglri | error ] MODULES_BUILD_DIR=`echo ${kernel}/lib/modules/*/build` -[ sglri | error ] sed -e 's@/lib/modules/`uname -r`/build@'$MODULES_BUILD_DIR@ \\ -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/applications/misc/xpdf/default.nix: character '\' unexpected at line 51, column 42 -[ sglri | error ] if test -n \"${base14Fonts}\"; then -[ sglri | error ] substituteInPlace $out/etc/xpdfrc \\ -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/applications/misc/i810/default.nix: character '\' unexpected at line 8, column 20 -[ sglri | error ] sed -i -e 's+/usr++' Makefile -[ sglri | error ] sed -i -e 's+^\\(.*putenv(\"PATH=\\).*$+\\1${pciutils}/sbin\");+' i810switch.c -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/applications/networking/instant-messengers/carrier/2.4.2.nix: character ')' unexpected at line 8, column 63 -[ sglri | error ] let -[ sglri | error ] externalPurple2 = lib.attrByPath ["purple2Source"] null args) != null; -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/applications/networking/browsers/firefox/binary.nix: character '\' unexpected at line 39, column 31 -[ sglri | error ] sed -e 's@moz_libdir=.*@moz_libdir='\$out'/firefox/@' -i \$out/bin/firefox -[ sglri | error ] sed -e 's@moz_libdir=.*@&\\nexport PATH=\$PATH:${coreutils}/bin@' -i \$out/bin/firefox -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/applications/networking/sniffers/kismet/default.nix: character '\' unexpected at line 13, column 35 -[ sglri | error ] postConfigure = -[ sglri | error ] "sed -e 's@-o \$(INSTUSR)@@' \\ -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/tools/filesystems/relfs/default.nix: character '\' unexpected at line 20, column 40 -[ sglri | error ] cd ../src -[ sglri | error ] sed -e 's/NULL\\|FALSE/0/g' -i Mimetype_lib.c -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/tools/misc/eProver/default.nix: character '\' unexpected at line 14, column 39 -[ sglri | error ] -[ sglri | error ] preConfigure = "sed -e 's@^EXECPATH\\s.*@EXECPATH = '\$out'/bin@' -i Makefile.vars"; -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/tools/networking/ssmtp/default.nix: character '\' unexpected at line 19, column 47 -[ sglri | error ] postConfigure = " -[ sglri | error ] sed -e '/INSTALLED_CONFIGURATION_FILE/d' \\ -[ sglri | error ] ^ -[ sglri | error ] ./pkgs/tools/X11/xlaunch/default.nix: character '\' unexpected at line 34, column 41 -[ sglri | error ] echo '#! ${stdenv.shell} -[ sglri | error ] USER=\$(egrep '\\''^[-a-z0-9A-Z_]*:[^:]*:'\\''\$1'\\'':'\\'' /etc/passwd | sed -e '\\''s/:.*//'\\'' ) -[ sglri | error ] ^ diff --git a/org.nix.editor/trans/check.str b/org.nix.editor/trans/check.str deleted file mode 100644 index bd348ed..0000000 --- a/org.nix.editor/trans/check.str +++ /dev/null @@ -1,51 +0,0 @@ -module check - -imports - libstratego-lib - include/Nix - lib/editor-common.generated - -rules - - // Analysis: does a topdown traversal of the tree, - // and tries to apply the record-entity rule. - analyze: - t -> t - with - <topdown(try(record-entity))> t - - // Records the definition of an entity in a dynamic rule GetEntity. - record-entity: - Entity(x, body) -> Entity(x, body) - with - // For a name 'x', GetEntity will return the original 'x' tree node - rules( - GetEntity :+ x -> x - ) -rules - - // Reports an error if a property type is undefined. - // This error is reported on the type name 'type'. - constraint-error: - Property(x, Type(type)) -> (type, $[Type [type] is not defined]) - where - not(!type => "String"); // String and Int are built-in types - not(!type => "Int"); - not(<GetEntity> type) // no entity for this type - - // Reports an error if an entity is defined more than once. - // This constraint is implemented by testing if the "bag" of - // all entities x is not a singleton list. - constraint-error: - Entity(x, _) -> (x, $[Duplicate entity name]) - where - not(<bagof-GetEntity> x => [_]) - - constraint-warning: - Entity(x, _) -> (x, $[Entity names must start with a capital]) - where - not(<explode-string; Hd; is-upper> x) - - constraint-note: - Module(x @ "example", _) -> (x, $[This is just an example program in the "entities" language - (this note is defined in trans/check.str) ]) diff --git a/org.nix.editor/trans/generate.str b/org.nix.editor/trans/generate.str deleted file mode 100644 index 6d1a040..0000000 --- a/org.nix.editor/trans/generate.str +++ /dev/null @@ -1,47 +0,0 @@ -module generate - -imports - libstratego-lib - libstratego-gpp - libstratego-aterm - include/Nix - lib/editor-common.generated - -rules - - to-java: - Module(x, d*) -> - $[ package [x]; - - [d'*] - ] - with - d'* := <to-java> d* - - to-java: - Entity(x, p*) -> - $[ class [x] { - [p'*] - } - ] - with - p'* := <to-java> p* - - to-java: - Property(x, Type(t)) -> $[ - private [t] [x]; - - public [t] get_[x] { - return [x]; - } - - public [t] set_[x] ([t] [x]) { - this.[x] = [x]; - } - ] - - to-java: - Type(t) -> t - - to-java: - t* -> <map(to-java)> t* diff --git a/org.nix.editor/trans/nix.str b/org.nix.editor/trans/nix.str index f1d43ae..d1d1138 100644 --- a/org.nix.editor/trans/nix.str +++ b/org.nix.editor/trans/nix.str @@ -1,37 +1,104 @@ module nix imports - libstratego-lib - libstratego-gpp - libstratego-aterm - include/Nix - lib/editor-common.generated - -rules // Main editor interface (defined by editor/Nix-Builders and -References.esv) - - generate-aterm: - (selected, position, ast, path, project-path) -> (filename, selected) - with - filename := <guarantee-extension(|"aterm")> path - - generate-decorated-ast: - (selected, position, ast, path, project-path) -> (filename, <DecoratedAst>ast) - with - filename := <guarantee-extension(|"decorated.aterm")> path + + libstratego-lib + libstratego-gpp + libstratego-aterm + include/Nix + editor/Nix-Outliner + lib/editor-common.generated + lib/runtime/index/- + lib/runtime/nabl/- + lib/runtime/properties/- + lib/runtime/types/- + lib/runtime/task/- + lib/runtime/analysis/- + lib/runtime/editor/- + +rules // Analysis + + editor-analyze = analysis-default-editor + + analysis-single-default-interface = + analysis-single-default(id, id, id|<language>) + analysis-multiple-default-interface = + analysis-multiple-default(parse-file <+ !(), id, id, id|<language>, <project-path>) + + editor-save = analysis-save-default(|<language>) +rules // Editor services + + // Resolves a reference when the user control-clicks or presses F3 in the editor. + editor-resolve: + (node, position, ast, path, project-path) -> definition + where + definition := <analysis-resolve(|<language>, project-path)> node + + // Gathers the outline nodes for the outline view. + editor-outline: + (node, position, ast, path, project-path) -> outline + where + outline := <simple-label-outline(to-outline-label)> ast + + // Completes an identifier when the user presses control-space + // (the completion identifier in the AST provides additional context information) + editor-complete: + (node, position, ast, path, project-path) -> proposals + where + proposals := <analysis-propose-completions(|<language>, project-path)> ast + +rules // Debugging + + // Prints the abstract syntax ATerm of a selection. + debug-show-aterm: + (selected, position, ast, path, project-path) -> (filename, result) + with + filename := <guarantee-extension(|"aterm")> path; + result := selected + + // Prints the analyzed annotated abstract syntax ATerm of a selection. + debug-show-analyzed: + (selected, position, ast, path, project-path) -> (filename, result) + with + filename := <guarantee-extension(|"analyzed.aterm")> path; + result := ast + + debug-index-project = + analysis-debug-index-project(|<language>) + debug-index-project-resolve = + analysis-debug-index-project-resolve(|<language>) + debug-index-partition = + analysis-debug-index-partition(|<language>) + + debug-task-project = + analysis-debug-task-project(|<language>) + debug-task-partition = + analysis-debug-task-partition(|<language>) + debug-task-selection = + analysis-debug-task-selection(|<language>) + + debug-project = + analysis-debug-project(|<language>) + debug-partition = + analysis-debug-partition(|<language>) + + debug-reanalyze = + analysis-debug-reanalyze(|<language>) + rules // import resolving editor-resolve = editor-resolve-decl <+ editor-resolve-path <+ editor-resolve-fallback - editor-resolve-decl : - (selected, position, ast, path, project-path) -> target - where - ast2 := <DecoratedAst>ast; + editor-resolve-decl : + (selected, position, ast, path, project-path) -> target + where + ast2 := <DecoratedAst>ast; target := <decl-of> <term-at-position(|position)>ast2 decl-of : Var(x) -> <VarDef>x //decl-of : Id(x) -> <VarDef>x - + editor-resolve-path : (Path(p), position, ast, path, project-path) -> <parse-file> file where @@ -43,15 +110,15 @@ rules // import resolving <oncetd(?Path(p))>t ; file := <resolve-import-path(|path)> p resolve-path(|basepath) = - ?p + ?p ; if <is-abspath>p then - imp := p + imp := p else imp := <concat-strings> [ <abspath ; dirname>basepath, "/", p ] end resolve-import-path(|basepath) = - resolve-path(|basepath) + resolve-path(|basepath) ; if test-extension("nix") then id else @@ -118,8 +185,8 @@ rules // analysis rename : RecAttributeSet(bs1) -> RecAttributeSet(bs3) where {| RenameId: - bs2 := <map(try(rename-bind))>bs1; - bs3 := <rename-top>bs2 + bs2 := <map(try(rename-bind))>bs1; + bs3 := <rename-top>bs2 |} rename : Let(bs1, e1) -> Let(bs3, e2) @@ -133,7 +200,7 @@ rules // analysis rename : d@Function(a1, e1) -> Function(a2, e2) where {| RenameId: - is-string; + is-string; a2 := <rename-bind-int(|d)>a1; e2 := <rename-top>e1 |} @@ -150,7 +217,7 @@ rules // analysis nix-warning(|path) : - Path(p) -> (<id>, $[Path/file '[p]' does not exist.]) + Path(p) -> (<id>, $[Path/file '[p]' does not exist.]) where <resolve-path(|path)> p ; not(file-exists) @@ -169,10 +236,10 @@ rules where file := <resolve-import-path(|path)> p ; if file-exists then - fatal-err-msg(|"File already exists.") + fatal-err-msg(|"File already exists.") end; if not( relfile := <make-project-relative-path(|project-path)> file ) then - fatal-err-msg(|$[Cannot create a nix expression outside the workspace]) + fatal-err-msg(|$[Cannot create a nix expression outside the workspace]) end ; ( (name, allinputs) := <deconstruct-import-call(|position)>ast ; if <elem>("stdenv", allinputs) ; <elem>("fetchurl", allinputs) then @@ -186,11 +253,11 @@ rules ; <queue-analysis> path make-project-relative-path(|project-path) = - <concat-strings>["./", <str-left-match>(<id>, project-path)] + <concat-strings>["./", <str-left-match>(<id>, project-path)] deconstruct-import-call(|position) = - parent-at-position(|<repeat(remove-last|2)>position) ; deconstruct-bind-import-call - <+ parent-at-position(|<repeat(remove-last|1)>position) ; deconstruct-import-call + parent-at-position(|<repeat(remove-last|2)>position) ; deconstruct-bind-import-call + <+ parent-at-position(|<repeat(remove-last|1)>position) ; deconstruct-import-call deconstruct-bind-import-call : Bind([name], Call(Call(Var("import"), Path(_)), AttributeSet(as))) -> (name, inputs) @@ -224,7 +291,7 @@ rules name = "<name>"; src = fetchurl { url = http://someplace.com ; - sha256 = ""; + sha256 = ""; }; buildInputs = [< <separate-by(!" ")>inputs >] ; meta = { @@ -299,10 +366,10 @@ strategies (node, position, ast, path, project-path) -> proposals where {| current-path, current-project-path: - rules( - current-path := path - current-project-path := project-path - ) ; + rules( + current-path := path + current-project-path := project-path + ) ; proposals := <propose-completion <+ ![]> node |} @@ -316,6 +383,4 @@ strategies contents := < readdir ; string-sort ; filter( where(<str-left-match>(<id>, file)) ; <concat-strings>[dir, "/", <id>] ) - >abspath - - + >abspath \ No newline at end of file