Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ba3c4ed
Merge branch 'desarrollo'
m-herrera Oct 17, 2017
c6dcfe7
Arreglo barras de desplazamiento
JassonRM Oct 19, 2017
4a9b488
Funciones para actualizar el dibujo de acuerdo con el metodo
JassonRM Oct 19, 2017
174dd09
Nueva vista para el explorador de metodos
JassonRM Oct 19, 2017
eaa59a3
[NEW] Obtener número de linea del debugger
m-herrera Oct 24, 2017
29cfe35
Merge branch 'master' of https://github.com/JassonRM/Flow.git
m-herrera Oct 24, 2017
a1d04d8
Implementacion de la interfaz Widget
JassonRM Oct 25, 2017
44b7311
Cambio de iconos y arreglo de botones
JassonRM Oct 25, 2017
0ec62d8
[NEW] documentación y otros
m-herrera Oct 25, 2017
374171a
Merge branch 'master' of https://github.com/JassonRM/Flow.git
m-herrera Oct 25, 2017
64eb11c
[NEW] Reordenamiento de código
m-herrera Oct 26, 2017
4796871
[UPDATE] documentación de código
m-herrera Oct 26, 2017
cd33625
Actualización interfaz gráfica
JassonRM Oct 26, 2017
27f0aca
Merge branch 'master' of https://github.com/JassonRM/Flow.git
JassonRM Oct 26, 2017
3f5f38f
Documentacion
JassonRM Oct 26, 2017
bd2960a
Reparacion de la interfaz grafica
JassonRM Oct 26, 2017
478d8b9
[NEW] Pruebas de Complejidad
m-herrera Oct 27, 2017
6f139c1
Merge branch 'master' of https://github.com/JassonRM/Flow.git
m-herrera Oct 27, 2017
252b7bb
[NEW] Búsqueda de Metodos para step Into
m-herrera Oct 27, 2017
03502b8
Dibujo del diagrama de flujo primera etapa
JassonRM Nov 1, 2017
3c5b3c9
[NEW] obtener Numero de Linea
m-herrera Nov 1, 2017
9b89a34
[NEW] MethodInvocation
m-herrera Nov 2, 2017
1514376
Diagrama de flujo segunda etapa
JassonRM Nov 3, 2017
11c69dc
Diagrama de flujo etapa final y numero de linea en el grafico
JassonRM Nov 4, 2017
a632ba9
[NEW] Agregar numero de linea con Debugger
m-herrera Nov 4, 2017
e908e76
Resaltado debugger
JassonRM Nov 6, 2017
aa9cc3a
Carga del diagrama al hacer step into
JassonRM Nov 7, 2017
a0e493d
[New] Reparar StepInto
m-herrera Nov 7, 2017
283baf1
[Update] Step Into clases externas
m-herrera Nov 7, 2017
2ed8634
Errores por arreglar
JassonRM Nov 8, 2017
184ff13
Correccion
JassonRM Nov 8, 2017
d5bddc0
[Update] Cambios menores
m-herrera Nov 8, 2017
ef1389f
Merge branch 'master' of https://github.com/JassonRM/Flow.git
m-herrera Nov 8, 2017
48e0c64
[New] Step clases externas
m-herrera Nov 8, 2017
36beaac
[Update] finalizar ejecución
m-herrera Nov 8, 2017
d08d4e9
[Update] cambios
m-herrera Nov 8, 2017
6ddad48
Arreglo breakpointHit
JassonRM Nov 8, 2017
5925f3f
Ajustes finales
JassonRM Nov 15, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
14 changes: 7 additions & 7 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
6 changes: 6 additions & 0 deletions .idea/misc.xml

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

8 changes: 8 additions & 0 deletions .idea/modules.xml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

