Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8348029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:33:55+00:00 2026-06-09T07:33:55+00:00

I just asked the support guys on GitHub why AspectJ (*.aj) files are not

  • 0

I just asked the support guys on GitHub why AspectJ (*.aj) files are not syntax-highlighted. The answer was that they are using Pygments, but are unaware of any existing lexer for AspectJ. I did a quick web search and did not find any either. Has anyone here written one or can point me to a link for an existing one?

Long ago I have written a lexer for Kconfig (Linux kernel configuration) files, but it was rather hard for me because I do not speak Python. So before I start torturing my brain again, I thought I should better ask first instead of possibly re-inventing the wheel.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:33:58+00:00Added an answer on June 9, 2026 at 7:33 am

    After having created a “copy, paste & modify” solution of JavaLexer initially because I really do not speak Python, I managed to hack another quick’n’dirty solution which subclasses JavaLexer and delegates lexing to it for the most part. Exceptions are

    • AspectJ-specific keywords,
    • handling of inter-type declarations followed by colons without a space not as Java labels, but as AspectJ keywords plus “:” operator and
    • handling of inter-type annotation declarations as AspectJ keywords and not as Java name decorators.

    I am sure my little heuristic solution misses some details, but as Andrew Eisenberg said: an imperfect, but working solution is better than a non-existent perfect one:

    class AspectJLexer(JavaLexer):
        """
        For `AspectJ <http://www.eclipse.org/aspectj/>`_ source code.
        """
    
        name = 'AspectJ'
        aliases = ['aspectj']
        filenames = ['*.aj']
        mimetypes = ['text/x-aspectj']
    
        aj_keywords = [
            'aspect', 'pointcut', 'privileged', 'call', 'execution',
            'initialization', 'preinitialization', 'handler', 'get', 'set',
            'staticinitialization', 'target', 'args', 'within', 'withincode',
            'cflow', 'cflowbelow', 'annotation', 'before', 'after', 'around',
            'proceed', 'throwing', 'returning', 'adviceexecution', 'declare',
            'parents', 'warning', 'error', 'soft', 'precedence', 'thisJoinPoint',
            'thisJoinPointStaticPart', 'thisEnclosingJoinPointStaticPart',
            'issingleton', 'perthis', 'pertarget', 'percflow', 'percflowbelow',
            'pertypewithin', 'lock', 'unlock', 'thisAspectInstance'
        ]
        aj_inter_type = ['parents:', 'warning:', 'error:', 'soft:', 'precedence:']
        aj_inter_type_annotation = ['@type', '@method', '@constructor', '@field']
    
        def get_tokens_unprocessed(self, text):
            for index, token, value in JavaLexer.get_tokens_unprocessed(self, text):
                if token is Name and value in self.aj_keywords:
                    yield index, Keyword, value
                elif token is Name.Label and value in self.aj_inter_type:
                    yield index, Keyword, value[:-1]
                    yield index, Operator, value[-1]
                elif token is Name.Decorator and value in self.aj_inter_type_annotation:
                    yield index, Keyword, value
                else:
                    yield index, token, value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just asked how to check if an internet connection exists using javascript and got
I asked this morning a question about a jQuery code that's not working (which
Couldn't find any answer to this problem, or not even any questions asked. So
I have a remote git server that does not support registering a public key
Just asked a question about linking Boost libraries in the make file. Thanks to
I just asked a question earlier today because I wanted to run an executable
I've just asked a question about an hour ago, while waiting for replies, I've
yesterday I just asked following question. How to customize tableView Section View - iPhone
I have just asked this question an hour ago but with regards to IE8
Following a question I just asked, what is the need for a reset.css to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.