Example usage for org.eclipse.jdt.core.compiler BuildContext getContents

List of usage examples for org.eclipse.jdt.core.compiler BuildContext getContents

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.compiler BuildContext getContents.

Prototype

public char[] getContents() 

Source Link

Document

Returns the contents of the compilation unit.

Usage

From source file:org.eclipse.swt.tools.builders.Check64CompilationParticipant.java

License:Open Source License

@Override
public void buildStarting(BuildContext[] files, boolean isBatch) {
    if (sources == null)
        sources = new HashSet<String>();
    //   long time = System.currentTimeMillis();
    for (int i = 0; i < files.length; i++) {
        BuildContext context = files[i];
        IFile file = context.getFile();/*ww  w . ja v  a 2  s. com*/
        IProject project = file.getProject();
        Path path = new Path(buildDir + file.getProjectRelativePath().toPortableString());
        IFile newFile = project.getFile(path);
        sources.add(newFile.getLocation().toPortableString());
        try {
            if (newFile.exists()) {
                newFile.delete(true, null);
            }
            create(newFile.getParent());
            char[] source = context.getContents();
            replace(source);
            newFile.create(new ByteArrayInputStream(new String(source).getBytes()), true, null);
        } catch (CoreException e) {
            e.printStackTrace();
        }
    }
    //   System.out.println("copying time=" + (System.currentTimeMillis() - time));   
}