Skip to content
This repository
Browse code

use outlines from usage file for auto completion

  • Loading branch information...
commit f3eb3387d448dbf36c43a7f3cc6bcc2a8d5f7a79 1 parent 048c21a
JP Moresmau authored
332 net.sf.eclipsefp.haskell-feature/feature.xml
... ... @@ -1,169 +1,169 @@
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<feature
3   - id="net.sf.eclipsefp.haskell"
4   - label="%bundleName"
5   - version="2.2.5"
6   - provider-name="%bundleVendor">
7   -
8   - <description>
9   - Adds tools for the Haskell programming language to the Eclipse IDE.
10   - </description>
11   -
12   - <copyright>
13   - Copyright (c) 2003-2011 by the EclipseFP contributors
14   - </copyright>
15   -
16   - <license url="http://www.eclipse.org/legal/epl-v10.html">
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<feature
  3 + id="net.sf.eclipsefp.haskell"
  4 + label="%bundleName"
  5 + version="2.2.5"
  6 + provider-name="%bundleVendor">
  7 +
  8 + <description>
  9 + Adds tools for the Haskell programming language to the Eclipse IDE.
  10 + </description>
  11 +
  12 + <copyright>
  13 + Copyright (c) 2003-2011 by the EclipseFP contributors
  14 + </copyright>
  15 +
  16 + <license url="http://www.eclipse.org/legal/epl-v10.html">
