[Monodevelop-patches-list] r1249 - in trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding: . FormatingStrategy Project ProjectTreeBuilder

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Thu Mar 25 21:16:04 EST 2004


Author: jluke
Date: 2004-03-25 21:16:04 -0500 (Thu, 25 Mar 2004)
New Revision: 1249

Modified:
   trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/ChangeLog
   trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/FormatingStrategy/JavaFormattingStrategy.cs
   trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/JavaBindingCompilerServices.cs
   trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/JavaBindingExecutionServices.cs
   trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/Makefile.am
   trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/Project/JavaCompilerParameters.cs
   trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/Project/JavaProject.cs
   trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/ProjectTreeBuilder/JavaNodeBuilder.cs
Log:
compiling seems to work, and I can almost run now


Modified: trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/ChangeLog
===================================================================
--- trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/ChangeLog	2004-03-26 00:03:38 UTC (rev 1248)
+++ trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/ChangeLog	2004-03-26 02:16:04 UTC (rev 1249)
@@ -2,3 +2,4 @@
 	
 	import from SD and make it build with our
 	namespaces and SourceEditor
+	change to work like CSharpBinding 

Modified: trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/FormatingStrategy/JavaFormattingStrategy.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/FormatingStrategy/JavaFormattingStrategy.cs	2004-03-26 00:03:38 UTC (rev 1248)
+++ trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/FormatingStrategy/JavaFormattingStrategy.cs	2004-03-26 02:16:04 UTC (rev 1249)
@@ -33,46 +33,43 @@
 		/// <summary>
 		/// Define Java specific smart indenting for a line :)
 		/// </summary>
