Java Code Examples for javax.tools.JavaFileObject.Kind#OTHER

The following examples show how to use javax.tools.JavaFileObject.Kind#OTHER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseFileManager.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static Kind getKind(String name) {
    if (name.endsWith(Kind.CLASS.extension))
        return Kind.CLASS;
    else if (name.endsWith(Kind.SOURCE.extension))
        return Kind.SOURCE;
    else if (name.endsWith(Kind.HTML.extension))
        return Kind.HTML;
    else
        return Kind.OTHER;
}
 
Example 2
Source File: JavaFileObjects.java    From compile-testing with Apache License 2.0 5 votes vote down vote up
static Kind deduceKind(URI uri) {
  String path = uri.getPath();
  for (Kind kind : Kind.values()) {
    if (path.endsWith(kind.extension)) {
      return kind;
    }
  }
  return Kind.OTHER;
}
 
Example 3
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Kind getKind(String extension) {
	if (Kind.CLASS.extension.equals(extension)) {
		return Kind.CLASS;
	} else if (Kind.SOURCE.extension.equals(extension)) {
		return Kind.SOURCE;
	} else if (Kind.HTML.extension.equals(extension)) {
		return Kind.HTML;
	}
	return Kind.OTHER;
}
 
Example 4
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Kind getKind(String extension) {
	if (Kind.CLASS.extension.equals(extension)) {
		return Kind.CLASS;
	} else if (Kind.SOURCE.extension.equals(extension)) {
		return Kind.SOURCE;
	} else if (Kind.HTML.extension.equals(extension)) {
		return Kind.HTML;
	}
	return Kind.OTHER;
}
 
Example 5
Source File: FormattingFilerTest.java    From google-java-format with Apache License 2.0 5 votes vote down vote up
@Override
public FileObject createResource(
    Location location,
    CharSequence pkg,
    CharSequence relativeName,
    Element... originatingElements)
    throws IOException {
  return new ObservingJavaFileObject(pkg.toString() + relativeName, Kind.OTHER);
}
 
Example 6
Source File: InMemoryJavaFileManager.java    From Akatsuki with Apache License 2.0 5 votes vote down vote up
static Kind deduceKind(URI uri) {
	String path = uri.getPath();
	for (Kind kind : Kind.values()) {
		if (path.endsWith(kind.extension)) {
			return kind;
		}
	}
	return Kind.OTHER;
}
 
Example 7
Source File: BaseFileManager.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static Kind getKind(String name) {
    if (name.endsWith(Kind.CLASS.extension))
        return Kind.CLASS;
    else if (name.endsWith(Kind.SOURCE.extension))
        return Kind.SOURCE;
    else if (name.endsWith(Kind.HTML.extension))
        return Kind.HTML;
    else
        return Kind.OTHER;
}
 
Example 8
Source File: BaseFileManager.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static Kind getKind(String name) {
    if (name.endsWith(Kind.CLASS.extension))
        return Kind.CLASS;
    else if (name.endsWith(Kind.SOURCE.extension))
        return Kind.SOURCE;
    else if (name.endsWith(Kind.HTML.extension))
        return Kind.HTML;
    else
        return Kind.OTHER;
}
 
Example 9
Source File: BaseFileManager.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static Kind getKind(String name) {
    if (name.endsWith(Kind.CLASS.extension))
        return Kind.CLASS;
    else if (name.endsWith(Kind.SOURCE.extension))
        return Kind.SOURCE;
    else if (name.endsWith(Kind.HTML.extension))
        return Kind.HTML;
    else
        return Kind.OTHER;
}
 
Example 10
Source File: BaseFileManager.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static Kind getKind(String name) {
    if (name.endsWith(Kind.CLASS.extension))
        return Kind.CLASS;
    else if (name.endsWith(Kind.SOURCE.extension))
        return Kind.SOURCE;
    else if (name.endsWith(Kind.HTML.extension))
        return Kind.HTML;
    else
        return Kind.OTHER;
}
 
Example 11
Source File: BaseFileManager.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public static Kind getKind(String name) {
    if (name.endsWith(Kind.CLASS.extension))
        return Kind.CLASS;
    else if (name.endsWith(Kind.SOURCE.extension))
        return Kind.SOURCE;
    else if (name.endsWith(Kind.HTML.extension))
        return Kind.HTML;
    else
        return Kind.OTHER;
}
 