17 17 This content is made available by the project eclipsefp.sourceforge.net
18 18 under the terms of the Eclipse Public License Version 1.0 (EPL).
19 19 A copy of the EPL is provided with this content and is also
20   -available at http://www.eclipse.org/legal/epl-v10.html.
21   - </license>
22   -
23   - <requires>
24   - <import plugin="org.eclipse.ui.cheatsheets" version="3.2.0" match="compatible"/>
25   - <import plugin="org.eclipse.core.expressions" version="3.2.0" match="compatible"/>
26   - <import plugin="org.eclipse.core.runtime" version="3.2.0" match="compatible"/>
27   - <import plugin="org.eclipse.debug.core" version="3.2.0" match="compatible"/>
28   - <import plugin="org.eclipse.ui" version="3.5.0" match="greaterOrEqual"/>
29   - <import plugin="org.eclipse.text" version="3.5.0" match="greaterOrEqual"/>
30   - <import plugin="org.eclipse.ui.editors" version="3.5.0" match="greaterOrEqual"/>
31   - <import plugin="org.eclipse.ui.ide" version="3.5.2" match="greaterOrEqual"/>
32   - <import plugin="org.eclipse.jface.text" version="3.2.0" match="compatible"/>
33   - <import plugin="org.eclipse.ltk.core.refactoring"/>
34   - <import plugin="org.eclipse.ltk.ui.refactoring"/>
35   - <import plugin="org.eclipse.ui" version="3.2.0" match="compatible"/>
36   - <import plugin="org.eclipse.ui.console" version="3.1.0" match="compatible"/>
37   - <import plugin="org.eclipse.ui.ide" version="3.2.0" match="compatible"/>
38   - <import plugin="org.eclipse.ui.navigator"/>
39   - <import plugin="org.eclipse.ui.views" version="3.2.0" match="compatible"/>
40   - <import plugin="org.eclipse.ui.workbench.texteditor" version="3.2.0" match="compatible"/>
41   - <import plugin="org.eclipse.debug.ui" version="3.2.0" match="compatible"/>
42   - <import plugin="org.eclipse.ui.forms"/>
43   - <import plugin="org.eclipse.core.variables" version="3.2.200" match="greaterOrEqual"/>
44   - <import plugin="org.apache.ant"/>
45   - <import plugin="org.eclipse.core.filesystem"/>
46   - <import plugin="org.eclipse.core.resources" version="3.2.0" match="compatible"/>
47   - <import plugin="org.eclipse.jface.text" version="3.5.0" match="greaterOrEqual"/>
48   - <import plugin="org.eclipse.ui.workbench.texteditor" version="3.5.0" match="greaterOrEqual"/>
49   - <import plugin="org.eclipse.jface.text" version="3.5.1" match="greaterOrEqual"/>
50   - <import plugin="org.eclipse.ui.console" version="3.2.0" match="greaterOrEqual"/>
51   - <import plugin="org.eclipse.jface.text" version="3.2.0" match="greaterOrEqual"/>
52   - <import plugin="org.eclipse.osgi"/>
53   - <import plugin="org.eclipse.core.net"/>
54   - <import plugin="org.eclipse.ui" version="3.2.0" match="greaterOrEqual"/>
55   - <import plugin="org.eclipse.core.runtime" version="3.2.0" match="greaterOrEqual"/>
56   - <import plugin="org.eclipse.core.commands"/>
57   - <import plugin="org.eclipse.jface"/>
58   - <import plugin="org.eclipse.swt"/>
59   - <import plugin="org.eclipse.core.resources" version="3.5.2" match="greaterOrEqual"/>
60   - <import plugin="org.eclipse.jface.text" version="3.5.2" match="greaterOrEqual"/>
61   - <import plugin="net.sf.eclipsefp.haskell.ui"/>
62   - <import plugin="net.sf.eclipsefp.haskell.haddock"/>
63   - <import plugin="net.sf.eclipsefp.haskell.core"/>
64   - <import plugin="net.sf.eclipsefp.haskell.util"/>
65   - <import plugin="net.sf.eclipsefp.haskell.debug.ui"/>
66   - <import plugin="net.sf.eclipsefp.haskell.debug.core"/>
67   - <import plugin="net.sf.eclipsefp.haskell.ghccompiler"/>
68   - <import plugin="net.sf.eclipsefp.haskell.compat"/>
69   - </requires>
70   -
71   - <plugin
72   - id="net.sf.eclipsefp.haskell"
73   - download-size="0"
74   - install-size="0"
75   - version="2.2.4"
76   - unpack="false"/>
77   -
78   - <plugin
79   - id="net.sf.eclipsefp.haskell.core"
80   - download-size="0"
81   - install-size="0"
82   - version="2.2.5"
83   - unpack="false"/>
84   -
85   - <plugin
86   - id="net.sf.eclipsefp.haskell.doc.user"
87   - download-size="0"
88   - install-size="0"
89   - version="2.2.4"
90   - unpack="false"/>
91   -
92   - <plugin
93   - id="net.sf.eclipsefp.haskell.ui"
94   - download-size="0"
95   - install-size="0"
96   - version="2.2.5"
97   - unpack="false"/>
98   -
99   - <plugin
100   - id="net.sf.eclipsefp.haskell.hugs"
101   - download-size="0"
102   - install-size="0"
103   - version="2.2.4"
104   - unpack="false"/>
105   -
106   - <plugin
107   - id="net.sf.eclipsefp.haskell.ghccompiler"
108   - download-size="0"
109   - install-size="0"
110   - version="2.2.4"
111   - unpack="false"/>
112   -
113   - <plugin
114   - id="net.sf.eclipsefp.haskell.debug.ui"
115   - download-size="0"
116   - install-size="0"
117   - version="2.2.4"
118   - unpack="false"/>
119   -
120   - <plugin
121   - id="net.sf.eclipsefp.haskell.debug.core"
122   - download-size="0"
123   - install-size="0"
124   - version="2.2.4"
125   - unpack="false"/>
126   -
127   - <plugin
128   - id="net.sf.eclipsefp.haskell.compat"
129   - download-size="0"
130   - install-size="0"
131   - version="2.2.4"
132   - unpack="false"/>
133   -
134   - <plugin
135   - id="net.sf.eclipsefp.haskell.util"
136   - download-size="0"
137   - install-size="0"
138   - version="2.2.5"
139   - unpack="false"/>
140   -
141   - <plugin
142   - id="net.sf.eclipsefp.haskell.browser"
143   - download-size="0"
144   - install-size="0"
145   - version="2.2.4"
146   - unpack="false"/>
147   -
148   - <plugin
149   - id="net.sf.eclipsefp.haskell.hlint"
150   - download-size="0"
151   - install-size="0"
152   - version="2.2.4"
153   - unpack="false"/>
154   -
155   - <plugin
156   - id="net.sf.eclipsefp.haskell.profiler"
157   - download-size="0"
158   - install-size="0"
159   - version="2.2.5"
160   - unpack="false"/>
161   -
162   - <plugin
163   - id="net.sf.eclipsefp.haskell.buildwrapper"
164   - download-size="0"
165   - install-size="0"
166   - version="2.2.5"
167   - unpack="false"/>
168   -
169   -</feature>
  20 +available at http://www.eclipse.org/legal/epl-v10.html.
  21 + </license>
  22 +
  23 + <requires>
  24 + <import plugin="org.eclipse.ui.cheatsheets" version="3.2.0" match="compatible"/>
  25 + <import plugin="org.eclipse.core.expressions" version="3.2.0" match="compatible"/>
  26 + <import plugin="org.eclipse.core.runtime" version="3.2.0" match="compatible"/>
  27 + <import plugin="org.eclipse.debug.core" version="3.2.0" match="compatible"/>
  28 + <import plugin="org.eclipse.ui" version="3.5.0" match="greaterOrEqual"/>
  29 + <import plugin="org.eclipse.text" version="3.5.0" match="greaterOrEqual"/>
  30 + <import plugin="org.eclipse.ui.editors" version="3.5.0" match="greaterOrEqual"/>
  31 + <import plugin="org.eclipse.ui.ide" version="3.5.2" match="greaterOrEqual"/>
  32 + <import plugin="org.eclipse.jface.text" version="3.2.0" match="compatible"/>
  33 + <import plugin="org.eclipse.ltk.core.refactoring"/>
  34 + <import plugin="org.eclipse.ltk.ui.refactoring"/>
  35 + <import plugin="org.eclipse.ui" version="3.2.0" match="compatible"/>
  36 + <import plugin="org.eclipse.ui.console" version="3.1.0" match="compatible"/>
  37 + <import plugin="org.eclipse.ui.ide" version="3.2.0" match="compatible"/>
  38 + <import plugin="org.eclipse.ui.navigator"/>
  39 + <import plugin="org.eclipse.ui.views" version="3.2.0" match="compatible"/>
  40 + <import plugin="org.eclipse.ui.workbench.texteditor" version="3.2.0" match="compatible"/>
  41 + <import plugin="org.eclipse.debug.ui" version="3.2.0" match="compatible"/>
  42 + <import plugin="org.eclipse.ui.forms"/>
  43 + <import plugin="org.eclipse.core.variables" version="3.2.200" match="greaterOrEqual"/>
  44 + <import plugin="org.apache.ant"/>
  45 + <import plugin="org.eclipse.core.filesystem"/>
  46 + <import plugin="org.eclipse.core.resources" version="3.2.0" match="compatible"/>
  47 + <import plugin="org.eclipse.jface.text" version="3.5.0" match="greaterOrEqual"/>
  48 + <import plugin="org.eclipse.ui.workbench.texteditor" version="3.5.0" match="greaterOrEqual"/>
  49 + <import plugin="org.eclipse.jface.text" version="3.5.1" match="greaterOrEqual"/>
  50 + <import plugin="org.eclipse.ui.console" version="3.2.0" match="greaterOrEqual"/>
  51 + <import plugin="org.eclipse.jface.text" version="3.2.0" match="greaterOrEqual"/>
  52 + <import plugin="org.eclipse.osgi"/>
  53 + <import plugin="org.eclipse.core.net"/>
  54 + <import plugin="org.eclipse.ui" version="3.2.0" match="greaterOrEqual"/>
  55 + <import plugin="org.eclipse.core.runtime" version="3.2.0" match="greaterOrEqual"/>
  56 + <import plugin="org.eclipse.core.commands"/>
  57 + <import plugin="org.eclipse.jface"/>
  58 + <import plugin="org.eclipse.swt"/>
  59 + <import plugin="org.eclipse.core.resources" version="3.5.2" match="greaterOrEqual"/>
  60 + <import plugin="org.eclipse.jface.text" version="3.5.2" match="greaterOrEqual"/>
  61 + <import plugin="net.sf.eclipsefp.haskell.ui"/>
  62 + <import plugin="net.sf.eclipsefp.haskell.haddock"/>
  63 + <import plugin="net.sf.eclipsefp.haskell.core"/>
  64 + <import plugin="net.sf.eclipsefp.haskell.util"/>
  65 + <import plugin="net.sf.eclipsefp.haskell.debug.ui"/>
  66 + <import plugin="net.sf.eclipsefp.haskell.debug.core"/>
  67 + <import plugin="net.sf.eclipsefp.haskell.ghccompiler"/>
  68 + <import plugin="net.sf.eclipsefp.haskell.compat"/>
  69 + </requires>
  70 +
  71 + <plugin
  72 + id="net.sf.eclipsefp.haskell"
  73 + download-size="0"
  74 + install-size="0"
  75 + version="2.2.4"
  76 + unpack="false"/>
  77 +
  78 + <plugin
  79 + id="net.sf.eclipsefp.haskell.core"
  80 + download-size="0"
  81 + install-size="0"
  82 + version="2.2.5"
  83 + unpack="false"/>
  84 +
  85 + <plugin
  86 + id="net.sf.eclipsefp.haskell.doc.user"
  87 + download-size="0"
  88 + install-size="0"
  89 + version="2.2.4"
  90 + unpack="false"/>
  91 +
  92 + <plugin
  93 + id="net.sf.eclipsefp.haskell.ui"
  94 + download-size="0"
  95 + install-size="0"
  96 + version="2.2.5"
  97 + unpack="false"/>
  98 +
  99 + <plugin
  100 + id="net.sf.eclipsefp.haskell.hugs"
  101 + download-size="0"
  102 + install-size="0"
  103 + version="2.2.4"
  104 + unpack="false"/>
  105 +
  106 + <plugin
  107 + id="net.sf.eclipsefp.haskell.ghccompiler"
  108 + download-size="0"
  109 + install-size="0"
  110 + version="2.2.4"
  111 + unpack="false"/>
  112 +
  113 + <plugin
  114 + id="net.sf.eclipsefp.haskell.debug.ui"
  115 + download-size="0"
  116 + install-size="0"
  117 + version="2.2.4"
  118 + unpack="false"/>
  119 +
  120 + <plugin
  121 + id="net.sf.eclipsefp.haskell.debug.core"
  122 + download-size="0"
  123 + install-size="0"
  124 + version="2.2.4"
  125 + unpack="false"/>
  126 +
  127 + <plugin
  128 + id="net.sf.eclipsefp.haskell.compat"
  129 + download-size="0"
  130 + install-size="0"
  131 + version="2.2.4"
  132 + unpack="false"/>
  133 +
  134 + <plugin
  135 + id="net.sf.eclipsefp.haskell.util"
  136 + download-size="0"
  137 + install-size="0"
  138 + version="2.2.5"
  139 + unpack="false"/>
  140 +
  141 + <plugin
  142 + id="net.sf.eclipsefp.haskell.browser"
  143 + download-size="0"
  144 + install-size="0"
  145 + version="2.2.5"
  146 + unpack="false"/>
  147 +
  148 + <plugin
  149 + id="net.sf.eclipsefp.haskell.hlint"
  150 + download-size="0"
  151 + install-size="0"
  152 + version="2.2.4"
  153 + unpack="false"/>
  154 +
  155 + <plugin
  156 + id="net.sf.eclipsefp.haskell.profiler"
  157 + download-size="0"
  158 + install-size="0"
  159 + version="2.2.5"
  160 + unpack="false"/>
  161 +
  162 + <plugin
  163 + id="net.sf.eclipsefp.haskell.buildwrapper"
  164 + download-size="0"
  165 + install-size="0"
  166 + version="2.2.5"
  167 + unpack="false"/>
  168 +
  169 +</feature>