477 changes: 477 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Binary file added Class Diagram.pdf
Binary file not shown.
Binary file added Documentación Flow.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Require-Bundle: javax.inject,
org.eclipse.jface.text;bundle-version="3.12.0",
org.eclipse.core.resources;bundle-version="3.12.0",
org.eclipse.ui;bundle-version="3.109.0",
org.eclipse.jdt.debug;bundle-version="3.11.0",
org.eclipse.debug.core;bundle-version="3.11.0"
org.eclipse.debug.core;bundle-version="3.11.0",
org.eclipse.jdt.debug;bundle-version="3.11.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: javax.annotation;version="1.2.0"
Bundle-ActivationPolicy: lazy
Binary file added Manual Flow.pdf
Binary file not shown.
53 changes: 28 additions & 25 deletions fragment.e4xmi
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
<?xml version="1.0" encoding="ASCII"?>
<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/descriptor/basic" xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_BxaXACerEeWxCPrV0pAZQQ">
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_EI7oACerEeWxCPrV0pAZQQ" featurename="descriptors" parentElementId="xpath:/">
<elements xsi:type="basic:PartDescriptor" xmi:id="_KMklcCerEeWxCPrV0pAZQQ" elementId="org.tec.datos1.flow.mainview" label="FlowChart" iconURI="platform:/plugin/org.tec.datos1.flow/icons/002-flow-1.png" tooltip="" category="Flow" contributionURI="bundleclass://org.tec.datos1.flow/org.tec.datos1.flow.parts.DiagramView">
<tags>View</tags>
<tags>categoryTag:Sample Category</tags>
</elements>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_g64RQK_UEeeYCvxE0peUaw" featurename="handlers" parentElementId="xpath:/">
<elements xsi:type="commands:Handler" xmi:id="_xotggK_UEeeYCvxE0peUaw" elementId="org.tec.datos1.flow.handler.stepin" contributionURI="bundleclass://org.tec.datos1.flow/org.tec.datos1.flow.handlers.StepInHandler" command="_K1w-0K_VEeeYCvxE0peUaw"/>
<elements xsi:type="commands:Handler" xmi:id="_4e_b0K_UEeeYCvxE0peUaw" elementId="org.tec.datos1.flow.handler.stepover" contributionURI="bundleclass://org.tec.datos1.flow/org.tec.datos1.flow.handlers.StepOverHandler" command="_bALX8K_VEeeYCvxE0peUaw"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_HmRkAK_VEeeYCvxE0peUaw" featurename="commands" parentElementId="xpath:/">
<elements xsi:type="commands:Command" xmi:id="_K1w-0K_VEeeYCvxE0peUaw" elementId="org.tec.datos1.flow.command.stepin" commandName="Step In"/>
<elements xsi:type="commands:Command" xmi:id="_bALX8K_VEeeYCvxE0peUaw" elementId="org.tec.datos1.flow.command.stepover" commandName="Step Over"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_c2QHoLFoEeefrPZk3-rHaA" featurename="trimContributions" parentElementId="xpath:/">
<elements xsi:type="menu:TrimContribution" xmi:id="_iTHY8LFoEeefrPZk3-rHaA" elementId="org.tec.datos1.flow.trimcontribution.0" parentId="org.eclipse.ui.main.toolbar" positionInParent="">
<children xsi:type="menu:ToolBar" xmi:id="_9BC0ILFoEeefrPZk3-rHaA" elementId="org.tec.datos1.flow.toolbar">
<children xsi:type="menu:HandledToolItem" xmi:id="__af-0LFoEeefrPZk3-rHaA" elementId="org.tec.datos1.flow.handledtoolitem.stepin" label="Step In" iconURI="platform:/plugin/org.tec.datos1.flow/icons/008-login-square-arrow-button-outline.png" command="_K1w-0K_VEeeYCvxE0peUaw"/>
<children xsi:type="menu:HandledToolItem" xmi:id="_Ff_WYLFpEeefrPZk3-rHaA" elementId="org.tec.datos1.flow.handledtoolitem.stepover" label="Step Over" iconURI="platform:/plugin/org.tec.datos1.flow/icons/006-arrow-into-drive-symbol.png" command="_bALX8K_VEeeYCvxE0peUaw"/>
</children>
</elements>
</fragments>
</fragment:ModelFragments>
<?xml version="1.0" encoding="ASCII"?>
<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/descriptor/basic" xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_BxaXACerEeWxCPrV0pAZQQ">
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_EI7oACerEeWxCPrV0pAZQQ" featurename="descriptors" parentElementId="xpath:/">
<elements xsi:type="basic:PartDescriptor" xmi:id="_KMklcCerEeWxCPrV0pAZQQ" elementId="org.tec.datos1.flow.mainview" label="FlowChart" iconURI="platform:/plugin/org.tec.datos1.flow/icons/003-flow-1.png" tooltip="" category="Flow" contributionURI="bundleclass://org.tec.datos1.flow/org.tec.datos1.flow.parts.DiagramView">
<tags>View</tags>
<tags>categoryTag:Sample Category</tags>
</elements>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_g64RQK_UEeeYCvxE0peUaw" featurename="handlers" parentElementId="xpath:/">
<elements xsi:type="commands:Handler" xmi:id="_4e_b0K_UEeeYCvxE0peUaw" elementId="org.tec.datos1.flow.handler.stepover" contributionURI="bundleclass://org.tec.datos1.flow/org.tec.datos1.flow.handlers.StepOverHandler" command="_bALX8K_VEeeYCvxE0peUaw"/>
<elements xsi:type="commands:Handler" xmi:id="_xotggK_UEeeYCvxE0peUaw" elementId="org.tec.datos1.flow.handler.stepin" contributionURI="bundleclass://org.tec.datos1.flow/org.tec.datos1.flow.handlers.StepInHandler" command="_K1w-0K_VEeeYCvxE0peUaw"/>
<elements xsi:type="commands:Handler" xmi:id="_p6u8ILrgEeeTZLRilA2UMQ" elementId="org.tec.datos1.flow.handler.load" contributionURI="bundleclass://org.tec.datos1.flow/org.tec.datos1.flow.handlers.Load" command="_vqwaALrgEeeTZLRilA2UMQ"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_HmRkAK_VEeeYCvxE0peUaw" featurename="commands" parentElementId="xpath:/">
<elements xsi:type="commands:Command" xmi:id="_K1w-0K_VEeeYCvxE0peUaw" elementId="org.tec.datos1.flow.command.stepin" commandName="Step In"/>
<elements xsi:type="commands:Command" xmi:id="_bALX8K_VEeeYCvxE0peUaw" elementId="org.tec.datos1.flow.command.stepover" commandName="Step Over"/>
<elements xsi:type="commands:Command" xmi:id="_vqwaALrgEeeTZLRilA2UMQ" elementId="org.tec.datos1.flow.command.load" commandName="Load"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_c2QHoLFoEeefrPZk3-rHaA" featurename="trimContributions" parentElementId="xpath:/">
<elements xsi:type="menu:TrimContribution" xmi:id="_iTHY8LFoEeefrPZk3-rHaA" elementId="org.tec.datos1.flow.trimcontribution.0" parentId="org.eclipse.ui.main.toolbar" positionInParent="after=additions">
<children xsi:type="menu:ToolBar" xmi:id="_9BC0ILFoEeefrPZk3-rHaA" elementId="org.tec.datos1.flow.toolbar">
<children xsi:type="menu:HandledToolItem" xmi:id="__af-0LFoEeefrPZk3-rHaA" elementId="org.tec.datos1.flow.handledtoolitem.stepin" label="Step In" iconURI="platform:/plugin/org.tec.datos1.flow/icons/icons8-step_into.png" command="_K1w-0K_VEeeYCvxE0peUaw"/>
<children xsi:type="menu:HandledToolItem" xmi:id="_Ff_WYLFpEeefrPZk3-rHaA" elementId="org.tec.datos1.flow.handledtoolitem.stepover" label="Step Over" iconURI="platform:/plugin/org.tec.datos1.flow/icons/icons8-step_over.png" command="_bALX8K_VEeeYCvxE0peUaw"/>
<children xsi:type="menu:HandledToolItem" xmi:id="_zJsmELrgEeeTZLRilA2UMQ" elementId="org.tec.datos1.flow.handledtoolitem.load" label="Load" iconURI="platform:/plugin/org.tec.datos1.flow/icons/005-browser.png" command="_vqwaALrgEeeTZLRilA2UMQ"/>
</children>
</elements>
</fragments>
</fragment:ModelFragments>
Binary file added icons/.DS_Store
Binary file not shown.
Binary file removed icons/001-diagrams.png
Binary file not shown.
Binary file removed icons/002-flow-1.png
Binary file not shown.
Binary file added icons/003-flow-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/003-flow-1@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed icons/003-flow.png
Binary file not shown.
Binary file removed icons/004-debug.png
Binary file not shown.
Binary file modified icons/005-browser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/005-browser@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed icons/006-arrow-into-drive-symbol.png
Binary file not shown.
Binary file removed icons/007-downloaded-into-inbox.png
Binary file not shown.
Binary file removed icons/008-login-square-arrow-button-outline.png
Binary file not shown.
Binary file added icons/icons8-step_into.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icons8-step_into@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icons8-step_out@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icons8-step_over.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icons8-step_over@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions org.tec.datos1.flow.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Osmorc" name="OSGi">
<configuration manifestGenerationMode="Manually" manifestLocation="META-INF/MANIFEST.MF" jarfileLocation="org.tec.datos1.flow.jar" outputPathType="CompilerOutputPath" bndFileLocation="" bundlorFileLocation="" bundleActivator="" bundleSymbolicName="" bundleVersion="1.0.0" ignoreFilePattern="" useProjectDefaultManifestFileLocation="false" alwaysRebuildBundleJAR="false" doNotSynchronizeWithMaven="false">
<additionalProperties />
<additionalJARContents />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/bin" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="JavaSE-1.8" jdkType="JavaSDK" />
<orderEntry type="library" name="ECLIPSE" level="application" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
56 changes: 0 additions & 56 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,62 +11,6 @@
</fragment>
</extension>

