So I’ll talk about language design and I’ll tell you how to do it but first a quick question how many of you have ever designed a programming language or a language feature or plan to do so less than I expected but maybe the others will get inspired and also design something okay but to the teutuls who raised their.
Hands we have to talk while you were designing your languages I.
Was working in an ID IntelliJ IDEA I was trying to support those languages some of them directly and some indirectly by discussing it with colleagues and it turned out that many of the languages are not very easy to support many actively resist any kind of ideas support and therefore I have a suggestion for you why.
Don’t you design your language in a way that’s easy to support him an ID in an ID friendly way in return you can get.
A really nice feature rich ID plugin for your language which works fast works reliable works reliably and everything is great and I’ll tell you.
But first I’ll tell you what I mean by ad friendliness so an ID has many many features but we consider some of them more basic than others these are listed here editing formatting highlighting navigation code completion and notably find usages and rename these are all very basic features and then if we.
Quite easily add more advanced features on top of that like 30 more refactorings many inspections with automatic quick fixes very advanced data flow.
Advanced debugger features for special with special support for future streams and whatnot detecting duplicate code and so on but the soul requires these basic features so an ID friendly language is a language for which these basic features are relatively easy to support so it takes not much effort and the result.
Works fast and flawlessly and I will mostly talk about intelligent architecture but I believe that the issues.
That he’ll discuss there are more or less common in other ideas and static analysis tools so.
Without further adieu his here’s a recipe for an idea.
Friendly language it consists of 5 simple steps first an ID I need to look at your source code and recognize which syntactic construction is used there just so it second after it has recognized the construction it needs to understand if that construction declares anything and if yes then what which names are declared and which kinds like classes or methods syntactic construction can.
That case it would be nice to know the names of the things it’s her first and for references it would be also very nice to know how.
How to resolve them where approximately the declarations could be and finally.
Much not least point so it deserves the number zero is that all of this should be possible by just looking at one files content all it applies to all these points except maybe for the.
Point about result hints where it’s not obligatory but still would be very nice.
To have so let’s look at these points in more detail let’s start with the point zero by single files content why do we need that what is this and what happens if this is not true so we need this because then we can treat each file separately loaded contents parse it extract all the information about the declarations and references and store it into.
Internal debt database called index and then quite efficiently use it and and we treat each file separately to be sure that we can invalidate all this cash in the database when these file changes and not anything else changes okay and here’s a simple example from Java a simple file which declares a class named foo we.
Index that information it also it extends.
Something some class named bar we have this we don’t know where this bar is declared we don’t know.
Its qualified name because it’s not written in this class in this file but we nevertheless can index.
This information and it’s quite enough we because we index also all they import statements and the package.
And then when the time comes we can resolve that super class reference pretty fast this is a good example of determining information from single files content unfortunately it’s not always so good even Java has its problems to even start parsing Java you need.
To know how to parse it namely which version of Java is used in some version assert and enum are keywords in some other version those are.
Just plain identifiers which can be used like references and this information is not stored in the source file it starts somewhere in the project settings and so we need to keep additional tracking of all.
Those settings and see if it’s changed then.
We should invalidate the cache for all Java files at least the affected ones and that takes quite some amount of effort it’s basically the common pattern to.
This to the stock if you are ID friendly then the ID support it is very easy to.
Add but if the language is not so I differently then we as ad authors will we spend more time.
Just supporting these basic features and the result will probably work not so efficiently as it could work with an ID friendly language so in this case we have to spend additional efforts on tracking the changes to the Java source version and then to re-indexing everything but that’s not.
Not totally bad what totally bad is c and c++ because it has this includes directive which.
Just takes some file and includes int verbatim and this can affect lexer and parser and everything.
And the problem is that if this file food at H is included in 200 other files and you go into that file and start typing there we need to basically invalidate all the caches for although that all those hundreds of files and update them and repassing all of them isn’t usually a very fast process in.
Addition we as IDU vendors have to track where these food @h is included and where it’s not included to avoid invalidating the caches for a completely whole project so this means more efforts for for us and in the result we get less resources to spend on more advanced features okay that’s all about single fast content next point.
By looking at a piece of code you need to know which syntactic construction it is because otherwise you cannot start even analyzing.
The syntax is unclear and here is a very nice ID friendly example of a class with a method with method.