36 net.sf.eclipsefp.haskell.browser/META-INF/MANIFEST.MF
... ... @@ -1,18 +1,18 @@
1   -Manifest-Version: 1.0
2   -Bundle-ManifestVersion: 2
3   -Bundle-Name: %bundleName
4   -Bundle-SymbolicName: net.sf.eclipsefp.haskell.browser; singleton:=true
5   -Bundle-Version: 2.2.4
6   -Bundle-Localization: plugin
7   -Bundle-Activator: net.sf.eclipsefp.haskell.browser.BrowserPlugin
8   -Require-Bundle: org.eclipse.ui;bundle-version="3.2.0",
9   - org.eclipse.core.runtime;bundle-version="3.2.0",
10   - net.sf.eclipsefp.haskell.core;bundle-version="2.0.5",
11   - net.sf.eclipsefp.haskell.util;bundle-version="2.0.3",
12   - org.eclipse.jface.text;bundle-version="3.2.0"
13   -Bundle-ActivationPolicy: lazy
14   -Bundle-RequiredExecutionEnvironment: JavaSE-1.6
15   -Bundle-Vendor: %bundleVendor
16   -Export-Package: net.sf.eclipsefp.haskell.browser,
17   - net.sf.eclipsefp.haskell.browser.items
18   -Bundle-ClassPath: .
  1 +Manifest-Version: 1.0
  2 +Bundle-ManifestVersion: 2
  3 +Bundle-Name: %bundleName
  4 +Bundle-SymbolicName: net.sf.eclipsefp.haskell.browser; singleton:=true
  5 +Bundle-Version: 2.2.5
  6 +Bundle-Localization: plugin
  7 +Bundle-Activator: net.sf.eclipsefp.haskell.browser.BrowserPlugin
  8 +Require-Bundle: org.eclipse.ui;bundle-version="3.2.0",
  9 + org.eclipse.core.runtime;bundle-version="3.2.0",
  10 + net.sf.eclipsefp.haskell.core;bundle-version="2.0.5",
  11 + net.sf.eclipsefp.haskell.util;bundle-version="2.0.3",
  12 + org.eclipse.jface.text;bundle-version="3.2.0"
  13 +Bundle-ActivationPolicy: lazy
  14 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6
  15 +Bundle-Vendor: %bundleVendor
  16 +Export-Package: net.sf.eclipsefp.haskell.browser,
  17 + net.sf.eclipsefp.haskell.browser.items
  18 +Bundle-ClassPath: .
