public class CSSSemanticAnalyzer extends Object
CSSManager
.Constructor and Description |
---|
CSSSemanticAnalyzer() |
Modifier and Type | Method and Description |
---|---|
static com.google.common.collect.ImmutableMap<String,IClassDefinition> |
buildQNameToDefinitionMap(Collection<IClassDefinition> classDefinitions)
Build a map from QNames to class definitions.
|
static com.google.common.collect.ImmutableSet<ICSSSelector> |
getAllSelectors(ICSSDocument document)
Collect all the selectors in the CSS document including the subjects and
the combination selectors.
|
static com.google.common.collect.ImmutableSet<IClassDefinition> |
getClassDefinitionSet(Collection<IDefinition> definitions)
Find all the class definitions in the given collection.
|
static com.google.common.collect.ImmutableSet<ICSSRule> |
getMatchedRules(CSSCompilationSession session,
IFlexProject flexProject,
ICSSDocument cssDocument,
com.google.common.collect.ImmutableSet<String> qnames,
Collection<ICompilerProblem> problems)
Get a set of
ICSSRule 's that match any of the class definitions
passed in. |
static boolean |
isWildcardSelector(ICSSSelector selector)
Check if the selector is a wildcard selector.
|
static void |
resolveDependencies(Map<CSSFunctionCallPropertyValue,EmbedCompilationUnit> resolvedEmbedProperties,
ICSSRule cssRule,
ICompilerProject project,
Set<IClassDefinition> classReferences,
Set<EmbedCompilationUnit> embedCompilationUnits,
Collection<ICompilerProblem> problems)
Try to resolve all the dependencies introduced by
ClassReference() and Embed() property values in a CSS
rule. |
static com.google.common.collect.ImmutableMap<ICSSSelector,String> |
resolveSelectors(IXMLNameResolver xmlNameResolver,
ICSSDocument css,
Collection<ICompilerProblem> problems,
boolean isCompatibilityVersion3)
Resolve type selectors to class definitions within a file scope context
If a namespace short name is mapped to a undefined namespace URI, just
ignore.
|
static void |
validate(Set<ICompilationUnit> linkingCompilationUnits,
CSSCompilationSession session,
Collection<ICompilerProblem> problems)
Validate a CSS model.
|
public static void resolveDependencies(Map<CSSFunctionCallPropertyValue,EmbedCompilationUnit> resolvedEmbedProperties, ICSSRule cssRule, ICompilerProject project, Set<IClassDefinition> classReferences, Set<EmbedCompilationUnit> embedCompilationUnits, Collection<ICompilerProblem> problems)
ClassReference()
and Embed()
property values in a CSS
rule.resolvedEmbedProperties
- A map from Embed()
property values
to their resolved EmbedCompilationUnit
's.cssRule
- CSS rule.project
- Current project.classReferences
- Definitions of the ClassReference("...")
properties will be stored in this collection after the function returns.embedCompilationUnits
- EmbedCompilationUnit
's used in the
rules will be stored in this collection after the function returns.problems
- Compiler problems. This method reports
CSSUnresolvedClassReferenceProblem
issues.public static com.google.common.collect.ImmutableMap<ICSSSelector,String> resolveSelectors(IXMLNameResolver xmlNameResolver, ICSSDocument css, Collection<ICompilerProblem> problems, boolean isCompatibilityVersion3)
If a namespace short name is mapped to a undefined namespace URI, just ignore.
xmlNameResolver
- XML name resolvercss
- CSS DOM.problems
- Collect problems.isCompatibilityVersion3
- If true, do not create
CSSUnknownDefaultNamespaceProblem
's.public static com.google.common.collect.ImmutableSet<ICSSSelector> getAllSelectors(ICSSDocument document)
document
- CSS documentpublic static com.google.common.collect.ImmutableSet<ICSSRule> getMatchedRules(CSSCompilationSession session, IFlexProject flexProject, ICSSDocument cssDocument, com.google.common.collect.ImmutableSet<String> qnames, Collection<ICompilerProblem> problems)
ICSSRule
's that match any of the class definitions
passed in.session
- CSS compilation session data.flexProject
- Flex project.cssDocument
- CSS document.qnames
- A set of QNames of the definitions to be matched the CSS
rules.problems
- Problems collection.public static boolean isWildcardSelector(ICSSSelector selector)
selector
- CSS selectorpublic static final com.google.common.collect.ImmutableMap<String,IClassDefinition> buildQNameToDefinitionMap(Collection<IClassDefinition> classDefinitions)
classDefinitions
- Class definitions.public static com.google.common.collect.ImmutableSet<IClassDefinition> getClassDefinitionSet(Collection<IDefinition> definitions)
definitions
- A collection of definitions.public static void validate(Set<ICompilationUnit> linkingCompilationUnits, CSSCompilationSession session, Collection<ICompilerProblem> problems) throws InterruptedException
Validate a CSS model. The validation only works for Flex 4+.
The result is added to the problem collection.
For example, if an MXML document only uses <s:Button>
tags, and
its <fx:Style>
block contains:
... s|Button { fontSize : 12; } local|MyComponent { color : red; } ...Since
<local:MyComponent>
isn't used in the current MXML
document, the local|MyComponent
is a rule with an unused type
selector.
The validation process only finds all the unused type selectors, but it doesn't take them out of the code generation.
CSSExcludedStylePropertyProblem
.
[Exclude(kind="style", name="foo")] public class MyButton { }The following CSS will cause the problem:
local|MyButton { foo : something; }
linkingCompilationUnits
- All type selectors that doesn't map to any
definition in this collection are "unused".session
- CSSCompilationSession.cssDocuments
has all the CSS
models an MXML document has.InterruptedException
- Abort compilation.Copyright © 2016 The Apache Software Foundation. All rights reserved.