[svn] 1063: ImplementationCompiler abstract syntax tree generation

Revision: 1063
Author: [email protected]
Date: 2008-04-02 08:31:38 -0700 (Wed, 02 Apr 2008)
Log Message:
ImplementationCompiler abstract syntax tree generation
work-in-progress. Most of the methods for the equivalent Velocity
macros in ClassDef.vm and ClassDefLib.vm are stubbed out in
ImplementationGenerator. Note, with -generate-abstract-syntax-tree
set to true, mxml compilation is mostly broken. The current default
is false.
checkintests Passed: YES
Needs QA: Not yet
Needs DOC: NO
API Change: NO
Code-level description of changes:
swfutils/src/java/flash/swf/tools/SyntaxTreeDumper.java
Added evaluate() for BlockNode, CommentNode, TypeIdentifierNode,
and UsePragmaNode.
Modified evaluate() for CallExpressionNode, GetExpressionNode,
SetExpressionNode, and FunctionSignatureNode to include more info.
compiler/src/java/flex2/compiler/as3/AbstractSyntaxTreeUtil.java
Initial checkin.
compiler/src/java/flex2/compiler/as3/binding/DataBindingExtension.java
Moved numerous common methods to AbstractSyntaxTreeUtil.
compiler/src/java/flex2/compiler/mxml/rep/Model.java
Made getEffects() public.
compiler/src/java/flex2/compiler/mxml/rep/MxmlDocument.java
Added generics to getDeclarationIterator(), getImports(),
getScripts(), and getMetadata().
Added getInterfaceNames().
compiler/src/java/flex2/compiler/mxml/rep/DocumentInfo.java
Changed return type of getImportNames() from Collection to Set.
compiler/src/java/flex2/compiler/mxml/ImplementationCompiler.java
Modified parse1() to call generateImplementationAST() if
getGenerateAbstractSyntaxTree() is true. Otherwise,
generateImplementation() is called.
compiler/src/java/flex2/compiler/mxml/ImplementationGenerator.java
Initial checkin.
Modified Paths:
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/binding/DataBindingExtension. java
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/ImplementationCompiler.java
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/DocumentInfo.java
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/Model.java
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/MxmlDocument.java
flex/sdk/trunk/modules/swfutils/src/java/flash/swf/tools/SyntaxTreeDumper.java
Added Paths:
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/AbstractSyntaxTreeUtil.java
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/ImplementationGenerator.java

Hi Florian,
you can use the resource / EMF API directly in a plain (non-interactive)
environment.
If you want to enrich your model you should investigate using imported
metamodels and derived properties for the derivable information.
However, the Linker#afterModelLinked is usually a good place to enhance
the model.
Regards,
Sebastian
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 29.11.10 19:39, schrieb Florian Gessner:
> Hi Sebastian,
>
> thanks for your fast reply.
> The example described in the blog uses the IDocumentEditor to manipulate
> the data. I do not want to implement this in the UI layer but in the
> backend.
> I think EMF should would independent from this, but for me it is not
> clear how I can integrate this into the backend. I think it would be a
> bit strange if I would enrich the model by some logic during validation
> or linking. Or is this how it works?
>
> Thanks and best regards
> Florian

