Skip to content

Commit

Permalink
Well. well. well. Mostly some small syntax changes, half hearted atte…
Browse files Browse the repository at this point in the history
…mpt at find usages.
  • Loading branch information
drewmutt committed Jun 3, 2017
1 parent 937e723 commit 57ecd98
Show file tree
Hide file tree
Showing 18 changed files with 421 additions and 246 deletions.
281 changes: 142 additions & 139 deletions gen/com/mwplugin/MediaWikiLexer.java

Large diffs are not rendered by default.

222 changes: 164 additions & 58 deletions gen/com/mwplugin/parser/MediaWikiParser.java

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion gen/com/mwplugin/psi/MediaWikiTypes.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions gen/com/mwplugin/psi/MediaWikiVisitor.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions out/production/wikimedia/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<idea-plugin version="2">
<id>org.wikipedia.tools.puggle</id>
<name>Puggle</name>
<version>0.9a</version>
<version>0.11a</version>
<vendor email="[email protected]" url="http://www.wikipedia.org">YourCompany</vendor>

<description><![CDATA[
A smart editor for editting MediaWiki
A smart editor for editing MediaWiki
]]></description>

<change-notes><![CDATA[
Expand All @@ -22,7 +22,6 @@
<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
<lang.findUsagesProvider language="MediaWiki" implementationClass="com.mwplugin.MediaWikiFindUsagesProvider"/>
<lang.findUsagesProvider language="MediaWiki" implementationClass="com.mwplugin.MediaWikiFindUsagesProvider"/>
<lang.foldingBuilder language="MediaWiki" implementationClass="com.mwplugin.MediaWikiFoldingBuilder"/>
<fileTypeFactory implementation="com.mwplugin.MediaWikiFileFactory"/>
<lang.parserDefinition language="MediaWiki" implementationClass="com.mwplugin.MediaWikiParserDefinition"/>
Expand Down
Binary file modified out/production/wikimedia/com/mwplugin/MediaWikiLexer.class
Binary file not shown.
25 changes: 15 additions & 10 deletions out/production/wikimedia/com/mwplugin/mediawiki.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
tokens = [
// space='regexp:\s+'
// comment='regexp://.*'
galleryopen = "<gallery>"
galleryopen = "regexp:<gallery.*>"
galleryclose = "</gallery>"
pipedash = "|-"
pipeplus = "|+"
Expand Down Expand Up @@ -65,7 +65,7 @@
curlyopen2 = "{{"
curlyclose2 = "}}"
pipe = "|"
symboltoken = "regexp:[\.,\(\)\-\:#\/';–\!%\?_—\+\$~·’†½\*@−‘\^ᴥ•…`“”、」「』『。\"±€‐×°]"
symboltoken = "regexp:[\.,\(\)\-\:#\/';–\!%\?_—\+\$~·’†½\*@−‘\^ᴥ•§…`“«®✋‑”、」「』『。\"±€‐×°′́aʿמָשִׁיחַמשיח[^\x00-\x7F]]"

// okaysymbols = "regexp:[\(|\)|_|\.|\!|\/|\-|\:|#]"
// lcaseletter="regexp:\d"
Expand All @@ -89,9 +89,11 @@ character ::=
mixin="com.mwplugin.psi.impl.MediaWikiNamedElementImpl"
implements="com.mwplugin.psi.IMediaWikiNamedElement"
}

whitespace-char ::=
space-tab|
newline
newline|
" "| " "|" "
{
mixin="com.mwplugin.psi.impl.MediaWikiNamedElementImpl"
implements="com.mwplugin.psi.IMediaWikiNamedElement"
Expand Down Expand Up @@ -466,12 +468,14 @@ inline-text ::=
inline-element-sans-pipe ::= ( !"|" (all-inline-elements))*

all-inline-elements ::= (letter|symbol|decimaldigit|whitespace-char|inline-element|special-block)
all-inline-elements-without-newline ::= (letter|symbol|decimaldigit|space-tab|inline-element|special-block)
all-inline-elements-including-pipe ::= (letter|symbol|decimaldigit|whitespace-char|inline-element|special-block|"|")

inline-element ::=
gallery-block |
html-tag |
url|
bracketed-content |
category-link |
link |
magic-link |
Expand Down Expand Up @@ -545,7 +549,7 @@ link ::=
}

internal-link ::=
internal-link-start article-link ("#" section-id)? (("|"|doublepipe) (internal-link-property | internal-link-unassigned-property))* internal-link-end extra-description?
internal-link-start article-link ("#" section-id)? (("|"|doublepipe|pipedash|pipeplus) (internal-link-property | internal-link-unassigned-property))* internal-link-end extra-description?
{
mixin="com.mwplugin.psi.impl.MediaWikiNamedElementImpl"
implements="com.mwplugin.psi.IMediaWikiNamedElement"
Expand Down Expand Up @@ -761,7 +765,7 @@ image-mode-manual-thumb ::=
}

image-name ::=
interwiki-prefix (letter|decimal-number|symbol|whitespace)*
interwiki-prefix all-inline-elements-without-newline*
{
mixin="com.mwplugin.psi.impl.MediaWikiNamedElementImpl"
implements="com.mwplugin.psi.IMediaWikiNamedElement"
Expand Down Expand Up @@ -909,7 +913,7 @@ image-valign-text-bottom ::=
}

caption ::=
inline-text
all-inline-elements-without-newline*
{
mixin="com.mwplugin.psi.impl.MediaWikiNamedElementImpl"
implements="com.mwplugin.psi.IMediaWikiNamedElement"
Expand Down Expand Up @@ -947,7 +951,7 @@ image-param-border ::=
}

gallery-block ::=
galleryopen newline? gallery-image (newline? gallery-image)* newline? galleryclose
galleryopen newline? gallery-image (newline gallery-image)* newline? galleryclose
{
mixin="com.mwplugin.psi.impl.MediaWikiNamedElementImpl"
implements="com.mwplugin.psi.IMediaWikiNamedElement"
Expand Down Expand Up @@ -1107,8 +1111,9 @@ named-reference-block-self-closing ::=
implements="com.mwplugin.psi.IMediaWikiNamedElement"
}

reference-content ::= url? all-inline-elements*
reference-content ::= url? (all-inline-elements)*

bracketed-content ::= openbracket (!protocol !closebracket all-inline-elements)* closebracket
//Don't need quotes unless you have whitespace
property-assignment ::= (whitespace? doublequote? reference-name doublequote? whitespace?)//|(whitespace? doublequote reference-name whitespace doublequote whitespace?)

Expand Down Expand Up @@ -1273,7 +1278,7 @@ plain-text ::=
implements="com.mwplugin.psi.IMediaWikiNamedElement"
}

friendly-ref-link-char ::= ("!"|"$"|"%"|"&"|"("|")"|"*"|","|"-"|"."|":"|";"|"<"|"@"|"["|"]"|"^"|"_"|"`"|"{"|"|"|"}"|"~"|letter|decimaldigit|"–"|"'"|"/"|template-block|"?"|"’")
friendly-ref-link-char ::= ("!"|"$"|"%"|"&"|"("|")"|"*"|","|"-"|"."|":"|";"|"<"|"@"|"["|"]"|"^"|"_"|"`"|"{"|"|"|"}"|"~"|letter|decimaldigit|"–"|"'"|"/"|template-block|"?"|"’"|"=")

unicode-wiki ::=
letter |
Expand Down Expand Up @@ -1494,7 +1499,7 @@ table-row ::= table-header|table-cell|table-header-double-delimited|table-cell-d
implements="com.mwplugin.psi.IMediaWikiNamedElement"
}

