Package javax.tools

Examples of javax.tools.JavaFileObject.toUri()


          // Best effort to get a java.io.File
          JavaFileObject obj = diagnostic.getSource();
          String source = null;
          File resolvedFile = null;
          if (obj != null) {
            URI uri = obj.toUri();
            source = uri.getPath();
            if (obj instanceof JavaFileObjectImpl) {
              JavaFileObjectImpl foo = (JavaFileObjectImpl)obj;
              try {
                resolvedFile = foo.getFile();
View Full Code Here


            if (path != null) {
              Method getCompilationUnitMethod = path.getClass().getMethod("getCompilationUnit");
              Object cu = getCompilationUnitMethod.invoke(path);
              Method getSourceFileMethod = cu.getClass().getMethod("getSourceFile");
              JavaFileObject file = (JavaFileObject)getSourceFileMethod.invoke(cu);
              URI uri = file.toUri();
              log.info("Resolved uri " + uri + " for package " + context.getPackageName());
              File f = new File(uri.getPath());
              if (f.exists() && f.isFile()) {
                File dir = f.getParentFile().getParentFile();
                javax.lang.model.element.Name name = element.getQualifiedName();
View Full Code Here

@RunWith(JUnit4.class)
public class JavaFileObjectsTest {
  @Test public void forResource_inJarFile() throws URISyntaxException, IOException {
    JavaFileObject resourceInJar = JavaFileObjects.forResource("java/lang/Object.class");
    assertThat(resourceInJar.getKind()).isEqualTo(CLASS);
    assertThat(resourceInJar.toUri()).isEqualTo(URI.create("/java/lang/Object.class"));
    assertThat(resourceInJar.getName())
        .isEqualTo(Resources.getResource("java/lang/Object.class").toString());
    assertThat(resourceInJar.isNameCompatible("Object", CLASS)).isTrue();
  }
View Full Code Here

                column += 1; // make it 1-based, like line numbers
            JavaFileObject source = diagnostic.getSource();
            File file = null;
            if(source != null) {
                try {
                    file = new File(source.toUri());
                } catch (IllegalArgumentException ignore) {
                    // An entry in a zip file that is not hierarchical
                }
            }
            switch(kind){
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.