Similar Messages

  • [svn] 1150: More direct syntax tree generation work-in-progress.

    Revision: 1150
    Author: [email protected]
    Date: 2008-04-08 14:56:01 -0700 (Tue, 08 Apr 2008)
    Log Message:
    More direct syntax tree generation work-in-progress. FlexStore now
    compiles and runs with -generate-abstract-syntax-tree set to true, but
    we still parse AS in a few places, like data bindings and styles,
    where it isn't always necessary. The unnecessary cases will be
    removed in the future to maximize performance.
    Asserts have been added to the places that will need an implementation
    before the full compiler test suite will pass.
    checkintests Passed: YES
    Needs QA: Not yet
    Needs DOC: NO
    API Change: NO
    Code-level description of changes:
    compiler/as3/AbstractSyntaxTreeUtil.java
    Added generateAssignment(), generateIdentifier(),
    generateMetaData(), generateParameter(), generateTypeExpression(),
    generateVariable(), generateVariableNew(), and parse().
    Combined generateConstructorDefinition() and
    generateConstructorCommon() into generateConstructor().
    compiler/as3/binding/DataBindingExtension.java
    Modified generateClassDefinition() to call
    nodeFactory.StartClassDefs() to fix a downstream FlowAnalyzer null
    pointer exception.
    Removed generateParameter(), which was added to AbstractSyntaxTreeUtil.
    compiler/mxml/builder/AbstractDocumentBuilder.java
    Modified analyze(BindingNode) to call setFromBindingNode().
    compiler/mxml/rep/Model.java
    Added getSubInitializerIterator().
    compiler/mxml/rep/AtResource.java
    Added getValueExpression().
    compiler/mxml/rep/MxmlDocument.java
    Made getTopLevelInitializerIterator() public and added some
    additional generics usage.
    compiler/mxml/rep/Array.java
    Added getSubInitializerIterator() and some additional generics
    usage.
    compiler/mxml/rep/init/EffectInitializer.java
    Added generateAssignExpr().
    compiler/mxml/rep/init/ValueInitializer.java
    Added generateValueExpr(), generateInlineRValue(),
    generateDefinitionBody(), generateDefinitions(), and AST versions
    of addAssignExprs(), formatExpr(), asArrayLiteral(),
    asObjectLiteral(), asXmlLiteral(), and asXMLList().
    compiler/mxml/rep/init/Initializer.java
    Added generateValueExpr(), generateAssignExpr(), and
    generateDefinitions().
    compiler/mxml/rep/init/StyleInitializer.java
    Added generateAssignExpr().
    compiler/mxml/rep/init/EventInitializer.java
    Added generateValueExpr(), generateAssignExpr(),
    generateDefinitionBody(), and generateDefinitions().
    compiler/mxml/rep/init/NamedInitializer.java
    Added generateAssignExpr().
    compiler/mxml/rep/init/VisualChildInitializer.java
    Added generateAssignExpr().
    compiler/mxml/rep/init/ArrayElementInitializer.java
    Added generateAssignExpr().
    compiler/mxml/rep/decl/InitializedPropertyDeclaration.java
    Added generateAssignExpr().
    compiler/mxml/rep/MovieClip.java
    Added getSubInitializerIterator().
    compiler/mxml/rep/BindingExpression.java
    Added isFromBindingNode variable and accessors.
    Created ensureHighestLevelModelDeclared() from common code.
    Added generateDestinationAssignment(),
    generateDestinationSetStyle(), and generateDestinationPathRoot().
    compiler/mxml/ImplementationCompiler.java
    Added short circuit to parse1() for the generate AST case.
    compiler/mxml/gen/ClassDefLib.vm
    Removed unnecessary variable declaration.
    compiler/mxml/ImplementationGenerator.java
    Added a truck load of new methods and implemented numerous
    previously stubbed out methods.
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/AbstractSyntaxTreeUtil.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/binding/DataBindingExtension. java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/ImplementationCompiler.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/ImplementationGenerator.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/builder/AbstractDocumentBuil der.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/gen/ClassDefLib.vm
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/Array.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/AtResource.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/BindingExpression.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/Model.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/MovieClip.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/MxmlDocument.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/decl/InitializedProperty Declaration.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/init/ArrayElementInitial izer.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/init/EffectInitializer.j ava
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/init/EventInitializer.ja va
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/init/Initializer.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/init/NamedInitializer.ja va
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/init/StyleInitializer.ja va
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/init/ValueInitializer.ja va
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/init/VisualChildInitiali zer.java

    Hi,
    I'm unsure how long this post will be on the forums, but here it goes.
    Yes, customizing ADF in any way requires a lot of time.
    ADF is build with the concept of less coding and more drag and drop. The framework tailored specifically to this requirement.
    This means that if you use ADF, you must be willing to change business requirements if ADF does not easily allow you to implement them.
    This is of course true for almost any Framework, but for ADF it is really extreme.
    I need to go back to the business a lot when working with ADF, explaining that if we change this requirement development is a lot easier and that sometimes I'm even unsure if I can make it work in ADF.
    But that said, most of the screen WILL work with basic drag and drop and minimal backing beans, ADF is worth it then.
    If people try to convince you, you do not need to code at all with ADF, just ignore them.
    They have never work on a real commercial project with real customers, simple as that.
    On your question, I believe I did something similar in ADF 10.1.3, but I cannot find the code atm.
    But yes, use the native Trinidad components, forget about the bindings for now, bindings will only make your time a lot harder.
    Work with the underlying app module and the view objects directly.
    There is no reason this should not work, but yes you will bypass the binding layer.
    When I have to customize something, I start by checking if the ADF components allow me todo something declarative, this is hardly ever the case.
    I changed to backing beans really fast, then I try to use the bindings, but I never spend much time on this and go directly to the underlying app module.
    -Anton

  • How can i extract  symbol table and Abstract syntax tree of a java compiler

    How can i extract the Abstract Syntax tree and the Symbol Table from the class file of java.I need to have the code for extracting it.
    Can anyone help me in this matter.
    Sreeram

    Everything that it is possible to retrieve from a class file can be deduced from the class file definition.
    http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html
    Sylvia.

  • Identifying all the types that implements a particular type using roslyn syntax tree.

    I have a method that takes the syntax tree of a .cs file as an argument.This method has to find all the types that inherits or implements a  particular type e.g. finds occurrences of all instances of statements "SqlConn
    c = new SqlConn()" because it implements IDisposable. I am using Roslyn API.

    I had a system recently containing seven sequence files, approx 20 subsequences in each, and around 10-20 steps in each sub-sequence. Every step (except for the NI non-code module types) was an instance of a step type.
    Each one of these steps had an Edit sub-step and a code module called through the code module adapter.
    In order to make these into "wrapped up" step types it was decided to move the code module to a Post-Step substep (as also done in the NI-IVI step types) - so that developers cannot fiddle with the code prototype or module.
    In order to do this I had to open all 7 of the sequence files, make the changes and then ensure that "Apply changes in this dialog to a loaded instances" was checked. This seems to sort of work, but some steps started causing Error 17502 (System Error) when you configure them (call the Edit substep). Over the course of the past few months I have had to effectively check every instance of a type to see if it works (deleting the step and replacing it when it doesnt). Other strange things happened like some of the step type instances now have the "None" (adapter) icon associated with them - but both still work.
    The idea of creating a type-def of a step type is a good one, but frustrating that it doesnt seem to fully work. Why should the sequence file also store a version of the step-type - which is what is effectively causing this problem - why not make it so that if you dont have the step types installed in the type palette - TOUGH! Message Edited by RichM on 03-15-2005 06:55 AM

  • Custom Control - Best place for visual-tree generation?

    I'm building a custom control (extending Canvas) which should present a chartflow diagram (nodes and connectors). It will be feeded through databinding and a dependency property (ItemSource). The control will generate:
    1. Node-items (based on ItemSource)
    2. Connectors (lines) between each and every node
    3. An adornerlayer on most of the nodes
    Should I generate this visual/logical -tree inside my ItemSourceUpdated -eventhandler? In the overrided ArrangeOverride method? Or whats best practice?

    Please don't ask several questions in the same thread. Your original question was about where to add the visual elements when creating a custom Panel and now you are asking about adorners. Please close the thread by marking all helpful posts as answer when
    your original quesion has been answered and then start a new thread if you have a new question.
    Please refer to the following page for more information about adorners:
    https://msdn.microsoft.com/en-us/library/ms743737(v=vs.110).aspx
    Sorry but no, my original question was about where to place creation code for:
    1. Node-items (based on ItemSource)
    2. Connectors (lines) between each and every node
    3.
    An adornerlayer
    on most of the nodes
    Since you cant create adorners immediately after you have added a new elemented to the visual tree (and before the layout pass) your previous
    answer was appreciated, but not sufficient.

  • Resolve full qualified type from compiler syntax tree

    I'm writting a program to perform some analysis on arbitrary Java source code and I need to be able to resolve types that are imported. This is relatively easy if the type is explicitly imported e.g.
    import java.util.List;
    List x = null;
    then the type of x can be determined to be List.
    However if wildcard imports are used e.g.
    import java.util.*;
    import java.io.*;
    List x = nulll;
    How can I determine what the type of x actually is? I'm using the java compiler API to parse the source code:
    CompilationTask task = compiler.getTask(null, null, null, options, null, files);
    JavacTask javacTask = (JavacTask) task;
    Iterable<? extends CompilationUnitTree> tree = javacTask.parse();
    and then scanning the CompilationUnitTree for items of interest.
    I suspect I need to execute the analyze phase of the compiler but I can't see that the output of that phase is immediatly useful.
    Thanks
    Ian Clough

    GardenAway wrote:
    So, I suspect something did not get set properly when the existing app was imported from FB4 Beta to FB4 GA.
    dp
    I had the same null argument problem as you did. Thank you for the insight above. It saved me a load of time.
    Here are some more details:
    when I moved onto FB4GA from beta 2, the .actionScriptProperties file contained bunch entries like the following
    <compiler>
       <modifiedEntries>
         <libraryPathEntry index="4" kind="3" linkType="4" path="${PROJECT_FR
                <crossDomainRsls>
                  <crossDomainRslEntry autoExtract="true" policyFileUrl="" rslUrl=
                  <crossDomainRslEntry autoExtract="true" policyFileUrl="http://fp
                </crossDomainRsls>
         </libraryPathEntry>
              about 3-4 more entries like the above
       </modifiedEntries>
       <libraryPathEntry kind="1" linkType="1" path="${FLEXUNIT_LIB_LOCATION}/
    </compiler>
    In eclipse, I went into project properties > Flex Build Path, deleted all the build path libraries/sdks and re-added only the SDK. The .actionScriptProperties file now has all the libraryPathEntries lines replaced with the following
        <libraryPath defaultLinkType="3">
          <libraryPathEntry kind="4" path="">
            <excludedEntries>
              <libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/flex.swc" useDefaultLinkType="false"/>
            </excludedEntries>
          </libraryPathEntry>
        </libraryPath>
    and the null argument problem went away

  • Syntax tree of a java source file

    i am making a java IDE. i need a way to display tree which contain the name of classes, import files, and variables used in the code as nodes.just like the tree make in JCreator and JBuilder.

    I'm currently developing a LaTeX editor(MDI) and I do the same thing, but I don't know what exactly do you need.

  • [svn:fx-trunk] 9947: Syntax fix for Border' s backgroundImageResizeMode Style metadata enumeration.

    Revision: 9947
    Author:   [email protected]
    Date:     2009-09-02 18:05:01 -0700 (Wed, 02 Sep 2009)
    Log Message:
    Syntax fix for Border's backgroundImageResizeMode Style metadata enumeration.
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/Border.as

    You have used elements like header, footer, footer1 and nav without using the correct DOCTYPE declaration. Replace the first line of your code with
    <!doctype html>
    Also have a look here for other problems http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fhome.surewest.net%2Fstorytales%2F test%2Fforposting.html
    After the above has been fixed, please come back here to fix the remaining problem(s)
    Gramps

  • [svn] 1965: * Made AST generation the default.

    Revision: 1965
    Author: [email protected]
    Date: 2008-06-05 07:18:47 -0700 (Thu, 05 Jun 2008)
    Log Message:
    * Made AST generation the default. To turn it off set
    -generate-abstract-syntax-tree to false.
    * Fixed two small issues found by the mxunit and mxmlcunit tests.
    tests Passed: checkintests, mxunit and mxmlcunit
    Needs QA: YES
    Needs DOC: NO
    Bug fixes:
    API Change: NO
    Reviewer: pfarland
    Code-level description of changes:
    as3/OffsetInputBuffer.java
    Modified constructor to set "curr_line_offset", because if the
    first token is xml, "curr_line_offset" will not have been
    initialized using "pos".
    common/CompilerConfiguration.java
    Changed generateAbstractSyntaxTree to true.
    mxml/rep/BindingExpression.java
    Modified generateNamespaceDeclarations() to intern the generated
    namespace, because it is assumed to be interned by ASC. The
    assert in IdentifierNode caught this.
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/OffsetInputBuffer.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/common/CompilerConfiguration.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/BindingExpression.java

    Remember that Arch Arm is a different distribution, but we try to bend the rules and provide limited support for them.  This may or may not be unique to Arch Arm, so you might try asking on their forums as well.

  • [svn] 1967: * Fixed issue where -keep-generated-actionscript would not work

    Revision: 1967
    Author: [email protected]
    Date: 2008-06-05 08:12:21 -0700 (Thu, 05 Jun 2008)
    Log Message:
    * Fixed issue where -keep-generated-actionscript would not work
    properly when -generate-abstract-syntax-tree was enabled, which is
    now the default.
    tests Passed: checkintests
    Needs QA: YES
    Needs DOC: NO
    API Change: NO
    Reviewer: clucier
    Code-level description of changes:
    CompilerConfiguration.java
    Modified setKeepGeneratedActionScript() to force AST generation
    off when the value is true.
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/common/CompilerConfiguration.java

    Remember that Arch Arm is a different distribution, but we try to bend the rules and provide limited support for them.  This may or may not be unique to Arch Arm, so you might try asking on their forums as well.

  • [svn] 1378: Fixed some recently introduced mxunit databinding failures when

    Revision: 1378
    Author: [email protected]
    Date: 2008-04-24 07:15:10 -0700 (Thu, 24 Apr 2008)
    Log Message:
    Fixed some recently introduced mxunit databinding failures when
    -generate-abstract-syntax-tree is turned on.
    checkintests Passed: YES
    Needs QA: No
    Needs DOC: NO
    API Change: NO
    Code-level description of changes:
    AbstractSyntaxTreeUtil.java
    Added some asserts to parse() to help catch ASC changes early.
    binding/DataBindingExtension.java
    Modified both generateAccessorFunction()'s to no longer skip the
    first two nodes as AbstractSyntaxTreeUtil.parse() handles this.
    Modified generateInitFunctionCommon() to set the
    FunctionSignatureNode's void_anno to true.
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/AbstractSyntaxTreeUtil.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/binding/DataBindingExtension. java

  • [svn] 954: Fixed ASC so that Context.input can be null.

    Revision: 954
    Author: [email protected]
    Date: 2008-03-27 08:02:13 -0700 (Thu, 27 Mar 2008)
    Log Message:
    Fixed ASC so that Context.input can be null. This will be the case
    when the AST (abstract syntax tree) is generated.
    checkintests Passed: YES
    Needs QA: NO
    Needs DOC: NO
    API Change: NO
    Code-level description of changes:
    asc/semantics/CodeGenerator.java
    Added checks for a null context.input before using it.
    asc/parser/SelectorNode.java
    Made class abstract, so SyntaxTreeDumper can be sure that it
    doesn't have to handle this class directly, only it's subclasses.
    asc/parser/PackageIdentifiersNode.java
    Made IS_DEFINITION_FLAG private and added isDefinition() for use
    by SyntaxTreeDumper and toString().
    asc/embedding/LintEvaluator.java
    Added checks for a null context.input before using it.
    Modified Paths:
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/embedding/LintEvaluator.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/parser/PackageIdentifiersNode.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/parser/SelectorNode.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/semantics/CodeGenerator.java

    I have already set it to FALSE. The solution to this will be some different OSD Task Sequence variables or a statement that it can't be made to work.
    I believe that setting defines what volume will be the BOOT / OS Drive Letter. Some people were getting D:\WINDOWS as their boot volume drive letter. Setting to true means whatever was the System Drive letter (usually C) in the image will remain as such
    after it was was applied, setting it to false will make the system have the same drive letter arrangement as what Windows PE detects. In my case I set it to false so that no matter what the new VHD file setup as drive C will be the system drive. I'll set it
    to true on the next deployment but I expect there to be no difference, because in both PE and the WIM the installation volume is the C:.
    We are talking about the DRIVE LETTERS Windows PE SCCM OSD is using for it's temporary files - and how we can manipulate these locations using OSD Task Sequence Variables, so the Apply OS doesn't try and clean up files that are not there
    - and fail with an error if you have added a VHD Native Boot volume.
    This OSDPreserveDriveLetter setting isn't having any effect on the problem here.
    I believe that Format step is setting some task variables used by the OSD Deployment process - telling it where to store it's temporary files. However between the Format Disks and Apply operating system steps the OSD Task Sequence isn't picking up on the
    fact what was the C:\ after Format HDD step is now the D:\ .
    A developer who has an understanding of how the OSD boot process executes in order would be able to see what's going on here.
    MCSE,MCNE,SCO,Sair Linux/GNU, Open source-enthusiast.

  • How to count number of lines inside methods() using the Doclet API

    Wrote a custom doclet using the [Doclet API|http://java.sun.com/j2se/1.3/docs/tooldocs/javadoc/doclet/index.html ] .
    The purpose for the doclet is to load Java source files and create stubs (which are identical Java source files but do not contain any method implementation details).
    Instead, the method implementation details need to be replaced with blank lines...
    public class MyDoclet {
         private static String TAB = "\t";
         public static boolean start(RootDoc root) {
              ClassDoc[] classes = root.classes();
              // Parse through class or interface
              for (ClassDoc clazz : classes) {
                   Type superClass = clazz.superclassType();     
                   // Print Methods
                   MethodDoc[] methods = clazz.methods();
                   for (MethodDoc method : methods) {
                        Parameter[] parameters = method.parameters();
                        println();
                        if (!method.isPrivate()) {
                             print(TAB + method.modifiers() + " "
                                                    + method.returnType().simpleTypeName() + " " + method.name());
                             print("(");
                             for (int i=0; i < parameters.length; i++) {
                                  Parameter parameter = (Parameter) parameters;
                                  print(parameter.type().simpleTypeName() + " " + parameter.name());
                                  if (i != parameters.length - 1) {
                                       print(", ");
                             print(")");
                             println(" {");
                             println("\n");
                             println(TAB + "}");
              return true;
    As one can see, I am just creating the method and placing the opening and closing curly braces (along with a new \n line escape sequence, in between).
    Am not really that familiar with the Doclet API...
    Question(s):
    (1) What is the best way to figure out how many lines of code are inside each method and then use a for loop to insert the exact same number of blank lines inside the methods?
    (2) Is there a way to do it using the com.sun.javadoc.SourcePosition.line() method?
    Would really appreciate it if someone could help me because this is an important requirement (hence the 10 Duke Stars).
    Happy coding to all,
    Mike                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    This is not possible using the Doclet API, because JavaDoc does not store any information regarding implementation detail. Although MethodDoc#position will give you the line where the method is declared, there is no way to determine where the method body starts and ends.
    If you need that much information, maybe you would be better of using a tool such as Eclipse's Abstract Syntax Tree parser. AST will provide you with line numbers for each code expression, hence it is relatively easy to compute the first and last line in a method body.

  • Parsing and rewriting an SQL query

    Hi all,
    I need to rewrite bits of a valid PL/SQL query. In order to do so, I need semantic information about the query, such as "what are the table names columns are being selected from" or "do aggregate functions in a select provide column alias in order to use the query in +CREATE TABLE AS+ ...".
    Is it possible to somehow "ask" the Oracle parser for those bits of semantic info? I am using 9i.
    E.g.
    select X.ID, Y.NAME, SUM(ABS(Y.VALUE))
    from
    TABLE_X X,
    (select NAME, VALUE from TABLE_Z where DATE_STR = '20090101') Y
    where
    will become
    select X.ID, Y.NAME, SUM(ABS(Y.VALUE)) COL1
    from
    TABLE_X prefix. X,
    (select NAME, VALUE from prefix. TABLE_Z where DATE_STR = '20090101') Y
    where
    ...

    Thanks for your answers (which, unfortunately, do not give much hope)!
    +..so unfortunately you won't be able to use the 11g method introduced here (Anyhow still undocumented!).+
    Yes, that's very disappointing. I actually added the "has to be 9i compatible" remark after I found out the XML dump does not work on our servers - and read the manual page to realize why that's the case.
    I think you'd need to write your own, which will be extremely difficult and hard to maintain.*
    There is a BNF grammar of PL/SQL (homebrew, apparently - so no guarantees): http://www.antlr.org/grammar/1107752678378/PLSQLGrammar.g
    Now, if I only knew practical stuff about lexers and parsers and abstract syntax trees...

  • Javadoc Comments Begin and End Offset, Line number etc...

    Hello Everyone,
    I was wondering if there is a method that return the begin and end offsets, and line number of source code comment. I know this is possible to get the line number for Doc, MethodDoc, ConstutorDoc etc... with the position() method. I was unable to get the locations of comments corresponding to the actual source code. Also, I found that when asking for the position of constructors the value returned was that of the class, is this a known bug?
    Thanks in Advanced,
    Nick

    nkhamis wrote:
    Just out of curiosity, what do the folks at sun use for Java Parsers?They didn't need to go too far. The Java Parser must be a part of any Java compiler itself! Therefore, it is a part of any JDK. Obviously, they have some internal API of their Java parser and, I guess, Javadoc uses it to build the Java code model provided via the Doclet API. But Sun had never published the full API to their Java parser. (At least, I don't know such.) Although, it would be very useful indeed...
    FYI, a parser for a high-level programming language (like Java) is a software module that inputs a program written (by humans) as text in that language and converts it into some object representation (model) "understandable" to computer. That object representation must be a sort of tree representing all the language constructs found in the program. Typically, that tree is accessible via a certain API, which I call here a Parser API (although, other terminology may be used).
    Other software modules may use that object representation of the program for various purposes, for instance:
    - To generate an executable machine (or byte-) code by it
    - To transform the initial program in order to optimize it (this is used by compilers) or to do other things (e.g. refactoring)
    - To generate documentation (that's what Javadoc does)
    Besides generating the program object representation, another job of a parser is to provide diagnostics about various syntactical errors found in the initial program source (a well as possibly some semantic warnings).
    A parser is rather sophisticated piece of code. To develop it properly, one needs to learn first some theory about this, e.g. a formal grammar that describes the given programming language and how to deal with it. I know, there have been attempts to create some universal parsers that can be adjusted to parse any programming language (within a certain range) by specifying to them some formal grammar of that language. That topic was particularly beloved by university guys, so there must be many scientific articles about this.
    thomas.behr wrote:
    Well, if you are developing an Eclipse plugin, have you considered working with Eclipse' Abstract Syntax Tree (basically an object model for Java code) instead of the Doclet API?Interesting stuff... Looks like this might be that very Java parser API I am talking about here.
    Leonid Rudy
    [http://www.docflex.com|http://www.docflex.com]

Maybe you are looking for

  • How do I stop a CCC partition auto mounting in Lion

    I have an external USB drive with 2 partitions. The first partition has a CCC Clone of my drive before Lion. The second is used for Time Machine. This drive auto mounts on boot which is fine but the CCC partition causes problems with the App Store as

  • My Second Display connected on VGA is "blue-ish"

    When I try to hook up a second VGA TFT-display using DVI-VGA adapter on the GT 120 the second screen has a blue-ish look. I can see the background picture, I can change the resolution settings but I can't get rid od the blueish tone. On the mini-disp

  • How do I remove the on-screen volume and brightness displays?

    The on screen displays for volume and brightness controls on my ProBook 455 really lag behind pressing the buttons and aren't terribly helpful anyway. Can I remove them? I've seen people ask in the past and they are told about something called an "HP

  • Archive Purchase Info Record MM_EINA : problem with CDHDR

    Hello, I have notice that when i archive an Info Record, Only CDPOS is deleted and not CDHDR. In the customizing, Object Class CHANGEDOCU is set. Can someone explain why datas in CDHDR are not deleted ? Thank you, Cipriano

  • Trouble get in to the payment option

    Hi, I have 8520, OS : 5.0.0.1075 BlackBerry App World : 4.0.0.55 BlackBerry Identity : 5.3.0.14 Everything is OK, but I can not open "payment option" in the BlackBerry App World. Please, does any one have the answer ? Regards