You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2015/06/05 21:02:33 UTC
[1/2] git commit: [flex-falcon] [refs/heads/develop] - remove a rule
that appears to remove extra spaces that seemed to confuse the lexer and loop
forever at the end of the comment
Repository: flex-falcon
Updated Branches:
refs/heads/develop 94b22a971 -> e96f9f228
remove a rule that appears to remove extra spaces that seemed to confuse the lexer and loop forever at the end of the comment
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/c0058b90
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/c0058b90
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/c0058b90
Branch: refs/heads/develop
Commit: c0058b906f310d17d645f989ff4e613ddabc5f7a
Parents: 94b22a9
Author: Alex Harui <ah...@apache.org>
Authored: Fri Jun 5 11:59:40 2015 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Jun 5 11:59:40 2015 -0700
----------------------------------------------------------------------
.../flex/compiler/internal/parsing/as/RawASDocTokenizer.lex | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c0058b90/compiler/src/org/apache/flex/compiler/internal/parsing/as/RawASDocTokenizer.lex
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/parsing/as/RawASDocTokenizer.lex b/compiler/src/org/apache/flex/compiler/internal/parsing/as/RawASDocTokenizer.lex
index 03b7a8f..2880dd4 100644
--- a/compiler/src/org/apache/flex/compiler/internal/parsing/as/RawASDocTokenizer.lex
+++ b/compiler/src/org/apache/flex/compiler/internal/parsing/as/RawASDocTokenizer.lex
@@ -141,11 +141,6 @@ NS_WHITE_SPACE_CHAR=[\r\n\t\b\012]
startOrContinueAggregate();
}
-<YYINITIAL> " "*
-{
- startOrContinueAggregate(" ");
-}
-
<YYINITIAL> "<!---"
{
if (!fromMXML)
@@ -161,7 +156,7 @@ NS_WHITE_SPACE_CHAR=[\r\n\t\b\012]
{
}
-<YYINITIAL> "*"
+<YYINITIAL> "* "
{
}
[2/2] git commit: [flex-falcon] [refs/heads/develop] - add the
beginnings of ASDoc generator. It doesn't generate anything right now but in
theory you could replace the System.out.println with whatever output you want
Posted by ah...@apache.org.
add the beginnings of ASDoc generator. It doesn't generate anything right now but in theory you could replace the System.out.println with whatever output you want
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/e96f9f22
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/e96f9f22
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/e96f9f22
Branch: refs/heads/develop
Commit: e96f9f228f3574a5faeb23fa3001d0c36ff58b7a
Parents: c0058b9
Author: Alex Harui <ah...@apache.org>
Authored: Fri Jun 5 12:00:30 2015 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Jun 5 12:00:30 2015 -0700
----------------------------------------------------------------------
.../flex/compiler/asdoc/ASDocComment.java | 81 +++++++
.../org/apache/flex/compiler/clients/ASDOC.java | 242 +++++++++++++++++++
.../parsing/as/SimpleASDocDelegate.java | 143 +++++++++++
3 files changed, 466 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e96f9f22/compiler/src/org/apache/flex/compiler/asdoc/ASDocComment.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/asdoc/ASDocComment.java b/compiler/src/org/apache/flex/compiler/asdoc/ASDocComment.java
new file mode 100644
index 0000000..a18a721
--- /dev/null
+++ b/compiler/src/org/apache/flex/compiler/asdoc/ASDocComment.java
@@ -0,0 +1,81 @@
+/*
+ *
+ * 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.asdoc;
+
+import java.io.StringReader;
+
+import org.apache.flex.compiler.asdoc.IASDocComment;
+import org.apache.flex.compiler.internal.parsing.as.ASDocToken;
+import org.apache.flex.compiler.internal.parsing.as.ASDocTokenizer;
+import org.apache.flex.compiler.internal.parsing.as.ASTokenTypes;
+
+import antlr.Token;
+
+public class ASDocComment implements IASDocComment
+{
+
+ public ASDocComment(Token t)
+ {
+ token = t;
+ String data = token.getText();
+ ASDocTokenizer tokenizer = new ASDocTokenizer(false);
+ tokenizer.setReader(new StringReader(data));
+ ASDocToken tok = tokenizer.next();
+ boolean foundDescription = false;
+
+ try
+ {
+ while (tok != null)
+ {
+ if (!foundDescription
+ && tok.getType() == ASTokenTypes.TOKEN_ASDOC_TEXT)
+ {
+ System.out.println("ASDOC Text: " + tok.getText() );
+ foundDescription = true;
+ }
+ else
+ {
+ // do tags
+ if (tok.getType() == ASTokenTypes.TOKEN_ASDOC_TAG)
+ {
+ System.out.println("ASDOC Tag: " + tok.getText() );
+ }
+ else if (tok.getType() == ASTokenTypes.TOKEN_ASDOC_TEXT)
+ {
+ System.out.println("ASDOC Description: " + tok.getText() );
+ }
+ }
+
+ tok = tokenizer.next();
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ Token token;
+
+ public Token getToken()
+ {
+ return token;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e96f9f22/compiler/src/org/apache/flex/compiler/clients/ASDOC.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/clients/ASDOC.java b/compiler/src/org/apache/flex/compiler/clients/ASDOC.java
new file mode 100644
index 0000000..dadfbf7
--- /dev/null
+++ b/compiler/src/org/apache/flex/compiler/clients/ASDOC.java
@@ -0,0 +1,242 @@
+/*
+ *
+ * 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;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.flex.compiler.Messages;
+import org.apache.flex.compiler.common.VersionInfo;
+import org.apache.flex.compiler.config.Configurator;
+import org.apache.flex.compiler.config.ICompilerSettingsConstants;
+import org.apache.flex.compiler.exceptions.ConfigurationException;
+import org.apache.flex.compiler.internal.config.COMPCConfiguration;
+import org.apache.flex.compiler.internal.parsing.as.SimpleASDocDelegate;
+import org.apache.flex.compiler.internal.targets.SWFTarget;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.problems.MissingRequirementConfigurationProblem;
+import org.apache.flex.compiler.targets.ISWCTarget;
+import org.apache.flex.compiler.targets.ITargetSettings;
+import org.apache.flex.compiler.targets.ITarget.TargetType;
+import org.apache.flex.swc.ISWC;
+import org.apache.flex.swc.io.ISWCWriter;
+import org.apache.flex.swc.io.SWCDirectoryWriter;
+import org.apache.flex.swc.io.SWCWriter;
+import org.apache.flex.swf.io.SizeReportWritingSWFWriter;
+import org.apache.flex.tools.FlexTool;
+import org.apache.flex.utils.FilenameNormalization;
+
+/**
+ * Documentation compiler entry point.
+ * <p>
+ * This class is a quick start of component compiler. It depends on most of the
+ * functionalities developed for mxmlc.
+ */
+public class ASDOC extends MXMLC implements FlexTool
+{
+ /**
+ * Entry point for <code>compc</code> tool.
+ *
+ * @param args command line arguments
+ */
+ public static void main(final String[] args)
+ {
+ int exitCode = staticMainNoExit(args);
+ System.exit(exitCode);
+ }
+
+ /**
+ * Entry point for the {@code <compc>} Ant task.
+ *
+ * @param args Command line arguments.
+ * @return An exit code.
+ */
+ public static int staticMainNoExit(final String[] args)
+ {
+ final ASDOC asdoc = new ASDOC();
+ return asdoc.mainNoExit(args);
+ }
+
+ public ASDOC()
+ {
+ super();
+ workspace.setASDocDelegate(new SimpleASDocDelegate());
+ }
+
+ @Override
+ public String getName() {
+ return FLEX_TOOL_ASDOC;
+ }
+
+ @Override
+ public int execute(String[] args) {
+ return mainNoExit(args);
+ }
+
+ /**
+ * Console message describing the results of the ASDoc compilation
+ */
+ private String asdocOutputMessage;
+
+ @Override
+ public boolean configure(String[] args)
+ {
+ return super.configure(args);
+ }
+
+ @Override
+ protected String getConfigurationDefaultVariable()
+ {
+ return ICompilerSettingsConstants.INCLUDE_CLASSES_VAR;
+ }
+
+ @Override
+ protected Configurator createConfigurator()
+ {
+ return new Configurator(COMPCConfiguration.class);
+ }
+
+ @Override
+ protected String getProgramName()
+ {
+ return "asdoc";
+ }
+
+ @Override
+ protected String getStartMessage()
+ {
+ // This message should not be localized.
+ String message = "Apache Flex ASDoc Compiler" + NEWLINE +
+ VersionInfo.buildMessage() + NEWLINE;
+ return message;
+ }
+
+ /**
+ * Build SWC library artifact. The compilation units are already built at
+ * this point.
+ */
+ @Override
+ protected void buildArtifact() throws InterruptedException, IOException
+ {
+ // Write the SWC model to disk.
+ final String outputOptionValue = config.getOutput();
+ if (outputOptionValue == null || outputOptionValue.length() == 0)
+ {
+ ICompilerProblem problem = new MissingRequirementConfigurationProblem(ICompilerSettingsConstants.OUTPUT_VAR);
+ problems.add(problem);
+ return;
+ }
+
+ // SWC target will create a SWC model.
+ ISWCTarget swcTarget;
+ ITargetSettings targetSettings = projectConfigurator.getTargetSettings(TargetType.SWC);
+ if (targetSettings == null)
+ return;
+
+ swcTarget = project.createSWCTarget(targetSettings, null);
+ target = (SWFTarget)swcTarget.getLibrarySWFTarget();
+
+ Collection<ICompilerProblem> swcProblems = new ArrayList<ICompilerProblem>();
+ final ISWC swc = swcTarget.build(swcProblems);
+
+ problems.addAll(swcProblems);
+
+ // Don't create a SWC if there are errors unless a
+ // developer requested otherwise.
+ if (!config.getCreateTargetWithErrors() && problems.hasErrors())
+ return;
+
+ boolean useCompression = targetSettings.useCompression();
+ if (config.getOutputSwcAsDirectory())
+ {
+ final String path = FilenameNormalization.normalize(outputOptionValue);
+ final ISWCWriter swcWriter = new SWCDirectoryWriter(path, useCompression,
+ targetSettings.isDebugEnabled(), targetSettings.isTelemetryEnabled(),
+ SizeReportWritingSWFWriter.getSWFWriterFactory(targetSettings.getSizeReport()));
+ swcWriter.write(swc);
+ long endTime = System.nanoTime();
+ String seconds = String.format("%5.3f", (endTime - startTime) / 1e9);
+ Map<String, Object> params = new HashMap<String, Object>();
+ params.put("path", path);
+ params.put("seconds", seconds);
+ asdocOutputMessage =
+ Messages.getString("COMPC.swc_written_open_directory_in_seconds_format",
+ params);
+ }
+ else
+ {
+ final ISWCWriter swcWriter = new SWCWriter(outputOptionValue, useCompression,
+ targetSettings.isDebugEnabled(), targetSettings.isTelemetryEnabled(),
+ SizeReportWritingSWFWriter.getSWFWriterFactory(targetSettings.getSizeReport()));
+ swcWriter.write(swc);
+ final File outputFile = new File(outputOptionValue);
+ long endTime = System.nanoTime();
+ String seconds = String.format("%5.3f", (endTime - startTime) / 1e9);
+ Map<String, Object> params = new HashMap<String, Object>();
+ params.put("byteCount", outputFile.length());
+ params.put("path", outputFile.getCanonicalPath());
+ params.put("seconds", seconds);
+ asdocOutputMessage = Messages.getString("MXMLC.bytes_written_to_file_in_seconds_format",
+ params);
+ }
+ }
+
+ @Override
+ protected void reportTargetCompletion()
+ {
+ if (asdocOutputMessage != null)
+ println(asdocOutputMessage);
+ }
+
+ /**
+ * Compc uses the target file as the output SWC file name. Nothing needs to
+ * be done here.
+ */
+ @Override
+ protected boolean setupTargetFile() throws InterruptedException
+ {
+ return true;
+ }
+
+ /**
+ * Compc uses the target file as the output SWC file name if provided.
+ * Nothing needs to be done here.
+ */
+ @Override
+ protected void validateTargetFile() throws ConfigurationException
+ {
+ }
+
+ @Override
+ protected boolean isCompc()
+ {
+ return true;
+ }
+
+ @Override
+ protected TargetType getTargetType()
+ {
+ return TargetType.SWC;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e96f9f22/compiler/src/org/apache/flex/compiler/internal/parsing/as/SimpleASDocDelegate.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/parsing/as/SimpleASDocDelegate.java b/compiler/src/org/apache/flex/compiler/internal/parsing/as/SimpleASDocDelegate.java
new file mode 100644
index 0000000..4fbe6fe
--- /dev/null
+++ b/compiler/src/org/apache/flex/compiler/internal/parsing/as/SimpleASDocDelegate.java
@@ -0,0 +1,143 @@
+/*
+ *
+ * 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.internal.parsing.as;
+
+
+
+
+import antlr.Token;
+
+import org.apache.flex.compiler.asdoc.IASDocComment;
+import org.apache.flex.compiler.asdoc.IASDocDelegate;
+import org.apache.flex.compiler.asdoc.IASParserASDocDelegate;
+import org.apache.flex.compiler.asdoc.IMetadataParserASDocDelegate;
+import org.apache.flex.compiler.asdoc.IPackageDITAParser;
+import org.apache.flex.compiler.asdoc.ASDocComment;
+import org.apache.flex.compiler.common.ISourceLocation;
+import org.apache.flex.compiler.definitions.IDocumentableDefinition;
+import org.apache.flex.compiler.tree.as.IDocumentableDefinitionNode;
+
+/**
+ * Default implementation of {@link IASDocDelegate} that does not have any code
+ * model or eclipse dependencies.
+ */
+public final class SimpleASDocDelegate implements IASDocDelegate
+{
+ private static final SimpleASDocDelegate INSTANCE = new SimpleASDocDelegate();
+
+ /**
+ * Gets the single instance of this delegate.
+ *
+ * @return The single instance of this delegate.
+ */
+ public static IASDocDelegate get()
+ {
+ return INSTANCE;
+ }
+
+ public SimpleASDocDelegate()
+ {
+ }
+
+ @Override
+ public IASParserASDocDelegate getASParserASDocDelegate()
+ {
+ return new ASDelegate();
+ }
+
+ @Override
+ public IASDocComment createASDocComment(ISourceLocation location, IDocumentableDefinition definition)
+ {
+ return null;
+ }
+
+ @Override
+ public IPackageDITAParser getPackageDitaParser()
+ {
+ return IPackageDITAParser.NIL_PARSER;
+ }
+
+ private static final class ASDelegate implements IASParserASDocDelegate
+ {
+ @SuppressWarnings("unused")
+ static final ASDelegate INSTANCE = new ASDelegate();
+
+ @Override
+ public void beforeVariable()
+ {
+ }
+
+ @Override
+ public void afterVariable()
+ {
+ }
+
+ Token currentToken;
+
+ @Override
+ public void setCurrentASDocToken(Token asDocToken)
+ {
+ currentToken = asDocToken;
+ }
+
+ @Override
+ public IASDocComment afterDefinition(IDocumentableDefinitionNode definitionNode)
+ {
+ if (currentToken == null)
+ return null;
+
+ ASDocComment comment = new ASDocComment(currentToken);
+ currentToken = null;
+ return comment;
+ }
+
+ @Override
+ public IMetadataParserASDocDelegate getMetadataParserASDocDelegate()
+ {
+ return MetadataDelegate.INSTANCE;
+ }
+
+ }
+
+ private static final class MetadataDelegate implements IMetadataParserASDocDelegate
+ {
+ static final MetadataDelegate INSTANCE = new MetadataDelegate();
+
+ @Override
+ public void setCurrentASDocToken(Token asDocToken)
+ {
+ }
+
+ @Override
+ public IASDocComment afterDefinition(IDocumentableDefinitionNode definitionNode)
+ {
+ return null;
+ }
+
+ @Override
+ public void clearMetadataComment(String metaDataTagName)
+ {
+ }
+
+ @Override
+ public void afterMetadata(int metaDataEndOffset)
+ {
+ }
+ }
+}