View Issue Details

IDProjectCategoryView StatusLast Update
0024706LazarusPatchpublic2013-08-25 01:45
ReporterFlávio Etrusco Assigned ToMartin Friebe  
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
Product Version1.1 (SVN) 
Target Version1.2.0Fixed in Version1.1 (SVN) 
Summary0024706: SynHighlighterJava: basic parsing of Annotations
DescriptionThe attached patch adds parsing of Annotations (anything started with '@') and adds additional state for TExtTokenKind (since its value is only valid when TokenID is tkSymbol, adds TxtkNonSymbol value so that it's always valid/predictable).
Based on r25023. I can provide a patch including the necessary/missing changes in syneditstrconst.pp and resource files, only problem is I don't know how to create a svn-compatible patch in git :-/
TagsNo tags attached.
Fixed in Revision42488
LazTarget1.2
Widgetset
Attached Files

Activities

Flávio Etrusco

2013-07-05 06:59

developer  

synhighlighterjava.pas (39,288 bytes)

Juha Manninen

2013-07-05 09:51

developer   ~0068719

Git formatted patches are supported now. See :
  http://wiki.freepascal.org/Creating_A_Patch#Creating_a_patch_using_Git

"patch" command with -p1, and many other programs can apply it.

Martin Friebe

2013-07-20 12:28

manager   ~0068966

Last edited: 2013-07-20 12:30

View 2 revisions

I added TxtkNonSymbol in rev 42148 (slightly different) which was an issue of its own.

For the rest I also need the changes to the resource files, please. (all based on the updated source)

Flávio Etrusco

2013-08-25 01:21

developer  

synjavasyn-annotation.patch (4,346 bytes)   
commit 3bddae5d5a4525825fd3b375ef3d09a19c6a4092
Author: Flavio Etrusco <flavio.etrusco@gmail.com>
Date:   Tue Jul 23 23:04:12 2013 -0300

    SynHighlighterJava: basic Annotation parsing.

diff --git a/components/synedit/syneditstrconst.pp b/components/synedit/syneditstrconst.pp
index c390401..41788ba 100644
--- a/components/synedit/syneditstrconst.pp
+++ b/components/synedit/syneditstrconst.pp
@@ -56,6 +56,7 @@ resourcestring
   SYNS_AttrASP                  =  'Asp';
   SYNS_AttrCDATA                =  'CDATA';
   SYNS_AttrDOCTYPE              =  'DOCTYPE';
+  SYNS_AttrAnnotation           =  'Annotation';
   SYNS_AttrAssembler            =  'Assembler';
   SYNS_AttrAttributeName        =  'Attribute Name';
   SYNS_AttrAttributeValue       =  'Attribute Value';
@@ -170,6 +171,7 @@ const
   SYNS_XML_AttrASP                  =  'Asp';
   SYNS_XML_AttrCDATA                =  'CDATA';
   SYNS_XML_AttrDOCTYPE              =  'DOCTYPE';
+  SYNS_XML_AttrAnnotation           =  'Annotation';
   SYNS_XML_AttrAssembler            =  'Assembler';
   SYNS_XML_AttrAttributeName        =  'Attribute Name';
   SYNS_XML_AttrAttributeValue       =  'Attribute Value';
diff --git a/components/synedit/synhighlighterjava.pas b/components/synedit/synhighlighterjava.pas
index 2bcdcd9..65e1e98 100644
--- a/components/synedit/synhighlighterjava.pas
+++ b/components/synedit/synhighlighterjava.pas
@@ -54,7 +54,7 @@ uses
 
 type
   TtkTokenKind = (tkComment, tkDocument, tkIdentifier, tkInvalid, tkKey,
-    tkNull, tkNumber, tkSpace, tkString, tkSymbol, tkUnknown);
+    tkNull, tkNumber, tkSpace, tkString, tkSymbol, tkUnknown, tkAnnotation);
 
   TxtkTokenKind = (
     xtkAdd, xtkAddAssign, xtkAnd, xtkAndAssign, xtkAssign, xtkBitComplement,
@@ -99,6 +99,7 @@ type
     fSpaceAttri: TSynHighlighterAttributes;
     fStringAttri: TSynHighlighterAttributes;
     fSymbolAttri: TSynHighlighterAttributes;
+    fAnnotationAttri: TSynHighlighterAttributes;
     function KeyHash(ToHash: PChar): Integer;
     function KeyComp(const aKey: String): Boolean;
     function Func17: TtkTokenKind;
@@ -149,7 +150,7 @@ type
     procedure CommentProc;
     procedure AndSymbolProc;
     procedure AsciiCharProc;
-    procedure AtSymbolProc;
+    procedure AnnotationProc;
     procedure BraceCloseProc;
     procedure BraceOpenProc;
     procedure CRProc;
@@ -211,6 +212,8 @@ type
     procedure ResetRange; override;
     property ExtTokenID: TxtkTokenKind read GetExtTokenID;
   published
+    property AnnotationAttri: TSynHighlighterAttributes read fAnnotationAttri
+      write fAnnotationAttri;
     property CommentAttri: TSynHighlighterAttributes read fCommentAttri
       write fCommentAttri;
     property DocumentAttri: TSynHighlighterAttributes read fDocumentAttri
@@ -605,7 +608,7 @@ begin
     case I of
       '&': fProcTable[I] := @AndSymbolProc;
       #39: fProcTable[I] := @AsciiCharProc;
-      '@': fProcTable[I] := @AtSymbolProc;
+      '@': fProcTable[I] := @AnnotationProc;
       '}': fProcTable[I] := @BraceCloseProc;
       '{': fProcTable[I] := @BraceOpenProc;
       #13: fProcTable[I] := @CRProc;
@@ -650,6 +653,8 @@ end;
 constructor TSynJavaSyn.Create(AOwner: TComponent);
 begin
   inherited Create(AOwner);
+  fAnnotationAttri := TSynHighlighterAttributes.Create(@SYNS_AttrAnnotation, SYNS_XML_AttrAnnotation);
+  AddAttribute(fAnnotationAttri);
   fCommentAttri := TSynHighlighterAttributes.Create(@SYNS_AttrComment, SYNS_XML_AttrComment);
   fCommentAttri.Style := [fsItalic];
   AddAttribute(fCommentAttri);
@@ -768,10 +773,11 @@ begin
   if FLine[Run] <> #0 then inc(Run);
 end;
 
-procedure TSynJavaSyn.AtSymbolProc;
+procedure TSynJavaSyn.AnnotationProc;
 begin
-  fTokenID := tkInvalid;
   inc(Run);
+  fTokenID := tkAnnotation;
+  while Identifiers[fLine[Run]] do inc(Run);
 end;
 
 procedure TSynJavaSyn.BraceCloseProc;
@@ -1260,6 +1266,7 @@ end;
 procedure TSynJavaSyn.Next;
 begin
   fTokenPos := Run;
+  FExtTokenID := xtkNonSymbol;
   Case fRange of
     rsComment: CommentProc;
     rsDocument: CommentProc;
@@ -1335,6 +1342,7 @@ end;
 function TSynJavaSyn.GetTokenAttribute: TSynHighlighterAttributes;
 begin
   case fTokenID of
+    tkAnnotation: Result := fAnnotationAttri;
     tkComment: Result := fCommentAttri;
     tkDocument: Result := fDocumentAttri;
     tkIdentifier: Result := fIdentifierAttri;
synjavasyn-annotation.patch (4,346 bytes)   

Flávio Etrusco

2013-08-25 01:21

developer   ~0069516

Patch uploaded. Thanks for the heads up, Martin.

Martin Friebe

2013-08-25 01:45

manager   ~0069517

thanks

Issue History

Date Modified Username Field Change
2013-07-05 06:59 Flávio Etrusco New Issue
2013-07-05 06:59 Flávio Etrusco File Added: synhighlighterjava.pas
2013-07-05 09:51 Juha Manninen Note Added: 0068719
2013-07-18 09:48 Martin Friebe Assigned To => Martin Friebe
2013-07-18 09:48 Martin Friebe Status new => assigned
2013-07-20 12:28 Martin Friebe Note Added: 0068966
2013-07-20 12:28 Martin Friebe Status assigned => feedback
2013-07-20 12:30 Martin Friebe Note Edited: 0068966 View Revisions
2013-08-25 01:21 Flávio Etrusco File Added: synjavasyn-annotation.patch
2013-08-25 01:21 Flávio Etrusco Note Added: 0069516
2013-08-25 01:21 Flávio Etrusco Status feedback => assigned
2013-08-25 01:45 Martin Friebe Fixed in Revision => 42488
2013-08-25 01:45 Martin Friebe LazTarget - => 1.2
2013-08-25 01:45 Martin Friebe Note Added: 0069517
2013-08-25 01:45 Martin Friebe Status assigned => resolved
2013-08-25 01:45 Martin Friebe Fixed in Version => 1.1 (SVN)
2013-08-25 01:45 Martin Friebe Resolution open => fixed
2013-08-25 01:45 Martin Friebe Target Version => 1.2.0