109 net.sf.eclipsefp.haskell.browser/src/net/sf/eclipsefp/haskell/browser/items/Constructor.java
... ... @@ -1,49 +1,60 @@
1   -/**
2   - * (c) 2011, Alejandro Serrano
3   - * Released under the terms of the EPL.
4   - */
5   -package net.sf.eclipsefp.haskell.browser.items;
6   -
7   -import org.json.JSONException;
8   -import org.json.JSONObject;
9   -
10   -/**
11   - * Represents a GADT constructor.
12   - *
13   - * @author Alejandro Serrano
14   - */
15   -public class Constructor extends Documented {
16   - String name;
17   - String signature;
18   -
19   - public Constructor(String doc, String name, String signature) {
20   - this.setDoc(doc);
21   - this.name = name;
22   - this.signature = signature;
23   - }
24   -
25   - public Constructor(JSONObject o) throws JSONException {
26   - this.setDoc(o);
27   - this.name = o.getString("name");
28   - this.signature = o.getString("type");
29   - }
30   -
31   - public String getName() {
32   - return this.name;
33   - }
34   -
35   - public String getSignature() {
36   - return this.signature;
37   - }
38   -
39   - public String getCompleteDefinition() {
40   - StringBuilder builder = new StringBuilder(this.getName());
41   - builder.append(" :: ");
42   - builder.append(this.getSignature());
43   - return builder.toString();
44   - }
45   -
46   - public String getShownName() {
47   - return this.name + " :: " + this.signature;
48   - }
49   -}
  1 +/**
  2 + * (c) 2011, Alejandro Serrano
  3 + * Released under the terms of the EPL.
  4 + */
  5 +package net.sf.eclipsefp.haskell.browser.items;
  6 +
  7 +import org.json.JSONException;
  8 +import org.json.JSONObject;
  9 +
  10 +/**
  11 + * Represents a GADT constructor.
  12 + *
  13 + * @author Alejandro Serrano
  14 + */
  15 +public class Constructor extends Documented {
  16 + private String name;
  17 + private String signature;
  18 + private String typeName;
  19 +
  20 +
  21 + public Constructor(String doc, String name, String signature,String typeName) {
  22 + this.setDoc(doc);
  23 + this.name = name;
  24 + this.signature = signature;
  25 + this.typeName = typeName;
  26 + }
  27 +
  28 + public Constructor(JSONObject o) throws JSONException {
  29 + this.setDoc(o);
  30 + this.name = o.getString("name");
  31 + this.signature = o.getString("type");
  32 + }
  33 +
  34 + public String getName() {
  35 + return this.name;
  36 + }
  37 +
  38 + public String getSignature() {
  39 + return this.signature;
  40 + }
  41 +
  42 + public String getCompleteDefinition() {
  43 + StringBuilder builder = new StringBuilder(this.getName());
  44 + builder.append(" :: ");
  45 + builder.append(this.getSignature());
  46 + return builder.toString();
  47 + }
  48 +
  49 + public String getShownName() {
  50 + return this.name + " :: " + this.signature;
  51 + }
  52 +
  53 + public String getTypeName() {
  54 + return typeName;
  55 + }
  56 +
  57 + public void setTypeName(String typeName) {
  58 + this.typeName = typeName;
  59 + }
  60 +}
