[Monodevelop-patches-list] r2237 - trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Sat Feb 5 20:36:17 EST 2005
Author: jluke
Date: 2005-02-05 20:36:17 -0500 (Sat, 05 Feb 2005)
New Revision: 2237
Removed:
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/ProjectTreeBuilder/
Modified:
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/ChangeLog
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/JavaBinding.addin.xml
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/JavaBindingCompilerServices.cs
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/Makefile.am
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/TODO
Log:
update java binding
Modified: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/ChangeLog 2005-02-06 01:29:45 UTC (rev 2236)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/ChangeLog 2005-02-06 01:36:17 UTC (rev 2237)
@@ -1,3 +1,14 @@
+2005-02-05 John Luke <john.luke at gmail.com>
+
+ * Makefile.am
+ * JavaBinding.addin.xml: remove custom node builder
+ * ProjectTreeBuilder/JavaNodeBuilder.cs: remove custom
+ node builder in favor of using the default so references
+ can be added (ikvm projects need IKVM.GNU.Classpath.dll and
+ IKVM.Runtime.dll)
+ * JavaBindingCompilerServices.cs: work like the C# bindings,
+ error parsing is broken but Im pretty sure it already was
+
2005-01-24 Lluis Sanchez Gual <lluis at novell.com>
* JavaBindingCompilerServices.cs:
Modified: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/JavaBinding.addin.xml
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/JavaBinding.addin.xml 2005-02-06 01:29:45 UTC (rev 2236)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/JavaBinding.addin.xml 2005-02-06 01:36:17 UTC (rev 2237)
@@ -73,10 +73,4 @@
class = "JavaBinding.JavaLanguageBinding" />
</Extension>
- <Extension path = "/SharpDevelop/Views/ProjectBrowser/NodeBuilders">
- <Class id = "JavaNodeBuilder"
- insertbefore = "DefaultBuilder"
- class = "JavaBinding.JavaNodeBuilder"/>
- </Extension>
-
</AddIn>
Modified: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/JavaBindingCompilerServices.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/JavaBindingCompilerServices.cs 2005-02-06 01:29:45 UTC (rev 2236)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/JavaBindingCompilerServices.cs 2005-02-06 01:36:17 UTC (rev 2237)
@@ -9,6 +9,7 @@
using System.Diagnostics;
using System.IO;
using System.CodeDom.Compiler;
+using System.Text;
using MonoDevelop.Gui.Components;
using MonoDevelop.Services;
@@ -24,14 +25,10 @@
return Path.GetExtension(fileName) == ".java";
}
- FileUtilityService fileUtilityService = (FileUtilityService) ServiceManager.GetService(typeof(FileUtilityService));
-
string GetCompilerName (JavaCompilerParameters cp)
{
if (cp.Compiler == JavaCompiler.Gcj)
- {
return "gcj";
- }
return "javac";
}
@@ -39,7 +36,8 @@
public ICompilerResult Compile (ProjectFileCollection projectFiles, ProjectReferenceCollection references, DotNetProjectConfiguration configuration, IProgressMonitor monitor)
{
JavaCompilerParameters compilerparameters = (JavaCompilerParameters) configuration.CompilationParameters;
- if (compilerparameters == null) compilerparameters = new JavaCompilerParameters ();
+ if (compilerparameters == null)
+ compilerparameters = new JavaCompilerParameters ();
string outdir = configuration.OutputDirectory;
string options = "";
@@ -77,7 +75,6 @@
}
}
- TempFileCollection tf = new TempFileCollection ();
string args = "";
if (compilerparameters.Compiler == JavaCompiler.Gcj)
@@ -92,20 +89,27 @@
}
//Console.WriteLine (args);
- StreamReader output;
- StreamReader error;
- DoCompilation (monitor, compiler, args, tf, configuration, compilerparameters, out output, out error);
- ICompilerResult cr = ParseOutput (tf, error);
-
+ string output = String.Empty;
+ string error = String.Empty;
+ TempFileCollection tf = new TempFileCollection ();
+ DoCompilation (monitor, compiler, args, tf, configuration, compilerparameters, ref output, ref error);
+ ICompilerResult cr = ParseOutput (tf, output, error);
+ File.Delete (output);
+ File.Delete (error);
return cr;
}
- private void DoCompilation (IProgressMonitor monitor, string compiler, string args, TempFileCollection tf, DotNetProjectConfiguration configuration, JavaCompilerParameters compilerparameters, out StreamReader output, out StreamReader error)
+ private void DoCompilation (IProgressMonitor monitor, string compiler, string args, TempFileCollection tf, DotNetProjectConfiguration configuration, JavaCompilerParameters compilerparameters, ref string output, ref string error)
{
+ output = Path.GetTempFileName ();
+ error = Path.GetTempFileName ();
+
try {
monitor.BeginTask (null, 2);
monitor.Log.WriteLine ("Compiling Java source code ...");
- ProcessStartInfo si = new ProcessStartInfo (compiler, args);
+ string arguments = String.Format ("-c \"{0} {1} > {2} 2> {3}\"", compiler, args, output, error);
+ ProcessStartInfo si = new ProcessStartInfo ("/bin/sh", arguments);
+ //Console.WriteLine ("{0} {1}", si.FileName, si.Arguments);
si.RedirectStandardOutput = true;
si.RedirectStandardError = true;
si.UseShellExecute = false;
@@ -116,27 +120,22 @@
monitor.Step (1);
monitor.Log.WriteLine ("Generating assembly ...");
- CompileToAssembly (configuration, compilerparameters);
-
- // FIXME: avoid having a full buffer
- // perhaps read one line and append parsed output
- // and then return cr at end
- output = p.StandardOutput;
- error = p.StandardError;
+ CompileToAssembly (configuration, compilerparameters, output, error);
} finally {
monitor.EndTask ();
}
}
- void CompileToAssembly (DotNetProjectConfiguration configuration, JavaCompilerParameters compilerparameters)
+ void CompileToAssembly (DotNetProjectConfiguration configuration, JavaCompilerParameters compilerparameters, string output, string error)
{
string outdir = configuration.OutputDirectory;
string outclass = Path.Combine (outdir, configuration.OutputAssembly + ".class");
string asm = Path.GetFileNameWithoutExtension (outclass);
// sadly I dont think we can specify the output .class name
- string args = String.Format ("{0} -assembly:{1}", "*.class", asm);
- ProcessStartInfo si = new ProcessStartInfo ("ikvmc", args);
+ string args = String.Format ("-c \"ikvmc {0} -assembly:{1} > {2} 2> {3}\"", "*.class", asm, output, error);
+ ProcessStartInfo si = new ProcessStartInfo ("/bin/sh", args);
+ //Console.WriteLine ("{0} {1}", si.FileName, si.Arguments);
si.WorkingDirectory = outdir;
si.RedirectStandardOutput = true;
si.RedirectStandardError = true;
@@ -147,48 +146,72 @@
p.WaitForExit ();
}
- ICompilerResult ParseOutput (TempFileCollection tf, StreamReader errorStream)
+ ICompilerResult ParseOutput (TempFileCollection tf, string stdout, string stderr)
{
- string compilerOutput = "";
- StreamReader sr = errorStream;
+ StringBuilder compilerOutput = new StringBuilder ();
CompilerResults cr = new CompilerResults (tf);
- while (true)
+ foreach (string s in new string[] { stdout, stderr })
{
- string next = sr.ReadLine ();
+ StreamReader sr = File.OpenText (s);
+ while (true)
+ {
+ string next = sr.ReadLine ();
- if (next == null)
- break;
+ if (next == null)
+ break;
- CompilerError error = new CompilerError ();
+ CompilerError error = CreateErrorFromString (next);
- int errorCol = 0;
- string col = next.Trim ();
- if (col.Length == 1 && col == "^")
- errorCol = next.IndexOf ("^");
+ if (error != null)
+ cr.Errors.Add (error);
+ }
+ sr.Close ();
+ }
+ return new DefaultCompilerResult (cr, compilerOutput.ToString ());
+ }
- compilerOutput += next + "\n";
+ // FIXME: the various java compilers will probably need to be parse on
+ // their own and then ikvmc would need one as well
+ private static CompilerError CreateErrorFromString (string error)
+ {
+ if (error.StartsWith ("Note") || error.StartsWith ("Warning"))
+ return null;
+ string trimmed = error.Trim ();
+ if (trimmed.StartsWith ("(to avoid this warning add"))
+ return null;
+ //Console.WriteLine ("error: {0}", error);
- int index1 = next.IndexOf (".java:");
- if (index1 < 0)
- continue;
+ CompilerError cerror = new CompilerError ();
+ cerror.ErrorText = error;
+ return cerror;
+ }
+/* old javac parser
+ CompilerError error = new CompilerError ();
+
+ int errorCol = 0;
+ string col = next.Trim ();
+ if (col.Length == 1 && col == "^")
+ errorCol = next.IndexOf ("^");
+
+ compilerOutput.Append (next);
+ compilerOutput.Append ("\n");
+
+ int index1 = next.IndexOf (".java:");
+ if (index1 < 0)
+ continue;
- //string s1 = next.Substring (0, index1);
- string s2 = next.Substring (index1 + 6);
- int index2 = s2.IndexOf (":");
- int line = Int32.Parse (next.Substring (index1 + 6, index2));
- //error.IsWarning = what[0] == "warning";
- //error.ErrorNumber = what[what.Length - 1];
+ //string s1 = next.Substring (0, index1);
+ string s2 = next.Substring (index1 + 6);
+ int index2 = s2.IndexOf (":");
+ int line = Int32.Parse (next.Substring (index1 + 6, index2));
+ //error.IsWarning = what[0] == "warning";
+ //error.ErrorNumber = what[what.Length - 1];
- error.Column = errorCol;
- error.Line = line;
- error.ErrorText = next.Substring (index1 + index2 + 7);
- error.FileName = Path.GetFullPath (next.Substring (0, index1) + ".java"); //Path.GetFileName(filename);
- cr.Errors.Add (error);
- }
-
- sr.Close ();
- return new DefaultCompilerResult (cr, compilerOutput);
- }
+ error.Column = errorCol;
+ error.Line = line;
+ error.ErrorText = next.Substring (index1 + index2 + 7);
+ error.FileName = Path.GetFullPath (next.Substring (0, index1) + ".java"); //Path.GetFileName(filename);
+*/
}
}
Modified: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/Makefile.am
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/Makefile.am 2005-02-06 01:29:45 UTC (rev 2236)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/Makefile.am 2005-02-06 01:36:17 UTC (rev 2237)
@@ -13,8 +13,7 @@
Project/JavaCompilerParameters.cs \
JavaBindingCompilerServices.cs \
JavaCompiler.cs \
-JavaLanguageBinding.cs \
-ProjectTreeBuilder/JavaNodeBuilder.cs
+JavaLanguageBinding.cs
TEMPLATES = \
templates/EmptyJavaFile.xft.xml \
Modified: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/TODO
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/TODO 2005-02-06 01:29:45 UTC (rev 2236)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/JavaBinding/TODO 2005-02-06 01:36:17 UTC (rev 2237)
@@ -1,4 +1,4 @@
- - fix execution from MD
+ - fix regluar java templates
- make classpath handling better
- support turning a jar to a dll simply
- support more java compilers (like ecj)
More information about the Monodevelop-patches-list
mailing list