Child pages
  • Using in JetBrains projects

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

As Nitra progresses we will use it in a number of places for dog-fooding and optimizing our own development.

Errors DSL

We have errors.xml files, which utilize Xml as a syntax for input for code generator. Here is how we can improve it:

  1. Using Nitra Parser, create a DSL syntax for these files. It could look like this:
    CodeRedundancies.issues
    Code Block
    
    using System.Collections.Generic; // import namespaces
     
    issues CodeRedundancy[language = CSharp, base = CSharpHighlightingBase]  // declare group, language, base type
    {
      issue RedundantCast  // declare issue type (tag)
      {
        Title = "Redundant cast"; // specify properties
        Description = "Type cast can be safely removed.";
        DefaultSeverity = Warning;
        Behavior = DeadCode;
     
        analysis RedundantCast(node : ICastExpression) // declare analysis
        {
          Message = "Type cast is redundant";
          Range = {@ CSharpErrorUtil.RangeByCastExpression(node); @};
          Fixes = [ RemoveCastFix ];
        }
     
        analysis RedundantAsCast(node : IAsExpression) // declare another analysis for the same tag
        {
          Message = "Type cast is redundant";
          Range = {@ CSharpErrorUtil.RangeByAsExpression(node); @};
          Fixes = [ RemoveAsFix, RemoveSomething ];
           
          {@
             void FooBar() { ... }
          @} 
        }
      }
     
      // more issues
    }
    
    First phase is to parse it and use AST instead of XElements to power ErrorsGenerator
  2. Use embedded C# language. It should work a bit like Razor, allowing C# code in specific places.
  3. Code completion for keywords, expand selection, comments, syntax errors, and all other AST-based features in ReSharper extension
  4. Resolve, completion, find usages and renames
  5. "Go to" navigation
  6. Create from usage for Fixes

AllAssemblies DSL

  1. Measure speed of AST building compared to XmlSerializer

Actions DSL

  1. Measure speed of processing during load at runtime, build ActionManager's data on parse.
  2. Generate action handlers
    Code Block
    using JetBrains.UI.Resources;
    
    command GotoPreviousOccurence // declares command
    {
      Text = "Previous Item"
      Image = CommonThemedIcons.Up
      bind(vs) Control+Alt+PageUp  // binds shortcuts
      bind(idea) Control+Alt+Up 
    
      action(context : IDataContext, manager : NavigateOccurenceManager) // declares action handler
      {
        var provider = manager.GetActiveProvider(context);
        if (provider != null && provider.PreviousExists)
          execute  // yields execution code, means update is successful
          { 
            provider.MoveToPreviousOccurence(); 
          } 
      }
    }
    

CQL

  1. Design code query language
  2. Implement processing in ReSharper
    Code Block
    t:type where t is sealed && t contains (m:member where m is constructor && m.Parameters > 0);
    m:member where m.Name like "~*";
    f:file where f contains (t:type where !(t.Name == f.Name));