contributing for dummies

hi there,

i'm trying to put some more sense into my life, and i've reached "try to fix some scala plugin bugs" on my todo list.
where to start?
a) get source from somewhere and build it. is there a recent how-to?
b) install idea twice, so i can use one to develop the plugin and another to test it? at least that's what i would have tried. do i need anything besides the plugin source? i've zero experience writing plugins for intellij.
c) look at some tests to see how things work?

0

first problem: lots of classes are missing which happen to be in com.intellij and org.intellij. also, junit is missing (it's not part of the git repo and the project doesn't reference it)
where do i get the intellij stuff?

also, i fixed a typo (fuction instead of function) as a "proof on concept". how to make a pull request?

0

You probably need the IntelliJ sources: http://www.jetbrains.org/display/IJOS/Download

0

a) Repository:  git://git.jetbrains.org/idea/scala-plugin.git
As about build, I want to improve things with configuring scala plugin project, when you need just to setup JDK. However it will be done in approx. month.
Current state is following:
You should add IntelliJ IDEA SDK as project SDK (just choose IDEA installation directory), which depends on your JDK. Additionaly you should add to classpath of IntelliJ IDEA SDK following things:
1. tools.jar from JDK lib
2. idea.jar from IDEA lib directory
3. maven plugin jars from IDEA plugin directory
4. IntelliLang plugin jars
5. Copyright plugin jars
After that you should be able to compile project using IDEA.
b) You should install IDEA only once. To run debug IDEA from IDEA you should create plugin run configuration and run it.
c) I think it's hard to describe how things works in few words and tests hardly ever can help you. The best practice would be to write me directly (using email for example) what you want to fix or what feature you want to add, and I'll say you what classes to discover and what exactly to do and also I'll say how simple to do it. You also can send me few things, which you want to fix/add. Then I can choose one of them, which is the simplest for you.

Are you attending to ScalaDays? If I get British visa, I'll be able to help you here face to face (it save some time for you I think).

Best regards,
Alexander Podkhalyuzin.

0

I don't know if it's possible to make pull request using our GitHub mirror I think it's possible, but now you can just send patch to me, I'll push it ASAP. Moreover after few good patches it's simple to get you commit rights.
What about com.intellij classes I just described, that you need to setup IntelliJ IDEA SDK.

Best regards,
Alexander Podkhalyuzin.

0

i've set everything up, tests are running. that was easier than expected (i tried to set up lift once)
no, i won't be at scaladays. i'll just use my batman-level code reading skills to see what's going on.
as for explaining, assume the following:
1) i don't know anything about the plugin and how it works, here you need to do some explaining.
2) i have 15 years of programming (and research out of curiosity) experience in total in various languages, so you can safely skip the babysitting.

the patch file is attached



Attachment(s):
typo_fixed.patch.zip
0

Ok, patch is applied.

1.First of all you need to know about plugin.xml file. You can register here any implemented API classes.
Next thing is to understand Psi. After lexing and parser psi tree is created. Additionally for every file stub tree is created (for performance reasons, stub tree is serializable). Psi tree should be created only for opened in editor files. Otherwise we should use stub tree.
Resolve and completion works in following way. We have processors (Resolve or Completion), which collects all visible symbols in scope (using methods processDeclarations), after that processor can collect all candidates, and choose all applicable and most specific of them (for completion it can return just all candidates).
If you want some specific action (not from API, like common refactorings and so on), you can add something like org.jetbrains.plugins.scala.actions.ShowImplicitParametersAction, which extends AnAction, then in plugin.xml you should register this action with your default shortcut.
Error highlighting added using ScalaAnnotator. It called for every psi element. So for example for references we can call ref.resolve and check if it has only one resolve result. If so we can highlight it we custom colors (depends on resolve result), otherwise we can highlight it red.
Inspections can be added extending LocalInspectionTool class (there are many inspections example in code).
Refactorings and other code changes, should be done in one of two ways: you can work with psi tree, using replace, delete or addChild or something like that, or you can work with text using Editor.getDocument.insertString and so on. If you worked with text then you shouldn't work with tree, because they are not synchronized. To synchronize them you should use method PsiDocumentManager.commitDocument. All write operations should be inside write actions. Use method org.jetbrains.plugins.scala.extensions#inWriteAction for this. For read actions use inReadAction.

One more addition. To develop Scala Plugin it's better to run idea with vm parameter: -Didea.is.internal=true.
First, you will get action Tools -> View Psi Structure (so you will be able to see how parsed any Scala code).
Second, hystorically current architecture of plugin is terrible. For example ScObject extends PsiClass. PsiClass is common Java interface. However ScObject in bytecode usually compiled into two classes. So Java should see two PsiClasses, and ScObject class name should be Name$. However working in Scala it's not convenient and name should be just Name.
So ScObject.getName returns Name$ and ScObject.name returns name. To avoid bugs, which are simple to introduce, I added inspection under internal mode to highlight getName usages. Common cases are covered by this inspection, but something still can be missed. So be careful. To improve things, ScObject shouldn't implement PsiClass, ScFunction shouldn't implement PsiMethod and so on. But it's too complex task for many workdays. So now ScObject is PsiClass for Java Psi and ScTypeDefinition for Scala Psi.

Please ask any question, if you have.

2. It's not babysitting, just trying to help you save some time. Anyway you can ask anything about plugin or IDEA API, I'll try to answer as soon as possible.

Best regards,
Alexander Podkhalyuzin.

0

thanks for the info. i'll look into it and try to make a fix soon (got to finish arkham city first). could you pick one which is not too difficult, preferrably one of those i reported myself?

by babysitting i meant explaining stuff at lower levels ("this is a trait."). you can just explain things as you just did, i'll ask for details if i need to.

0

Most of your issues is about error highlighting, so it's not easy. However this issue is localized: http://youtrack.jetbrains.com/issue/SCL-4006, moreover it seems it's something, which is not implemented yet, so it shouldn't be too dificult. I left comment with hint.

Best regards,
Alexander Podkhalyuzin.

0

> i don't know anything about the plugin and how it works, here you need to do some explaining.

Here's a good source of information for a start:http://confluence.jetbrains.net/display/IDEADEV/PluginDevelopment

(particularly, http://confluence.jetbrains.net/display/IDEADEV/Developing+Custom+Language+Plugins+for+IntelliJ+IDEA)

0

thx, it will be read.

0

Would it be the same instructions for a Mac ?

Thanks

0

Sorry for long answer, I was on scaladays.
For mac it should be the same.

Best regards,
Alexander Podkhalyuzin.

0

Thanks, have got that up and running.

To debug you say create a plugin run configurator.

What sort of values do you use ? How does it know to debug the scala plugin ?

And does it matter having the released scala plugin installed ?

Thanks

0

i did nothing special, it just worked. the scala plugin already has everything configured. if you "run the plugin", another instance of intellij starts up, using the scala plugin you just compiled. it doesn't matter what plugins you already have installed, the second instance uses its own config directory.


btw, what timezone are you living in? maybe we can join our forces. i'm a beginner at intellij/scala plugins

0

i did nothing special, it just worked

0

what i wrote here was pretty stupid, so i deleted it

:)
0

请先登录再写评论。