table-block ::= whitespace? table-section-start (!"|" cell-formatting)? newline (table-row)*
table-block ::= whitespace? (table-row)* table-section-start (!"|" cell-formatting)? newline (table-row)*
{
mixin="com.mwplugin.psi.impl.MediaWikiNamedElementImpl"
implements="com.mwplugin.psi.IMediaWikiNamedElement"
Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified out/production/wikimedia/com/mwplugin/psi/MediaWikiTypes.class
Binary file not shown.
Binary file modified out/production/wikimedia/com/mwplugin/psi/MediaWikiVisitor.class
Binary file not shown.
1 change: 0 additions & 1 deletion resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
<lang.findUsagesProvider language="MediaWiki" implementationClass="com.mwplugin.MediaWikiFindUsagesProvider"/>
<lang.findUsagesProvider language="MediaWiki" implementationClass="com.mwplugin.MediaWikiFindUsagesProvider"/>
<lang.foldingBuilder language="MediaWiki" implementationClass="com.mwplugin.MediaWikiFoldingBuilder"/>
<fileTypeFactory implementation="com.mwplugin.MediaWikiFileFactory"/>
<lang.parserDefinition language="MediaWiki" implementationClass="com.mwplugin.MediaWikiParserDefinition"/>
Expand Down
9 changes: 9 additions & 0 deletions src/com/mwplugin/MediaWikiAnnotator.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder hold
// if (properties.size() == 1)
// {


// if(element instanceof MediaWikiExternalLink)
// {
// MediaWikiReferenceBlock externalLink = (MediaWikiExternalLink) element;
// TextRange range = new TextRange(element.getTextRange().getStartOffset(), element.getTextRange().getEndOffset());
// Annotation annotation = holder.createInfoAnnotation(range, null);
// annotation.setTextAttributes(entry.getValue());
// }

if(element instanceof MediaWikiReferenceBlock)
{
MediaWikiReferenceBlock referenceBlock = (MediaWikiReferenceBlock) element;
Expand Down
30 changes: 12 additions & 18 deletions src/com/mwplugin/MediaWikiFindUsagesProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import com.intellij.lang.findUsages.FindUsagesProvider;
import com.intellij.psi.*;
import com.intellij.psi.tree.TokenSet;
import com.mwplugin.psi.IMediaWikiNamedElement;
import com.mwplugin.psi.MediaWikiNamedReferenceBlockUrl;
import com.mwplugin.psi.MediaWikiReferenceBlock;
import com.mwplugin.psi.MediaWikiTypes;
import com.mwplugin.psi.*;
import org.jetbrains.annotations.*;

public class MediaWikiFindUsagesProvider implements FindUsagesProvider {
Expand All @@ -16,17 +13,14 @@ public class MediaWikiFindUsagesProvider implements FindUsagesProvider {
public WordsScanner getWordsScanner() {

return new DefaultWordsScanner(new MediaWikiLexerAdapter(),
TokenSet.create(MediaWikiTypes.REFERENCE_BLOCK),
TokenSet.create(MediaWikiTypes.REFERENCE_NAME),
TokenSet.create(MediaWikiTypes.NAMED_REFERENCE_BLOCK),
TokenSet.create(MediaWikiTypes.HTML_COMMENT),
TokenSet.EMPTY);



}

@Override
public boolean canFindUsagesFor(@NotNull PsiElement psiElement) {
return psiElement instanceof IMediaWikiNamedElement;
return psiElement instanceof MediaWikiNamedReferenceBlock;
}

@Nullable
Expand All @@ -48,8 +42,8 @@ public String getType(@NotNull PsiElement element) {
@NotNull
@Override
public String getDescriptiveName(@NotNull PsiElement element) {
if (element instanceof MediaWikiNamedReferenceBlockUrl) {
return ((MediaWikiNamedReferenceBlockUrl) element).getURL();
if (element instanceof MediaWikiNamedReferenceBlock) {
return ((MediaWikiNamedReferenceBlock) element).getReferenceName();
} else {
return "";
}
Expand All @@ -58,11 +52,11 @@ public String getDescriptiveName(@NotNull PsiElement element) {
@NotNull
@Override
public String getNodeText(@NotNull PsiElement element, boolean useFullName) {
// if (element instanceof MediaWikiNamedReferenceBlockUrl) {
// return ((MediaWikiNamedReferenceBlockUrl) element).getReferenceName()+ ":" + ((MediaWikiNamedReferenceBlockUrl) element).getURL();
// } else {
// return "";
// }
return "gey";
if (element instanceof MediaWikiNamedReferenceBlock) {
return ((MediaWikiNamedReferenceBlock) element).getReferenceName();
} else {
return "";
}
// return "gey";
}
}
5 changes: 3 additions & 2 deletions src/com/mwplugin/_MediaWikiLexer.flex
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ otherletter=[\p{L}]
lcaseletter=[a-z]
ucaseletter=[A-Z]
decimaldigit=[0-9]
galleryopen=<gallery.*>
tab=\t
symboltoken = [\.,\(\)\-\:#\/';–\!%\?_—\+\$~·’†½\*@−‘\^ᴥ•…`“”、」「』『。\"±‐×°]
symboltoken = [\.,\(\)\-\:#\/';–\!%\?_—\+\$~·’†½\*@®−‘\^ᴥ•…`“‑§”、」「✋«』『。\"±‐×°′́aʿמָשִׁיחַמשיח[^\x00-\x7F]]
//okaysymbols = "regexp:[\(|\)|_|\.|\!|\/|\\|\-|\:|#]"

%%
Expand All @@ -45,7 +46,6 @@ symboltoken = [\.,\(\)\-\:#\/';–\!%\?_—\+\$~·’†½\*@−‘\^ᴥ•…`
"<ref>" { return refopencomplete; }
"<ref" { return refopen; }
"</ref>" { return refclose; }
"<gallery>" {return galleryopen;}
"</gallery>" {return galleryclose;}
// "<br/>" {return htmltagnewline;}
"=====" { return equals5; }
Expand All @@ -71,6 +71,7 @@ symboltoken = [\.,\(\)\-\:#\/';–\!%\?_—\+\$~·’†½\*@−‘\^ᴥ•…`

// {okaysymbols} { return okaysymbols; }
{newline} { return newline; }
{galleryopen} { return galleryopen; }
{lcaseletter} { return lcaseletter; }
{ucaseletter} { return ucaseletter; }
{decimaldigit} { return decimaldigit; }
Expand Down
Loading

0 comments on commit 57ecd98

Please sign in to comment.