unused files
authorLukas Jungmann <jungi@netbeans.org>
Tue, 03 Jan 2012 23:07:38 +0100
changeset 1773075a602db53b1
parent 17729 7b3b96bba65e
child 17731 191d7139f1a0
unused files
testng/src/org/netbeans/modules/contrib/testng/output/TestClassScanner.java
testng/test/unit/src/org/netbeans/modules/contrib/testng/output/TestClassScannerTest.java
     1.1 --- a/testng/src/org/netbeans/modules/contrib/testng/output/TestClassScanner.java	Tue Jan 03 23:04:24 2012 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,124 +0,0 @@
     1.4 -/*
     1.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     1.6 - *
     1.7 - * Copyright © 2008-2011 Oracle and/or its affiliates. All rights reserved.
     1.8 - *
     1.9 - * The contents of this file are subject to the terms of either the GNU
    1.10 - * General Public License Version 2 only ("GPL") or the Common
    1.11 - * Development and Distribution License("CDDL") (collectively, the
    1.12 - * "License"). You may not use this file except in compliance with the
    1.13 - * License. You can obtain a copy of the License at
    1.14 - * http://www.netbeans.org/cddl-gplv2.html
    1.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    1.16 - * specific language governing permissions and limitations under the
    1.17 - * License.  When distributing the software, include this License Header
    1.18 - * Notice in each file and include the License file at
    1.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    1.20 - * particular file as subject to the "Classpath" exception as provided
    1.21 - * by Sun in the GPL Version 2 section of the License file that
    1.22 - * accompanied this code. If applicable, add the following below the
    1.23 - * License Header, with the fields enclosed by brackets [] replaced by
    1.24 - * your own identifying information:
    1.25 - * "Portions Copyrighted [year] [name of copyright owner]"
    1.26 - *
    1.27 - * If you wish your version of this file to be governed by only the CDDL
    1.28 - * or only the GPL Version 2, indicate your decision by adding
    1.29 - * "[Contributor] elects to include this software in this distribution
    1.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
    1.31 - * single choice of license, a recipient has the option to distribute
    1.32 - * your version of this file under either the CDDL, the GPL Version 2 or
    1.33 - * to extend the choice of license to its licensees as provided above.
    1.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
    1.35 - * Version 2 license, then the option applies only if the new code is
    1.36 - * made subject to such option by the copyright holder.
    1.37 - *
    1.38 - * Contributor(s):
    1.39 - *
    1.40 - * Portions Copyrighted 2008 Sun Microsystems, Inc.
    1.41 - */
    1.42 -package org.netbeans.modules.contrib.testng.output;
    1.43 -
    1.44 -import com.sun.source.tree.ClassTree;
    1.45 -import com.sun.source.tree.MethodTree;
    1.46 -import com.sun.source.util.TreePathScanner;
    1.47 -import javax.lang.model.element.Element;
    1.48 -import javax.lang.model.element.ElementKind;
    1.49 -import javax.lang.model.element.ExecutableElement;
    1.50 -import javax.lang.model.element.TypeElement;
    1.51 -import org.netbeans.api.java.source.CancellableTask;
    1.52 -import org.netbeans.api.java.source.CompilationController;
    1.53 -import org.netbeans.api.java.source.CompilationInfo;
    1.54 -import org.netbeans.api.java.source.JavaSource.Phase;
    1.55 -
    1.56 -/**
    1.57 - *
    1.58 - * @author lukas
    1.59 - */
    1.60 -final class TestClassScanner implements CancellableTask<CompilationController> {
    1.61 -
    1.62 -    private String className;
    1.63 -    private String methodName;
    1.64 -    private int offset;
    1.65 -
    1.66 -    TestClassScanner(String className, String methodName) {
    1.67 -        assert className != null;
    1.68 -        this.className = className;
    1.69 -        this.methodName = methodName;
    1.70 -    }
    1.71 -
    1.72 -    public void cancel() {
    1.73 -    }
    1.74 -
    1.75 -    public void run(CompilationController controller) throws Exception {
    1.76 -        controller.toPhase(Phase.RESOLVED);
    1.77 -        ClassVisitor cv = methodName != null
    1.78 -                ? new ClassVisitor(controller, ClassVisitor.METHOD, methodName)
    1.79 -                : new ClassVisitor(controller, ClassVisitor.CLASS, className);
    1.80 -        offset = cv.scan(controller.getCompilationUnit(), className)[0];
    1.81 -    }
    1.82 -
    1.83 -    int getOffset() {
    1.84 -        return offset;
    1.85 -    }
    1.86 -
    1.87 -    private class ClassVisitor extends TreePathScanner<int[], String> {
    1.88 -
    1.89 -        static final int CLASS = 0;
    1.90 -        static final int METHOD = 1;
    1.91 -        private CompilationInfo controller;
    1.92 -        private int type;
    1.93 -        String name;
    1.94 -
    1.95 -        public ClassVisitor(CompilationInfo info, int type, String name) {
    1.96 -            this.controller = info;
    1.97 -            this.type = type;
    1.98 -            this.name = name;
    1.99 -        }
   1.100 -
   1.101 -        @Override
   1.102 -        public int[] visitClass(ClassTree node, String p) {
   1.103 -            TypeElement el = (TypeElement) controller.getTrees().getElement(getCurrentPath());
   1.104 -            if (el != null) {
   1.105 -                if (el.getKind() == ElementKind.CLASS) {
   1.106 -                    if (methodName == null) {
   1.107 -                        if (name.equals(el.getSimpleName().toString())) {
   1.108 -                            ClassTree tree = controller.getTrees().getTree(el);
   1.109 -                            return controller.getTreeUtilities().findNameSpan(tree);
   1.110 -                        }
   1.111 -                    } else {
   1.112 -                        for (Element e : el.getEnclosedElements()) {
   1.113 -                            if (e.getKind() == ElementKind.METHOD) {
   1.114 -                                if (name.equals(e.getSimpleName().toString())) {
   1.115 -
   1.116 -                                    MethodTree tree = controller.getTrees().getTree((ExecutableElement) e);
   1.117 -                                    return controller.getTreeUtilities().findNameSpan(tree);
   1.118 -                                }
   1.119 -                            }
   1.120 -                        }
   1.121 -                    }
   1.122 -                }
   1.123 -            }
   1.124 -            return new int[] { -1 };
   1.125 -        }
   1.126 -    }
   1.127 -}
     2.1 --- a/testng/test/unit/src/org/netbeans/modules/contrib/testng/output/TestClassScannerTest.java	Tue Jan 03 23:04:24 2012 +0100
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,68 +0,0 @@
     2.4 -/*
     2.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     2.6 - *
     2.7 - * Copyright © 2008-2011 Oracle and/or its affiliates. All rights reserved.
     2.8 - *
     2.9 - * The contents of this file are subject to the terms of either the GNU
    2.10 - * General Public License Version 2 only ("GPL") or the Common
    2.11 - * Development and Distribution License("CDDL") (collectively, the
    2.12 - * "License"). You may not use this file except in compliance with the
    2.13 - * License. You can obtain a copy of the License at
    2.14 - * http://www.netbeans.org/cddl-gplv2.html
    2.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    2.16 - * specific language governing permissions and limitations under the
    2.17 - * License.  When distributing the software, include this License Header
    2.18 - * Notice in each file and include the License file at
    2.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    2.20 - * particular file as subject to the "Classpath" exception as provided
    2.21 - * by Sun in the GPL Version 2 section of the License file that
    2.22 - * accompanied this code. If applicable, add the following below the
    2.23 - * License Header, with the fields enclosed by brackets [] replaced by
    2.24 - * your own identifying information:
    2.25 - * "Portions Copyrighted [year] [name of copyright owner]"
    2.26 - *
    2.27 - * If you wish your version of this file to be governed by only the CDDL
    2.28 - * or only the GPL Version 2, indicate your decision by adding
    2.29 - * "[Contributor] elects to include this software in this distribution
    2.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
    2.31 - * single choice of license, a recipient has the option to distribute
    2.32 - * your version of this file under either the CDDL, the GPL Version 2 or
    2.33 - * to extend the choice of license to its licensees as provided above.
    2.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
    2.35 - * Version 2 license, then the option applies only if the new code is
    2.36 - * made subject to such option by the copyright holder.
    2.37 - *
    2.38 - * Contributor(s):
    2.39 - *
    2.40 - * Portions Copyrighted 2008 Sun Microsystems, Inc.
    2.41 - */
    2.42 -package org.netbeans.modules.contrib.testng.output;
    2.43 -
    2.44 -import java.io.IOException;
    2.45 -import org.netbeans.api.java.source.JavaSource;
    2.46 -import org.netbeans.modules.contrib.testng.actions.RetoucheTestBase;
    2.47 -
    2.48 -/**
    2.49 - *
    2.50 - * @author lukas
    2.51 - */
    2.52 -public class TestClassScannerTest extends RetoucheTestBase {
    2.53 -
    2.54 -    public TestClassScannerTest(String name) {
    2.55 -        super(name);
    2.56 -    }
    2.57 -
    2.58 -    public void testClass() throws IOException {
    2.59 -        JavaSource src = JavaSource.forFileObject(getTestFO());
    2.60 -        TestClassScanner task = new TestClassScanner("Test", null);
    2.61 -        src.runUserActionTask(task, true);
    2.62 -        assertEquals(34, task.getOffset());
    2.63 -    }
    2.64 -
    2.65 -    public void testMethod() throws IOException {
    2.66 -        JavaSource src = JavaSource.forFileObject(getTestFO());
    2.67 -        TestClassScanner task = new TestClassScanner("Test", "method");
    2.68 -        src.runUserActionTask(task, true);
    2.69 -        assertEquals(67, task.getOffset());
    2.70 -    }
    2.71 -}
    2.72 \ No newline at end of file