2,073 net.sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/BWFacade.java
... ... @@ -1,1034 +1,1039 @@
1   -package net.sf.eclipsefp.haskell.buildwrapper;
2   -
3   -import java.io.BufferedReader;
4   -import java.io.File;
5   -import java.io.IOException;
6   -import java.io.InputStreamReader;
7   -import java.io.Writer;
8   -import java.util.ArrayList;
9   -import java.util.HashMap;
10   -import java.util.HashSet;
11   -import java.util.Iterator;
12   -import java.util.LinkedList;
13   -import java.util.List;
14   -import java.util.Map;
15   -import java.util.Set;
16   -
17   -import net.sf.eclipsefp.haskell.buildwrapper.types.BWTarget;
18   -import net.sf.eclipsefp.haskell.buildwrapper.types.BuildFlags;
19   -import net.sf.eclipsefp.haskell.buildwrapper.types.BuildOptions;
20   -import net.sf.eclipsefp.haskell.buildwrapper.types.CabalPackage;
21   -import net.sf.eclipsefp.haskell.buildwrapper.types.Component;
22   -import net.sf.eclipsefp.haskell.buildwrapper.types.ThingAtPoint;
23   -import net.sf.eclipsefp.haskell.buildwrapper.types.Component.ComponentType;
24   -import net.sf.eclipsefp.haskell.buildwrapper.types.Location;
25   -import net.sf.eclipsefp.haskell.buildwrapper.types.Note;
26   -import net.sf.eclipsefp.haskell.buildwrapper.types.Note.Kind;
27   -import net.sf.eclipsefp.haskell.buildwrapper.types.Occurrence;
28   -import net.sf.eclipsefp.haskell.buildwrapper.types.OutlineDef;
29   -import net.sf.eclipsefp.haskell.buildwrapper.types.OutlineResult;
30   -import net.sf.eclipsefp.haskell.buildwrapper.types.TokenDef;
31   -import net.sf.eclipsefp.haskell.buildwrapper.util.BWText;
32   -import net.sf.eclipsefp.haskell.util.FileUtil;
33   -import net.sf.eclipsefp.haskell.util.LangUtil;
34   -import net.sf.eclipsefp.haskell.util.OutputWriter;
35   -import net.sf.eclipsefp.haskell.util.SingleJobQueue;
36   -
37   -import org.eclipse.core.resources.IFile;
38   -import org.eclipse.core.resources.IFolder;
39   -import org.eclipse.core.resources.IProject;
40   -import org.eclipse.core.resources.IResource;
41   -import org.eclipse.core.runtime.CoreException;
42   -import org.eclipse.core.runtime.IProgressMonitor;
43   -import org.eclipse.core.runtime.NullProgressMonitor;
44   -import org.json.JSONArray;
45   -import org.json.JSONException;
46   -import org.json.JSONObject;
47   -
48   -/**
49   - * API facade to buildwrapper: exposes all operations and calls the build wrapper executable
50   - * @author JP Moresmau
51   - *
52   - */
53   -public class BWFacade {
54   - public static final String DIST_FOLDER=".dist-buildwrapper";
55   - public static final String DIST_FOLDER_CABAL=DIST_FOLDER+"/dist";
56   -
57   - private static final String prefix="build-wrapper-json:";
58   -
59   - private static boolean showedNoExeError=false;
60   -
61   - private String bwPath;
62   - //private String tempFolder=".dist-buildwrapper";
63   - private String cabalPath;
64   - private String cabalFile;
65   - private String cabalShortName;
66   -
67   - private String flags;
68   - private List<String> extraOpts=new LinkedList<String>();
69   -
70   - private File workingDir;
71   -
72   - private Writer outStream;
73   -
74   - private IProject project;
75   -
76   - private OutputWriter ow;
77   -
78   - private List<Component> components;
79   - private Map<String, CabalPackage[]> packageDB;
80   -
81   - /**
82   - * where ever we come from, we only launch one build operation at a time, and lose the intermediate operations
83   - */
84   - private SingleJobQueue buildJobQueue=new SingleJobQueue();
85   - /**
86   - * query for thing at point for a given file, so that we never have more than two jobs at one time
87   - */
88   - private Map<IFile,SingleJobQueue> tapQueuesByFiles=new HashMap<IFile, SingleJobQueue>();
89   -
90   - /**
91   - * map of outlines for files (key is relative path)
92   - */
93   - private Map<String,OutlineResult> outlines=new HashMap<String, OutlineResult>();
94   -
95   -
96   - /**
97   - * map of flag info for files
98   - */
99   - //private Map<IFile, BuildFlagInfo> flagInfos=new HashMap<IFile, BuildFlagInfo>();
100   -
101   -
102   - /**
103   - * do we need to set derived on dist dir?
104   - */
105   - private boolean needSetDerivedOnDistDir=false;
106   -
107   - private boolean hasCabalProblems=false;
108   -
109   - public SingleJobQueue getBuildJobQueue() {
110   - return buildJobQueue;
111   - }
112   -
113   - public synchronized SingleJobQueue getThingAtPointJobQueue(IFile f){
114   - SingleJobQueue sjq=tapQueuesByFiles.get(f);
115   - if (sjq==null){
116   - sjq=new SingleJobQueue();
117   - tapQueuesByFiles.put(f, sjq);
118   - }
119   - return sjq;
120   - }
121   -
122   - private void deleteCabalProblems(){
123   - String relCabal=getCabalFile().substring(getProject().getLocation().toOSString().length());
124   - IFile f=getProject().getFile(relCabal);
125   - if (f!=null && f.exists()){
126   - BuildWrapperPlugin.deleteProblems(f);
127   - }
128   - }
129   -
130   - public JSONArray build(BuildOptions buildOptions){
131   - JSONArray arrC=null;
132   - if (buildOptions.isConfigure()){
133   - arrC=configure(buildOptions);
134   - if (!isOK(arrC)){
135   - return arrC;
136   - }
137   - }
138   -
139   - if (hasCabalProblems){
140   - deleteCabalProblems();
141   - hasCabalProblems=false;
142   - }
143   -
144   - LinkedList<String> command=new LinkedList<String>();
145   - command.add("build");
146   - command.add("--output="+buildOptions.isOutput());
147   - command.add("--cabaltarget="+buildOptions.getTarget().toString());
148   - JSONArray arr=run(command,ARRAY,false);
149   - if (arrC!=null){
150   - for (int a=0;a<arrC.length();a++){
151   - try {
152   - arr.put(a, arrC.get(a));
153   - } catch (JSONException je){
154   - BuildWrapperPlugin.logError(BWText.process_parse_note_error, je);
155   - }
156   - }
157   - }
158   -
159   - return arr;
160   - }
161   -
162   - public boolean parseBuildResult(JSONArray arr){
163   - if (arr!=null && arr.length()>1){
164   - Set<IResource> ress=new HashSet<IResource>();
165   - JSONObject obj=arr.optJSONObject(0);
166   - if (obj!=null){
167   - JSONArray files=obj.optJSONArray("fps");
168   - if (files!=null){
169   - for (int a=0;a<files.length();a++){
170   - String s=files.optString(a);
171   - if (s!=null && s.length()>0){
172   - final IResource res=project.findMember(s);
173   - if (res!=null){
174   - ress.add(res);
175   - BuildWrapperPlugin.deleteProblems(res);
176   - }
177   - }
178   - }
179   - }
180   - }
181   -
182   - JSONArray notes=arr.optJSONArray(1);
183   - return parseNotes(notes,ress);
184   - }
185   - return true;
186   - }
187   -
188   -// private static String escapeFlags(String flag){
189   -// // not needed any more: we have encoded them in Base 64
190   -// //flag=flag.replace("\"", "\\\"");
191   -// return flag;
192   -// }
193   -
194   - public boolean build1(IFile file){
195   - //BuildFlagInfo i=getBuildFlags(file);
196   - String path=file.getProjectRelativePath().toOSString();
197   - LinkedList<String> command=new LinkedList<String>();
198   - command.add("build1");
199   - command.add("--file="+path);
200   - //long t0=System.currentTimeMillis();
201   - //command.add("--buildflags="+escapeFlags(i.getFlags()));
202   - JSONArray arr=run(command,ARRAY);
203   - //long t1=System.currentTimeMillis();
204   - //BuildWrapperPlugin.logInfo("build:"+(t1-t0)+"ms");
205   - if (arr!=null && arr.length()>1){
206   - Set<IResource> ress=new HashSet<IResource>();
207   - ress.add(file);
208   - BuildWrapperPlugin.deleteProblems(file);
209   - JSONArray notes=arr.optJSONArray(1);
210   - //notes.putAll(i.getNotes());
211   - return parseNotes(notes,ress);
212   - }
213   - return true;
214   - }
215   -
216   -// public BuildFlagInfo getBuildFlags(IFile file){
217   -// BuildFlagInfo i=flagInfos.get(file);
218   -// if (i==null){
219   -// String path=file.getProjectRelativePath().toOSString();
220   -// LinkedList<String> command=new LinkedList<String>();
221   -// command.add("getbuildflags");
222   -// command.add("--file="+path);
223   -// JSONArray arr=run(command,ARRAY);
224   -// String s="";
225   -// JSONArray notes=new JSONArray();
226   -// if (arr!=null && arr.length()>1){
227   -// Set<IResource> ress=new HashSet<IResource>();
228   -// ress.add(file);
229   -// s=arr.optString(0);
230   -// notes=arr.optJSONArray(1);
231   -// }
232   -// i=new BuildFlagInfo(s, notes);
233   -// flagInfos.put(file, i);
234   -// }
235   -// return i;
236   -// }
237   -
238   - public JSONArray configure(BuildOptions buildOptions){
239   - parseFlags(); // reset flags in case they have changed
240   - //BuildWrapperPlugin.deleteProblems(getProject());
241   - LinkedList<String> command=new LinkedList<String>();
242   - command.add("configure");
243   - command.add("--cabaltarget="+buildOptions.getTarget().toString());
244   - JSONArray arr=run(command,ARRAY);
245   - if (arr!=null && arr.length()>1){
246   - JSONArray notes=arr.optJSONArray(1);
247   - return notes;
248   - }
249   - return null;
250   - }
251   -
252   - public void synchronize(boolean force){
253   - LinkedList<String> command=new LinkedList<String>();
254   - command.add("synchronize");
255   - command.add("--force="+force);
256   - JSONArray arr=run(command,ARRAY);
257   - if (arr!=null){
258   - if(arr.length()>1){
259   -
260   - JSONArray notes=arr.optJSONArray(1);
261   - parseNotes(notes);
262   - }
263   - JSONArray allPaths=arr.optJSONArray(0);
264   - if (allPaths!=null){
265   - JSONArray paths=allPaths.optJSONArray(0);
266   - if (paths!=null){
267   - for (int a=0;a<paths.length();a++){
268   - try {
269   - String p=paths.getString(a);
270   - if (p!=null && p.equals(cabalShortName)){
271   - cabalFileChanged();
272   - }
273   - // remove from cache if file has changed
274   - outlines.remove(p);
275   - } catch (JSONException je){
276   - BuildWrapperPlugin.logError(BWText.process_parse_component_error, je);
277   - }
278   - }
279   - }
280   - JSONArray dels=allPaths.optJSONArray(1);
281   - if (dels!=null){
282   - for (int a=0;a<dels.length();a++){
283   - try {
284   - String p=dels.getString(a);
285   - BuildWrapperPlugin.getDefault().getUsageAPI().removeFile(getProject(), p);
286   - } catch (JSONException je){
287   - BuildWrapperPlugin.logError(BWText.process_parse_component_error, je);
288   - }
289   - }
290   - }
291   - }
292   - }
293   - }
294   -
295   - public void generateUsage(Component c,boolean returnAll){
296   - LinkedList<String> command=new LinkedList<String>();
297   - command.add("generateusage");
298   - command.add("--cabalcomponent="+serializeComponent(c));
299   - command.add("--returnall="+returnAll);
300   - JSONArray arr=run(command,ARRAY);
301   - if (arr!=null){
302   - if(arr.length()>1){
303   -
304   - JSONArray notes=arr.optJSONArray(1);
305   - parseNotes(notes);
306   - }
307   - JSONArray allPaths=arr.optJSONArray(0);
308   - if (allPaths!=null){
309   - if (allPaths.length()>0){
310   - IFolder fldr=getProject().getFolder(BWFacade.DIST_FOLDER);
311   - if (fldr!=null && fldr.exists()){
312   - try {
313   - fldr.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
314   - } catch (CoreException ce){
315   - BuildWrapperPlugin.logError(BWText.error_refreshLocal, ce);
316   - }
317   - }
318   - }
319   - for (int a=0;a<allPaths.length();a++){
320   - try {
321   - String p=allPaths.getString(a);
322   - BuildWrapperPlugin.getDefault().getUsageAPI().addFile(getProject(),c, p);
323   - } catch (JSONException je){
324   - BuildWrapperPlugin.logError(BWText.error_parsing_usage_path, je);
325   - }
326   - }
327   - }
328   - }
329   - }
330   -
331   - public void cabalFileChanged(){
332   - components=null;
333   - packageDB=null;
334   - //flagInfos.clear();
335   - }
336   -
337   - public boolean synchronize1(IFile file,boolean force){
338   - String path=file.getProjectRelativePath().toOSString();
339   - LinkedList<String> command=new LinkedList<String>();
340   - command.add("synchronize1");
341   - command.add("--file="+path);
342   - command.add("--force="+force);
343   - String s=run(command,STRING);
344   - return s!=null;
345   - }
346   -
347   - public File write(IFile file,String contents){
348   - /*String path=file.getProjectRelativePath().toOSString();
349   - LinkedList<String> command=new LinkedList<String>();
350   - command.add("write");
351   - command.add("--file="+path);
352   - //command.add("--contents="+contents);
353   - //command.add("--contents=\""+contents.replace("\"", "\\\"")+"\"");
354   - command.add("--contents="+contents.replace("\"", "\\\""));
355   - String s=run(command,STRING);
356   - return s!=null;*/
357   - try {
358   - String path=file.getProjectRelativePath().toOSString();
359   - File tgt=new File(new File(workingDir,DIST_FOLDER),path);
360   - tgt.getParentFile().mkdirs();
361   - write(file,tgt, contents);
362   - return tgt;
363   - } catch (Exception e){
364   - BuildWrapperPlugin.logError(e.getLocalizedMessage(), e);
365   - }
366   - return null;
367   - }
368   -
369   - public boolean write(IFile file,File tgt,String contents){
370   - outlines.remove(file.getProjectRelativePath().toOSString());
371   - try {
372   - FileUtil.writeSharedFile(tgt, contents, 5);
373   - } catch (Exception e){
374   - BuildWrapperPlugin.logError(e.getLocalizedMessage(), e);
375   - }
376   - return false;
377   - }
378   -
379   - public List<Component> getComponents(){
380   - if (components!=null){
381   - return components;
382   - }
383   - LinkedList<String> command=new LinkedList<String>();
384   - command.add("components");
385   - JSONArray arr=run(command,ARRAY);
386   - List<Component> cps=new LinkedList<Component>();
387   - if (arr!=null){
388   - if (arr.length()>1){
389   -
390   - JSONArray notes=arr.optJSONArray(1);
391   - parseNotes(notes);
392   - }
393   - JSONArray objs=arr.optJSONArray(0);
394   - for (int a=0;a<objs.length();a++){
395   - try {
396   - cps.add(parseComponent(objs.getJSONObject(a)));
397   - } catch (JSONException je){
398   - BuildWrapperPlugin.logError(BWText.process_parse_component_error, je);
399   - }
400   - }
401   - }
402   - components=cps;
403   - return components;
404   - }
405   -
406   - public Map<String, CabalPackage[]> getPackagesByDB() {
407   - if (packageDB!=null){
408   - return packageDB;
409   - }
410   - LinkedList<String> command=new LinkedList<String>();
411   - command.add("dependencies");
412   - JSONArray arr=run(command,ARRAY);
413   - if (arr==null){
414   - return new HashMap<String, CabalPackage[]>();
415   - }
416   - Map<String, CabalPackage[]> cps=new HashMap<String, CabalPackage[]>();
417   - if (arr!=null && arr.length()>1){
418   - JSONArray notes=arr.optJSONArray(1);
419   - parseNotes(notes);
420   - }
421   - JSONArray objs=arr.optJSONArray(0);
422   - for (int a=0;a<objs.length();a++){
423   - try {
424   - JSONArray arr1=objs.getJSONArray(a);
425   - String fp=arr1.getString(0);
426   - JSONArray arr2=arr1.getJSONArray(1);
427   - CabalPackage[] pkgs=new CabalPackage[arr2.length()];
428   - for (int b=0;b<arr2.length();b++){
429   - pkgs[b]=parsePackage(arr2.getJSONObject(b));
430   - }
431   - cps.put(fp, pkgs);
432   - } catch (JSONException je){
433   - BuildWrapperPlugin.logError(BWText.process_parse_package_error, je);
434   - }
435   - }
436   - packageDB=cps;
437   - return packageDB;
438   - }
439   -
440   - public OutlineResult outline(IFile file){
441   -
442   - String path=file.getProjectRelativePath().toOSString();
443   - OutlineResult or=outlines.get(path);
444   - if (or!=null){
445   - return or;
446   - }
447   - //BuildFlagInfo i=getBuildFlags(file);
448   - LinkedList<String> command=new LinkedList<String>();
449   - command.add("outline");
450   - command.add("--file="+path);
451   - //command.add("--buildflags="+escapeFlags(i.getFlags()));
452   - JSONArray arr=run(command,ARRAY);
453   - or=new OutlineResult();
454   - if (arr!=null){
455   - if (arr.length()>1){
456   - JSONArray notes=arr.optJSONArray(1);
457   - //notes.putAll(i.getNotes());
458   - boolean b=parseNotes(notes);
459   - or.setBuildOK(b);
460   - }
461   - JSONObject obj=arr.optJSONObject(0);
462   - if (obj!=null){
463   - try {
464   - or=new OutlineResult(file, obj);
465   - } catch (JSONException je){
466   - BuildWrapperPlugin.logError(BWText.process_parse_outline_error, je);
467   - }
468   - } else {
469   - // old version pre 0.2.3
470   - JSONArray objs=arr.optJSONArray(0);
471   - for (int a=0;a<objs.length();a++){
472   - try {
473   - or.getOutlineDefs().add(new OutlineDef(file,objs.getJSONObject(a)));
474   - } catch (JSONException je){
475   - BuildWrapperPlugin.logError(BWText.process_parse_outline_error, je);
476   - }
477   - }
478   - }
479   - }
480   - outlines.put(path,or);
481   - return or;
482   - }
483   -
484   - public List<TokenDef> tokenTypes(IFile file){
485   - //long t0=System.currentTimeMillis();
486   - String path=file.getProjectRelativePath().toOSString();
487   - LinkedList<String> command=new LinkedList<String>();
488   - command.add("tokentypes");
489   - command.add("--file="+path);
490   - JSONArray arr=run(command,ARRAY);
491   - //long t01=System.currentTimeMillis();
492   - List<TokenDef> cps;
493   - if (arr!=null){
494   - if (arr.length()>1){
495   - JSONArray notes=arr.optJSONArray(1);
496   - parseNotes(notes);
497   - }
498   - JSONArray objs=arr.optJSONArray(0);
499   - cps=new ArrayList<TokenDef>(objs.length());
500   - String fn=file.getLocation().toOSString();
501   - for (int a=0;a<objs.length();a++){
502   - try {
503   - cps.add(new TokenDef(fn,objs.getJSONObject(a)));
504   - } catch (JSONException je){
505   - BuildWrapperPlugin.logError(BWText.process_parse_outline_error, je);
506   - }
507   - }
508   - } else {
509   - cps=new ArrayList<TokenDef>();
510   - }
511   - //long t1=System.currentTimeMillis();
512   - //BuildWrapperPlugin.logInfo("tokenTypes:"+(t1-t0)+"ms, parsing:"+(t1-t01)+"ms");
513   - return cps;
514   - }
515   -
516   - public BuildFlags getBuildFlags(IFile file){
517   - String path=file.getProjectRelativePath().toOSString();
518   - LinkedList<String> command=new LinkedList<String>();
519   - command.add("getbuildflags");
520   - command.add("--file="+path);
521   - JSONArray arr=run(command,ARRAY);
522   - if (arr!=null){
523   - if (arr.length()>1){
524   - JSONArray notes=arr.optJSONArray(1);
525   - //notes.putAll(i.getNotes());
526   - parseNotes(notes);