Browse Source

Fixed BOO-380 (Namespace aliases handled incorrectly during code completion).

Fixed BOO-515 (Expression resolver thinks " is String.Empty).
Fixed BOO-346 (Addin does not reference Boo.Lang.Useful by default)

ParserFoldingStrategy now uses both the RecentCompilationUnit and ValidCompilationUnit for folding. This makes folding more stable in VB and Boo.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@584 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
53453edab6
  1. 1
      src/AddIns/BackendBindings/Boo/BooBinding/Project/PostBuildEvent.bat
  2. 3
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/BooProject.cs
  3. 13
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooParser.cs
  4. 5
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooResolver.cs
  5. 2
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/CompletionBinding.cs
  6. 8
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/ConvertVisitor.cs
  7. 80
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/ExpressionFinder.cs
  8. 8
      src/Main/Base/Project/Src/Dom/IExpressionFinder.cs
  9. 19
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/ParserFoldingStrategy.cs

1
src/AddIns/BackendBindings/Boo/BooBinding/Project/PostBuildEvent.bat

@ -9,5 +9,6 @@ popd @@ -9,5 +9,6 @@ popd
:copyFiles
copy "%1\..\..\RequiredLibraries\booc.*" .
copy "%1\..\..\RequiredLibraries\*.targets" .
copy "%1\..\..\RequiredLibraries\Boo.Lang.Useful.dll" .
copy "%1\..\..\RequiredLibraries\Boo.Microsoft.Build.Tasks.dll" .
:BooPostBuildEventEnd

3
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/BooProject.cs

@ -57,6 +57,9 @@ namespace Grunwald.BooBinding @@ -57,6 +57,9 @@ namespace Grunwald.BooBinding
pc.ReferencedContents.Add(ProjectContentRegistry.GetProjectContentForReference(systemItem));
ReferenceProjectItem booLangItem = new ReferenceProjectItem(this, typeof(Boo.Lang.Builtins).Assembly.Location);
pc.ReferencedContents.Add(ProjectContentRegistry.GetProjectContentForReference(booLangItem));
string booDir = Path.GetDirectoryName(typeof(Boo.Lang.Builtins).Assembly.Location);
ReferenceProjectItem booUsefulItem = new ReferenceProjectItem(this, Path.Combine(booDir, "Boo.Lang.Useful.dll"));
pc.ReferencedContents.Add(ProjectContentRegistry.GetProjectContentForReference(booUsefulItem));
pc.DefaultImports = new DefaultUsing(pc);
pc.DefaultImports.Usings.Add("Boo.Lang.Builtins");
return pc;

13
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooParser.cs

@ -103,16 +103,21 @@ namespace Grunwald.BooBinding.CodeCompletion @@ -103,16 +103,21 @@ namespace Grunwald.BooBinding.CodeCompletion
num = compilePipe.Find(typeof(TransformCallableDefinitions));
compilePipe.RemoveAt(num);
for (int i = 0; i < compilePipe.Count; i++) {
Console.WriteLine(compilePipe[i]);
}
//for (int i = 0; i < compilePipe.Count; i++) {
// Console.WriteLine(compilePipe[i]);
//}
compilePipe.BreakOnErrors = false;
compiler.Parameters.Pipeline = compilePipe;
int errorCount = 0;
compilePipe.AfterStep += delegate(object sender, CompilerStepEventArgs args) {
if (args.Step == parsingStep)
errorCount = args.Context.Errors.Count;
};
try {
compiler.Run();
//visitor.Cu.ErrorsDuringCompile = compiler.Errors.Count > 0
visitor.Cu.ErrorsDuringCompile = errorCount > 0;
} catch (Exception ex) {
MessageService.ShowError(ex);
}

5
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooResolver.cs

@ -148,6 +148,11 @@ namespace Grunwald.BooBinding.CodeCompletion @@ -148,6 +148,11 @@ namespace Grunwald.BooBinding.CodeCompletion
{
if (!Initialize(fileName, caretLineNumber, caretColumn))
return null;
LoggingService.Debug("Resolve " + expressionResult.ToString());
if (expressionResult.Expression == "__GlobalNamespace") { // used for "import" completion
return new NamespaceResolveResult(callingClass, callingMember, "");
}
AST.Expression expr = Boo.Lang.Parser.BooParser.ParseExpression("expression", expressionResult.Expression);
if (expr is AST.IntegerLiteralExpression)
return null; // no CC for "5."

2
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/CompletionBinding.cs

@ -36,7 +36,7 @@ namespace Grunwald.BooBinding.CodeCompletion @@ -36,7 +36,7 @@ namespace Grunwald.BooBinding.CodeCompletion
{
switch (word.ToLower(CultureInfo.InvariantCulture)) {
case "import":
editor.ShowCompletionWindow(new CodeCompletionDataProvider(new ExpressionResult("Global", ExpressionContext.Type)), ' ');
editor.ShowCompletionWindow(new CodeCompletionDataProvider(new ExpressionResult("__GlobalNamespace", ExpressionContext.Type)), ' ');
return true;
case "as":
case "isa":

8
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/ConvertVisitor.cs

@ -39,7 +39,6 @@ namespace Grunwald.BooBinding.CodeCompletion @@ -39,7 +39,6 @@ namespace Grunwald.BooBinding.CodeCompletion
public override void Run()
{
LoggingService.Debug("RUN");
try {
Visit(CompileUnit);
} catch (Exception ex) {
@ -47,6 +46,11 @@ namespace Grunwald.BooBinding.CodeCompletion @@ -47,6 +46,11 @@ namespace Grunwald.BooBinding.CodeCompletion
}
}
protected override void OnError(AST.Node node, Exception error)
{
MessageService.ShowError(error, "error processing " + node.ToCodeString());
}
private ModifierEnum GetModifier(AST.TypeMember m)
{
ModifierEnum r = ModifierEnum.None;
@ -119,7 +123,7 @@ namespace Grunwald.BooBinding.CodeCompletion @@ -119,7 +123,7 @@ namespace Grunwald.BooBinding.CodeCompletion
if (p.Alias == null)
u.Usings.Add(p.Namespace);
else
u.Aliases[p.Alias.Name] = new GetClassReturnType(_cu.ProjectContent, p.Namespace, 0);
u.AddAlias(p.Alias.Name, new GetClassReturnType(_cu.ProjectContent, p.Namespace, 0));
_cu.Usings.Add(u);
}

80
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/ExpressionFinder.cs

@ -90,7 +90,6 @@ namespace Grunwald.BooBinding.CodeCompletion @@ -90,7 +90,6 @@ namespace Grunwald.BooBinding.CodeCompletion
inText = SimplifyCode(inText, offset);
if (inText == null) {
LoggingService.Debug("SimplifyCode returned null (cursor is in comment/string???)");
return new ExpressionResult(null);
}
// inText now has no comments or string literals, but the same meaning in
@ -162,34 +161,35 @@ namespace Grunwald.BooBinding.CodeCompletion @@ -162,34 +161,35 @@ namespace Grunwald.BooBinding.CodeCompletion
// state = -1 : accepting current identifier
// state >= 0 : accepting brackets/parenthesis
Stack<int> bracketStack = new Stack<int>();
for (int i = offset + 1; i < inText.Length; i++) {
int i;
for (i = offset + 1; i < inText.Length; i++) {
char c = inText[i];
if (state == -1) {
if (char.IsLetterOrDigit(c) || c == '_') {
// continue reading identifier
} else {
state = 0;
}
if (char.IsLetterOrDigit(c) || c == '_') {
// continue reading identifier
} else {
state = 0;
break;
}
if (state >= 0) {
state = FeedStateMachine(state, c);
if (IsInNormalCode(state)) {
int bracket = _openingBrackets.IndexOf(c);
if (bracket >= 0) {
bracketStack.Push(bracket);
} else {
if (bracketStack.Count == 0) {
result.Expression = b.ToString();
return result;
}
}
bracket = _closingBrackets.IndexOf(c);
if (bracket >= 0) {
while (bracketStack.Count > 0 && bracketStack.Pop() > bracket);
}
}
i -= 1;
while (state >= 0) {
state = FindNextCodeCharacter(state, inText, ref i);
if (state < 0) break;
char c = inText[i];
int bracket = _openingBrackets.IndexOf(c);
if (bracket >= 0) {
bracketStack.Push(bracket);
} else {
if (bracketStack.Count == 0) {
b.Append(inText, offset + 1, i - offset - 1);
result.Expression = b.ToString();
return result;
}
}
b.Append(c);
bracket = _closingBrackets.IndexOf(c);
if (bracket >= 0) {
while (bracketStack.Count > 0 && bracketStack.Pop() > bracket);
}
}
return new ExpressionResult(null);
}
@ -276,6 +276,34 @@ namespace Grunwald.BooBinding.CodeCompletion @@ -276,6 +276,34 @@ namespace Grunwald.BooBinding.CodeCompletion
return action;
}
/// <summary>
/// Goes to the next position in "text" that is code (not comment, string etc.).
/// Returns a state that has be passed in as <paramref name="state"/> on the
/// next call.
/// </summary>
public int FindNextCodeCharacter(int state, string text, ref int pos)
{
ResetStateMachine();
do {
pos += 1;
if (pos >= text.Length)
return -1;
char c = text[pos];
state = FeedStateMachine(state, c);
if (state == 12) {
// after / could be a regular expression, do a special check for that
int regexEnd = SkipRegularExpression(text, pos, text.Length - 1);
if (regexEnd > 0) {
pos = regexEnd;
} else if (regexEnd == -1) {
// cursor is in regex
return -1;
} // else: regexEnd is 0 if its not a regex
}
} while (!IsInNormalCode(state));
return state;
}
/// <summary>This method makes boo source code "simpler" by removing all comments
/// and replacing all string litarals through string.Empty.
/// Regular expressions literals are replaced with the simple regex /a/</summary>
@ -311,7 +339,7 @@ namespace Grunwald.BooBinding.CodeCompletion @@ -311,7 +339,7 @@ namespace Grunwald.BooBinding.CodeCompletion
}
}
if (state == 2 || (state >= 6 && state <= 11))
result.Append("string.Empty");
result.Append("''");
if (IsInNormalCode(state))
result.Append(c);
state = action;

8
src/Main/Base/Project/Src/Dom/IExpressionFinder.cs

@ -54,5 +54,13 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -54,5 +54,13 @@ namespace ICSharpCode.SharpDevelop.Dom
this.Context = context;
this.Tag = tag;
}
public override string ToString()
{
if (Context == ExpressionContext.Default)
return "<" + Expression + ">";
else
return "<" + Expression + "> (" + Context.ToString() + ")";
}
}
}

19
src/Main/Base/Project/Src/TextEditor/Gui/Editor/ParserFoldingStrategy.cs

@ -66,10 +66,23 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -66,10 +66,23 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
if (parseInformation == null || parseInformation.MostRecentCompilationUnit == null) {
return null;
}
List<FoldMarker> foldMarkers = GetFoldMarkers(document, parseInformation.MostRecentCompilationUnit);
if (parseInformation.BestCompilationUnit != parseInformation.MostRecentCompilationUnit) {
List<FoldMarker> oldFoldMarkers = GetFoldMarkers(document, parseInformation.BestCompilationUnit);
int lastLine = (foldMarkers.Count == 0) ? 0 : foldMarkers[foldMarkers.Count - 1].EndLine;
int totalNumberOfLines = document.TotalNumberOfLines;
foreach (FoldMarker marker in oldFoldMarkers) {
if (marker.StartLine > lastLine && marker.EndLine < totalNumberOfLines)
foldMarkers.Add(marker);
}
}
return foldMarkers;
}
List<FoldMarker> GetFoldMarkers(IDocument document, ICompilationUnit cu)
{
List<FoldMarker> foldMarkers = new List<FoldMarker>();
ICompilationUnit cu = (ICompilationUnit)parseInformation.MostRecentCompilationUnit;
bool firstTime = document.FoldingManager.FoldMarker.Count == 0;
foreach (FoldingRegion foldingRegion in cu.FoldingRegions) {
foldMarkers.Add(new FoldMarker(document, foldingRegion.Region.BeginLine - 1, foldingRegion.Region.BeginColumn - 1,

Loading…
Cancel
Save