Skip to content

Commit 3ba9f8d

Browse files
committed
<dt>0.1.7</dt>
<dd>Focusing on WebStorm 7 compatibility</dd> <dt>0.1.6</dt> <dd>Adding navigation, auto-closing {{, attribute autocomplete on all elements, and "jump to docs"</dd>
1 parent 9076d43 commit 3ba9f8d

18 files changed

+265
-242
lines changed

.idea/misc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

META-INF/plugin.xml

+15-7
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
<change-notes><![CDATA[
77
<html>
88
<dl>
9+
<dt>0.1.7</dt>
10+
<dd>Focusing on WebStorm 7 compatibility</dd>
911
<dt>0.1.6</dt>
10-
<dd>Adding navigation and auto-closing {{</dd>
12+
<dd>Adding navigation, auto-closing {{, attribute autocomplete on all elements, and "jump to docs"</dd>
1113
<dt>0.1.5</dt>
1214
<dd>Adding "href" and "disabled" to the descriptors list</dd>
1315
<dt>0.1.4</dt>
@@ -29,7 +31,7 @@
2931

3032

3133
<!-- please see http://confluence.jetbrains.net/display/IDEADEV/Build+Number+Ranges for description -->
32-
<idea-version since-build="107.105"/>
34+
<idea-version since-build="130.000"/>
3335

3436
<depends>JavaScript</depends>
3537
<depends>com.intellij.modules.platform</depends>
@@ -42,23 +44,29 @@
4244
</project-components>
4345

4446
<actions>
45-
<!-- <action id="GotoAngularAction"
47+
<action id="GotoAngularAction"
4648
class="org.angularjs.GotoAngularAction"
4749
text="Go to Angular"
4850
description="Navigate to Angular code">
4951
<keyboard-shortcut keymap="$default"
5052
first-keystroke="ctrl l"/>
5153
<keyboard-shortcut keymap="Mac OS X" first-keystroke="ctrl l"/>
5254
<keyboard-shortcut keymap="Mac OS X 10.5+" first-keystroke="ctrl l"/>
53-
</action>-->
55+
</action>
5456
</actions>
5557

5658
<extensions defaultExtensionNs="com.intellij">
57-
<xml.attributeDescriptorsProvider implementation="org.angularjs.AngularJSCustomAttributeDescriptorsProvider"/>
59+
<!--<xml.attributeDescriptorsProvider implementation="org.angularjs.AngularJSCustomAttributeDescriptorsProvider"/>-->
5860
<defaultLiveTemplatesProvider implementation="org.angularjs.AngularJSTemplatesProvider"/>
61+
5962
<typedHandler implementation="org.angularjs.AngularBracesInterpolationTypedHandler"/>
60-
<applicationConfigurable instance="org.angularjs.AngularJSConfig"/>
61-
<!--<completion.contributor language="HTML" implementationClass="org.angularjs.AngularCompletionContributor"/>-->
63+
<!--<applicationConfigurable instance="org.angularjs.AngularJSConfig"/>-->
64+
<completion.contributor language="HTML" implementationClass="org.angularjs.DirectiveCompletionContributor"/>
65+
<intentionAction>
66+
<className>org.angularjs.OpenInDocsIntention</className>
67+
<category>HTML</category>
68+
<descriptionDirectoryName>HTML</descriptionDirectoryName>
69+
</intentionAction>
6270
<!--
6371
<localInspection language="JavaScript" groupPath="JavaScript" displayName="AngularDisplayName" groupName="AngularGroup" shortName="AngularShortName"
6472
enabledByDefault="true" level="WARNING"

angularjs-plugin.jar

-21.4 KB
Binary file not shown.

lib/kotlin-runtime.jar

224 KB
Binary file not shown.

src/intentionDescriptions/OpenInDocsIntention/after.java.template

Whitespace-only changes.

src/intentionDescriptions/OpenInDocsIntention/before.java.template

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<html>
2+
<body>
3+
This intention opens the docs for an AngularJS directive
4+
</body>
5+
</html>

src/org/angularjs/AngularBracesInterpolationTypedHandler.kt

+21-78
Original file line numberDiff line numberDiff line change
@@ -8,65 +8,48 @@ import com.intellij.openapi.editor.EditorModificationUtil
88
import com.intellij.openapi.fileTypes.FileType
99
import com.intellij.openapi.project.Project
1010
import com.intellij.psi.PsiFile
11-
import com.intellij.psi.xml.XmlElementType
12-
import com.jetbrains.django.lang.template.DjangoTemplateFileViewProvider
13-
import com.jetbrains.python.codeInsight.PyCodeInsightSettings
14-
import java.util.Arrays
15-
import java.util.ArrayList
1611

12+
/**
13+
* Heavily borrow from @dcheryasov's work on Django braces
14+
*/
1715
public open class AngularBracesInterpolationTypedHandler(): TypedHandlerDelegate() {
1816
public override fun beforeCharTyped(c: Char, project: Project?, editor: Editor?, file: PsiFile?, fileType: FileType?): TypedHandlerDelegate.Result? {
1917
if (file?.getFileType() == HtmlFileType.INSTANCE)
2018
{
21-
if (isInteresting(c))
19+
if (c == '{')
2220
{
2321
val document: Document? = editor?.getDocument()
2422
val offset: Int = editor?.getCaretModel()?.getOffset()!!
2523
var chars: CharSequence? = document?.getCharsSequence()
2624
if (offset > 0 && (chars?.charAt(offset - 1))!! == '{')
2725
{
28-
if (interpolateCommentBetweenBraces(editor, chars, c, offset))
26+
if (offset < 2 || (chars?.charAt(offset - 2))!! != '{')
2927
{
30-
return TypedHandlerDelegate.Result.STOP
31-
}
32-
else
33-
if (offset < 2 || (chars?.charAt(offset - 2))!! != '{')
28+
if (alreadyHasEnding(chars, c, offset))
29+
{
30+
return TypedHandlerDelegate.Result.CONTINUE
31+
}
32+
else
3433
{
35-
if (alreadyHasEnding(chars, c, offset))
34+
var interpolation: String? = null
35+
if (c == '{')
3636
{
37-
return TypedHandlerDelegate.Result.CONTINUE
37+
interpolation = "{ }"
3838
}
39-
else
40-
{
41-
var interpolation: String? = null
42-
if (c == '{')
43-
{
44-
interpolation = "{ }"
45-
}
46-
else
47-
if (c == '%')
48-
{
49-
interpolation = "% %"
50-
}
51-
else
52-
if (c == '#')
53-
{
54-
interpolation = "# #"
55-
}
5639

57-
if (interpolation != null)
40+
if (interpolation != null)
41+
{
42+
if (offset == (chars?.length())!! || (offset < (chars?.length())!! && (chars?.charAt(offset))!! != '}'))
5843
{
59-
if (offset == (chars?.length())!! || (offset < (chars?.length())!! && (chars?.charAt(offset))!! != '}'))
60-
{
61-
interpolation += "}"
62-
}
63-
64-
typeInStringAndMoveCaret(editor, offset + 2, interpolation)
65-
return TypedHandlerDelegate.Result.STOP
44+
interpolation += "}"
6645
}
6746

47+
typeInStringAndMoveCaret(editor, offset + 2, interpolation)
48+
return TypedHandlerDelegate.Result.STOP
6849
}
50+
6951
}
52+
}
7053

7154
}
7255

@@ -78,14 +61,6 @@ public open class AngularBracesInterpolationTypedHandler(): TypedHandlerDelegate
7861
}
7962

8063
class object {
81-
private var ourInterestingChars: ArrayList<Char>? = null
82-
{
83-
ourInterestingChars = arrayListOf('{', '%', '#')
84-
ourInterestingChars?.sort()
85-
}
86-
private open fun isInteresting(c: Char): Boolean {
87-
return ourInterestingChars!!.contains(c)
88-
}
8964
open fun typeInStringAndMoveCaret(editor: Editor?, offset: Int, str: String?): Unit {
9065
EditorModificationUtil.typeInStringAtCaretHonorBlockSelection(editor, str, true)
9166
editor?.getCaretModel()?.moveToOffset(offset)
@@ -112,37 +87,5 @@ public open class AngularBracesInterpolationTypedHandler(): TypedHandlerDelegate
11287

11388
return false
11489
}
115-
private open fun interpolateCommentBetweenBraces(editor: Editor?, chars: CharSequence?, c: Char, offset: Int): Boolean {
116-
if ((chars?.length())!! <= offset)
117-
{
118-
return false
119-
}
120-
121-
var cc: Char = chars?.charAt(offset)!!
122-
if (c != '#' || cc != '%')
123-
{
124-
return false
125-
}
126-
127-
for (i in offset..chars?.length()!! - 1) {
128-
if ((chars?.charAt(i))!! == '\n')
129-
{
130-
break
131-
}
132-
133-
if ((chars?.charAt(i))!! == '}' && i - 1 > offset)
134-
{
135-
if ((chars?.charAt(i - 1))!! == (chars?.charAt(offset))!!)
136-
{
137-
typeInStringAndMoveCaret(editor, i + 1, "#")
138-
typeInStringAndMoveCaret(editor, offset, "#")
139-
return true
140-
}
141-
142-
}
143-
144-
}
145-
return false
146-
}
14790
}
14891
}

src/org/angularjs/AngularCompletionContributor.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@
88
import com.intellij.find.FindModel;
99
import com.intellij.find.impl.FindInProjectUtil;
1010
import com.intellij.lang.javascript.psi.ecmal4.JSQualifiedNamedElement;
11-
import com.intellij.lang.javascript.psi.resolve.JSResolveUtil;
1211
import com.intellij.openapi.application.ApplicationManager;
1312
import com.intellij.openapi.editor.Document;
1413
import com.intellij.openapi.project.Project;
1514
import com.intellij.openapi.util.Segment;
15+
import com.intellij.lang.javascript.psi.resolve.JSResolveUtil;
1616
import com.intellij.psi.PsiDirectory;
1717
import com.intellij.psi.PsiElement;
1818
import com.intellij.psi.PsiManager;
19-
import com.intellij.psi.PsiNameHelper;
2019
import com.intellij.psi.search.GlobalSearchScope;
2120
import com.intellij.psi.search.ProjectScope;
22-
import com.intellij.psi.util.PsiUtil;
21+
import com.intellij.psi.util.PsiUtilBase;
2322
import com.intellij.usageView.UsageInfo;
2423
import com.intellij.usages.Usage;
2524
import com.intellij.usages.UsageInfo2UsageAdapter;
@@ -57,7 +56,7 @@ public void fillCompletionVariants(CompletionParameters parameters, final Comple
5756

5857
PsiDirectory directory = PsiManager.getInstance(project).findDirectory(project.getBaseDir());
5958
FindInProjectUtil.findUsages(findModel, directory, project,
60-
true, new AdapterProcessor<UsageInfo, Usage>(collectProcessor, UsageInfo2UsageAdapter.CONVERTER));
59+
true, new AdapterProcessor<UsageInfo, Usage>(collectProcessor, UsageInfo2UsageAdapter.CONVERTER), FindInProjectUtil.setupProcessPresentation(project, true, FindInProjectUtil.setupViewPresentation(true, findModel)));
6160

6261

6362
final Collection<Usage> usages = collectProcessor.getResults();
@@ -84,8 +83,8 @@ public boolean process(Segment segment) {
8483
String s = foundString.toString();
8584
String regExMatch = FindManager.getInstance(project).getStringToReplace(s, findModel, textOffset, document.getText());
8685
System.out.println(regExMatch);
87-
PsiElement element = PsiUtil.getElementAtOffset(((UsageInfo2UsageAdapter) r).getUsageInfo().getFile(), textOffset + 1);
88-
PsiElement propElement = PsiUtil.getElementAtOffset(((UsageInfo2UsageAdapter) r).getUsageInfo().getFile(), textOffset + 1 + "$scope".length());
86+
PsiElement element = PsiUtilBase.getElementAtOffset(((UsageInfo2UsageAdapter) r).getUsageInfo().getFile(), textOffset + 1);
87+
PsiElement propElement = PsiUtilBase.getElementAtOffset(((UsageInfo2UsageAdapter) r).getUsageInfo().getFile(), textOffset + 1 + "$scope".length());
8988
String elementText = element.getText();
9089
System.out.println(elementText + ": " + regExMatch + " - " + s);
9190

src/org/angularjs/AngularInspection.java

-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
package org.angularjs;
22

3-
import com.intellij.codeInspection.LocalInspectionToolSession;
4-
import com.intellij.codeInspection.LocalQuickFix;
5-
import com.intellij.codeInspection.ProblemDescriptor;
63
import com.intellij.codeInspection.ProblemsHolder;
74
import com.intellij.codeInspection.htmlInspections.HtmlLocalInspectionTool;
8-
import com.intellij.lang.javascript.inspections.JSInspection;
9-
import com.intellij.lang.javascript.psi.JSElementVisitor;
10-
import com.intellij.lang.javascript.psi.JSParameter;
11-
import com.intellij.openapi.project.Project;
12-
import com.intellij.psi.PsiElementVisitor;
135
import com.intellij.psi.xml.XmlAttribute;
146
import org.jetbrains.annotations.NotNull;
157

src/org/angularjs/AngularJSConfig.kt

-17
This file was deleted.

src/org/angularjs/AngularJSCustomAttributeDescriptorsProvider.java

-91
This file was deleted.

0 commit comments

Comments
 (0)