当前位置: 首页>>代码示例>>Java>>正文


Java FilerException类代码示例

本文整理汇总了Java中javax.annotation.processing.FilerException的典型用法代码示例。如果您正苦于以下问题:Java FilerException类的具体用法?Java FilerException怎么用?Java FilerException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FilerException类属于javax.annotation.processing包,在下文中一共展示了FilerException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openBinary

import javax.annotation.processing.FilerException; //导入依赖的package包/类
@Override
public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
    String qualifiedClassName = toQualifiedClassName(pkg, fileName);

    try {
        JavaFileObject sourceFile;

        sourceFile = filer.createSourceFile(qualifiedClassName, mElements);

        return sourceFile.openOutputStream();
    } catch (FilerException e) {
        /*
* This exception is expected, when some files are created twice. We
* cannot delete existing files, unless using a dirty hack. Files a
* created twice when the same file is created from different
* annotation rounds. Happens when renaming classes, and for
* Background executor. It also probably means I didn't fully
* understand how annotation processing works. If anyone can point
* me out...
*/
        return VOID_OUTPUT_STREAM;
    }
}
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:24,代码来源:SourceCodeWriter.java

示例2: getResource

import javax.annotation.processing.FilerException; //导入依赖的package包/类
@Override
public FileObject getResource(Location location, CharSequence pkg,
		CharSequence relativeName) throws IOException {
	validateName(relativeName);
	FileObject fo = _fileManager.getFileForInput(
			location, pkg.toString(), relativeName.toString());
	if (fo == null) {
		throw new FileNotFoundException("Resource does not exist : " + location + '/' + pkg + '/' + relativeName); //$NON-NLS-1$
	}
	URI uri = fo.toUri();
	if (_createdFiles.contains(uri)) {
		throw new FilerException("Resource already created : " + location + '/' + pkg + '/' + relativeName); //$NON-NLS-1$
	}

	_createdFiles.add(uri);
	return fo;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:BatchFilerImpl.java

示例3: loadImage

import javax.annotation.processing.FilerException; //导入依赖的package包/类
public Image loadImage(String filename, boolean createByteBuffer) {
	logger.info("Loading: " + filename);
	Image image = new Image();
	
	try {	
		BufferedImage bi = ImageIO.read(FileSystem.getStream(filename));

		if (bi != null && bi.getColorModel() != null) {
			image.format = bi.getColorModel().hasAlpha() ? GL_RGBA : GL_RGB;
			image.data = createByteBuffer(bi);
			image.image = bi;
		} else {
			throw new FilerException(filename);
		}

	} catch (Exception e) {
		logger.warn("Failed to load image: " + e.getMessage());
		return noImage;
	}

	return image;
}
 
开发者ID:Axodoss,项目名称:Wicken,代码行数:23,代码来源:ImageLoader.java

示例4: createSourceFile

import javax.annotation.processing.FilerException; //导入依赖的package包/类
@Override
public JavaFileObject createSourceFile(CharSequence name, Element... originatingElements) throws IOException {
  JavaFileObject sourceFile = fileManager.getJavaFileForOutput(StandardLocation.SOURCE_OUTPUT, name.toString(), JavaFileObject.Kind.SOURCE, null);
  if (!createdResources.add(sourceFile.toUri())) {
    throw new FilerException("Attempt to recreate file for type " + name);
  }
  return new JavaFileObjectImpl(sourceFile, new FileObjectDelegate() {

    private boolean closed = false;

    @Override
    protected void onClose(Output<File> generatedSource) {
      if (!closed) {
        closed = true;
        // TODO optimize if the regenerated sources didn't change compared the previous build
        CompilationUnit unit = new CompilationUnit(null, generatedSource.getResource().getAbsolutePath(), null /* encoding */);
        processingEnv.addNewUnit(unit);
        incrementalCompiler.addGeneratedSource(generatedSource);
      }
    }
  });
}
 
开发者ID:takari,项目名称:takari-lifecycle,代码行数:23,代码来源:FilerImpl.java

示例5: testRecreateSourceFile

import javax.annotation.processing.FilerException; //导入依赖的package包/类
@Test
public void testRecreateSourceFile() throws Exception {
  EclipseFileManager fileManager = new EclipseFileManager(null, Charsets.UTF_8);

  File outputDir = temp.newFolder();
  fileManager.setLocation(StandardLocation.SOURCE_OUTPUT, Collections.singleton(outputDir));

  FilerImpl filer = new FilerImpl(null /* context */, fileManager, null /* compiler */, null /* env */);

  filer.createSourceFile("test.Source");
  try {
    filer.createSourceFile("test.Source");
    Assert.fail();
  } catch (FilerException expected) {
    // From Filer javadoc:
    // @throws FilerException if the same pathname has already been
    // created, the same type has already been created, or the name is
    // not valid for a type
  }
}
 
开发者ID:takari,项目名称:takari-lifecycle,代码行数:21,代码来源:FilerImplTest.java

示例6: checkName

import javax.annotation.processing.FilerException; //导入依赖的package包/类
private void checkName(String name, boolean allowUnnamedPackageInfo) throws FilerException {
    if (!SourceVersion.isName(name) && !isPackageInfo(name, allowUnnamedPackageInfo)) {
        if (lint)
            log.warning("proc.illegal.file.name", name);
        throw new FilerException("Illegal name " + name);
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:8,代码来源:JavacFiler.java

示例7: checkNameAndExistence

import javax.annotation.processing.FilerException; //导入依赖的package包/类
private void checkNameAndExistence(String typename, boolean allowUnnamedPackageInfo) throws FilerException {
    // TODO: Check if type already exists on source or class path?
    // If so, use warning message key proc.type.already.exists
    checkName(typename, allowUnnamedPackageInfo);
    if (aggregateGeneratedSourceNames.contains(typename) ||
        aggregateGeneratedClassNames.contains(typename)) {
        if (lint)
            log.warning("proc.type.recreate", typename);
        throw new FilerException("Attempt to recreate a file for type " + typename);
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:12,代码来源:JavacFiler.java

示例8: checkFileReopening

import javax.annotation.processing.FilerException; //导入依赖的package包/类
/**
 * Check to see if the file has already been opened; if so, throw
 * an exception, otherwise add it to the set of files.
 */
private void checkFileReopening(FileObject fileObject, boolean addToHistory) throws FilerException {
    for(FileObject veteran : fileObjectHistory) {
        if (fileManager.isSameFile(veteran, fileObject)) {
            if (lint)
                log.warning("proc.file.reopening", fileObject.getName());
            throw new FilerException("Attempt to reopen a file for path " + fileObject.getName());
        }
    }
    if (addToHistory)
        fileObjectHistory.add(fileObject);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:16,代码来源:JavacFiler.java

示例9: isBug367599

import javax.annotation.processing.FilerException; //导入依赖的package包/类
/**
 * Determines if a given exception is (most likely) caused by
 * <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=367599">Bug 367599</a>.
 */
public static boolean isBug367599(Throwable t) {
    if (t instanceof FilerException) {
        for (StackTraceElement ste : t.getStackTrace()) {
            if (ste.toString().contains("org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeFilerImpl.create")) {
                // See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=367599
                return true;
            }
        }
    }
    if (t.getCause() != null) {
        return isBug367599(t.getCause());
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:GraphNodeProcessor.java

示例10: isBug367599

import javax.annotation.processing.FilerException; //导入依赖的package包/类
/**
 * Determines if a given exception is (most likely) caused by
 * <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=367599">Bug 367599</a>.
 */
private static boolean isBug367599(Throwable t) {
    if (t instanceof FilerException) {
        for (StackTraceElement ste : t.getStackTrace()) {
            if (ste.toString().contains("org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeFilerImpl.create")) {
                // See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=367599
                return true;
            }
        }
    }
    return t.getCause() != null && isBug367599(t.getCause());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:ServiceProviderProcessor.java

示例11: generateFromClazz

import javax.annotation.processing.FilerException; //导入依赖的package包/类
/**
 * Generates a source file from the specified {@link io.sundr.codegen.model.TypeDef}.
 * @param model                     The model of the class to generate.
 * @param resourceName              The template to use.
 * @throws IOException
 */
public void generateFromClazz(TypeDef model, String resourceName) throws IOException {
    try {
        generateFromClazz(model, processingEnv
                .getFiler()
                .createSourceFile(model.getFullyQualifiedName()), resourceName);
    } catch (FilerException e) {
        //TODO: Need to avoid dublicate interfaces here.
    }
}
 
开发者ID:sundrio,项目名称:sundrio,代码行数:16,代码来源:JavaGeneratingProcessor.java

示例12: createClassFile

import javax.annotation.processing.FilerException; //导入依赖的package包/类
@Override
public JavaFileObject createClassFile(CharSequence name,
		Element... originatingElements) throws IOException {
	JavaFileObject jfo = _fileManager.getJavaFileForOutput(
			StandardLocation.CLASS_OUTPUT, name.toString(), JavaFileObject.Kind.CLASS, null);
	URI uri = jfo.toUri();
	if (_createdFiles.contains(uri)) {
		throw new FilerException("Class file already created : " + name); //$NON-NLS-1$
	}

	_createdFiles.add(uri);
	return new HookedJavaFileObject(jfo, jfo.getName(), name.toString(), this);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:BatchFilerImpl.java

示例13: createResource

import javax.annotation.processing.FilerException; //导入依赖的package包/类
@Override
public FileObject createResource(Location location, CharSequence pkg,
		CharSequence relativeName, Element... originatingElements)
		throws IOException {
	validateName(relativeName);
	FileObject fo = _fileManager.getFileForOutput(
			location, pkg.toString(), relativeName.toString(), null);
	URI uri = fo.toUri();
	if (_createdFiles.contains(uri)) {
		throw new FilerException("Resource already created : " + location + '/' + pkg + '/' + relativeName); //$NON-NLS-1$
	}

	_createdFiles.add(uri);
	return fo;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:BatchFilerImpl.java

示例14: createSourceFile

import javax.annotation.processing.FilerException; //导入依赖的package包/类
@Override
public JavaFileObject createSourceFile(CharSequence name,
		Element... originatingElements) throws IOException {
	JavaFileObject jfo = _fileManager.getJavaFileForOutput(
			StandardLocation.SOURCE_OUTPUT, name.toString(), JavaFileObject.Kind.SOURCE, null);
	URI uri = jfo.toUri();
	if (_createdFiles.contains(uri)) {
		throw new FilerException("Source file already created : " + name); //$NON-NLS-1$
	}

	_createdFiles.add(uri);
	// hook the file object's writers to create compilation unit and add to addedUnits()
	return new HookedJavaFileObject(jfo, jfo.getName(), name.toString(), this);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:BatchFilerImpl.java

示例15: createClassFile

import javax.annotation.processing.FilerException; //导入依赖的package包/类
@Override
public JavaFileObject createClassFile(CharSequence name,
		Element... originatingElements) throws IOException {
	JavaFileObject jfo = _fileManager.getJavaFileForOutput(
			StandardLocation.CLASS_OUTPUT, name.toString(), JavaFileObject.Kind.CLASS, null);
	URI uri = jfo.toUri();
	if (_createdFiles.contains(uri)) {
		throw new FilerException("Class file already created : " + name); //$NON-NLS-1$
	}

	_createdFiles.add(uri);
	return new HookedJavaFileObject(jfo, jfo.getName(), this);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:14,代码来源:BatchFilerImpl.java


注:本文中的javax.annotation.processing.FilerException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。