Example 12
Source File: BaseFileManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static Kind getKind(String name) {
    if (name.endsWith(Kind.CLASS.extension))
        return Kind.CLASS;
    else if (name.endsWith(Kind.SOURCE.extension))
        return Kind.SOURCE;
    else if (name.endsWith(Kind.HTML.extension))
        return Kind.HTML;
    else
        return Kind.OTHER;
}
 
Example 13
Source File: BaseFileManager.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Kind getKind(String name) {
    if (name.endsWith(Kind.CLASS.extension))
        return Kind.CLASS;
    else if (name.endsWith(Kind.SOURCE.extension))
        return Kind.SOURCE;
    else if (name.endsWith(Kind.HTML.extension))
        return Kind.HTML;
    else
        return Kind.OTHER;
}
 
Example 14
Source File: BaseFileManager.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static Kind getKind(String name) {
    if (name.endsWith(Kind.CLASS.extension))
        return Kind.CLASS;
    else if (name.endsWith(Kind.SOURCE.extension))
        return Kind.SOURCE;
    else if (name.endsWith(Kind.HTML.extension))
        return Kind.HTML;
    else
        return Kind.OTHER;
}
 
Example 15
Source File: BaseFileManager.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public static Kind getKind(String name) {
    if (name.endsWith(Kind.CLASS.extension))
        return Kind.CLASS;
    else if (name.endsWith(Kind.SOURCE.extension))
        return Kind.SOURCE;
    else if (name.endsWith(Kind.HTML.extension))
        return Kind.HTML;
    else
        return Kind.OTHER;
}
 
Example 16
Source File: BaseFileManager.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static Kind getKind(String name) {
    if (name.endsWith(Kind.CLASS.extension))
        return Kind.CLASS;
    else if (name.endsWith(Kind.SOURCE.extension))
        return Kind.SOURCE;
    else if (name.endsWith(Kind.HTML.extension))
        return Kind.HTML;
    else
        return Kind.OTHER;
}
 
Example 17
Source File: FormattingFilerTest.java    From google-java-format with Apache License 2.0 4 votes vote down vote up
@Override
public FileObject getResource(Location location, CharSequence pkg, CharSequence relativeName)
    throws IOException {
  return new ObservingJavaFileObject(pkg.toString() + relativeName, Kind.OTHER);
}
 
Example 18
Source File: TestingJavaFileManager.java    From doma with Apache License 2.0 4 votes vote down vote up
@Override
public FileObject getFileForOutput(
    final Location location,
    final String packageName,
    final String relativeName,
    final FileObject sibling)
    throws IOException {
  if (relativeName.endsWith(".java")) {
    return getJavaFileForOutput(location, packageName + "." + relativeName, Kind.SOURCE, sibling);
  }
  if (relativeName.endsWith(".class")) {
    return getJavaFileForOutput(location, packageName + "." + relativeName, Kind.CLASS, sibling);
  }
  final String key = createKey(packageName, relativeName);
  if (fileObjects.containsKey(key)) {
    return fileObjects.get(key);
  }

  byte[] content = null;
  URI uri = null;
  try {
    FileObject originalFileObject = null;
    if (location == StandardLocation.CLASS_OUTPUT) {
      // Because resources are not copied to the CLASS_OUTPUT in the Aptina Unit environment, we
      // read
      // them from SOURCE_PATH first
      originalFileObject =
          super.getFileForInput(StandardLocation.SOURCE_PATH, packageName, relativeName);
    }
    if (originalFileObject == null) {
      originalFileObject = super.getFileForOutput(location, packageName, relativeName, sibling);
    }
    uri = originalFileObject.toUri();
    content = IOUtils.readBytes(originalFileObject.openInputStream());
  } catch (final FileNotFoundException ignore) {
  }
  final InMemoryJavaFileObject fileObject =
      new InMemoryJavaFileObject(
          uri != null ? uri : toURI(location, packageName, relativeName),
          Kind.OTHER,
          charset,
          content);
  fileObjects.put(key, fileObject);
  return fileObject;
}