-		protected override int SmartIndentLine(IFormattableDocument textArea, int lineNr)
+		protected override int SmartIndentLine(IFormattableDocument d, int lineNr)
 		{
-/*
 			if (lineNr > 0) {
-				LineSegment lineAbove    = textArea.Document.GetLineSegment(lineNr - 1);
-				string  lineAboveText = textArea.Document.GetText(lineAbove.Offset, lineAbove.Length).Trim();
-				
-				LineSegment curLine = textArea.Document.GetLineSegment(lineNr);
-				string  curLineText = textArea.Document.GetText(curLine.Offset, curLine.Length).Trim();
-				
+				string  lineAboveText = d.GetLineAsString (lineNr - 1);
+                string  trimlineAboveText = lineAboveText.Trim ();
+                string  curLineText = d.GetLineAsString (lineNr);
+                string  trimcurLineText = curLineText.Trim ();
+
 				if (lineAboveText.EndsWith(")") && curLineText.StartsWith("{")) {
-					string indentation = GetIndentation(textArea, lineNr - 1);
-					textArea.Document.Replace(curLine.Offset, curLine.Length, indentation + curLineText);
+					string indentation = GetIndentation(d, lineNr - 1);
+					d.ReplaceLine (lineNr, indentation + curLineText);
 					return indentation.Length;
 				}
 				
 				if (curLineText.StartsWith("}")) { // indent closing bracket.
-					int closingBracketOffset = TextUtilities.SearchBracketBackward(textArea.Document, curLine.Offset + textArea.Document.GetText(curLine.Offset, curLine.Length).IndexOf('}') - 1, '{', '}');
+					int openLine;
+					int closingBracketOffset = d.GetClosingBraceForLine (lineNr, out openLine);
 					if (closingBracketOffset == -1) {  // no closing bracket found -> autoindent
-						return AutoIndentLine(textArea, lineNr);
+						return AutoIndentLine(d, lineNr);
 					}
 					
-					string indentation = GetIndentation(textArea, textArea.Document.GetLineNumberForOffset(closingBracketOffset));
+					string indentation = GetIndentation (d, lineNr - 1);
 					
-					textArea.Document.Replace(curLine.Offset, curLine.Length, indentation + curLineText);
+					d.ReplaceLine (lineNr, indentation + curLineText);
 					return indentation.Length;
 				}
 				
 				if (lineAboveText.EndsWith(";")) { // expression ended, reset to valid indent.
-					int closingBracketOffset = TextUtilities.SearchBracketBackward(textArea.Document, curLine.Offset + textArea.Document.GetText(curLine.Offset, curLine.Length).IndexOf('}') - 1, '{', '}');
-					
+					int openLine;
+					int closingBracketOffset = d.GetClosingBraceForLine (lineNr, out openLine);	
 					if (closingBracketOffset == -1) {  // no closing bracket found -> autoindent
-						return AutoIndentLine(textArea, lineNr);
+						return AutoIndentLine(d, lineNr);
 					}
 					
-					int closingBracketLineNr = textArea.Document.GetLineNumberForOffset(closingBracketOffset);
-					LineSegment closingBracketLine = textArea.Document.GetLineSegment(closingBracketLineNr);
-					string  closingBracketLineText = textArea.Document.GetText(closingBracketLine.Offset, closingBracketLine.Length).Trim();
+					string closingBracketLineText = d.GetLineAsString (openLine).Trim ();
 					
-					string indentation = GetIndentation(textArea, closingBracketLineNr);
+					string indentation = GetIndentation (d, openLine);
 					
 					// special handling for switch statement formatting.
 					if (closingBracketLineText.StartsWith("switch")) {
@@ -80,12 +77,12 @@
 						    lineAboveText.StartsWith("goto")   || 
 						    lineAboveText.StartsWith("return")) {
 					    } else {
-					    	indentation += ICSharpCode.TextEditor.Actions.Tab.GetIndentationString(textArea.Document);
+					    	indentation += d.IndentString;
 					    }
 					}
-			    	indentation += ICSharpCode.TextEditor.Actions.Tab.GetIndentationString(textArea.Document);
+			    	indentation += d.IndentString;
 					
-					textArea.Document.Replace(curLine.Offset, curLine.Length, indentation + curLineText);
+					d.ReplaceLine (lineNr, indentation + curLineText);
 					return indentation.Length;
 				}
 				
@@ -96,8 +93,8 @@
 			    	 lineAboveText.StartsWith("while") ||
 			    	 lineAboveText.StartsWith("for"))) ||
 			    	 lineAboveText.EndsWith("else")) {
-			    	 	string indentation = GetIndentation(textArea, lineNr - 1) + ICSharpCode.TextEditor.Actions.Tab.GetIndentationString(textArea.Document);
-						textArea.Document.Replace(curLine.Offset, curLine.Length, indentation + curLineText);
+						string indentation = GetIndentation (d, lineNr - 1) + d.IndentString;
+                        d.ReplaceLine (lineNr, indentation + curLineText);
 						return indentation.Length;
 			    } else {
 			    	// try to indent linewrap
@@ -116,19 +113,18 @@
 			    	}
 			    	if (bracketPos.Count > 0) {
 			    		int bracketIndex = (int)bracketPos[bracketPos.Count - 1];
-			    		string indentation = GetIndentation(textArea, lineNr - 1);
+			    		string indentation = GetIndentation (d, lineNr - 1);
 			    		
 			    		for (int i = 0; i <= bracketIndex; ++i) { // insert enough spaces to match
 			    			indentation += " ";                   // brace start in the next line
 			    		}
 			    		
-						textArea.Document.Replace(curLine.Offset, curLine.Length, indentation + curLineText);
+						d.ReplaceLine (lineNr, indentation + curLineText);
 						return indentation.Length;
 			    	}
 			    }
 			}
-			return AutoIndentLine(textArea, lineNr);*/
-			return 0;
+			return AutoIndentLine (d, lineNr);
 		}
 		
 		bool NeedCurlyBracket(string text) 
@@ -184,62 +180,57 @@
 			return curlyCounter > 0;
 		}
 		
