Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/23/17 00:52:14 (7 years ago)
Author:
abeham
Message:

#2258: merged r13329:14000 from trunk into branch

Location:
branches/Async
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/Async

  • branches/Async/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeCompletion/CSharp/CSharpCodeCompletionStrategy.cs

    r12646 r15280  
    4444      var document = codeEditor.TextEditor.Document;
    4545      int offset = codeEditor.TextEditor.CaretOffset;
     46      var result = new CodeCompletionResult();
    4647
    47       var result = new CodeCompletionResult();
    48       var completionContext = new CSharpCodeCompletionContext(document, offset, projectContent);
    49       var completionFactory = new CSharpCodeCompletionDataFactory(completionContext);
    50       var cce = new CSharpCompletionEngine(
    51         completionContext.Document,
    52         completionContext.CompletionContextProvider,
    53         completionFactory,
    54         completionContext.ProjectContent,
    55         completionContext.TypeResolveContextAtCaret
    56         );
    57 
    58       char completionChar = completionContext.Document.GetCharAt(completionContext.Offset - 1);
    59       int startPos, triggerWordLength;
    60       IEnumerable<ICompletionData> completionData;
    61 
    62       if (controlSpace) {
    63         if (!cce.TryGetCompletionWord(completionContext.Offset, out startPos, out triggerWordLength)) {
    64           startPos = completionContext.Offset;
    65           triggerWordLength = 0;
    66         }
    67         completionData = cce.GetCompletionData(startPos, true);
    68       } else {
    69         startPos = completionContext.Offset;
    70         if (char.IsLetterOrDigit(completionChar) || completionChar == '_') {
    71           if (startPos > 1 && char.IsLetterOrDigit(completionContext.Document.GetCharAt((startPos - 2))))
    72             return result;
    73           completionData = cce.GetCompletionData(startPos, false);
    74           triggerWordLength = 1;
    75         } else {
    76           completionData = cce.GetCompletionData(startPos, false);
    77           triggerWordLength = 0;
    78         }
    79       }
    80 
    81       result.TriggerWordLength = triggerWordLength;
    82       result.TriggerWord = completionContext.Document.GetText(completionContext.Offset - triggerWordLength, triggerWordLength);
    83 
    84       if (completionData.Any() && cce.AutoCompleteEmptyMatch) {
    85         foreach (var completion in completionData) {
    86           var cast = completion as CompletionData;
    87           if (cast != null) {
    88             cast.TriggerWord = result.TriggerWord;
    89             cast.TriggerWordLength = result.TriggerWordLength;
    90             result.CompletionData.Add(cast);
    91           }
    92         }
    93       }
    94 
    95       if (!controlSpace) {
    96         var pce = new CSharpParameterCompletionEngine(
     48      try {
     49        var completionContext = new CSharpCodeCompletionContext(document, offset, projectContent);
     50        var completionFactory = new CSharpCodeCompletionDataFactory(completionContext);
     51        var cce = new CSharpCompletionEngine(
    9752          completionContext.Document,
    9853          completionContext.CompletionContextProvider,
     
    10055          completionContext.ProjectContent,
    10156          completionContext.TypeResolveContextAtCaret
    102         );
     57          );
    10358
    104         var parameterDataProvider = pce.GetParameterDataProvider(completionContext.Offset, completionChar);
    105         result.OverloadProvider = parameterDataProvider as IUpdatableOverloadProvider;
     59        char completionChar = completionContext.Document.GetCharAt(completionContext.Offset - 1);
     60        int startPos, triggerWordLength;
     61        IEnumerable<ICompletionData> completionData;
     62
     63        if (controlSpace) {
     64          if (!cce.TryGetCompletionWord(completionContext.Offset, out startPos, out triggerWordLength)) {
     65            startPos = completionContext.Offset;
     66            triggerWordLength = 0;
     67          }
     68          completionData = cce.GetCompletionData(startPos, true);
     69        } else {
     70          startPos = completionContext.Offset;
     71          if (char.IsLetterOrDigit(completionChar) || completionChar == '_') {
     72            if (startPos > 1 && char.IsLetterOrDigit(completionContext.Document.GetCharAt((startPos - 2))))
     73              return result;
     74            completionData = cce.GetCompletionData(startPos, false);
     75            triggerWordLength = 1;
     76          } else {
     77            completionData = cce.GetCompletionData(startPos, false);
     78            triggerWordLength = 0;
     79          }
     80        }
     81
     82        result.TriggerWordLength = triggerWordLength;
     83        result.TriggerWord = completionContext.Document.GetText(completionContext.Offset - triggerWordLength, triggerWordLength);
     84
     85        if (completionData.Any() && cce.AutoCompleteEmptyMatch) {
     86          foreach (var completion in completionData) {
     87            var cast = completion as CompletionData;
     88            if (cast != null) {
     89              cast.TriggerWord = result.TriggerWord;
     90              cast.TriggerWordLength = result.TriggerWordLength;
     91              result.CompletionData.Add(cast);
     92            }
     93          }
     94        }
     95
     96        if (!controlSpace) {
     97          var pce = new CSharpParameterCompletionEngine(
     98            completionContext.Document,
     99            completionContext.CompletionContextProvider,
     100            completionFactory,
     101            completionContext.ProjectContent,
     102            completionContext.TypeResolveContextAtCaret
     103            );
     104
     105          var parameterDataProvider = pce.GetParameterDataProvider(completionContext.Offset, completionChar);
     106          result.OverloadProvider = parameterDataProvider as IUpdatableOverloadProvider;
     107        }
     108      } catch {
     109        // ignore exceptions thrown during code completion
    106110      }
    107111
  • branches/Async/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeFolding/CSharp/CSharpCodeFoldingStrategy.cs

    r12012 r15280  
    3131      var result = new CodeFoldingResult();
    3232
    33       var foldingContext = new CSharpCodeFoldingContext(document);
    34       var v = new FoldingVisitor();
    35       v.document = foldingContext.Document;
    36       foldingContext.SyntaxTree.AcceptVisitor(v);
    37       result.FoldingData = v.foldings.OrderBy(x => x.StartOffset).ToList();
     33      try {
     34        var foldingContext = new CSharpCodeFoldingContext(document);
     35        var v = new FoldingVisitor();
     36        v.document = foldingContext.Document;
     37        foldingContext.SyntaxTree.AcceptVisitor(v);
     38        result.FoldingData = v.foldings.OrderBy(x => x.StartOffset).ToList();
    3839
    39       var firstError = foldingContext.SyntaxTree.Errors.FirstOrDefault();
    40       firstErrorOffset = firstError != null
    41         ? foldingContext.Document.GetOffset(firstError.Region.Begin)
    42         : int.MaxValue;
     40        var firstError = foldingContext.SyntaxTree.Errors.FirstOrDefault();
     41        firstErrorOffset = firstError != null
     42          ? foldingContext.Document.GetOffset(firstError.Region.Begin)
     43          : int.MaxValue;
     44      } catch {
     45        // ignore exceptions thrown during code folding
     46        firstErrorOffset = int.MaxValue;
     47      }
    4348
    4449      return result;
Note: See TracChangeset for help on using the changeset viewer.