Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.CompilationUnit


    "}" +
    "class Outer { }";
 
  @Test
  public void testInner() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("Outer", INNER);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    ClassInstanceCreation instance = (ClassInstanceCreation) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(instance);
    Assert.assertTrue(instr != null);
View Full Code Here


    "    }" +
    "}";
 
  @Test
  public void testExplicitInner() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("OuterExplicit", EXPLICIT_INNER);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    ClassInstanceCreation instance = (ClassInstanceCreation) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(instance);
    Assert.assertTrue(instr != null);
View Full Code Here

    "    }" +
    "}";
 
  @Test
  public void testStaticInner() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("OuterStaticInner", STATIC_INNER);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    ClassInstanceCreation instance = (ClassInstanceCreation) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(instance);
    Assert.assertTrue(instr != null);
View Full Code Here

    "    }" +
    "}";
 
  @Test
  public void testLocal() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("OuterLocal", LOCAL);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    ClassInstanceCreation instance = (ClassInstanceCreation) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(instance);
    Assert.assertTrue(instr != null);
View Full Code Here

    "    }" +
    "}";
 
  @Test
  public void testAnonymous() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("OuterAnon", ANON);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    ClassInstanceCreation instance = (ClassInstanceCreation) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(instance);
    Assert.assertTrue(instr != null);
View Full Code Here

            }
            if (logger.isLoggable(Level.FINE))
              logger.fine("Running Crystal on: " + cu.getResource().getLocation().toOSString());
           
            // Run each analysis on the current compilation unit.
            CompilationUnit ast_comp_unit =
                (CompilationUnit) WorkspaceUtilities.getASTNodeFromCompilationUnit(cu);

            // Here, create one TAC cache per compilation unit.
            final CompilationUnitTACs compUnitTacs = new CompilationUnitTACs();
View Full Code Here

   * @return <code>true</code> if the given node hits a breakpoint, <code>false</code> otherwise.
   */
  protected final boolean checkBreakpoint(ASTNode node) {
    if(node == null)
      return false;
    final CompilationUnit compUnit = (CompilationUnit) node.getRoot();
    int nodeLine = compUnit.getLineNumber(node.getStartPosition());
    if(nodeLine < 0 || lastLine == nodeLine)
      // error getting the line number or last AST node seen was on the same line
      // no need to check/break again
      return false;
    lastLine = nodeLine;
    IResource r = compUnit.getJavaElement().getResource();
    try {
      // TODO Increase efficiency by filtering markers inside analyzed method up-front
      for(IMarker m : r.findMarkers(IBreakpoint.BREAKPOINT_MARKER, true, IResource.DEPTH_INFINITE)) {
        // see if one of the breakpoint markers for the analyzed resource is on the node's line
        if(((Integer) m.getAttribute(IMarker.LINE_NUMBER, 0)) == nodeLine) {
View Full Code Here

    return (Statement) stmts.get(stmts.size()-1);
  }
 
  public static CompilationUnit parseCode(String qualifiedCompUnitName, String code) throws CoreException {
    ASTParser parser = ASTParser.newParser(AST.JLS3);
    CompilationUnit node;
   
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("CrystalTest");
    project.open(null /* IProgressMonitor */);
   
    IJavaProject javaProject = JavaCore.create(project);

    parser.setKind(ASTParser.K_COMPILATION_UNIT);
    parser.setProject(javaProject);
    parser.setSource(code.toCharArray());
    parser.setUnitName("/CrystalTest/" + qualifiedCompUnitName);
    parser.setResolveBindings(true);
    node = (CompilationUnit) parser.createAST(null);
   
    Message[] msgs = node.getMessages();
    if(msgs.length > 0) {
      StringBuffer errs = new StringBuffer();
      errs.append("Compiler problems for ");
      errs.append(qualifiedCompUnitName);
      for(Message m : msgs) {
View Full Code Here

*/
public class EclipseTACFieldTest {

  @Test
  public void testReadField() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("FieldRead", FIELD_READ);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    Expression read = (Expression) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(read);
    Assert.assertTrue(instr != null);
View Full Code Here

    "    }" +
    "}";
 
  @Test
  public void testReadThis() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("ThisRead", THIS_READ);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    FieldAccess read = (FieldAccess) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(read);
    Assert.assertTrue(instr != null);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.CompilationUnit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.