-		public override int FormatLine(IFormattableDocument textArea,int lineNr, int cursorOffset, char ch) // used for comment tag formater/inserter
+		// used for comment tag formater/inserter
+		public override int FormatLine (IFormattableDocument d, int lineNr, int cursorOffset, char ch)
 		{
-/*
 			switch (ch) {
-				case '}':
-				case '{':
-					return textArea.Document.FormattingStrategy.IndentLine(textArea, lineNr);
+				//case '}':
+				//case '{':
+				//	return d.FormattingStrategy.IndentLine (d, lineNr);
 				case '\n':
 					if (lineNr <= 0) {
-						return IndentLine(textArea, lineNr);
+						return IndentLine(d, lineNr);
 					}
 					
-					if (textArea.TextEditorProperties.AutoInsertCurlyBracket) {
-						string oldLineText = TextUtilities.GetLineAsString(textArea.Document, lineNr - 1);
-						if (oldLineText.EndsWith("{")) {
-							if (NeedCurlyBracket(textArea.Document.TextContent)) {
-								textArea.Document.Insert(textArea.Caret.Offset, "\n}");
-								IndentLine(textArea, lineNr + 1);
-							}
+					if (d.AutoInsertCurlyBracket) {
+						string oldLineText = d.GetLineAsString (lineNr - 1);
+						if (oldLineText.EndsWith ("{") && NeedCurlyBracket (d.TextContent)) {
+								d.Insert (cursorOffset, "\n}");
+								IndentLine(d, lineNr + 1);
 						}
 					}
 					
-					LineSegment    lineAbove     = textArea.Document.GetLineSegment(lineNr - 1);
-					string  lineAboveText = textArea.Document.GetText(lineAbove.Offset, lineAbove.Length);
+					string  lineAboveText = d.GetLineAsString (lineNr - 1);
 					
-					LineSegment    curLine       = textArea.Document.GetLineSegment(lineNr);
-			
-					LineSegment    nextLine      = lineNr + 1 < textArea.Document.TotalNumberOfLines ? textArea.Document.GetLineSegment(lineNr + 1) : null;
-					string  nextLineText  = lineNr + 1 < textArea.Document.TotalNumberOfLines ? textArea.Document.GetText(nextLine.Offset, nextLine.Length) : "";
 					
+#if NON_PORTABLE_CODE
 					if (lineAbove.HighlightSpanStack != null && lineAbove.HighlightSpanStack.Count > 0) {				
 						if (!((Span)lineAbove.HighlightSpanStack.Peek()).StopEOL) {	// case for /* style comments
 							int index = lineAboveText.IndexOf("/*");
 							
 							if (index > 0) {
-								string indentation = GetIndentation(textArea, lineNr - 1);
+								string indentation = GetIndentation(d, lineNr - 1);
 								for (int i = indentation.Length; i < index; ++ i) {
 									indentation += ' ';
 								}
-								textArea.Document.Replace(curLine.Offset, cursorOffset - curLine.Offset, indentation + " * ");
+								d.Document.Replace(curLine.Offset, cursorOffset - curLine.Offset, indentation + " * ");
 								return indentation.Length + 3;
 							}
 							
 							index = lineAboveText.IndexOf("*");
 							if (index > 0) {
-								string indentation = GetIndentation(textArea, lineNr - 1);
+								string indentation = GetIndentation(d, lineNr - 1);
 								for (int i = indentation.Length; i < index; ++ i) {
 									indentation += ' ';
 								}
-								textArea.Document.Replace(curLine.Offset, cursorOffset - curLine.Offset, indentation + "* ");
+								d.Document.Replace(curLine.Offset, cursorOffset - curLine.Offset, indentation + "* ");
 								return indentation.Length + 2;
 							}
 						}
 					}
-					return IndentLine(textArea, lineNr);
-			}*/
+#endif
+					return IndentLine(d, lineNr);
+			}
 			return 0;
 		}
 	}

Modified: trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/JavaBindingCompilerServices.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/JavaBindingCompilerServices.cs	2004-03-26 00:03:38 UTC (rev 1248)
+++ trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/JavaBindingCompilerServices.cs	2004-03-26 02:16:04 UTC (rev 1249)
@@ -6,6 +6,7 @@
 // </file>
 
 using System;
+using System.Diagnostics;
 using System.IO;
 using System.CodeDom.Compiler;
 
@@ -64,7 +65,9 @@
 		{
 			return Path.ChangeExtension(fileName, ".class");
 		}
+
 		FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.Services.GetService(typeof(FileUtilityService));
+
 		public string GetCompiledOutputName(IProject project)
 		{
 			JavaProject p = (JavaProject)project;
@@ -122,10 +125,11 @@
 			
 			//string outstr = compilerparameters.CompilerPath + "" + files + " -classpath " + compilerparameters.ClassPath + options;
 			//string outstr = compilerparameters.CompilerPath + "" + files + " -classpath " + compilerparameters.ClassPath + options;
+
 			string outstr = compilerparameters.CompilerPath + " " + files + options;			
-			Executor.ExecWaitWithCapture(outstr, tf, ref error , ref output);			
-			ICompilerResult cr = ParseOutput(tf, output);			
-			
+			DoCompilation (outstr, tf, ref output, ref error);
+			//Executor.ExecWaitWithCapture(outstr, tf, ref error , ref output);			
+			ICompilerResult cr = ParseOutput (tf, output);			
 			File.Delete(output);
 			File.Delete(error);
 			
@@ -143,6 +147,23 @@
 			
 			return cr;
 		}
