Skip to content
Snippets Groups Projects
Commit bf03d7c2 authored by Johannes Mey's avatar Johannes Mey
Browse files

align with master

parent 89cba244
No related branches found
No related tags found
No related merge requests found
Pipeline #9968 passed
Showing
with 110 additions and 109 deletions
...@@ -10,7 +10,7 @@ import com.intellij.psi.search.FileTypeIndex; ...@@ -10,7 +10,7 @@ import com.intellij.psi.search.FileTypeIndex;
import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiTreeUtil;
import org.jastadd.tooling.grammar.psi.GrammarFile; import org.jastadd.tooling.grammar.psi.GrammarFile;
import org.jastadd.tooling.grammar.psi.RelAstGrammarTypeDecl; import org.jastadd.tooling.grammar.psi.GrammarTypeDecl;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.*; import java.util.*;
...@@ -30,17 +30,17 @@ public class GrammarUtil { ...@@ -30,17 +30,17 @@ public class GrammarUtil {
* @param name to check * @param name to check
* @return matching TypeDecls * @return matching TypeDecls
*/ */
public static List<RelAstGrammarTypeDecl> findTypeDecl(Project project, String name) { public static List<GrammarTypeDecl> findTypeDecl(Project project, String name) {
List<RelAstGrammarTypeDecl> result = new ArrayList<>(); List<GrammarTypeDecl> result = new ArrayList<>();
Collection<VirtualFile> virtualFiles = Collection<VirtualFile> virtualFiles =
FileTypeIndex.getFiles(GrammarFileType.INSTANCE, GlobalSearchScope.allScope(project)); FileTypeIndex.getFiles(GrammarFileType.INSTANCE, GlobalSearchScope.allScope(project));
for (VirtualFile virtualFile : virtualFiles) { for (VirtualFile virtualFile : virtualFiles) {
GrammarFile simpleFile = (GrammarFile) PsiManager.getInstance(project).findFile(virtualFile); GrammarFile simpleFile = (GrammarFile) PsiManager.getInstance(project).findFile(virtualFile);
if (simpleFile != null) { if (simpleFile != null) {
// TODO check if file is ignored or generated! // TODO check if file is ignored or generated!
RelAstGrammarTypeDecl[] typeDecls = PsiTreeUtil.getChildrenOfType(simpleFile, RelAstGrammarTypeDecl.class); GrammarTypeDecl[] typeDecls = PsiTreeUtil.getChildrenOfType(simpleFile, GrammarTypeDecl.class);
if (typeDecls != null) { if (typeDecls != null) {
for (RelAstGrammarTypeDecl typeDecl : typeDecls) { for (GrammarTypeDecl typeDecl : typeDecls) {
if (name.equals(typeDecl.getName())) { if (name.equals(typeDecl.getName())) {
result.add(typeDecl); result.add(typeDecl);
} }
...@@ -57,15 +57,15 @@ public class GrammarUtil { ...@@ -57,15 +57,15 @@ public class GrammarUtil {
* @param project current project * @param project current project
* @return all TypeDecls * @return all TypeDecls
*/ */
public static List<RelAstGrammarTypeDecl> findTypeDecl(Project project) { public static List<GrammarTypeDecl> findTypeDecl(Project project) {
List<RelAstGrammarTypeDecl> result = new ArrayList<>(); List<GrammarTypeDecl> result = new ArrayList<>();
Collection<VirtualFile> virtualFiles = Collection<VirtualFile> virtualFiles =
FileTypeIndex.getFiles(GrammarFileType.INSTANCE, GlobalSearchScope.allScope(project)); FileTypeIndex.getFiles(GrammarFileType.INSTANCE, GlobalSearchScope.allScope(project));
for (VirtualFile virtualFile : virtualFiles) { for (VirtualFile virtualFile : virtualFiles) {
GrammarFile simpleFile = (GrammarFile) PsiManager.getInstance(project).findFile(virtualFile); GrammarFile simpleFile = (GrammarFile) PsiManager.getInstance(project).findFile(virtualFile);
if (simpleFile != null) { if (simpleFile != null) {
// TODO check if file is ignored or generated! // TODO check if file is ignored or generated!
RelAstGrammarTypeDecl[] typeDecls = PsiTreeUtil.getChildrenOfType(simpleFile, RelAstGrammarTypeDecl.class); GrammarTypeDecl[] typeDecls = PsiTreeUtil.getChildrenOfType(simpleFile, GrammarTypeDecl.class);
if (typeDecls != null) { if (typeDecls != null) {
result.addAll(Arrays.asList(typeDecls)); result.addAll(Arrays.asList(typeDecls));
} }
......
...@@ -16,6 +16,7 @@ import org.jastadd.tooling.grammar.lexer.GrammarLexerAdapter; ...@@ -16,6 +16,7 @@ import org.jastadd.tooling.grammar.lexer.GrammarLexerAdapter;
import org.jastadd.tooling.grammar.psi.GrammarFile; import org.jastadd.tooling.grammar.psi.GrammarFile;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class GrammarParserDefinition implements ParserDefinition { public class GrammarParserDefinition implements ParserDefinition {
public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE); public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE);
......
...@@ -13,14 +13,14 @@ public class GrammarElementFactory { ...@@ -13,14 +13,14 @@ public class GrammarElementFactory {
throw new IllegalStateException("Utility class"); throw new IllegalStateException("Utility class");
} }
public static RelAstGrammarDeclaredName createDeclaredName(Project project, String name) { public static GrammarDeclaredName createDeclaredName(Project project, String name) {
final GrammarFile file = createFile(project, name + ";"); final GrammarFile file = createFile(project, name + ";");
return (RelAstGrammarDeclaredName) file.getFirstChild().getFirstChild(); return (GrammarDeclaredName) file.getFirstChild().getFirstChild();
} }
public static RelAstGrammarTypeReference createTypeReference(Project project, String name) { public static GrammarTypeReference createTypeReference(Project project, String name) {
final GrammarFile file = createFile(project, "X : " + name + ";"); final GrammarFile file = createFile(project, "X : " + name + ";");
return (RelAstGrammarTypeReference) (Objects.requireNonNull(file.getFirstChild().getNode().findChildByType(GrammarTypes.TYPE_REFERENCE)).getPsi()); return (GrammarTypeReference) (Objects.requireNonNull(file.getFirstChild().getNode().findChildByType(GrammarTypes.TYPE_REFERENCE)).getPsi());
} }
public static GrammarFile createFile(Project project, String text) { public static GrammarFile createFile(Project project, String text) {
......
package org.jastadd.tooling.grammar.psi; package org.jastadd.tooling.grammar.psi;
import com.intellij.extapi.psi.PsiFileBase; import com.intellij.extapi.psi.PsiFileBase;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.psi.FileViewProvider; import com.intellij.psi.FileViewProvider;
import org.jastadd.tooling.grammar.Grammar; import org.jastadd.tooling.grammar.Grammar;
import org.jastadd.tooling.grammar.GrammarFileType; import org.jastadd.tooling.grammar.GrammarFileType;
...@@ -14,7 +15,7 @@ public class GrammarFile extends PsiFileBase { ...@@ -14,7 +15,7 @@ public class GrammarFile extends PsiFileBase {
@NotNull @NotNull
@Override @Override
public com.intellij.openapi.fileTypes.FileType getFileType() { public FileType getFileType() {
return GrammarFileType.INSTANCE; return GrammarFileType.INSTANCE;
} }
......
...@@ -13,7 +13,7 @@ public class GrammarTokenType extends IElementType { ...@@ -13,7 +13,7 @@ public class GrammarTokenType extends IElementType {
@Override @Override
public String toString() { public String toString() {
return "RelAstGrammarTokenType." + super.toString(); return "GrammarTokenType." + super.toString();
} }
} }
...@@ -7,7 +7,7 @@ import com.intellij.util.IncorrectOperationException; ...@@ -7,7 +7,7 @@ import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class GrammarTypeReferenceManipulator extends AbstractElementManipulator<RelAstGrammarTypeReference> implements ElementManipulator<RelAstGrammarTypeReference> { public class GrammarTypeReferenceManipulator extends AbstractElementManipulator<GrammarTypeReference> implements ElementManipulator<GrammarTypeReference> {
/** /**
* Changes the element's text to the given new text. * Changes the element's text to the given new text.
* *
...@@ -19,9 +19,9 @@ public class GrammarTypeReferenceManipulator extends AbstractElementManipulator< ...@@ -19,9 +19,9 @@ public class GrammarTypeReferenceManipulator extends AbstractElementManipulator<
*/ */
@Nullable @Nullable
@Override @Override
public RelAstGrammarTypeReference handleContentChange(@NotNull RelAstGrammarTypeReference element, @NotNull TextRange range, String newContent) { public GrammarTypeReference handleContentChange(@NotNull GrammarTypeReference element, @NotNull TextRange range, String newContent) {
try { try {
return (RelAstGrammarTypeReference) element.setName(range.replace(element.getText(), newContent)); return (GrammarTypeReference) element.setName(range.replace(element.getText(), newContent));
} catch (Exception e) { // e.g., in case the range is wrong } catch (Exception e) { // e.g., in case the range is wrong
throw new IncorrectOperationException(e); throw new IncorrectOperationException(e);
} }
......
...@@ -5,8 +5,8 @@ import com.intellij.lang.ASTNode; ...@@ -5,8 +5,8 @@ import com.intellij.lang.ASTNode;
import com.intellij.navigation.ItemPresentation; import com.intellij.navigation.ItemPresentation;
import com.intellij.psi.PsiReference; import com.intellij.psi.PsiReference;
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry; import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
import org.jastadd.tooling.util.JastAddIcons;
import org.jastadd.tooling.grammar.psi.GrammarNamedElement; import org.jastadd.tooling.grammar.psi.GrammarNamedElement;
import org.jastadd.tooling.util.JastAddIcons;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
......
...@@ -3,9 +3,9 @@ package org.jastadd.tooling.grammar.psi.impl; ...@@ -3,9 +3,9 @@ package org.jastadd.tooling.grammar.psi.impl;
import com.intellij.lang.ASTNode; import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jastadd.tooling.grammar.parser.GrammarTypes; import org.jastadd.tooling.grammar.parser.GrammarTypes;
import org.jastadd.tooling.grammar.psi.GrammarTypeDeclExtension; import org.jastadd.tooling.grammar.psi.GrammarDeclaredName;
import org.jastadd.tooling.grammar.psi.RelAstGrammarDeclaredName;
import org.jastadd.tooling.grammar.psi.GrammarElementFactory; import org.jastadd.tooling.grammar.psi.GrammarElementFactory;
import org.jastadd.tooling.grammar.psi.GrammarTypeDeclExtension;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class GrammarTypeDeclImplExtension extends GrammarNamedElementImpl implements GrammarTypeDeclExtension { public class GrammarTypeDeclImplExtension extends GrammarNamedElementImpl implements GrammarTypeDeclExtension {
...@@ -27,7 +27,7 @@ public class GrammarTypeDeclImplExtension extends GrammarNamedElementImpl implem ...@@ -27,7 +27,7 @@ public class GrammarTypeDeclImplExtension extends GrammarNamedElementImpl implem
public PsiElement setName(@NotNull String newName) { public PsiElement setName(@NotNull String newName) {
ASTNode keyNode = getNode().findChildByType(GrammarTypes.DECLARED_NAME); ASTNode keyNode = getNode().findChildByType(GrammarTypes.DECLARED_NAME);
if (keyNode != null) { if (keyNode != null) {
RelAstGrammarDeclaredName name = GrammarElementFactory.createDeclaredName(getProject(), newName); GrammarDeclaredName name = GrammarElementFactory.createDeclaredName(getProject(), newName);
ASTNode newKeyNode = name.getNode(); ASTNode newKeyNode = name.getNode();
getNode().replaceChild(keyNode, newKeyNode); getNode().replaceChild(keyNode, newKeyNode);
} }
......
...@@ -3,8 +3,8 @@ package org.jastadd.tooling.grammar.psi.impl; ...@@ -3,8 +3,8 @@ package org.jastadd.tooling.grammar.psi.impl;
import com.intellij.lang.ASTNode; import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jastadd.tooling.grammar.psi.GrammarElementFactory; import org.jastadd.tooling.grammar.psi.GrammarElementFactory;
import org.jastadd.tooling.grammar.psi.GrammarTypeReference;
import org.jastadd.tooling.grammar.psi.GrammarTypeReferenceExtension; import org.jastadd.tooling.grammar.psi.GrammarTypeReferenceExtension;
import org.jastadd.tooling.grammar.psi.RelAstGrammarTypeReference;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class GrammarTypeReferenceImplExtension extends GrammarNamedElementImpl implements GrammarTypeReferenceExtension { public class GrammarTypeReferenceImplExtension extends GrammarNamedElementImpl implements GrammarTypeReferenceExtension {
...@@ -22,7 +22,7 @@ public class GrammarTypeReferenceImplExtension extends GrammarNamedElementImpl i ...@@ -22,7 +22,7 @@ public class GrammarTypeReferenceImplExtension extends GrammarNamedElementImpl i
// FIXME this can break the grammar when the type is used in an unnamed component (and in many other cases probably) // FIXME this can break the grammar when the type is used in an unnamed component (and in many other cases probably)
ASTNode keyNode = getNode().getFirstChildNode(); ASTNode keyNode = getNode().getFirstChildNode();
if (keyNode != null) { if (keyNode != null) {
RelAstGrammarTypeReference name = GrammarElementFactory.createTypeReference(getProject(), newName); GrammarTypeReference name = GrammarElementFactory.createTypeReference(getProject(), newName);
ASTNode newKeyNode = name.getNode().getFirstChildNode(); ASTNode newKeyNode = name.getNode().getFirstChildNode();
getNode().replaceChild(keyNode, newKeyNode); getNode().replaceChild(keyNode, newKeyNode);
} }
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
<lang.refactoringSupport language="JastAddGrammar" <lang.refactoringSupport language="JastAddGrammar"
implementationClass="org.jastadd.tooling.grammar.GrammarRefactoringSupportProvider"/> implementationClass="org.jastadd.tooling.grammar.GrammarRefactoringSupportProvider"/>
<lang.elementManipulator forClass="org.jastadd.tooling.grammar.psi.RelAstGrammarTypeReference" <lang.elementManipulator forClass="org.jastadd.tooling.grammar.psi.GrammarTypeReference"
implementationClass="org.jastadd.tooling.grammar.psi.GrammarTypeReferenceManipulator"/> implementationClass="org.jastadd.tooling.grammar.psi.GrammarTypeReferenceManipulator"/>
......
...@@ -3,10 +3,9 @@ ...@@ -3,10 +3,9 @@
xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#" xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns="http://www.w3.org/2000/svg"
width="16" width="16"
height="16" height="16"
id="svg4781" id="svg4781"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment