Add a source file completer to the CommandCompleters.
Add a way for the completers to say whether the completed argument should have a space inserted after is
or not.
Added the file name completer to the "file" command.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@107247 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp
index c4abb8d..f37e985 100644
--- a/source/Interpreter/CommandInterpreter.cpp
+++ b/source/Interpreter/CommandInterpreter.cpp
@@ -653,11 +653,13 @@
                 int num_matches;
                 int cursor_index = command_args.GetArgumentCount() - 1;
                 int cursor_char_position = strlen (command_args.GetArgumentAtIndex(command_args.GetArgumentCount() - 1));
+                bool word_complete;
                 num_matches = HandleCompletionMatches (command_args, 
                                                        cursor_index,
                                                        cursor_char_position,
                                                        0, 
                                                        -1, 
+                                                       word_complete,
                                                        matches);
 
                 if (num_matches > 0)
@@ -692,11 +694,15 @@
                                              int &cursor_char_position,
                                              int match_start_point,
                                              int max_return_elements,
+                                             bool &word_complete,
                                              StringList &matches)
 {
     int num_command_matches = 0;
     bool include_aliases = true;
     bool look_for_subcommand = false;
+    
+    // For any of the command completions a unique match will be a complete word.
+    word_complete = true;
 
     if (cursor_index == -1)
     {
@@ -743,7 +749,8 @@
                                                                     cursor_index, 
                                                                     cursor_char_position,
                                                                     match_start_point, 
-                                                                    max_return_elements, 
+                                                                    max_return_elements,
+                                                                    word_complete, 
                                                                     matches);
         }
     }
@@ -781,11 +788,13 @@
 
     // Only max_return_elements == -1 is supported at present:
     assert (max_return_elements == -1);
+    bool word_complete;
     num_command_matches = HandleCompletionMatches (parsed_line, 
                                                    cursor_index, 
                                                    cursor_char_position, 
                                                    match_start_point,
-                                                   max_return_elements, 
+                                                   max_return_elements,
+                                                   word_complete,
                                                    matches);
 
     if (num_command_matches <= 0)
@@ -809,7 +818,8 @@
         int partial_name_len = command_partial_str.size();
 
         // If we matched a unique single command, add a space...
-        if (num_command_matches == 1)
+        // Only do this if the completer told us this was a complete word, however...
+        if (num_command_matches == 1 && word_complete)
         {
             char quote_char = parsed_line.GetArgumentQuoteCharAtIndex(cursor_index);
             if (quote_char != '\0')
diff --git a/source/Interpreter/CommandObject.cpp b/source/Interpreter/CommandObject.cpp
index 2813ac1..7ee9137 100644
--- a/source/Interpreter/CommandObject.cpp
+++ b/source/Interpreter/CommandObject.cpp
@@ -304,6 +304,7 @@
     int &cursor_char_position,
     int match_start_point,
     int max_return_elements,
+    bool &word_complete,
     StringList &matches
 )
 {
@@ -345,6 +346,7 @@
                                                                       cursor_char_position,
                                                                       match_start_point,
                                                                       max_return_elements,
+                                                                      word_complete,
                                                                       matches);
             if (handled_by_options)
                 return matches.GetSize();
@@ -358,6 +360,7 @@
                                          opt_element_vector,
                                          match_start_point,
                                          max_return_elements,
+                                         word_complete,
                                          matches);
     }
 }
diff --git a/source/Interpreter/Options.cpp b/source/Interpreter/Options.cpp
index 5698b28..28f2922 100644
--- a/source/Interpreter/Options.cpp
+++ b/source/Interpreter/Options.cpp
@@ -538,9 +538,12 @@
     int char_pos,
     int match_start_point,
     int max_return_elements,
+    bool &word_complete,
     lldb_private::StringList &matches
 )
 {
+    word_complete = true;
+    
     // For now we just scan the completions to see if the cursor position is in
     // an option or its argument.  Otherwise we'll call HandleArgumentCompletion.
     // In the future we can use completion to validate options as well if we want.
@@ -658,6 +661,7 @@
                                                 i,
                                                 match_start_point,
                                                 max_return_elements,
+                                                word_complete,
                                                 matches);
                 return true;
             }
@@ -688,6 +692,7 @@
     int opt_element_index,
     int match_start_point,
     int max_return_elements,
+    bool &word_complete,
     lldb_private::StringList &matches
 )
 {
@@ -754,6 +759,7 @@
                                                                 match_start_point,
                                                                 max_return_elements,
                                                                 filter_ap.get(),
+                                                                word_complete,
                                                                 matches);
     
 }