<extension
point="org.eclipse.ui.commands">
<category
name="RunFlowChart"
id="org.tec.datos1.flow.commands.Run">
</category>
<command
name="Run Flow Chart"
categoryId="org.tec.datos1.flow.commands.Run"
id="org.tec.datos1.flow.commands.RunCommand">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="org.tec.datos1.flow.commands.RunCommand"
class="org.tec.datos1.flow.handlers.Handler">
</handler>
</extension>
<extension
point="org.eclipse.ui.bindings">
<key
commandId="org.tec.datos1.flow.commands.RunCommand"
contextId="org.eclipse.ui.contexts.window"
sequence="M1+6"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
</key>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
label="FlowChart"
mnemonic="M"
id="org.tec.datos1.flow.menus.FlowChart">
<command
commandId="org.tec.datos1.flow.commands.RunCommand"
mnemonic="S"
id="org.tec.datos1.flow.menus.RunCommand">
</command>
</menu>
</menuContribution>
<menuContribution
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar
id="org.tec.datos1.flow.toolbars.sampleToolbar">
<command
commandId="org.tec.datos1.flow.commands.RunCommand"
icon="icons/001-diagrams.png"
tooltip="Flow Chart"
id="org.tec.datos1.flow.toolbar.RunCommand">
</command>
</toolbar>
</menuContribution>
</extension>
<extension
point="org.eclipse.jdt.debug.breakpointListeners">
<breakpointActionDelegate
Expand Down
Binary file added src/.DS_Store
Binary file not shown.
Binary file added src/org/.DS_Store
Binary file not shown.
Binary file added src/org/tec/.DS_Store
Binary file not shown.
Binary file added src/org/tec/datos1/.DS_Store
Binary file not shown.
Binary file added src/org/tec/datos1/flow/.DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions src/org/tec/datos1/flow/Activator.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.tec.datos1.flow;

