You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2014/07/22 15:35:57 UTC
[31/51] [partial] - Migrated the directory structure to a more Maven
style structure. - Started migrating the Parser from Antlr2+3 and JFlex to
Antlr4.
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/59f6373b/compiler/src/main/java/org/apache/flex/compiler/clients/problems/ProblemQuery.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/clients/problems/ProblemQuery.java b/compiler/src/main/java/org/apache/flex/compiler/clients/problems/ProblemQuery.java
new file mode 100644
index 0000000..f233ebe
--- /dev/null
+++ b/compiler/src/main/java/org/apache/flex/compiler/clients/problems/ProblemQuery.java
@@ -0,0 +1,479 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.clients.problems;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.flex.compiler.config.ICompilerProblemSettings;
+import org.apache.flex.compiler.problems.AbstractSemanticProblem;
+import org.apache.flex.compiler.problems.CodegenInternalProblem;
+import org.apache.flex.compiler.problems.CodegenProblem;
+import org.apache.flex.compiler.problems.CompilerProblemSeverity;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.problems.ParserProblem;
+import org.apache.flex.compiler.problems.SemanticWarningProblem;
+import org.apache.flex.compiler.problems.StrictSemanticsProblem;
+import org.apache.flex.compiler.problems.UnfoundPropertyProblem;
+import org.apache.flex.compiler.problems.collections.CompositeProblemFilter;
+import org.apache.flex.compiler.problems.collections.FilteredIterator;
+import com.google.common.collect.Iterables;
+
+/**
+ * A ProblemQuery presents a higher-level view of a problem
+ * stream; it offers facilities to enable or disable diagnostics
+ * and presents filtered and (optionally) sorted views of the
+ * underlying problem stream.
+ */
+public class ProblemQuery
+{
+ /**
+ * Construct a ProblemQuery.
+ */
+ public ProblemQuery()
+ {
+ this(null);
+ }
+
+ /**
+ * Construct a ProblemQuery with settings to control how compiler problems
+ * are reported.
+ *
+ * @param problemSettings configuration settings to control how compiler
+ * problems are reported.
+ */
+ public ProblemQuery(ICompilerProblemSettings problemSettings)
+ {
+ this.problems = new ArrayList<ICompilerProblem>();
+
+ // An empty problem set is sorted.
+ this.sorted = true;
+
+ // Start with no restrictions on the problems presented.
+ this.problemFilter = new ProblemFilterClassCriteria();
+
+ this.problemSettings = problemSettings;
+ }
+
+ /** The underlying problem collection. */
+ private ArrayList<ICompilerProblem> problems;
+
+ /**
+ * Set to true when the problem collection
+ * is known to be in sorted order.
+ */
+ private boolean sorted;
+
+ /**
+ * Problems being rejected as a class.
+ */
+ private ProblemFilterClassCriteria problemFilter;
+
+ /**
+ * Configuration settings that control how errors are
+ * reported.
+ */
+ private ICompilerProblemSettings problemSettings;
+
+ /**
+ * Gets the list of compiler problems, with no filtering or sorting.
+ */
+ public List<ICompilerProblem> getProblems()
+ {
+ return problems;
+ }
+
+ /**
+ * Enable or disable strict semantics mode diagnostics.
+ * @param isStrict - if true, strict semantics mode
+ * diagnostics will appear in the filtered diagnostics.
+ */
+ public void setShowStrictSemantics(boolean isStrict)
+ {
+ setShowProblemByClass(StrictSemanticsProblem.class, isStrict);
+ }
+
+ /**
+ * Enable or disable semantic warnings.
+ * @param showWarnings - if true, semantic warnings
+ * will appear in the filtered diagnostics.
+ */
+ public void setShowWarnings(boolean showWarnings)
+ {
+ setShowProblemByClass(SemanticWarningProblem.class, showWarnings);
+ }
+
+ /**
+ * Enable or disable internal error display.
+ * @param showInternalErrors - if true, internal error
+ * diagnostics will appear in the filtered diagnostics.
+ */
+ public void setShowInternalErrors(boolean showInternalErrors)
+ {
+ setShowProblemByClass(CodegenInternalProblem.class,showInternalErrors);
+ }
+
+ /**
+ * Enable or disable display of "problems" that
+ * are used for compiler internal processing but
+ * have no relevance to the user.
+ * @param showIrrelevantProblems - if true, non-user-relevant
+ * diagnostics will appear in the filtered diagnostics.
+ */
+ public void setShowIrrelevantProblems(boolean showIrrelevantProblems)
+ {
+ setShowProblemByClass(UnfoundPropertyProblem.class,showIrrelevantProblems);
+ }
+
+ /**
+ * Enable or disable display of a specific problem class or superclass.
+ * @param problemClass - the problem class/superclass of interest.
+ * @param enable - if true, instances of this problem class
+ * will appear in the filtered diagnostics.
+ */
+ public void setShowProblemByClass(Class<? extends ICompilerProblem> problemClass, final boolean enable)
+ {
+ if ( enable )
+ {
+ problemFilter.removeRejectedClass(problemClass);
+ }
+ else
+ {
+ problemFilter.addRejectedClass(problemClass);
+ }
+ }
+
+ /**
+ * Add an array of compiler problems to the problems collection.
+ * @param newProblems - the problems to add.
+ * @post the problems collection is marked "not sorted."
+ */
+ public void addAll(ICompilerProblem[] newProblems)
+ {
+ addAll(Arrays.asList(newProblems));
+ }
+
+ /**
+ * Add a collection of compiler problems to the problems collection.
+ * @param newProblems - the problems to add.
+ * @post the problems collection is marked "not sorted."
+ */
+ public void addAll(Iterable<ICompilerProblem> newProblems)
+ {
+ this.sorted = false;
+ Iterables.addAll(this.problems, newProblems);
+ }
+
+ /**
+ * Add a single problem to the problems collection.
+ * @param problem - the problem to add.
+ * @post the problems collection is marked "not sorted."
+ */
+ public void add(ICompilerProblem problem)
+ {
+ this.sorted = false;
+ this.problems.add(problem);
+ }
+
+ /**
+ * Clear the underlying collection of problems.
+ */
+ public void clear()
+ {
+ this.sorted = true;
+ this.problems.clear();
+ }
+
+ /**
+ * Get an iterator over the set of problems that
+ * are to be reported based on the current settings.
+ * Problem categorization is built into this filter so that problems
+ * categorized as "ignore" are filtered out.
+ *
+ * @return an Iterable<ICompilerProblem> over the
+ * subset of problems that are of interest to the client.
+ */
+ public Iterable<ICompilerProblem> getFilteredProblems()
+ {
+ IProblemFilter filter = CompositeProblemFilter.and(this.problemFilter, new SkipSemanticCascadesFilter());
+ CompilerProblemCategorizer categorizer = new CompilerProblemCategorizer(problemSettings);
+
+ return getFilteredProblems(CompositeProblemFilter.and(filter, new ErrorsAndWarningsFilter(categorizer)));
+ }
+
+ /**
+ * Used internally as a base filter without any categorization built in.
+ * This is useful for clients that want to do the categorization themselves.
+ * Gets an iterator over the set of problems that are to be reported based
+ * on the current settings.
+ *
+ * @return an Iterable<ICompilerProblem> over the subset of problems
+ * that are of interest to the client.
+ */
+ private Iterable<ICompilerProblem> getFilteredProblemsUsingBaseFilter()
+ {
+ return getFilteredProblems(CompositeProblemFilter.and(this.problemFilter, new SkipSemanticCascadesFilter()));
+ }
+
+ /**
+ * Get an iterator over the set of problems that
+ * are to be reported based on the current settings.
+ *
+ * @param filter - the filter to apply.
+ *
+ * @return an Iterable<ICompilerProblem> over the
+ * subset of problems that are of interest to the client.
+ */
+ private Iterable<ICompilerProblem> getFilteredProblems(IProblemFilter filter)
+ {
+ if (problemSettings != null)
+ filter = CompositeProblemFilter.and(filter, new ProblemSettingsFilter(problemSettings));
+
+ // Sort the problems so that the semantic cascade
+ // filter can find semantic problems that occur
+ // on the same line as parser problems.
+ sortProblems();
+ return getProblemView(filter);
+ }
+
+ /**
+ * Any problems to report after filtering?
+ * @return true if there are filtered problems.
+ */
+ public boolean hasFilteredProblems()
+ {
+ return getFilteredProblems().iterator().hasNext();
+ }
+
+ /**
+ * Do any problems match the given filter?
+ * @param filter - the problem filter of interest.
+ */
+ public boolean hasFilteredProblems(final IProblemFilter filter)
+ {
+ return getProblemView(filter).iterator().hasNext();
+ }
+
+ /**
+ * Get a filtered view of the underlying problems.
+ * @param filter - the filter to apply.
+ * @return an Iterable that supplies a filtered iterator of the problems.
+ */
+ public Iterable<ICompilerProblem> getProblemView(final IProblemFilter filter)
+ {
+ return FilteredIterator.getFilteredIterable(problems, filter);
+ }
+
+ /**
+ * Get an iterator over all internal errors.
+ */
+ public Iterable<ICompilerProblem> getInternalErrors()
+ {
+ return getProblemView(new ProblemFilterClassCriteria(CodegenInternalProblem.class));
+ }
+
+ /**
+ * Sort the captured collection of problems so that we can filter out
+ * semantic problems that occur on the same line as parser problems.
+ */
+ public void sortProblems()
+ {
+ if ( ! this.sorted )
+ {
+ Collections.sort( this.problems, compareByPositionAndPhase);
+ }
+
+ this.sorted = true;
+ }
+
+ /**
+ * Categorize the compiler problems into two bins, errors and warning.
+ *
+ * @param errors the collection where the errors are added.
+ * @param warnings the collection where the warnings are added.
+ */
+ public void getErrorsAndWarnings(Collection<ICompilerProblem> errors,
+ Collection<ICompilerProblem> warnings)
+ {
+ CompilerProblemCategorizer categorizer = new CompilerProblemCategorizer(problemSettings);
+
+ // Get the filtered problems and classify the problems as either errors or
+ // warnings.
+ for (ICompilerProblem problem : getFilteredProblemsUsingBaseFilter())
+ {
+ CompilerProblemSeverity severity = categorizer.getProblemSeverity(problem);
+ if (severity == CompilerProblemSeverity.ERROR)
+ errors.add(problem);
+ else if (severity == CompilerProblemSeverity.WARNING)
+ warnings.add(problem);
+ }
+
+ }
+
+ /**
+ * Test if any of the problems are errors.
+ *
+ * return true if any of the problems are errors, false otherwise.
+ */
+ public boolean hasErrors()
+ {
+ CompilerProblemCategorizer categorizer = new CompilerProblemCategorizer(problemSettings);
+
+ for (ICompilerProblem problem : getFilteredProblemsUsingBaseFilter())
+ {
+ CompilerProblemSeverity severity = categorizer.getProblemSeverity(problem);
+ if (severity == CompilerProblemSeverity.ERROR)
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * This Comparator compares problems based on three criteria:
+ * <li> file path
+ * <li> line number
+ * <li> problem class - ParserProblems are "less than" semantic problems.
+ */
+ public static final Comparator<ICompilerProblem> compareByPositionAndPhase =
+ new Comparator<ICompilerProblem>()
+ {
+ @Override
+ public int compare(ICompilerProblem p1, ICompilerProblem p2)
+ {
+ int result = compareStrings( p1.getSourcePath(), p2.getSourcePath());
+
+ if ( result == 0 )
+ result = p1.getLine() - p2.getLine();
+
+ if ( result == 0 )
+ result = compareProblemClasses(p1, p2);
+
+ return result;
+ }
+
+ /**
+ * Look for configurations of problem classes that
+ * imply a definite arrangement; problems from the
+ * syntax analysis phase get ordered before problems
+ * from the semantic analysis phase so that the latter
+ * can be elided.
+ */
+ private int compareProblemClasses(ICompilerProblem p1, ICompilerProblem p2)
+ {
+ if ( p1 instanceof ParserProblem )
+ {
+ if ( !(p2 instanceof ParserProblem) )
+ return -1;
+ }
+ else if ( p2 instanceof ParserProblem )
+ {
+ if ( !(p1 instanceof ParserProblem) )
+ return 1;
+ }
+
+ return 0;
+ }
+ };
+
+
+ /**
+ * SkipSemanticCascadesFilter accepts any problem except a
+ * SemanticProblem or CodegenProblem on a line that has already
+ * reported some kind of parser problem.
+ */
+ private class SkipSemanticCascadesFilter implements IProblemFilter
+ {
+ private int lineNumber = -1;
+ private String fileName = null;
+ private boolean parserProblemOnLine = false;
+
+ @Override
+ public boolean accept(ICompilerProblem problem)
+ {
+ if ( problem.getLine() != lineNumber || compareStrings(this.fileName, problem.getSourcePath()) != 0 )
+ {
+ this.lineNumber = problem.getLine();
+ this.fileName = problem.getSourcePath();
+ }
+ else if ( parserProblemOnLine && (problem instanceof AbstractSemanticProblem || problem instanceof CodegenProblem) )
+ {
+ // Skip this problem.
+ return false;
+ }
+
+ this.parserProblemOnLine = problem instanceof ParserProblem;
+ return true;
+ }
+
+ }
+
+ /**
+ * ErrorsAndWarningsFilter accepts any problem that has a severity
+ * of error or warning.
+ */
+ private class ErrorsAndWarningsFilter implements IProblemFilter
+ {
+
+ ErrorsAndWarningsFilter(CompilerProblemCategorizer categorizer)
+ {
+ this.categorizer = categorizer;
+ }
+
+ private final CompilerProblemCategorizer categorizer;
+
+ @Override
+ public boolean accept(ICompilerProblem problem)
+ {
+ CompilerProblemSeverity severity = categorizer.getProblemSeverity(problem);
+ if (severity == CompilerProblemSeverity.ERROR ||
+ severity == CompilerProblemSeverity.WARNING)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ }
+
+ /**
+ * Compare two strings, either or both of which may be null.
+ * @param s1 - the first string.
+ * @param s2 - the second string.
+ * @return -1 if s1 is less than s2, either in the string comparison
+ * sense or because s1 is null and s2 is not; 0 if the strings
+ * compare equal; 1 if s1 is greater than s1, by the reasoning above.
+ */
+ private static int compareStrings(String s1, String s2)
+ {
+ if ( s1 == s2 )
+ return 0;
+ else if ( s1 != null && s2 != null )
+ return s1.compareTo(s2);
+ else
+ // One or the other is null, but not both.
+ return s1 == null? -1: 1;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/59f6373b/compiler/src/main/java/org/apache/flex/compiler/clients/problems/ProblemSettingsFilter.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/clients/problems/ProblemSettingsFilter.java b/compiler/src/main/java/org/apache/flex/compiler/clients/problems/ProblemSettingsFilter.java
new file mode 100644
index 0000000..7922e58
--- /dev/null
+++ b/compiler/src/main/java/org/apache/flex/compiler/clients/problems/ProblemSettingsFilter.java
@@ -0,0 +1,230 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.clients.problems;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.flex.compiler.config.ICompilerProblemSettings;
+import org.apache.flex.compiler.internal.config.ICompilerSettings;
+import org.apache.flex.compiler.problems.AbstractDeprecatedAPIProblem;
+import org.apache.flex.compiler.problems.ArrayCastProblem;
+import org.apache.flex.compiler.problems.AssignmentInConditionalProblem;
+import org.apache.flex.compiler.problems.ConstNotInitializedProblem;
+import org.apache.flex.compiler.problems.DateCastProblem;
+import org.apache.flex.compiler.problems.DeprecatedConfigurationOptionProblem;
+import org.apache.flex.compiler.problems.DuplicateQNameInSourcePathProblem;
+import org.apache.flex.compiler.problems.DuplicateVariableDefinitionProblem;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.problems.IllogicalComparionWithNaNProblem;
+import org.apache.flex.compiler.problems.IllogicalComparisonWithUndefinedProblem;
+import org.apache.flex.compiler.problems.InstanceOfProblem;
+import org.apache.flex.compiler.problems.NullUsedWhereOtherExpectedProblem;
+import org.apache.flex.compiler.problems.OverlappingSourcePathProblem;
+import org.apache.flex.compiler.problems.ScopedToDefaultNamespaceProblem;
+import org.apache.flex.compiler.problems.SemanticWarningProblem;
+import org.apache.flex.compiler.problems.StrictSemanticsProblem;
+import org.apache.flex.compiler.problems.VariableHasNoTypeDeclarationProblem;
+
+/**
+ * A problem filter that implements filtering based the values of the following
+ * compiler options:
+ *
+ * -allow-source-path-overlap
+ * -show-actionscript-warnings
+ * -show-binding-warnings
+ * -show-deprecation-warnings
+ * -show-multiple-definition-warnings
+ * -show-unused-type-selector-warnings
+ * -strict
+ * -warn-assignment-within-conditional
+ * -warn-bad-array-cast
+ * -warn-bad-date-cast
+ * -warn-bad-nan-comparision
+ * -warn-bad-null-assignment
+ * -warn-bad-undefined-comparision
+ * -warn-const-not-initialized
+ * -warn-duplicate-variable-def
+ * -warn-instanceof-changes
+ * -warn-missing-namespace-decl
+ * -warn-no-type-decl
+ *
+ */
+public class ProblemSettingsFilter implements IProblemFilter
+{
+
+ /**
+ * Create a filter based on problem settings.
+ *
+ * @param problemSettings The settings, may not be null.
+ */
+ public ProblemSettingsFilter(ICompilerProblemSettings problemSettings)
+ {
+ assert problemSettings != null : "Settings may not be null";
+
+ this.problemSettings = problemSettings;
+
+ init();
+ }
+
+ private final ICompilerProblemSettings problemSettings;
+ private final Set<Class<? extends ICompilerProblem>> filter = new HashSet<Class<? extends ICompilerProblem>>();
+
+ @Override
+ public boolean accept(ICompilerProblem p)
+ {
+ for (Class<?> filterClass : filter)
+ {
+ // This is equivalent to (p instanceof <filter class>)
+ if (filterClass.isInstance(p))
+ return false;
+ }
+
+ // accept it.
+ return true;
+ }
+
+ /**
+ * initialize filter from problem settings.
+ */
+ private void init()
+ {
+ setShowStrictSemantics(problemSettings.isStrict());
+ setShowWarnings(problemSettings.showActionScriptWarnings());
+ setShowDeprecationWarnings(problemSettings.showDeprecationWarnings());
+ setShowBindingWarnings(problemSettings.showBindingWarnings());
+ setShowMultipleDefinitionWarnings(problemSettings.showMultipleDefinitionWarnings());
+ setShowUnusedTypeSelectorWarnings(problemSettings.showUnusedTypeSelectorWarnings());
+ setAllowSourcePathOverlapWarnings(problemSettings.isSourcePathOverlapAllowed());
+ setShowActionScriptWarnings();
+ }
+
+ /**
+ * Enable or disable strict semantics mode diagnostics.
+ * @param isStrict - if true, strict semantics mode
+ * diagnostics will appear in the filtered diagnostics.
+ */
+ private void setShowStrictSemantics(boolean isStrict)
+ {
+ setShowProblemByClass(StrictSemanticsProblem.class, isStrict);
+ }
+
+ /**
+ * Enable or disable semantic warnings.
+ * @param showWarnings - if true, semantic warnings
+ * will appear in the filtered diagnostics.
+ */
+ private void setShowWarnings(boolean showWarnings)
+ {
+ setShowProblemByClass(SemanticWarningProblem.class, showWarnings);
+ }
+
+ private void setAllowSourcePathOverlapWarnings(boolean isSourcePathOverlapAllowed)
+ {
+ setShowProblemByClass(OverlappingSourcePathProblem.class, !isSourcePathOverlapAllowed);
+ }
+
+ private void setShowUnusedTypeSelectorWarnings(boolean showUnusedTypeSelectorWarnings)
+ {
+ // TODO: call setShowProblemByClass() with warnings relating to
+ // unused type selectors.
+ // CMP-1422
+ }
+
+ private void setShowBindingWarnings(boolean showBindingWarnings)
+ {
+ // TODO: call setShowProblemByClass() with problems relating to
+ // binding warnings.
+ // CMP-1424
+ }
+
+ private void setShowMultipleDefinitionWarnings(boolean b)
+ {
+ setShowProblemByClass(DuplicateQNameInSourcePathProblem.class, b);
+ }
+
+ private void setShowActionScriptWarnings()
+ {
+ // Associate compiler problems with the compiler -warn-xxx options
+ // that enable/disable them.
+ setShowActionScriptWarning(AssignmentInConditionalProblem.class,
+ ICompilerSettings.WARN_ASSIGNMENT_WITHIN_CONDITIONAL);
+ setShowActionScriptWarning(ArrayCastProblem.class,
+ ICompilerSettings.WARN_BAD_ARRAY_CAST);
+ setShowActionScriptWarning(DateCastProblem.class,
+ ICompilerSettings.WARN_BAD_DATE_CAST);
+ setShowActionScriptWarning(IllogicalComparionWithNaNProblem.class,
+ ICompilerSettings.WARN_BAD_NAN_COMPARISON);
+ setShowActionScriptWarning(NullUsedWhereOtherExpectedProblem.class,
+ ICompilerSettings.WARN_BAD_NULL_ASSIGNMENT);
+ setShowActionScriptWarning(IllogicalComparisonWithUndefinedProblem.class,
+ ICompilerSettings.WARN_BAD_UNDEFINED_COMPARISON);
+ setShowActionScriptWarning(ConstNotInitializedProblem.class,
+ ICompilerSettings.WARN_CONST_NOT_INITIALIZED);
+ setShowActionScriptWarning(DuplicateVariableDefinitionProblem.class,
+ ICompilerSettings.WARN_DUPLICATE_VARIABLE_DEF);
+ setShowActionScriptWarning(InstanceOfProblem.class,
+ ICompilerSettings.WARN_INSTANCEOF_CHANGES);
+ setShowActionScriptWarning(ScopedToDefaultNamespaceProblem.class,
+ ICompilerSettings.WARN_MISSING_NAMESPACE_DECL);
+ setShowActionScriptWarning(VariableHasNoTypeDeclarationProblem.class,
+ ICompilerSettings.WARN_NO_TYPE_DECL);
+ }
+
+ /**
+ * Hide/show actionscript warnings based on compiler option settings.
+ *
+ * @param problem
+ * @param warningCode
+ */
+ private void setShowActionScriptWarning(Class<? extends ICompilerProblem> problem,
+ int warningCode)
+ {
+ setShowProblemByClass(problem,
+ problemSettings.checkActionScriptWarning(warningCode));
+ }
+
+ /**
+ * Enable or disable deprecation warnings.
+ * @param showWarnings - if true, deprecation warnings
+ * will appear in the filtered diagnostics.
+ */
+ private void setShowDeprecationWarnings(boolean showWarnings)
+ {
+ setShowProblemByClass(AbstractDeprecatedAPIProblem.class, showWarnings);
+ setShowProblemByClass(DeprecatedConfigurationOptionProblem.class, showWarnings);
+ }
+
+ /**
+ * Enable or disable a compiler problem class.
+ *
+ * @param clazz the class to enable the problem.
+ * @param enable if true the problem is enabled and NOT filtered, otherwise
+ * the problem is filtered.
+ */
+ private void setShowProblemByClass(Class<? extends ICompilerProblem> clazz, boolean enable)
+ {
+ if (enable)
+ filter.remove(clazz);
+ else
+ filter.add(clazz);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/59f6373b/compiler/src/main/java/org/apache/flex/compiler/clients/problems/WorkspaceProblemFormatter.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/clients/problems/WorkspaceProblemFormatter.java b/compiler/src/main/java/org/apache/flex/compiler/clients/problems/WorkspaceProblemFormatter.java
new file mode 100644
index 0000000..a1a6df7
--- /dev/null
+++ b/compiler/src/main/java/org/apache/flex/compiler/clients/problems/WorkspaceProblemFormatter.java
@@ -0,0 +1,368 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.clients.problems;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.LineNumberReader;
+import java.io.Reader;
+
+import org.apache.commons.io.input.NullReader;
+
+import org.apache.flex.compiler.filespecs.IFileSpecification;
+import org.apache.flex.compiler.internal.workspaces.Workspace;
+import org.apache.flex.compiler.problems.CompilerProblemClassification;
+import org.apache.flex.compiler.problems.CompilerProblemSeverity;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+
+/**
+ * Problem formatter class that reports more detailed readable description of a
+ * problem. In addition to the problem message, this class reports the text
+ * where the problem occurred if any. This class requires a Workspace to access
+ * problem's file and the necessary line information.
+ *
+ * All the command line tools such as MXMLC, ASC should use this class for
+ * problem reporting as we would like to give as much detail as possible to
+ * the users in command line.
+ */
+public final class WorkspaceProblemFormatter extends ProblemFormatter
+{
+ private static final String NEW_LINE = System.getProperty("line.separator");
+ private static final int MAX_CACHED_LINES_PER_FILE = 10;
+
+ // The ProblemLocalizer appends these id and strings after the
+ // problem descriptions in a generated properties file.
+ private static String ERROR_FORMAT_ID = "ErrorFormat";
+ private static String WARNING_FORMAT_ID = "WarningFormat";
+ private static String SYNTAXERROR_FORMAT_ID = "SyntaxErrorFormat";
+ private static String INTERNALERROR_FORMAT_ID = "InternalErrorFormat";
+ private static String LOCATION_FORMAT_ID = "LocationFormat";
+ private static String LOCATION_FORMAT_STRING = "%s:%d";
+
+ private final Workspace workspace;
+ private final LoadingCache<String, FileLineInfo> readers;
+ private final CompilerProblemCategorizer problemCategorizer;
+
+ /**
+ * Constructor.
+ *
+ * @param workspace workspace that contains files associated with specified
+ * problems.
+ */
+ public WorkspaceProblemFormatter(final Workspace workspace)
+ {
+ this(workspace, null);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param workspace workspace that contains files associated with specified
+ * problems.
+ * @param problemCategorizer a class the categorizes problems into one of the
+ * values in {@link CompilerProblemSeverity}. Adds "Error:" and "Warning:" into
+ * the format of a problem. If null, the problem categories will not be added
+ * to the output.
+ */
+ public WorkspaceProblemFormatter(final Workspace workspace,
+ CompilerProblemCategorizer problemCategorizer)
+ {
+ super();
+
+ this.workspace = workspace;
+ this.problemCategorizer = problemCategorizer;
+
+ readers = CacheBuilder.newBuilder()
+ .concurrencyLevel(1)
+ .softValues()
+ .build(
+ new CacheLoader<String, FileLineInfo>()
+ {
+ @Override
+ public FileLineInfo load(String fileName)
+ {
+ return new FileLineInfo(fileName);
+ }
+ });
+ }
+
+ @Override
+ public String format(ICompilerProblem problem)
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ final String locationString = getLocationString(problem.getSourcePath(), problem.getLine());
+ if (!locationString.isEmpty())
+ {
+ buffer.append(locationString);
+ buffer.append(NEW_LINE);
+ }
+
+ String description = super.format(problem);
+
+ if (problemCategorizer != null)
+ {
+ // Prepend the classification on the front (ex: "Error: ")
+ description = String.format(getProblemFormat(problem), description);
+ }
+
+ assert description != null;
+ buffer.append(description);
+ buffer.append(NEW_LINE);
+
+ final String lineText = getLineText(problem);
+ if (lineText != null)
+ {
+ buffer.append(lineText);
+ buffer.append(NEW_LINE);
+ buffer.append(getLinePointer(lineText, problem.getColumn()));
+ buffer.append(NEW_LINE);
+ }
+
+ return buffer.toString();
+ }
+
+ /**
+ *
+ * @param problem the problem whose formatter we want
+ * @return an "sprints format string", like "Error: %s"
+ */
+ private String getProblemFormat(ICompilerProblem problem)
+ {
+ CompilerProblemSeverity severity = problemCategorizer.getProblemSeverity(problem);
+ CompilerProblemClassification classification = problemCategorizer.getProblemClassification(problem);
+
+ String formatString=null;
+ if (classification == CompilerProblemClassification.DEFAULT)
+ {
+ switch(severity)
+ {
+ case ERROR:
+ formatString = getErrorFormat();
+ break;
+ case WARNING:
+ formatString = getWarningFormat();
+ break;
+ default:
+ assert false;
+ formatString = getErrorFormat();
+ }
+ }
+ else
+ {
+ switch (classification)
+ {
+ case SYNTAX_ERROR:
+ formatString = getSyntaxErrorFormat();
+ break;
+ case INTERNAL_ERROR:
+ formatString = getInternalErrorFormat();
+ break;
+ default:
+ assert false;
+ }
+ }
+
+ assert formatString != null;
+ return formatString;
+ }
+
+ /**
+ * Gets the text of the line specified problem occured or
+ * <code>null</code> if there is no line information.
+ *
+ * @param problem problem to process
+ * @return the text of the line or <code>null</code> if there
+ * is no line information
+ */
+ protected String getLineText(ICompilerProblem problem)
+ {
+ String filePath = problem.getSourcePath();
+ if (filePath == null)
+ return null;
+
+ int lineNumber = problem.getLine();
+ if (lineNumber < 0)
+ return null;
+
+ FileLineInfo fileLineInfo = readers.getUnchecked(filePath);
+ return fileLineInfo.getLineText(lineNumber);
+ }
+
+
+ /*
+ * Helper method to display a caret marking a single character
+ * within the line of source text.
+ */
+ private String getLinePointer(final String lineText, int column)
+ {
+ if (lineText == null || column == -1)
+ return "";
+
+ final StringBuilder b = new StringBuilder(column);
+ final int len = lineText.length();
+ for (int i = 0; i < column; i++)
+ {
+ if (i < len && lineText.charAt(i) == '\t')
+ b.append('\t');
+ else
+ b.append(' ');
+ }
+ b.append('^');
+ return b.toString();
+ }
+
+ /*
+ * Helper method to display the file and line number.
+ * <p>
+ * Never returns null.
+ */
+ private String getLocationString(String filePath, int line)
+ {
+ if (filePath == null)
+ return "";
+
+ String location = filePath;
+ if (line != -1)
+ location = String.format(getLocationFormat(), location, (line + 1));
+ assert location != null;
+ return location;
+ }
+
+ private class FileLineInfo
+ {
+ FileLineInfo(String fileName)
+ {
+ this.fileName = fileName;
+ this.reader = createReader();
+
+ cachedLines = CacheBuilder.newBuilder()
+ .concurrencyLevel(1)
+ .softValues()
+ .maximumSize(MAX_CACHED_LINES_PER_FILE)
+ .build();
+ }
+
+ private LineNumberReader createReader()
+ {
+ IFileSpecification fileSpec = workspace.getFileSpecification(fileName);
+ Reader reader;
+ try
+ {
+ reader = fileSpec.createReader();
+ }
+ catch (FileNotFoundException e)
+ {
+ reader = new NullReader(0);
+ }
+
+ return new LineNumberReader(reader);
+ }
+
+ final String fileName;
+ LineNumberReader reader;
+ final Cache<Integer, String> cachedLines;
+
+ String getLineText(int lineNumber)
+ {
+ String result = cachedLines.getIfPresent(lineNumber);
+ if (result != null)
+ return result;
+
+
+ if (reader.getLineNumber() > lineNumber)
+ reader = createReader();
+
+ assert reader.getLineNumber() <= lineNumber;
+ try
+ {
+ while (reader.getLineNumber() < lineNumber)
+ {
+ final String lineText = reader.readLine();
+ if (lineText == null)
+ return null;
+ }
+
+ result = reader.readLine();
+ if (result == null)
+ return null;
+
+ cachedLines.put(lineNumber, result);
+ return result;
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ }
+ }
+
+ /**
+ * @return the string used to format messages categorized as errors.
+ */
+ private String getErrorFormat()
+ {
+ return getMessage(ERROR_FORMAT_ID);
+ }
+
+ /**
+ * @return the string used to format messages categorized as warnings.
+ */
+ private String getWarningFormat()
+ {
+ return getMessage(WARNING_FORMAT_ID);
+ }
+
+ /**
+ * @return the string used to format messages categorized as syntax errors.
+ */
+ private String getSyntaxErrorFormat()
+ {
+ return getMessage(SYNTAXERROR_FORMAT_ID);
+ }
+
+ /**
+ * @return the string used to format messages categorized as internal errors.
+ */
+ private String getInternalErrorFormat()
+ {
+ return getMessage(INTERNALERROR_FORMAT_ID);
+ }
+
+ /**
+ * Format of the line number the problem was found.
+ * Example) foo:7
+ * The problem was found on line 7 of foo.
+ *
+ * @return the string used to format line number of the problem in a file.
+ */
+ private String getLocationFormat()
+ {
+ String format = getMessage(LOCATION_FORMAT_ID);
+ if (format != null)
+ return format;
+
+ return LOCATION_FORMAT_STRING;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/59f6373b/compiler/src/main/java/org/apache/flex/compiler/clients/problems/package.html
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/clients/problems/package.html b/compiler/src/main/java/org/apache/flex/compiler/clients/problems/package.html
new file mode 100644
index 0000000..beccec4
--- /dev/null
+++ b/compiler/src/main/java/org/apache/flex/compiler/clients/problems/package.html
@@ -0,0 +1,27 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+<html>
+<body>
+
+This package contains classes and interfaces used by clients
+to report compiler problems.
+
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/59f6373b/compiler/src/main/java/org/apache/flex/compiler/common/ASImportTarget.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/common/ASImportTarget.java b/compiler/src/main/java/org/apache/flex/compiler/common/ASImportTarget.java
new file mode 100644
index 0000000..702d020
--- /dev/null
+++ b/compiler/src/main/java/org/apache/flex/compiler/common/ASImportTarget.java
@@ -0,0 +1,180 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.common;
+
+import org.apache.flex.compiler.definitions.INamespaceDefinition;
+import org.apache.flex.compiler.internal.definitions.NamespaceDefinition;
+import org.apache.flex.compiler.internal.workspaces.Workspace;
+import org.apache.flex.compiler.workspaces.IWorkspace;
+
+public class ASImportTarget implements IImportTarget
+{
+ private final NamespaceDefinition.ILanguageNamespaceDefinition importedPublicPackageNamespace;
+ private final String definitionName;
+
+ public static ASImportTarget get(IWorkspace w, String target)
+ {
+ String packageName = null;
+ String definitionName = null;
+ int lastDotIndex = target.lastIndexOf('.');
+ if (lastDotIndex == -1)
+ {
+ packageName = "";
+ if (!target.equals("*"))
+ {
+ definitionName = target;
+ }
+ }
+ else
+ {
+ packageName = target.substring(0, lastDotIndex);
+ String afterLastDot = target.substring(lastDotIndex + 1);
+ if (!afterLastDot.equals("*"))
+ definitionName = afterLastDot;
+ }
+ Workspace workspace = (Workspace)w;
+ NamespaceDefinition.ILanguageNamespaceDefinition packagePublicNamespace =
+ workspace.getPackageNamespaceDefinitionCache().get(packageName, false);
+ return new ASImportTarget(packagePublicNamespace, definitionName);
+ }
+
+ /**
+ * Create an ASImport from a package-style XML namespace
+ * @param xmlNamespace package-style XML namespace (e.g. mycontrols.* from xmlns:my="mycontrols.*")
+ * @return ASImport representing the imported classes (e.g. mycontrols.*)
+ */
+ public static IImportTarget buildImportFromXMLNamespace(IWorkspace w, String xmlNamespace)
+ {
+ String directory = xmlNamespace;
+ if (xmlNamespace != null && xmlNamespace.endsWith("*"))
+ {
+ directory = directory.substring(0, directory.length()-1);
+
+ // make sure the namespace id is actually a package name and not a URI
+ // like http://foo.adobe.com/2006/mxml
+ if (directory.indexOf("/") == -1 &&
+ directory.indexOf(":") == -1)
+ {
+ return get(w, xmlNamespace); //new ASImportTarget(xmlNamespace);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Create an ASImport from a package name (as it appears in a package definition)
+ * @param packageName package name (e.g. mx.controls)
+ * @return ASImport representing the imported classes (e.g. mx.controls.*)
+ */
+ public static IImportTarget buildImportFromPackageName(IWorkspace w, String packageName)
+ {
+ if (packageName == null || (packageName.length() == 1 && packageName.charAt(0) == '*') || packageName.length() == 0)
+ packageName = "";
+ Workspace workspace = (Workspace)w;
+ NamespaceDefinition.ILanguageNamespaceDefinition packagePublicNamespace =
+ workspace.getPackageNamespaceDefinitionCache().get(packageName, false);
+ return new ASImportTarget(packagePublicNamespace, null);
+ }
+
+ /**
+ * Constructor
+ * @param target import target (e.g. mx.controls.* or mx.controls.Button)
+ */
+ private ASImportTarget(NamespaceDefinition.ILanguageNamespaceDefinition namespace, String definitionName)
+ {
+ this.importedPublicPackageNamespace = namespace;
+ this.definitionName = definitionName;
+ }
+
+ @Override
+ public String getTargetPackage()
+ {
+ return importedPublicPackageNamespace.getURI();
+ }
+
+ @Override
+ public boolean isWildcard()
+ {
+ return definitionName == null;
+ }
+
+ @Override
+ public String getTargetName() {
+ return definitionName == null ? "" : definitionName;
+ }
+
+ @Override
+ public String getQualifiedName(String reference)
+ {
+ int lastIndexOfDotInReferece = reference.lastIndexOf('.');
+ // If we're referring to a short name (e.g. Button)...
+ if (lastIndexOfDotInReferece == -1)
+ {
+ if ((definitionName == null) || (reference.equals(definitionName))) // importing a whole package (e.g. mx.controls.*)
+ {
+ StringBuilder builder = new StringBuilder();
+ String uri = importedPublicPackageNamespace.getURI();
+ if (uri != null && uri.length() > 0) {
+ builder.append(uri);
+ builder.append('.');
+ }
+ builder.append(reference);
+ return builder.toString();
+ }
+ return null; // no match! (e.g. mx.controls.Button and RadioButton)
+
+ }
+ String packageNameInReference = reference.substring(0, lastIndexOfDotInReferece);
+ if (!packageNameInReference.equals(importedPublicPackageNamespace.getURI()))
+ return null; // package names don't match ( e.g. mx.core and mx.controls.Button
+
+ if (definitionName == null) // importing a whole package (e.g. mx.controls.*)
+ return reference;
+
+ String definitionNameInReference = reference.substring(lastIndexOfDotInReferece + 1);
+ if (definitionNameInReference.equals(definitionName)) // exact match! (e.g. mx.controls.Button and mx.controls.Button)
+ return reference;
+ // no match! (e.g. mx.controls.Button and mx.controls.RadioButton)
+ return null;
+
+ }
+
+ /**
+ * Get the import target as a string (as it would appear after the keyword "import").
+ * @return the string representation of the import target
+ */
+ @Override
+ public String toString()
+ {
+ String packageName = importedPublicPackageNamespace.getURI();
+ int definitionNameLen = definitionName == null ? 2 : definitionName.length();
+ StringBuilder builder = new StringBuilder(packageName.length() + definitionNameLen);
+ builder.append(packageName);
+ builder.append('.');
+ builder.append(definitionName == null ? "*" : definitionName);
+ return builder.toString();
+ }
+
+ @Override
+ public INamespaceDefinition getNamespace()
+ {
+ return this.importedPublicPackageNamespace;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/59f6373b/compiler/src/main/java/org/apache/flex/compiler/common/ASModifier.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/common/ASModifier.java b/compiler/src/main/java/org/apache/flex/compiler/common/ASModifier.java
new file mode 100644
index 0000000..df7edab
--- /dev/null
+++ b/compiler/src/main/java/org/apache/flex/compiler/common/ASModifier.java
@@ -0,0 +1,115 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.common;
+
+import java.util.HashMap;
+
+import org.apache.flex.compiler.constants.IASKeywordConstants;
+
+/**
+ * Modifiers found within the AS3 language.
+ * TODO: Make this class an enum.
+ */
+public class ASModifier
+{
+ private static HashMap<String, ASModifier> LOOKUP = new HashMap<String, ASModifier>(6);
+
+ /**
+ * Represents the <code>dynamic</code> modifier.
+ */
+ public static final ASModifier DYNAMIC = new ASModifier(IASKeywordConstants.DYNAMIC, 1 << 1);
+
+ /**
+ * Represents the <code>final</code> modifier.
+ */
+ public static final ASModifier FINAL = new ASModifier(IASKeywordConstants.FINAL, 1 << 2);
+
+ /**
+ * Represents the <code>native</code> modifier.
+ */
+ public static final ASModifier NATIVE = new ASModifier(IASKeywordConstants.NATIVE, 1 << 3);
+
+ /**
+ * Represents the <code>override</code> modifier.
+ */
+ public static final ASModifier OVERRIDE = new ASModifier(IASKeywordConstants.OVERRIDE, 1 << 4);
+
+ /**
+ * Represents the <code>static</code> modifier.
+ */
+ public static final ASModifier STATIC = new ASModifier(IASKeywordConstants.STATIC, 1 << 5);
+
+ /**
+ * Represents the <code>virtual</code> modifier.
+ */
+ public static final ASModifier VIRTUAL = new ASModifier(IASKeywordConstants.VIRTUAL, 1 << 6);
+
+ /**
+ * A list of all the modifiers that exist within AS3
+ */
+ public static final ASModifier[] MODIFIERS = new ASModifier[]
+ {
+ DYNAMIC,
+ FINAL,
+ NATIVE,
+ OVERRIDE,
+ STATIC,
+ VIRTUAL
+ };
+
+ /**
+ * Returns the {@link ASModifier} for the given string literal
+ * @param text a literal representing a modifier
+ * @return an {@link ASModifier} or null
+ */
+ public static ASModifier getASModifier(String text)
+ {
+ return LOOKUP.get(text);
+ }
+
+ /**
+ * Private constructor.
+ *
+ * @param text The text of the modifier.
+ * @param type An integer identifying the modifier
+ * that can be used as a bitmask value.
+ */
+ private ASModifier(String text, int maskValue)
+ {
+ this.text = text;
+ this.maskValue = maskValue;
+ LOOKUP.put(text, this);
+ }
+
+ private String text;
+
+ private int maskValue;
+
+ @Override
+ public String toString()
+ {
+ return text;
+ }
+
+ public int getMaskValue()
+ {
+ return maskValue;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/59f6373b/compiler/src/main/java/org/apache/flex/compiler/common/DependencyType.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/common/DependencyType.java b/compiler/src/main/java/org/apache/flex/compiler/common/DependencyType.java
new file mode 100644
index 0000000..0daf0fa
--- /dev/null
+++ b/compiler/src/main/java/org/apache/flex/compiler/common/DependencyType.java
@@ -0,0 +1,163 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.common;
+
+import org.apache.flex.compiler.internal.projects.DependencyGraph;
+
+
+/**
+ * An enumeration representing the four types of dependencies that an
+ * edge in a {@link DependencyGraph} can have.
+ */
+public enum DependencyType
+{
+ /**
+ * An <code>INHERITANCE</code> dependency is created by a reference
+ * to a class or interface in the <code>extends</code> clause or the
+ * <code>implements</code> clause of a class or interface declaration.
+ * <p>
+ * Examples:
+ * <ul>
+ * <li><code>class C2 extends <u>C1</u> implements <u>I1</u>, <u>I2</u></code>
+ * <li><code>interface I1 extends <u>I2</u>, <u>I3</u></code>
+ * </ul>
+ */
+ INHERITANCE('i'),
+
+ /**
+ * A <code>SIGNATURE</code> dependency is created by a type annotation
+ * that is not inside of a function body.
+ * <p>
+ * Examples:
+ * <ul>
+ * <li><code>public var i:<u>int</u></code>
+ * <li><code>private function f(i:<u>int</u>):<u>String</u></code>
+ * </ul>
+ */
+ SIGNATURE('s'),
+
+ /**
+ * A <code>NAMESPACE</code> dependency is created by a reference to a
+ * user-defined namespace.
+ * <p>
+ * Examples:
+ * <ul>
+ * <li><code><u>ns</u> var foo:int</code>
+ * <li><code><u>ns</u>::foo</code>
+ * <li><code>use namespace <u>ns</u></code>
+ * </ul>
+ */
+ NAMESPACE('n'),
+
+ /**
+ * An <code>EXPRESSION</code> dependency is any dependency that isn't
+ * one of the other three types.
+ */
+ EXPRESSION('e');
+
+ /**
+ * Private constructor.
+ *
+ * @param symbol The character representing the dependency type in XML
+ * format (such as the <code><dep></code> tag in a SWC catalog).
+ */
+ private DependencyType(char symbol)
+ {
+ this.symbol = symbol;
+ }
+
+ /**
+ * The character representing the dependency type in XML
+ * format (such as the <code><dep></code> tag in a SWC catalog).
+ */
+ private final char symbol;
+
+ /**
+ * Gets the character representing the dependency type in XML
+ * format (such as the <code><dep></code> tag in a SWC catalog).
+ *
+ * @return symbol The character.
+ */
+ public char getSymbol()
+ {
+ return symbol;
+ }
+
+ /**
+ * A helper function to check if this {@link DependencyType}
+ * is contained in an {@link DependencyTypeSet}.
+ *
+ * @param dependencies A {@link DependencyTypeSet} to look in.
+ * @return <code>true</code> if this {@link DependencyType}
+ * is contained in the specified {@link DependencyTypeSet}.
+ */
+ public boolean existsIn(DependencyTypeSet dependencies)
+ {
+ return dependencies.contains(this);
+ }
+
+ /**
+ * Gets the enum object from its symbol.
+ *
+ * @param symbol The character representing the dependency type in XML
+ * format (such as the <code><dep></code> tag in a SWC catalog),
+ * such as <code>'i'</code>.
+ * @return The enum object with the specified symbol,
+ * such as <code>INHERITANCE</code>.
+ */
+ public static DependencyType get(char symbol)
+ {
+ switch (symbol)
+ {
+ case 'i':
+ return INHERITANCE;
+ case 'n':
+ return NAMESPACE;
+ case 's':
+ return SIGNATURE;
+ case 'e':
+ return EXPRESSION;
+ default:
+ throw new IllegalArgumentException("Invalid symbol: " + symbol);
+ }
+ }
+
+ /**
+ * Gets a short string of symbols for the dependency types
+ * in a dependency type set.
+ *
+ * @param types A {@link DependencyTypeSet}.
+ * @return A short string of symbols of the types in the {@link DependencyTypeSet}
+ * in INHERITANCE, NAMESPACE, SIGNATURE, EXPRESSION order.
+ */
+ public static String getTypeString(DependencyTypeSet types)
+ {
+ StringBuilder sb = new StringBuilder();
+ if (INHERITANCE.existsIn(types))
+ sb.append('i');
+ if (NAMESPACE.existsIn(types))
+ sb.append('n');
+ if (SIGNATURE.existsIn(types))
+ sb.append('s');
+ if (EXPRESSION.existsIn(types))
+ sb.append('e');
+ return sb.toString();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/59f6373b/compiler/src/main/java/org/apache/flex/compiler/common/DependencyTypeSet.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/common/DependencyTypeSet.java b/compiler/src/main/java/org/apache/flex/compiler/common/DependencyTypeSet.java
new file mode 100644
index 0000000..e0d1c69
--- /dev/null
+++ b/compiler/src/main/java/org/apache/flex/compiler/common/DependencyTypeSet.java
@@ -0,0 +1,261 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.common;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+
+/**
+ * Stores the set of dependency types for an edge in the dependency graph.
+ * <p>
+ * The APIs of this class are similar to that of <code>EnumSet<DependencyType></code>.
+ * Instead of using an <code>EnumSet</code>, we use this smaller
+ * class which stores the dependencies as bitflags in a <code>int</code> field.
+ * <p>
+ * This class was originally designed to handle the fact that we shouldn't need
+ * to keep track of each type of dependency on each edge: if an edge has a more
+ * important dependency type we should be able to ignore the fact that it also has
+ * a less important dependency type. The idea was that this would reduce the size
+ * of the SWC catalog.
+ * <p>
+ * The <code>add()</code> was originally a bottleneck which added a dependency type
+ * to the set, and then cleaned up the set by removing lesser dependency types that
+ * are trumped by greater ones. (<code>SIGNATURE</code> trumped <code>EXPRESSION</code>;
+ * <code>INHERITANCE</code> trumped all others.) But this meant that APIs like
+ * <code>allOf()</code> didn't actually create a set that contained all the types,
+ * Although everything seemed to work, it seemed too dangerous given the way that
+ * sets are used for filtering of edges.
+ * <p>Therefore that "trumping" logic has moved to the SWC catalog writer and this
+ * class is merely a optimization.
+ */
+public final class DependencyTypeSet implements Iterable<DependencyType>
+{
+ private static DependencyType[] DEPENDENCY_TYPES = DependencyType.values();
+
+ /**
+ * Constructs a new empty set.
+ *
+ * @return The new {@link DependencyTypeSet}.
+ */
+ public static DependencyTypeSet noneOf()
+ {
+ return new DependencyTypeSet();
+ }
+
+ /**
+ * Constructs a new set with each type of dependency.
+ *
+ * @return The new {@link DependencyTypeSet}.
+ */
+ public static DependencyTypeSet allOf()
+ {
+ DependencyTypeSet typeSet = new DependencyTypeSet();
+ for (DependencyType type : DEPENDENCY_TYPES)
+ {
+ typeSet.add(type);
+ }
+ return typeSet;
+ }
+
+ /**
+ * Constructs a new set with the specified dependency types in it.
+ *
+ * @param types Zero or more parameters, each of which is a {@link DependencyType}.
+ * @return The new {@link DependencyTypeSet}.
+ */
+ public static DependencyTypeSet of(DependencyType ... types)
+ {
+ DependencyTypeSet typeSet = new DependencyTypeSet();
+ for (DependencyType type : types)
+ {
+ typeSet.add(type);
+ }
+ return typeSet;
+ }
+
+ /**
+ * Constructs a new set with the specified collection of dependency
+ * types in it.
+ *
+ * @param dependencyTypeCollection A collection of {@link DependencyType}s.
+ * @return The new {@link DependencyTypeSet}.
+ */
+ public static DependencyTypeSet copyOf(Collection<DependencyType> dependencyTypeCollection)
+ {
+ DependencyTypeSet typeSet = new DependencyTypeSet();
+ for (DependencyType type : dependencyTypeCollection)
+ {
+ typeSet.add(type);
+ }
+ return typeSet;
+ }
+
+ /**
+ * Constructs a copy of another {@link DependencyTypeSet}.
+ *
+ * @param otherTypeSet The {@link DependencyTypeSet} to copy.
+ * @return The new {@link DependencyTypeSet}.
+ */
+ public static DependencyTypeSet copyOf(DependencyTypeSet otherTypeSet)
+ {
+ DependencyTypeSet typeSet = new DependencyTypeSet();
+ typeSet.flags = otherTypeSet.flags;
+ return typeSet;
+ }
+
+ /**
+ * Private constructor.
+ * <p>
+ * Use one of the static method to construct an instance.
+ */
+ private DependencyTypeSet()
+ {
+ }
+
+ // The lowest four bits of this field are flags for INHERITANCE (0),
+ // SIGNATURE (1), NAMESPACE (2), and EXPRESSION (4).
+ // The bit position is the ordinal of the enum.
+ private int flags;
+
+ @Override
+ public Iterator<DependencyType> iterator()
+ {
+ return new Iterator<DependencyType>()
+ {
+ // Bit position of the DependencyType flag that next()
+ // last returned.
+ private int i = -1;
+
+ @Override
+ public boolean hasNext()
+ {
+ // Increment i until it points at a bit which is set
+ // or until we're past all the flag bits.
+ int bit = getNextBit(i + 1);
+ return bit < DEPENDENCY_TYPES.length;
+ }
+
+ @Override
+ public DependencyType next()
+ {
+ i = getNextBit(i + 1);
+ if (i < DEPENDENCY_TYPES.length)
+ return DEPENDENCY_TYPES[i];
+
+ throw new NoSuchElementException();
+ }
+
+ private int getNextBit(int startingBit)
+ {
+ int nextBit = startingBit;
+ while (nextBit < DEPENDENCY_TYPES.length)
+ {
+ int mask = 1 << nextBit;
+ if ((flags & mask) != 0)
+ break;
+ nextBit++;
+ }
+
+ return nextBit;
+ }
+
+ @Override
+ public void remove()
+ {
+ assert false: "This should never get called";
+ }
+ };
+ }
+
+ /**
+ * Determines if the set is empty.
+ *
+ * @return <code>true</code> if the set is empty.
+ */
+ public boolean isEmpty()
+ {
+ return flags == 0;
+ }
+
+ /**
+ * Adds a dependency type to the set.
+
+ * @param dependencyType The {@link DependencyType} to be
+ * added to the set.
+ */
+ public void add(DependencyType dependencyType)
+ {
+ int mask = 1 << dependencyType.ordinal();
+ flags |= mask;
+ }
+
+ /**
+ * Adds the dependencies in another set to this set.
+ *
+ * @param otherSet The other {@link DependencyTypeSet}.
+ */
+ public void addAll(DependencyTypeSet otherSet)
+ {
+ for (DependencyType type : otherSet)
+ {
+ add(type);
+ }
+ }
+
+ /**
+ * Determines whether this set contains the specified
+ * dependency type.
+
+ * @param dependencyType A {@link DependencyType}.
+ * @return <code>true</code> if this set contains
+ * that dependency type.
+ */
+ public boolean contains(DependencyType dependencyType)
+ {
+ int mask = 1 << dependencyType.ordinal();
+ return (flags & mask) != 0;
+ }
+
+ /**
+ * For debugging only.
+ * <p>
+ * @return A String like <code>"[ NAMESPACE EXPRESSION ]"</code>
+ * representing the dependency types in this set.
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append('[');
+ sb.append(' ');
+ for (DependencyType type : DependencyType.values())
+ {
+ if (contains(type))
+ {
+ sb.append(type.name());
+ sb.append(' ');
+ }
+ }
+ sb.append(']');
+ return sb.toString();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/59f6373b/compiler/src/main/java/org/apache/flex/compiler/common/IDecoration.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/common/IDecoration.java b/compiler/src/main/java/org/apache/flex/compiler/common/IDecoration.java
new file mode 100644
index 0000000..be60dba
--- /dev/null
+++ b/compiler/src/main/java/org/apache/flex/compiler/common/IDecoration.java
@@ -0,0 +1,41 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.common;
+
+import org.apache.flex.compiler.tree.as.IDefinitionNode;
+
+
+
+/**
+ * A {@link IDecoration} is a type of parse tree element that decorates an {@link IDefinitionNode}. An {@link IDecoration} is not a child of
+ * an {@link IDefinitionNode} node, rather it helps change the signature of the {@link IDefinitionNode}
+ * These include:
+ * -modifiers
+ * -namespaces
+ * -metadata
+ */
+public interface IDecoration
+{
+ /**
+ * Returns the parent that is being decorated by this {@link IDecoration}
+ * @return the {@link IDefinitionNode} representing the parent
+ */
+ IDefinitionNode getDecoratedDefinitionNode();
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/59f6373b/compiler/src/main/java/org/apache/flex/compiler/common/IDefinitionPriority.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/common/IDefinitionPriority.java b/compiler/src/main/java/org/apache/flex/compiler/common/IDefinitionPriority.java
new file mode 100644
index 0000000..8554a39
--- /dev/null
+++ b/compiler/src/main/java/org/apache/flex/compiler/common/IDefinitionPriority.java
@@ -0,0 +1,29 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.common;
+
+/**
+ * The "priority" of a definition determines whether that definition shadows definitions from other
+ * compilation units that have the same qname.
+ */
+public interface IDefinitionPriority extends Comparable<IDefinitionPriority>
+{
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/59f6373b/compiler/src/main/java/org/apache/flex/compiler/common/IEmbedResolver.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/common/IEmbedResolver.java b/compiler/src/main/java/org/apache/flex/compiler/common/IEmbedResolver.java
new file mode 100644
index 0000000..9b30dff
--- /dev/null
+++ b/compiler/src/main/java/org/apache/flex/compiler/common/IEmbedResolver.java
@@ -0,0 +1,49 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.common;
+
+import java.util.Collection;
+
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.ICompilerProject;
+import org.apache.flex.compiler.units.ICompilationUnit;
+
+/**
+ * Any Node related to embedding (EmbedNode, MXMLEmbedNode) needs to implement
+ * this interface so as to be able resolve the compilation unit related to that
+ * embedded asset.
+ */
+public interface IEmbedResolver
+{
+ /**
+ * Resolve the ICompilationUnit which is related to the node which
+ * implements this interface
+ * @param project Current project
+ * @param problems Any problems resolving the compilation unit
+ * @return An ICompilationUnit for the embedded asset, or null if error
+ * @throws InterruptedException
+ */
+ ICompilationUnit resolveCompilationUnit(ICompilerProject project, Collection<ICompilerProblem> problems) throws InterruptedException;
+
+ /**
+ * A variant of <code>resolveCompilationUnit()</code> that ignores problems.
+ */
+ ICompilationUnit resolveCompilationUnit(ICompilerProject project) throws InterruptedException;
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/59f6373b/compiler/src/main/java/org/apache/flex/compiler/common/IFileSpecificationGetter.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/common/IFileSpecificationGetter.java b/compiler/src/main/java/org/apache/flex/compiler/common/IFileSpecificationGetter.java
new file mode 100644
index 0000000..eea5e44
--- /dev/null
+++ b/compiler/src/main/java/org/apache/flex/compiler/common/IFileSpecificationGetter.java
@@ -0,0 +1,52 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.common;
+
+import org.apache.flex.compiler.filespecs.FileSpecification;
+import org.apache.flex.compiler.filespecs.IFileSpecification;
+import org.apache.flex.compiler.workspaces.IWorkspace;
+
+/**
+ * Interface that abstracts the acquisition of {@link IFileSpecification}'s which
+ * are used to open files by the compiler.
+ */
+public interface IFileSpecificationGetter
+{
+ /**
+ * Returns the most recent {@link IFileSpecification} given to the
+ * implementation for a specified path. If the implementation has not seen
+ * the specified path before, a new {@link FileSpecification} is returned.
+ *
+ * @param fileName Normalized absolute file name for which a
+ * {@link IFileSpecification} should be returned.
+ * @return The most recent {@link IFileSpecification} given to the
+ * implementation for a specified file name.
+ */
+ IFileSpecification getFileSpecification(String fileName);
+
+ /**
+ * Returns the {@link IWorkspace} associated with the implementation, must
+ * never be null.
+ *
+ * @return the {@link IWorkspace} associated with the implementation, must
+ * never be null.
+ */
+ IWorkspace getWorkspace();
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/59f6373b/compiler/src/main/java/org/apache/flex/compiler/common/IImportTarget.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/common/IImportTarget.java b/compiler/src/main/java/org/apache/flex/compiler/common/IImportTarget.java
new file mode 100644
index 0000000..54c5798
--- /dev/null
+++ b/compiler/src/main/java/org/apache/flex/compiler/common/IImportTarget.java
@@ -0,0 +1,78 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.common;
+
+import org.apache.flex.compiler.definitions.INamespaceDefinition;
+
+/**
+ * Represents the target of an import statement (e.g. import mx.controls.Button or import mx.controls.*)
+ * and encapsulates the logic involved in combining a reference (Button or mx.controls.Button) with
+ * the import target to get a fully qualified name. You can create import targets from the import
+ * target string (with the constructor), from a package name, or from an XML namespace.
+ */
+public interface IImportTarget {
+
+ /**
+ * Interpret the reference based on this import target, and try to build a qualified
+ * class name for it. If no logical path can be constructed from the two (because the
+ * reference contains package information that doesn't match the import target, or
+ * because the reference class doesn't match the import target class), this method
+ * returns null. The one exception to this rule (for convenience) is the import target
+ * "*", which will always return the reference itself
+ * Examples (import target + reference):
+ * mx.controls.* + Button => mx.controls.Button
+ * mx.core.* + Button => mx.core.Button
+ * mx.controls.Button + Button => mx.controls.Button
+ * mx.controls.RadioButton + Button => (null)
+ * * + Button => Button
+ * mx.controls.* + mx.controls.Button => mx.controls.Button
+ * mx.core.* + mx.controls.Button => (null)
+ * mx.controls.Button + mx.controls.Button => mx.controls.Button
+ * mx.controls.RadioButton + mx.controls.Button => (null)
+ * * + mx.controls.Button => mx.controls.Button
+ * @param reference the reference as it appears in the document
+ * @return a qualified name for the reference if it makes sense; null if it doesn't
+ */
+ String getQualifiedName(String reference);
+
+ /**
+ * Returns the name of the target package we are targeting
+ * @return the target package
+ */
+ String getTargetPackage();
+
+ /**
+ * True if this import is a wild card
+ * @return true if we are a wild card
+ */
+ boolean isWildcard();
+
+ /**
+ * Gets the name of the target in our import. In flash.events.EventDispatcher, it would be EventDispatcher
+ * @return the target name.
+ */
+ String getTargetName();
+
+ /**
+ * Gets the {@link INamespaceDefinition} for the imported package's public namespace.
+ * @return The {@link INamespaceDefinition} for the imported package's public namespace.
+ */
+ INamespaceDefinition getNamespace();
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/59f6373b/compiler/src/main/java/org/apache/flex/compiler/common/IMetaInfo.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/common/IMetaInfo.java b/compiler/src/main/java/org/apache/flex/compiler/common/IMetaInfo.java
new file mode 100644
index 0000000..6f2cf1f
--- /dev/null
+++ b/compiler/src/main/java/org/apache/flex/compiler/common/IMetaInfo.java
@@ -0,0 +1,56 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.common;
+
+import org.apache.flex.compiler.definitions.metadata.IMetaTagAttribute;
+import org.apache.flex.compiler.tree.metadata.IMetaTagNode;
+
+/**
+ * This interface represents the information content of one metadata annotation
+ * and is shared by {@link IMetaTagNode} and {@link org.apache.flex.compiler.definitions.metadata.IMetaTag}.
+ */
+public interface IMetaInfo
+{
+ /**
+ * Gets the name of this metadata annotation (like Event or IconFile)
+ * @return meta attribute name
+ */
+ String getTagName();
+
+ /**
+ * Returns an in-order list of all of the attributes contained within this {@link IMetaInfo}
+ * @return an array of {@link IMetaTagAttribute} objects or an empty array, never null.
+ */
+ IMetaTagAttribute[] getAllAttributes();
+
+ /**
+ * Gets the {@link IMetaTagAttribute} found on the tag for the given key
+ * @param key the attribute key we are looking for, or IMetaTagNode.SINGLE_VALUE if the attribute does not have a key
+ * @return the {@link IMetaTagAttribute}, or null
+ */
+ IMetaTagAttribute getAttribute(String key);
+
+ /**
+ * Gets the value of the given attribute found on the tag
+ * @param key the attribute key we are looking for, or IMetaTagNode.SINGLE_VALUE if the attribute does not have a key.
+ * @return the value of said attribute, or null
+ */
+ String getAttributeValue(String key);
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/59f6373b/compiler/src/main/java/org/apache/flex/compiler/common/IPathResolver.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/common/IPathResolver.java b/compiler/src/main/java/org/apache/flex/compiler/common/IPathResolver.java
new file mode 100644
index 0000000..4efeb7a
--- /dev/null
+++ b/compiler/src/main/java/org/apache/flex/compiler/common/IPathResolver.java
@@ -0,0 +1,41 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.common;
+
+import java.io.File;
+
+/**
+ * Interface for resolving path names to files.
+ */
+public interface IPathResolver
+{
+ /**
+ * Resolve a path to a file. The path may be absolute or my need to be
+ * resolved either relative to the resolver's root directory. The instance
+ * of the resolver determines what the root directory is. The path in the
+ * returned file has been normalized by calling
+ * FilenameNormalization.normalize() or some equivalent.
+ *
+ * @param path the path to resolve.
+ * @return a {@link File} of the resolved, and normalized path. The file
+ * is not guaranteed to exist.
+ */
+ File resolve(String path);
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/59f6373b/compiler/src/main/java/org/apache/flex/compiler/common/ISourceLocation.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/common/ISourceLocation.java b/compiler/src/main/java/org/apache/flex/compiler/common/ISourceLocation.java
new file mode 100644
index 0000000..738bdf3
--- /dev/null
+++ b/compiler/src/main/java/org/apache/flex/compiler/common/ISourceLocation.java
@@ -0,0 +1,75 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.common;
+
+/**
+ * This interface provides information about where something
+ * (a token, a tag, an attribute, a node, a definition, etc.)
+ * appears in source code.
+ * <p>
+ * Its primary purpose is for problem reporting.
+ * The start and end offsets are used to highlight
+ * a soruce range in the Flash Builder editor.
+ * The line and column numbers are used by command-line
+ * tools to report problems.
+ */
+public interface ISourceLocation
+{
+ /**
+ * Indicates an unknown or implicit starting offset, ending offset,
+ * line number, or column number.
+ */
+ static final int UNKNOWN = -1;
+
+ /**
+ * Gets the normalized source path.
+ */
+ String getSourcePath();
+
+ /**
+ * Gets the local starting offset. It is zero-based.
+ */
+ int getStart();
+
+ /**
+ * Gets the local ending offset. It is zero-based.
+ */
+ int getEnd();
+
+ /**
+ * Gets the local line number. It is zero-based.
+ */
+ int getLine();
+
+ /**
+ * Gets the local column number. It is zero-based.
+ */
+ int getColumn();
+
+ /**
+ * Gets the absolute starting offset. It is zero-based.
+ */
+ int getAbsoluteStart();
+
+ /**
+ * Gets the absolute starting offset. It is zero-based.
+ */
+ int getAbsoluteEnd();
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/59f6373b/compiler/src/main/java/org/apache/flex/compiler/common/LibraryPathUtils.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/common/LibraryPathUtils.java b/compiler/src/main/java/org/apache/flex/compiler/common/LibraryPathUtils.java
new file mode 100644
index 0000000..ac5e327
--- /dev/null
+++ b/compiler/src/main/java/org/apache/flex/compiler/common/LibraryPathUtils.java
@@ -0,0 +1,50 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.common;
+
+import java.io.File;
+
+import org.apache.flex.compiler.internal.projects.LibraryPathManager;
+
+/**
+ * Some stray library filename utils.
+ */
+public class LibraryPathUtils
+{
+ public static boolean isSWCFile(File file)
+ {
+ return LibraryPathManager.isSWCFile(file);
+ }
+
+ public static String getAttachedSourceFilename(String sourceDirectory, String qualifiedName)
+ {
+ return LibraryPathManager.getAttachedSourceFilename(sourceDirectory, qualifiedName);
+ }
+
+ public static String getDotSWCExt()
+ {
+ return LibraryPathManager.DOT_SWC_EXT;
+ }
+
+ public static String getSWCExt()
+ {
+ return LibraryPathManager.SWC_EXT;
+ }
+}