Skip to content

Commit

Permalink
fix: Text inside tags in design now supported (button caption, label …
Browse files Browse the repository at this point in the history
…valu etc.)

fix: component class names can contain numbers
fix: added custom Window attributes (centre, position, close-shortcut)
fix: meta tag formatting
  • Loading branch information
Kytýr Michal committed Apr 22, 2016
1 parent 33b9166 commit 51e4c59
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 64 deletions.

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

Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static List<PsiClass> findClasses(Project project, String packageName, St
Query<PsiClass> query = ClassInheritorsSearch.search(psiClass, scope, true);
return query.findAll().stream()
.filter(c -> c.getQualifiedName() != null
&& c.getQualifiedName().startsWith(packageName)
&& c.getQualifiedName().equals(packageName + "." + c.getName())
&& !c.isInterface()
&& !c.getModifierList().hasExplicitModifier("abstract"))
.collect(Collectors.toList());
Expand Down
5 changes: 0 additions & 5 deletions src/cz/mikrobestie/idea/vaadin/declarative/VDAnnotator.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder hold
}
} else {

String error = null;

// Type check
switch (type) {

Expand All @@ -79,9 +77,6 @@ public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder hold
}
break;
}
if (error != null) {
holder.createErrorAnnotation(attr.getLastChild(), error);
}
}
}
}
Expand Down
88 changes: 45 additions & 43 deletions src/cz/mikrobestie/idea/vaadin/declarative/VaadinDesignLexer.java

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

6 changes: 6 additions & 0 deletions src/cz/mikrobestie/idea/vaadin/declarative/VaadinUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public class VaadinUtils {
attrs.put("margin-left", TYPE_VOID);
componentAttrMap.put("com.vaadin.ui.AbstractOrderedLayout", attrs);

// Window
attrs = new HashMap<>();
attrs.put("center", TYPE_VOID);
attrs.put("position", TYPE_STRING);
attrs.put("close-shortcut", TYPE_STRING);
componentAttrMap.put("com.vaadin.ui.Window", attrs);

// Parent attrs
attrs = new HashMap<>();
Expand Down
2 changes: 1 addition & 1 deletion src/cz/mikrobestie/idea/vaadin/declarative/design.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
tokenTypeClass="cz.mikrobestie.idea.vaadin.declarative.psi.VDTokenType"
}

Document ::= DOCTYPE_DECL? (HtmlTag | Component)
Document ::= DOCTYPE_DECL? (Component | HtmlTag)
HtmlTag ::= COMMENT* EL_LEFT TAG_HTML Attr* EL_RIGHT HeadTag? BodyTag EL_CLOSE_LEFT TAG_HTML EL_RIGHT {pin = 2}
HeadTag ::= COMMENT* EL_LEFT TAG_HEAD EL_RIGHT (MetaTag | COMMENT)* EL_CLOSE_LEFT TAG_HEAD EL_RIGHT {pin = 2}
MetaTag ::= COMMENT* EL_LEFT TAG_META Attr+ EL_CLOSE_RIGHT {pin = 2}
Expand Down
2 changes: 1 addition & 1 deletion src/cz/mikrobestie/idea/vaadin/declarative/design.flex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import cz.mikrobestie.idea.vaadin.declarative.psi.VDTypes;
%unicode

WHITE_SPACE = [\ \t\f\r\n]
COMPONENT_NAME = [a-z]+(-[a-z]+)*
COMPONENT_NAME = [a-z0-9]+(-[a-z][a-z0-9]*)*
ATTR_NAME = [_:a-z]?[a-z-]*
ATTR_VALUE = \"[^\"]*\"?|'[^']*'?
EL_LEFT = "<"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ protected List<Block> buildChildren() {
public Indent getIndent() {
if (myNode.getElementType() == VDTypes.COMPONENT) {
return Indent.getNormalIndent();
} else if (myNode.getElementType() == VDTypes.META_TAG) {
return Indent.getNormalIndent();
} else if (myNode.getElementType() == VDTypes.ATTR) {
return Indent.getContinuationIndent(true);
}
return Indent.getNoneIndent();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiType;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.searches.MethodReferencesSearch;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.Query;
import cz.mikrobestie.idea.vaadin.declarative.PluginUtils;
import cz.mikrobestie.idea.vaadin.declarative.VaadinUtils;
import cz.mikrobestie.idea.vaadin.declarative.psi.VDAttrHelper;
Expand All @@ -16,6 +16,8 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;

/**
* Created by Michal on 29.11.2015.
*/
Expand Down Expand Up @@ -91,4 +93,16 @@ public String getValue() {
}
return null;
}

@NotNull
@Override
public PsiReference[] getReferences() {
PsiMethod setter = getSetter();
if (setter != null) {
Query<PsiReference> search = MethodReferencesSearch.search(setter);
Collection<PsiReference> references = search.findAll();
return references.toArray(new PsiReference[references.size()]);
}
return new PsiReference[0];
}
}

0 comments on commit 51e4c59

Please sign in to comment.