import org.eclipse.jdt.debug.core.JDIDebugModel;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.tec.datos1.flow.debug.DebugListener;

public class Activator implements BundleActivator {

Expand All @@ -16,7 +18,10 @@ static BundleContext getContext() {
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext bundleContext) throws Exception {
JDIDebugModel.addJavaBreakpointListener(new DebugListener());
Activator.context = bundleContext;


}

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,76 +1,96 @@
package org.tec.datos1.flow.handlers;


import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.debug.core.IJavaThread;
import org.eclipse.jdt.debug.core.JDIDebugModel;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.tec.datos1.flow.debug.DebugListener;
import org.tec.datos1.flow.storage.ASTStorage;

public class Handler extends AbstractHandler {

@Override

public Object execute(ExecutionEvent event) throws ExecutionException {

IWorkbenchPart workbenchPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
ICompilationUnit IcUnit = null;
try{
IFile file = (IFile) workbenchPart.getSite().getPage().getActiveEditor().getEditorInput().getAdapter(IFile.class);
IcUnit = (ICompilationUnit) JavaCore.create(file);
}catch(Exception e) {
System.err.println("Debe tener una clase abierta");
return null;
}
try {
createAST(IcUnit);

//poner en un "main"
JDIDebugModel.addJavaBreakpointListener(new DebugListener());

}catch(JavaModelException exeption){}

return null;
}

private void createAST(ICompilationUnit IcUnit)
throws JavaModelException {

CompilationUnit parse = parse(IcUnit);
ASTStorage.setCompUnit(parse);
MethodVisitor visitor = new MethodVisitor();
parse.accept(visitor);

}

/**
* Reads a ICompilationUnit and creates the AST DOM for manipulating the
* Java source file
*
* @param unit
* @return
*/

public static CompilationUnit parse(ICompilationUnit unit) {
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(unit);
parser.setResolveBindings(true);

return (CompilationUnit) parser.createAST(null); // parse
}



}
package org.tec.datos1.flow;


import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.tec.datos1.flow.handlers.MethodVisitor;
import org.tec.datos1.flow.storage.ASTStorage;


public class CodeParser {

/**
* Este método se encarga de parsear el código de la
* clase abierta en el instante que se llama el método
* @throws ExecutionException
*/
public static void execute() throws ExecutionException {
if (ASTStorage.getRoot() != null){
ASTStorage.getRoot().deleteChildren();
}
IWorkbenchPart workbenchPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
ICompilationUnit IcUnit = null;

try{
IFile file = (IFile) workbenchPart.getSite().getPage().getActiveEditor().getEditorInput().getAdapter(IFile.class);
IcUnit = (ICompilationUnit) JavaCore.create(file);
}catch(Exception e) {
System.err.println("Debe tener una clase abierta");
}
try {

createAST(IcUnit);

}catch(JavaModelException exeption){}

}

/**
* Este método se encarga de parsear el código de la
* clase abierta en el instante que se llama el método
* @throws ExecutionException
*/
public static void executeSpecific(ICompilationUnit unit ) throws ExecutionException {
if (ASTStorage.getRoot() != null){
ASTStorage.getRoot().deleteChildren();
}
try {
createAST(unit);
} catch (JavaModelException e) {
e.printStackTrace();
}
}

/**
* Crea el arbol AST
* @param IcUnit Clase que se va a analizar
* @throws JavaModelException
*/
private static void createAST(ICompilationUnit IcUnit) throws JavaModelException {

CompilationUnit parse = parse(IcUnit);
ASTStorage.setCompUnit(parse);
MethodVisitor visitor = new MethodVisitor();
parse.accept(visitor);

}


/**
* Reads a ICompilationUnit and creates the AST DOM for manipulating the
* Java source file
*
* @param unit
* @return
*/

public static CompilationUnit parse(ICompilationUnit unit) {
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(unit);
parser.setResolveBindings(true);

return (CompilationUnit) parser.createAST(null); // parse
}



}
Loading