-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
310 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/de/vette/idea/neos/lang/fusion/injection/FusionDslTextEscaper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* IntelliJ IDEA plugin to support the Neos CMS. | ||
* Copyright (C) 2016 Christian Vette | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.vette.idea.neos.lang.fusion.injection; | ||
|
||
import com.intellij.openapi.util.TextRange; | ||
import com.intellij.psi.LiteralTextEscaper; | ||
import de.vette.idea.neos.lang.fusion.psi.FusionValueDslContent; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class FusionDslTextEscaper extends LiteralTextEscaper<FusionValueDslContent> { | ||
|
||
public FusionDslTextEscaper(@NotNull FusionValueDslContent host) { | ||
super(host); | ||
} | ||
|
||
@Override | ||
public boolean decode(@NotNull TextRange rangeInsideHost, @NotNull StringBuilder outChars) { | ||
outChars.append(myHost.getText(), rangeInsideHost.getStartOffset(), rangeInsideHost.getEndOffset()); | ||
return true; | ||
} | ||
|
||
@Override | ||
public int getOffsetInHost(int offsetInDecoded, @NotNull TextRange rangeInsideHost) { | ||
int offset = offsetInDecoded + rangeInsideHost.getStartOffset(); | ||
if (offset < rangeInsideHost.getStartOffset()) offset = rangeInsideHost.getStartOffset(); | ||
if (offset > rangeInsideHost.getEndOffset()) offset = rangeInsideHost.getEndOffset(); | ||
return offset; | ||
} | ||
|
||
@Override | ||
public boolean isOneLine() { | ||
return false; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/de/vette/idea/neos/lang/fusion/injection/FusionLanguageInjectionSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* IntelliJ IDEA plugin to support the Neos CMS. | ||
* Copyright (C) 2016 Christian Vette | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package de.vette.idea.neos.lang.fusion.injection; | ||
|
||
import com.intellij.psi.PsiLanguageInjectionHost; | ||
import de.vette.idea.neos.lang.fusion.patterns.FusionPatterns; | ||
import org.intellij.plugins.intelliLang.inject.AbstractLanguageInjectionSupport; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class FusionLanguageInjectionSupport extends AbstractLanguageInjectionSupport { | ||
private final String SUPPORT_ID = "fusion"; | ||
|
||
@NotNull | ||
@Override | ||
public String getId() { | ||
return SUPPORT_ID; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public Class[] getPatternClasses() { | ||
return new Class[]{FusionPatterns.class}; | ||
} | ||
|
||
@Override | ||
public boolean useDefaultInjector(PsiLanguageInjectionHost host) { | ||
return false; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/de/vette/idea/neos/lang/fusion/injection/FusionLanguageInjector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* IntelliJ IDEA plugin to support the Neos CMS. | ||
* Copyright (C) 2016 Christian Vette | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version.eadzc | ||
* | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package de.vette.idea.neos.lang.fusion.injection; | ||
|
||
import com.intellij.lang.Language; | ||
import com.intellij.openapi.util.TextRange; | ||
import com.intellij.psi.InjectedLanguagePlaces; | ||
import com.intellij.psi.LanguageInjector; | ||
import com.intellij.psi.PsiLanguageInjectionHost; | ||
import org.intellij.plugins.intelliLang.Configuration; | ||
import org.intellij.plugins.intelliLang.inject.InjectedLanguage; | ||
import org.intellij.plugins.intelliLang.inject.config.BaseInjection; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.*; | ||
|
||
public class FusionLanguageInjector implements LanguageInjector { | ||
|
||
private final Configuration myInjectionConfiguration; | ||
|
||
public FusionLanguageInjector(Configuration configuration) { | ||
myInjectionConfiguration = configuration; | ||
} | ||
|
||
@Override | ||
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) { | ||
Iterator it = myInjectionConfiguration.getInjections("fusion").iterator(); | ||
while(it.hasNext()) { | ||
BaseInjection injection = (BaseInjection) it.next(); | ||
if (injection.acceptsPsiElement(host)) { | ||
Language language = InjectedLanguage.findLanguageById(injection.getInjectedLanguageId()); | ||
if (language != null) { | ||
injectionPlacesRegistrar.addPlace(language, new TextRange(0, host.getTextLength()), "", ""); | ||
} | ||
} | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/de/vette/idea/neos/lang/fusion/patterns/FusionElementPattern.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* IntelliJ IDEA plugin to support the Neos CMS. | ||
* Copyright (C) 2016 Christian Vette | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.vette.idea.neos.lang.fusion.patterns; | ||
|
||
import com.intellij.patterns.InitialPatternCondition; | ||
import com.intellij.patterns.PsiElementPattern; | ||
import com.intellij.psi.PsiElement; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class FusionElementPattern<T extends PsiElement,Self extends FusionElementPattern<T,Self>> extends PsiElementPattern<T,Self> { | ||
|
||
public FusionElementPattern(Class<T> aClass) { | ||
super(aClass); | ||
} | ||
|
||
public FusionElementPattern(@NotNull InitialPatternCondition<T> condition) { | ||
super(condition); | ||
} | ||
|
||
public static class Capture<T extends PsiElement> extends FusionElementPattern<T, FusionElementPattern.Capture<T>> { | ||
public Capture(Class<T> aClass) { | ||
super(aClass); | ||
} | ||
|
||
public Capture(@NotNull InitialPatternCondition<T> condition) { | ||
super(condition); | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/de/vette/idea/neos/lang/fusion/patterns/FusionPatterns.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* IntelliJ IDEA plugin to support the Neos CMS. | ||
* Copyright (C) 2016 Christian Vette | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.vette.idea.neos.lang.fusion.patterns; | ||
|
||
import com.intellij.patterns.InitialPatternCondition; | ||
import com.intellij.patterns.PlatformPatterns; | ||
import com.intellij.util.ProcessingContext; | ||
import de.vette.idea.neos.lang.fusion.psi.FusionValueDsl; | ||
import de.vette.idea.neos.lang.fusion.patterns.FusionElementPattern.Capture; | ||
import de.vette.idea.neos.lang.fusion.psi.FusionValueDslContent; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class FusionPatterns extends PlatformPatterns { | ||
|
||
public static FusionElementPattern fusionValueDsl(final String identifier) { | ||
return new Capture(new InitialPatternCondition<FusionValueDslContent>(FusionValueDslContent.class) { | ||
public boolean accepts(@Nullable Object o, ProcessingContext context) { | ||
if (o instanceof FusionValueDslContent) { | ||
FusionValueDsl s = (FusionValueDsl) ((FusionValueDslContent) o).getParent(); | ||
return s.getDslIdentifier().getText().equals(identifier); | ||
} | ||
|
||
return false; | ||
} | ||
}); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...main/java/de/vette/idea/neos/lang/fusion/psi/impl/ext/FusionValueDslContentImplMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* IntelliJ IDEA plugin to support the Neos CMS. | ||
* Copyright (C) 2016 Christian Vette | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.vette.idea.neos.lang.fusion.psi.impl.ext; | ||
|
||
import com.intellij.lang.ASTNode; | ||
import com.intellij.psi.LiteralTextEscaper; | ||
import com.intellij.psi.PsiLanguageInjectionHost; | ||
import de.vette.idea.neos.lang.fusion.injection.FusionDslTextEscaper; | ||
import de.vette.idea.neos.lang.fusion.psi.FusionValueDslContent; | ||
import de.vette.idea.neos.lang.fusion.psi.impl.FusionCompositeElementImpl; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class FusionValueDslContentImplMixin extends FusionCompositeElementImpl implements FusionValueDslContent { | ||
|
||
public FusionValueDslContentImplMixin(@NotNull ASTNode astNode) { | ||
super(astNode); | ||
} | ||
|
||
@Override | ||
public boolean isValidHost() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public PsiLanguageInjectionHost updateText(@NotNull String text) { | ||
return null; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public LiteralTextEscaper<? extends PsiLanguageInjectionHost> createLiteralTextEscaper() { | ||
return new FusionDslTextEscaper(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/resources/de/vette/idea/neos/lang/fusion/injection/fusionInjections.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<component name="LanguageInjectionConfiguration"> | ||
<injection language="HTML" injector-id="fusion"> | ||
<display-name>AFX</display-name> | ||
<place><![CDATA[fusionValueDsl("afx")]]></place> | ||
</injection> | ||
</component> |