NRefactoryChanges - mehdimo/janett GitHub Wiki

AST

Enums

  • Modifiers: transient, native, synchronized, final added
  • Modifiers: Classes can be final and fields can be transient
  • ParamModifier: final can be modifier for parameters
  • BinaryOperatorType: Unsigned shift right (>>>) and left (<<<)

TypeReference

  • Adding Java primitive types like C# and VB
  • If we have String in our code TypeReference change it to System.String because String is in VB primitive types and CSharpOutputVisitor prints string instead of that. This static field prevents this behavior. Maybe this problem has other solution like setting SystemType (currently read-only) to null.
  • Java has two special constructs: [.class] (http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#23302) and .this. We parse them to TypeReferenceExpression but store type of them in TypeReference.Kind. Also we should distinguish between TypeReferences in TypeDeclaration.BaseTypes which are part of extends part or implements part.

Parser

  • KeywordsList.txt changed for Java
  • Java lexer is a copy of C# Lexer without LambdaArrow support
  • JavaParser is a copy of CSharpParser:
    • Lots of non-used methods (because of changes in .ATG) were removed and IsTypeReferenceWithDotClassOrThis look-ahead function added.
  • Java.ATG first copied from cs.ATG:
    • All known Java constructs are supported except .new
    • All (if we are correct) non-Java (1.4) constructs (generics, pointers,…) are removed
    • This parser tested on 10 medium and large Java projects. There are 12 files (from 7919) in these projects it can’t parse. 4 of them because of .new and 8 of them because of lexer issues (some special numbers like -9223372036854775808L and strings like "173")
  • JavaParserTest.cs

OutputVisitor

  • Making CSharpOutputFormatter non-sealed to inherit JavaOutputFormatter
  • CSharpOutputVisitor
    • Extracting methods to replace different token for similar keywords (using – import, is – instanceof, lock – synchronized)
    • Making some fields and method protected for calling them in JavaOutputVisitor
    • Extracting method PrintBaseTypes (for extends and implements)
    • Extracting method PrintConstructorSignature for (in Java, [super and this] (http://java.sun.com/docs/books/jls/second\_edition/html/classes.doc.html#229267) should be in first line of body)
    • Extracting PrintArrayArguments because of different [array initialization syntax] (http://java.sun.com/docs/books/jls/second\_edition/html/arrays.doc.html\#25891) (new int[1][2];)
    • New virtual methods added: PrintThrows, PrintTypeReferenceKind
    • UnsignedShift support
    • Method parameters in Java can be final (TrackedVisitParameterDeclarationExpression) also OutputModifier changed
    • break and continue statement label (TrackedVisitBreakStatement)
    • AdditionalOutputModifier virtual method for other Java keywords
    • throw statement within switch sections also should not follows break;
    • JavaOutputTest.cs

Other changes

  • Merging goodness of NodeTrackingAstVisitor and NodeTrackingAstVisitor
  • Adding Java parser generation to gen.bat
  • SupportedLanguage.Java and other required changes in ParserFactory
  • Our UnitTests has TextFixtureSetup and TextFixtureTearDown attributes but StructuralTest only allows TestAttribute