+
+		private void DoCompilation (string outstr, TempFileCollection tf, ref string output, ref string error)
+		{
+			output = Path.GetTempFileName ();
+            error = Path.GetTempFileName ();
+
+            string arguments = outstr + " > " + output + " 2> " + error;
+            string command = arguments;
+            ProcessStartInfo si = new ProcessStartInfo("/bin/sh -c \"" + command + "\"");
+			si.RedirectStandardOutput = true;
+            si.RedirectStandardError = true;
+			si.UseShellExecute = false;
+			Process p = new Process ();
+            p.StartInfo = si;
+            p.Start ();
+            p.WaitForExit ();
+        }
 		
 		ICompilerResult ParseOutput(TempFileCollection tf, string file)
 		{

Modified: trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/JavaBindingExecutionServices.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/JavaBindingExecutionServices.cs	2004-03-26 00:03:38 UTC (rev 1248)
+++ trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/JavaBindingExecutionServices.cs	2004-03-26 02:16:04 UTC (rev 1249)
@@ -30,7 +30,7 @@
 		public void Execute(string filename)
 		{
 			string exe = Path.GetFileNameWithoutExtension(filename);
-			ProcessStartInfo psi = new ProcessStartInfo(Environment.GetEnvironmentVariable("ComSpec"), "/c java " + "\"" + exe + "\"" + " & pause");
+			ProcessStartInfo psi = new ProcessStartInfo(Environment.GetEnvironmentVariable("ComSpec"), "/c java\"" + " & pause");
 			psi.WorkingDirectory = Path.GetDirectoryName(filename);
 			psi.UseShellExecute = false;
 			try {
@@ -38,7 +38,7 @@
 				p.StartInfo = psi;
 				p.Start();
 			} catch (Exception) {
-				throw new ApplicationException("Can't execute " + "\"" + exe + "\"\n(.NET bug? Try restaring SD or manual start)");
+				throw new ApplicationException("Can not execute " + "\"" + exe + "\"\n(Try restarting MonoDevelop or manual start)");
 			}
 		}
 		
@@ -52,24 +52,31 @@
 			Directory.SetCurrentDirectory(parameters.OutputDirectory);
 			ProcessStartInfo psi;
 			if(((JavaCompilerParameters)project.ActiveConfiguration).MainClass==null) {
-				psi = new ProcessStartInfo(Environment.GetEnvironmentVariable("ComSpec"), "/c java " + ((JavaCompilerParameters)project.ActiveConfiguration).OutputAssembly +  " & pause");
+					//FIXME:
+				psi = new ProcessStartInfo("java " + ((JavaCompilerParameters)project.ActiveConfiguration).OutputAssembly);
 			} else {
 				if (parameters.PauseConsoleOutput) {
-					psi = new ProcessStartInfo(Environment.GetEnvironmentVariable("ComSpec"), "/c java " + ((JavaCompilerParameters)project.ActiveConfiguration).MainClass +  " & pause");
+					//FIXME:
+					psi = new ProcessStartInfo("java " + ((JavaCompilerParameters)project.ActiveConfiguration).MainClass);
 				} else {
-					psi = new ProcessStartInfo(Environment.GetEnvironmentVariable("ComSpec"), "/c java " + ((JavaCompilerParameters)project.ActiveConfiguration).MainClass);
+					//FIXME:
+					psi = new ProcessStartInfo("java " + ((JavaCompilerParameters)project.ActiveConfiguration).MainClass);
 				}
 			}
 			
 			try {
+				Console.WriteLine ("*******************");
+				Console.WriteLine (parameters.OutputDirectory);
+				Console.WriteLine (psi.WorkingDirectory);
 				psi.WorkingDirectory = parameters.OutputDirectory;
 				psi.UseShellExecute = false;
 			
 				Process p = new Process();
 				p.StartInfo = psi;
 				p.Start();
-			} catch (Exception) {
-				throw new ApplicationException("Can't execute");
+			} catch (Exception e) {
+				Console.WriteLine (e.ToString ());
+				throw new ApplicationException("Can not execute");
 			}
 			
 			Directory.SetCurrentDirectory(CurrentDir);		

Modified: trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/Makefile.am
===================================================================
--- trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/Makefile.am	2004-03-26 00:03:38 UTC (rev 1248)
+++ trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/Makefile.am	2004-03-26 02:16:04 UTC (rev 1249)
@@ -23,8 +23,12 @@
 all: $(ASSEMBLY)
 
 $(ASSEMBLY): $(FILES)
-	$(CSC) $(DLLS) $(FILES) /out:$(ASSEMBLY) /target:library
+	$(CSC) $(DLLS) $(FILES) /out:$(ASSEMBLY) /target:library \
+	&& cp $(ASSEMBLY) ../../../../build/AddIns/AddIns/BackendBindings/.
 
+assemblydir = $(libdir)/monodevelop/AddIns/AddIns/BackendBindings/
+assembly_DATA = $(ASSEMBLY)
+
 CLEANFILES = $(ASSEMBLY)
 EXTRA_DIST = $(FILES) $(ADDIN)
 

Modified: trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/Project/JavaCompilerParameters.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/Project/JavaCompilerParameters.cs	2004-03-26 00:03:38 UTC (rev 1248)
+++ trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/Project/JavaCompilerParameters.cs	2004-03-26 02:16:04 UTC (rev 1249)
@@ -40,7 +40,7 @@
 			public string         classpath = String.Empty;
 			
 			[XmlAttribute("compilerpath")]
-			public string         compilerpath  = "javac.exe";		
+			public string         compilerpath  = "javac";		
 			
 			[XmlAttribute("genwarnings")]
 			public bool genwarnings = false;
@@ -77,7 +77,9 @@
 		
 		public string CompilerPath {
 			get {
-				return codeGeneration.compilerpath;
+				//return codeGeneration.compilerpath;
+				//FIXME
+				return "javac";
 			}
 			set {
 				codeGeneration.compilerpath = value;

Modified: trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/Project/JavaProject.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/Project/JavaProject.cs	2004-03-26 00:03:38 UTC (rev 1248)
+++ trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/Project/JavaProject.cs	2004-03-26 02:16:04 UTC (rev 1249)
@@ -19,7 +19,7 @@
 {
 	
 	/// <summary>
-	/// This class describes a C Sharp project and it compilation options.
+	/// This class describes a Java project and it compilation options.
 	/// </summary>
 	public class JavaProject : AbstractProject
 	{		

Modified: trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/ProjectTreeBuilder/JavaNodeBuilder.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/ProjectTreeBuilder/JavaNodeBuilder.cs	2004-03-26 00:03:38 UTC (rev 1248)
+++ trunk/MonoDevelop/src/AddIns/BackendBindings/JavaBinding/ProjectTreeBuilder/JavaNodeBuilder.cs	2004-03-26 02:16:04 UTC (rev 1249)
@@ -18,6 +18,7 @@
 using MonoDevelop.Internal.Project;
 using MonoDevelop.Gui;
 using MonoDevelop.Gui.Pads.ProjectBrowser;
+using MonoDevelop.Gui.Widgets;
 
 namespace JavaBinding
 {
@@ -34,10 +35,9 @@
 		
 		public AbstractBrowserNode BuildProjectTreeNode(IProject project)
 		{
-/*
 			ProjectBrowserNode projectNode = new ProjectBrowserNode(project);
 			
-			projectNode.IconImage = iconService.GetImageForProjectType(project.ProjectType);
+			//projectNode.IconImage = iconService.GetImageForProjectType(project.ProjectType);
 			
 			// create 'empty' directories			
 			for (int i = 0; i < project.ProjectFiles.Count; ++i) {
@@ -54,8 +54,8 @@
 					AbstractBrowserNode currentPathNode = GetPath(directoryName, projectNode, true);
 					
 					DirectoryNode newFolderNode  = new DirectoryNode(project.ProjectFiles[i].Name);
-					newFolderNode.OpenedImage = resourceService.GetBitmap("Icons.16x16.OpenFolderBitmap");
-					newFolderNode.ClosedImage = resourceService.GetBitmap("Icons.16x16.ClosedFolderBitmap");
+					//newFolderNode.OpenedImage = resourceService.GetBitmap ("Icons.16x16.OpenFolderBitmap");
+					//newFolderNode.ClosedImage = resourceService.GetBitmap ("Icons.16x16.ClosedFolderBitmap");
 					
 					currentPathNode.Nodes.Add(newFolderNode);
 				
@@ -88,11 +88,8 @@
 			}
 			
 			return projectNode;
-*/
-			return null;
 		}
 
-/*		
 		AbstractBrowserNode GetNodeFromCollection (TreeNodeCollection collection, string title)
 		{
 			foreach (AbstractBrowserNode node in collection) {
@@ -102,7 +99,6 @@
 			}
 			return null;
 		}
-*/
 		
 		public AbstractBrowserNode GetPath(string filename, AbstractBrowserNode root, bool create)
 		{




More information about the Monodevelop-patches-list mailing list