diff options
author | Xavier Ducrohet <xav@android.com> | 2011-02-01 14:16:46 -0800 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2011-02-01 14:33:06 -0800 |
commit | f2acae181fdbbf644915cfa0ddd571b24eda440a (patch) | |
tree | e71be4f22a5174f6bdc485c383540067ff8d7400 /eclipse | |
parent | dad5a1712c76cdf5859603b436c1fdc179ccd71b (diff) | |
download | sdk-f2acae181fdbbf644915cfa0ddd571b24eda440a.zip sdk-f2acae181fdbbf644915cfa0ddd571b24eda440a.tar.gz sdk-f2acae181fdbbf644915cfa0ddd571b24eda440a.tar.bz2 |
Make up better class names.
JavaGenerator -> SourceProcessor
GeneratorDeltaVisitor -> SourceChangeHandler
NonJavaFileBundle -> SourceFileData
Change-Id: Idaacbef34007a1af730500d8009241683ee9e37b
Diffstat (limited to 'eclipse')
7 files changed, 151 insertions, 141 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AidlGenerator.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AidlProcessor.java index a3c587f..a4bcbed 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AidlGenerator.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AidlProcessor.java @@ -47,10 +47,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; /** - * A {@link JavaGenerator} for aidl files. + * A {@link SourceProcessor} for aidl files. * */ -public class AidlGenerator extends JavaGenerator { +public class AidlProcessor extends SourceProcessor { private static final String PROPERTY_COMPILE_AIDL = "compileAidl"; //$NON-NLS-1$ @@ -75,7 +75,7 @@ public class AidlGenerator extends JavaGenerator { // "^\\s*interface\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\s*(?:\\{.*)?$"); - public AidlGenerator(IJavaProject javaProject, IFolder genFolder) { + public AidlProcessor(IJavaProject javaProject, IFolder genFolder) { super(javaProject, genFolder); } @@ -136,16 +136,16 @@ public class AidlGenerator extends JavaGenerator { String osSourcePath = sourcePath.toOSString(); // look if we already know the output - NonJavaFileBundle bundle = getBundle(sourceFile); - if (bundle == null) { + SourceFileData data = getFileData(sourceFile); + if (data == null) { IFile javaFile = getAidlOutputFile(sourceFile, true /*createFolders*/, monitor); - bundle = new NonJavaFileBundle(sourceFile, javaFile); - addBundle(bundle); + data = new SourceFileData(sourceFile, javaFile); + addData(data); } // finish to set the command line. command[index] = osSourcePath; - command[index + 1] = bundle.getOutput().getLocation().toOSString(); + command[index + 1] = data.getOutput().getLocation().toOSString(); // launch the process if (execAidl(builder, project, command, sourceFile, verbose) == false) { @@ -159,12 +159,12 @@ public class AidlGenerator extends JavaGenerator { @Override protected void loadOutputAndDependencies() { IProgressMonitor monitor = new NullProgressMonitor(); - Collection<NonJavaFileBundle> bundles = getBundles(); - for (NonJavaFileBundle bundle : bundles) { + Collection<SourceFileData> dataList = getAllFileData(); + for (SourceFileData data : dataList) { try { - IFile javaFile = getAidlOutputFile(bundle.getSourceFile(), + IFile javaFile = getAidlOutputFile(data.getSourceFile(), false /*createFolders*/, monitor); - bundle.setOutputFile(javaFile); + data.setOutputFile(javaFile); } catch (CoreException e) { // ignore, we're not asking to create the folder so this won't happen anyway. } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/RenderScriptGenerator.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/RenderScriptProcessor.java index 458f1b5..28ba66e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/RenderScriptGenerator.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/RenderScriptProcessor.java @@ -51,10 +51,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; /** - * A {@link JavaGenerator} for RenderScript files. + * A {@link SourceProcessor} for RenderScript files. * */ -public class RenderScriptGenerator extends JavaGenerator { +public class RenderScriptProcessor extends SourceProcessor { private static final String PROPERTY_COMPILE_RS = "compileRenderScript"; //$NON-NLS-1$ @@ -63,7 +63,7 @@ public class RenderScriptGenerator extends JavaGenerator { */ private static Pattern sLlvmPattern1 = Pattern.compile("^(.+?):(\\d+):(\\d+):\\s(.+)$"); //$NON-NLS-1$ - private static class RsDeltaVisitor extends GeneratorDeltaVisitor { + private static class RsChangeHandler extends SourceChangeHandler { @Override public boolean handleGeneratedFile(IFile file, int kind) { @@ -73,14 +73,14 @@ public class RenderScriptGenerator extends JavaGenerator { AndroidConstants.EXT_DEP.equalsIgnoreCase(file.getFileExtension())) { // This looks to be an extension file. // For futureproofness let's make sure this dependency file was generated by - // this generator even if it's the only generator using them for now. + // this processor even if it's the only processor using them for now. // look for the original file. // We know we are in the gen folder, so make a path to the dependency file // relative to the gen folder. Convert this into a Renderscript source file, // and look to see if this file exists. - JavaGenerator generator = getGenerator(); - IFolder genFolder = generator.getGenFolder(); + SourceProcessor processor = getProcessor(); + IFolder genFolder = processor.getGenFolder(); IPath relative = file.getFullPath().makeRelativeTo(genFolder.getFullPath()); // remove the file name segment relative = relative.removeLastSegments(1); @@ -90,7 +90,7 @@ public class RenderScriptGenerator extends JavaGenerator { // now look for a match in the source folders. List<IPath> sourceFolders = BaseProjectHelper.getSourceClasspaths( - generator.getJavaProject()); + processor.getJavaProject()); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); for (IPath sourceFolderPath : sourceFolders) { @@ -98,8 +98,8 @@ public class RenderScriptGenerator extends JavaGenerator { // we don't look in the 'gen' source folder as there will be no source in there. if (sourceFolder.exists() && sourceFolder.equals(genFolder) == false) { IFile sourceFile = sourceFolder.getFile(relative); - NonJavaFileBundle bundle = generator.getBundle(sourceFile); - if (bundle != null) { + SourceFileData data = processor.getFileData(sourceFile); + if (data != null) { addFileToCompile(sourceFile); return true; } @@ -116,8 +116,8 @@ public class RenderScriptGenerator extends JavaGenerator { } } - public RenderScriptGenerator(IJavaProject javaProject, IFolder genFolder) { - super(javaProject, genFolder, new RsDeltaVisitor()); + public RenderScriptProcessor(IJavaProject javaProject, IFolder genFolder) { + super(javaProject, genFolder, new RsChangeHandler()); } @Override @@ -185,9 +185,9 @@ public class RenderScriptGenerator extends JavaGenerator { // Remove the RS error markers from the source file and the dependencies builder.removeMarkersFromFile(sourceFile, AndroidConstants.MARKER_RENDERSCRIPT); - NonJavaFileBundle bundle = getBundle(sourceFile); - if (bundle != null) { - for (IFile dep : bundle.getDependencyFiles()) { + SourceFileData data = getFileData(sourceFile); + if (data != null) { + for (IFile dep : data.getDependencyFiles()) { builder.removeMarkersFromFile(dep, AndroidConstants.MARKER_RENDERSCRIPT); } } @@ -358,7 +358,7 @@ public class RenderScriptGenerator extends JavaGenerator { @Override - protected void doRemoveFiles(NonJavaFileBundle bundle) throws CoreException { + protected void doRemoveFiles(SourceFileData bundle) throws CoreException { // call the super implementation, it will remove the output files super.doRemoveFiles(bundle); @@ -371,11 +371,11 @@ public class RenderScriptGenerator extends JavaGenerator { @Override protected void loadOutputAndDependencies() { - Collection<NonJavaFileBundle> bundles = getBundles(); - for (NonJavaFileBundle bundle : bundles) { + Collection<SourceFileData> dataList = getAllFileData(); + for (SourceFileData data : dataList) { // parse the dependency file. If this fails, force compilation of the file. - if (parseDependencyFileFor(bundle.getSourceFile()) == false) { - addFileToCompile(bundle.getSourceFile()); + if (parseDependencyFileFor(data.getSourceFile()) == false) { + addFileToCompile(data.getSourceFile()); } } } @@ -384,12 +384,12 @@ public class RenderScriptGenerator extends JavaGenerator { IFile depFile = getDependencyFileFor(sourceFile); File f = depFile.getLocation().toFile(); if (f.exists()) { - NonJavaFileBundle bundle = getBundle(sourceFile); - if (bundle == null) { - bundle = new NonJavaFileBundle(sourceFile); - addBundle(bundle); + SourceFileData data = getFileData(sourceFile); + if (data == null) { + data = new SourceFileData(sourceFile); + addData(data); } - parseDependencyFile(bundle, f); + parseDependencyFile(data, f); return true; } @@ -420,12 +420,12 @@ public class RenderScriptGenerator extends JavaGenerator { } /** - * Parses the given dependency file and fills the given {@link NonJavaFileBundle} with it. + * Parses the given dependency file and fills the given {@link SourceFileData} with it. * - * @param bundle the bundle to fill. + * @param data the bundle to fill. * @param file the dependency file */ - private void parseDependencyFile(NonJavaFileBundle bundle, File dependencyFile) { + private void parseDependencyFile(SourceFileData data, File dependencyFile) { //contents = file.getContents(); String content = AdtPlugin.readFile(dependencyFile); @@ -460,8 +460,8 @@ public class RenderScriptGenerator extends JavaGenerator { fillList(outputs, outputFiles); fillList(dependencies, dependencyFiles); - bundle.setOutputFiles(outputFiles); - bundle.setDependencyFiles(dependencyFiles); + data.setOutputFiles(outputFiles); + data.setDependencyFiles(dependencyFiles); } private void fillList(String[] paths, List<IFile> list) { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/GeneratorDeltaVisitor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/SourceChangeHandler.java index 01cd13e..537dd61 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/GeneratorDeltaVisitor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/SourceChangeHandler.java @@ -19,28 +19,25 @@ package com.android.ide.eclipse.adt.internal.build; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; import java.util.HashSet; import java.util.Set; /** - * Base delta visitor for the Java generator classes. + * Base source change handler for the {@link SourceProcessor} classes. * - * It can be used as is, as long as the matching {@link JavaGenerator} properly implements - * its abstract methods, and the generator does not output resource files, + * It can be used as is, as long as the matching {@link SourceProcessor} properly implements + * its abstract methods, and the processor does not output resource files, * or can be extended to provide custom implementation for: * {@link #handleSourceFile(IFile, int)} * {@link #handleGeneratedFile(IFile, int)} * {@link #handleResourceFile(IFile, int)} * {@link #filterResourceFolder(IContainer)} * - * Note that this is not actually a {@link IResourceDeltaVisitor}, it's meant to be used by - * PreCompilerDeltaVisitor */ -public class GeneratorDeltaVisitor { +public class SourceChangeHandler { - private JavaGenerator mGenerator; + private SourceProcessor mProcessor; /** List of source files found that are modified or new. */ private final Set<IFile> mToCompile = new HashSet<IFile>(); @@ -50,7 +47,7 @@ public class GeneratorDeltaVisitor { public boolean handleGeneratedFile(IFile file, int kind) { if (kind == IResourceDelta.REMOVED || kind == IResourceDelta.CHANGED) { - IFile sourceFile = mGenerator.isOutput(file); + IFile sourceFile = mProcessor.isOutput(file); if (sourceFile != null) { mToCompile.add(sourceFile); return true; @@ -61,8 +58,8 @@ public class GeneratorDeltaVisitor { } public void handleSourceFile(IFile file, int kind) { - // first the file itself if this is a match for the generator's extension - if (mGenerator.getExtension().equals(file.getFileExtension())) { + // first the file itself if this is a match for the processor's extension + if (mProcessor.getExtension().equals(file.getFileExtension())) { if (kind == IResourceDelta.REMOVED) { mRemoved.add(file); } else { @@ -72,7 +69,7 @@ public class GeneratorDeltaVisitor { // now the dependencies. In all case we compile the files that depend on the // added/changed/removed file. - mToCompile.addAll(mGenerator.isDependency(file)); + mToCompile.addAll(mProcessor.isDependency(file)); } public void handleResourceFile(IFile file, int kind) { @@ -111,11 +108,11 @@ public class GeneratorDeltaVisitor { mRemoved.clear(); } - protected JavaGenerator getGenerator() { - return mGenerator; + protected SourceProcessor getProcessor() { + return mProcessor; } - void init(JavaGenerator generator) { - mGenerator = generator; + void init(SourceProcessor processor) { + mProcessor = processor; } } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/NonJavaFileBundle.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/SourceFileData.java index fe071fb..1b6d3fb 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/NonJavaFileBundle.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/SourceFileData.java @@ -23,21 +23,21 @@ import java.util.Collections; import java.util.List; /** - * Data bundle for a given non-java source file. It contains a list of output files and a list + * Data for Android-specific source files. It contains a list of output files and a list * of dependencies. * The source file itself is a implied dependency and is not meant to be in the dependency list. */ -public class NonJavaFileBundle { +public class SourceFileData { private final IFile mSourceFile; private final List<IFile> mOutputFiles = new ArrayList<IFile>(); private final List<IFile> mDependencyFiles = new ArrayList<IFile>(); - public NonJavaFileBundle(IFile sourceFile) { + public SourceFileData(IFile sourceFile) { this(sourceFile, null, null); } - public NonJavaFileBundle(IFile sourceFile, + SourceFileData(IFile sourceFile, List<IFile> outputFiles, List<IFile> dependencyFiles) { mSourceFile = sourceFile; if (outputFiles != null) { @@ -48,40 +48,56 @@ public class NonJavaFileBundle { } } - public NonJavaFileBundle(IFile sourceFile, IFile outputFile) { + SourceFileData(IFile sourceFile, IFile outputFile) { mSourceFile = sourceFile; if (outputFile != null) { mOutputFiles.add(outputFile); } } + /** + * Returns the source file as an {@link IFile} + */ public IFile getSourceFile() { return mSourceFile; } + /** + * Returns whether the given file is a dependency for this source file. + * <p/>Note that the source file itself is not tested against. Therefore if + * {@code file.equals(getSourceFile()} returns {@code true}, this method will return + * {@code false}. + * @param file the file to check against + * @return true if the given file is a dependency for this source file. + */ public boolean dependsOn(IFile file) { return mDependencyFiles.contains(file); } + /** + * Returns whether the given file is an ouput of this source file. + * @param file the file to test. + * @return true if the file is an output file. + */ public boolean generated(IFile file) { return mOutputFiles.contains(file); } - public void setOutputFiles(List<IFile> outputFiles) { + void setOutputFiles(List<IFile> outputFiles) { mOutputFiles.clear(); if (outputFiles != null) { mOutputFiles.addAll(outputFiles); } } - public void setOutputFile(IFile outputFile) { + void setOutputFile(IFile outputFile) { mOutputFiles.clear(); if (outputFile != null) { mOutputFiles.add(outputFile); } } - public void setDependencyFiles(List<IFile> depFiles) { + void setDependencyFiles(List<IFile> depFiles) { mDependencyFiles.clear(); if (depFiles != null) { mDependencyFiles.addAll(depFiles); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/JavaGenerator.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/SourceProcessor.java index 9e38031..d08cdc5 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/JavaGenerator.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/SourceProcessor.java @@ -45,22 +45,19 @@ import java.util.Set; * It provides management for modified source file list, deleted source file list, reconciliation * of previous lists, storing the current state of the build. * - * It also provides a base class for delta visitor that should be customized for each Generator - * extending this class. - * */ -public abstract class JavaGenerator { +public abstract class SourceProcessor { public final static int COMPILE_STATUS_NONE = 0; public final static int COMPILE_STATUS_CODE = 0x1; public final static int COMPILE_STATUS_RES = 0x2; /** List of all source files, their dependencies, and their output. */ - private final Map<IFile, NonJavaFileBundle> mFiles = new HashMap<IFile, NonJavaFileBundle>(); + private final Map<IFile, SourceFileData> mFiles = new HashMap<IFile, SourceFileData>(); private final IJavaProject mJavaProject; private final IFolder mGenFolder; - private final GeneratorDeltaVisitor mDeltaVisitor; + private final SourceChangeHandler mDeltaVisitor; /** List of source files pending compilation at the next build */ private final List<IFile> mToCompile = new ArrayList<IFile>(); @@ -68,8 +65,8 @@ public abstract class JavaGenerator { /** List of removed source files pending cleaning at the next build. */ private final List<IFile> mRemoved = new ArrayList<IFile>(); - protected JavaGenerator(IJavaProject javaProject, IFolder genFolder, - GeneratorDeltaVisitor deltaVisitor) { + protected SourceProcessor(IJavaProject javaProject, IFolder genFolder, + SourceChangeHandler deltaVisitor) { mJavaProject = javaProject; mGenFolder = genFolder; mDeltaVisitor = deltaVisitor; @@ -94,21 +91,21 @@ public abstract class JavaGenerator { } } - protected JavaGenerator(IJavaProject javaProject, IFolder genFolder) { - this(javaProject, genFolder, new GeneratorDeltaVisitor()); + protected SourceProcessor(IJavaProject javaProject, IFolder genFolder) { + this(javaProject, genFolder, new SourceChangeHandler()); } /** - * Returns whether the given file is an output of this generator by return the source + * Returns whether the given file is an output of this processor by return the source * file that generated it. * @param file the file to test. * @return the source file that generated the given file or null. */ IFile isOutput(IFile file) { - for (NonJavaFileBundle bundle : mFiles.values()) { - if (bundle.generated(file)) { - return bundle.getSourceFile(); + for (SourceFileData data : mFiles.values()) { + if (data.generated(file)) { + return data.getSourceFile(); } } @@ -124,28 +121,28 @@ public abstract class JavaGenerator { */ List<IFile> isDependency(IFile file) { ArrayList<IFile> files = new ArrayList<IFile>(); - for (NonJavaFileBundle bundle : mFiles.values()) { - if (bundle.dependsOn(file)) { - files.add(bundle.getSourceFile()); + for (SourceFileData data : mFiles.values()) { + if (data.dependsOn(file)) { + files.add(data.getSourceFile()); } } return files; } - void addBundle(NonJavaFileBundle bundle) { - mFiles.put(bundle.getSourceFile(), bundle); + void addData(SourceFileData data) { + mFiles.put(data.getSourceFile(), data); } - NonJavaFileBundle getBundle(IFile file) { + SourceFileData getFileData(IFile file) { return mFiles.get(file); } - Collection<NonJavaFileBundle> getBundles() { + Collection<SourceFileData> getAllFileData() { return mFiles.values(); } - public final GeneratorDeltaVisitor getDeltaVisitor() { + public final SourceChangeHandler getChangeHandler() { return mDeltaVisitor; } @@ -190,7 +187,7 @@ public abstract class JavaGenerator { } /** - * Returns the extension of the source files handled by this generator. + * Returns the extension of the source files handled by this processor. * @return */ protected abstract String getExtension(); @@ -231,13 +228,13 @@ public abstract class JavaGenerator { // Remove the files created from source files that have been removed. for (IFile sourceFile : mRemoved) { // look if we already know the output - NonJavaFileBundle bundle = getBundle(sourceFile); - if (bundle != null) { - doRemoveFiles(bundle); + SourceFileData data = getFileData(sourceFile); + if (data != null) { + doRemoveFiles(data); } } - // remove the associated bundles. + // remove the associated file data. for (IFile removedFile : mRemoved) { mFiles.remove(removedFile); } @@ -261,13 +258,13 @@ public abstract class JavaGenerator { /** * Returns the type of compilation. It can be any of (in combination too): * <p/> - * {@link #COMPILE_STATUS_CODE} means this generator created source files. - * {@link #COMPILE_STATUS_RES} means this generator created resources. + * {@link #COMPILE_STATUS_CODE} means this processor created source code files. + * {@link #COMPILE_STATUS_RES} means this process created resources. */ protected abstract int getCompilationType(); - protected void doRemoveFiles(NonJavaFileBundle bundle) throws CoreException { - List<IFile> outputFiles = bundle.getOutputFiles(); + protected void doRemoveFiles(SourceFileData data) throws CoreException { + List<IFile> outputFiles = data.getOutputFiles(); for (IFile outputFile : outputFiles) { if (outputFile.exists()) { outputFile.getLocation().toFile().delete(); @@ -346,10 +343,10 @@ public abstract class JavaGenerator { switch (r.getType()) { case IResource.FILE: // if this a file, check that the file actually exist - // and that it's the type of of file that's used in this generator + // and that it's the type of of file that's used in this processor if (r.exists() && getExtension().equalsIgnoreCase(r.getFileExtension())) { - mFiles.put((IFile) r, new NonJavaFileBundle((IFile) r)); + mFiles.put((IFile) r, new SourceFileData((IFile) r)); } break; case IResource.FOLDER: @@ -373,7 +370,7 @@ public abstract class JavaGenerator { * delta visitor * @param visitor the delta visitor. */ - private void mergeFileModifications(GeneratorDeltaVisitor visitor) { + private void mergeFileModifications(SourceChangeHandler visitor) { Set<IFile> toRemove = visitor.getRemovedFiles(); Set<IFile> toCompile = visitor.getFilesToCompile(); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java index 8cd7aa4..5886cff 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java @@ -19,10 +19,10 @@ package com.android.ide.eclipse.adt.internal.build.builders; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AndroidConstants; import com.android.ide.eclipse.adt.internal.build.AaptParser; -import com.android.ide.eclipse.adt.internal.build.AidlGenerator; -import com.android.ide.eclipse.adt.internal.build.JavaGenerator; +import com.android.ide.eclipse.adt.internal.build.AidlProcessor; +import com.android.ide.eclipse.adt.internal.build.SourceProcessor; import com.android.ide.eclipse.adt.internal.build.Messages; -import com.android.ide.eclipse.adt.internal.build.RenderScriptGenerator; +import com.android.ide.eclipse.adt.internal.build.RenderScriptProcessor; import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs; import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.BuildVerbosity; import com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper; @@ -85,7 +85,7 @@ public class PreCompilerBuilder extends BaseBuilder { */ private boolean mMustCompileResources = false; - private final List<JavaGenerator> mGeneratorList = new ArrayList<JavaGenerator>(); + private final List<SourceProcessor> mProcessors = new ArrayList<SourceProcessor>(); /** cache of the java package defined in the manifest */ private String mManifestPackage; @@ -232,8 +232,8 @@ public class PreCompilerBuilder extends BaseBuilder { mMustCompileResources = true; - for (JavaGenerator generator : mGeneratorList) { - generator.prepareFullBuild(project); + for (SourceProcessor processor : mProcessors) { + processor.prepareFullBuild(project); } } else { AdtPlugin.printBuildToConsole(BuildVerbosity.VERBOSE, project, @@ -247,17 +247,17 @@ public class PreCompilerBuilder extends BaseBuilder { if (delta == null) { mMustCompileResources = true; - for (JavaGenerator generator : mGeneratorList) { - generator.prepareFullBuild(project); + for (SourceProcessor processor : mProcessors) { + processor.prepareFullBuild(project); } } else { - dv = new PreCompilerDeltaVisitor(this, sourceFolderPathList, mGeneratorList); + dv = new PreCompilerDeltaVisitor(this, sourceFolderPathList, mProcessors); delta.accept(dv); // record the state mMustCompileResources |= dv.getCompileResources(); - for (JavaGenerator generator : mGeneratorList) { - generator.doneVisiting(project); + for (SourceProcessor processor : mProcessors) { + processor.doneVisiting(project); } // get the java package from the visitor @@ -461,31 +461,31 @@ public class PreCompilerBuilder extends BaseBuilder { // force a clean doClean(project, monitor); mMustCompileResources = true; - for (JavaGenerator generator : mGeneratorList) { - generator.prepareFullBuild(project); + for (SourceProcessor processor : mProcessors) { + processor.prepareFullBuild(project); } saveProjectBooleanProperty(PROPERTY_COMPILE_RESOURCES , mMustCompileResources); } - // run the Java generators - int generatorStatus = JavaGenerator.COMPILE_STATUS_NONE; - for (JavaGenerator generator : mGeneratorList) { + // run the source processors + int processorStatus = SourceProcessor.COMPILE_STATUS_NONE; + for (SourceProcessor processor : mProcessors) { try { - generatorStatus |= generator.compileFiles(this, + processorStatus |= processor.compileFiles(this, project, projectTarget, sourceFolderPathList, monitor); } catch (Throwable t) { } } - // if a generator created some resources file, force recompilation of the resources. - if ((generatorStatus & JavaGenerator.COMPILE_STATUS_RES) != 0) { + // if a processor created some resources file, force recompilation of the resources. + if ((processorStatus & SourceProcessor.COMPILE_STATUS_RES) != 0) { mMustCompileResources = true; // save the current state before attempting the compilation saveProjectBooleanProperty(PROPERTY_COMPILE_RESOURCES , mMustCompileResources); } - // handle the resources, after the java generators are run since some (renderscript) + // handle the resources, after the processors are run since some (renderscript) // generate resources. boolean compiledTheResources = mMustCompileResources; if (mMustCompileResources) { @@ -493,7 +493,7 @@ public class PreCompilerBuilder extends BaseBuilder { saveProjectBooleanProperty(PROPERTY_COMPILE_RESOURCES , false); } - if (generatorStatus == JavaGenerator.COMPILE_STATUS_NONE && + if (processorStatus == SourceProcessor.COMPILE_STATUS_NONE && compiledTheResources == false) { AdtPlugin.printBuildToConsole(BuildVerbosity.VERBOSE, project, Messages.Nothing_To_Compile); @@ -552,11 +552,11 @@ public class PreCompilerBuilder extends BaseBuilder { IJavaProject javaProject = JavaCore.create(project); - // load the java generators - JavaGenerator aidlGenerator = new AidlGenerator(javaProject, mGenFolder); - mGeneratorList.add(aidlGenerator); - JavaGenerator renderScriptGenerator = new RenderScriptGenerator(javaProject, mGenFolder); - mGeneratorList.add(renderScriptGenerator); + // load the source processors + SourceProcessor aidlProcessor = new AidlProcessor(javaProject, mGenFolder); + mProcessors.add(aidlProcessor); + SourceProcessor renderScriptProcessor = new RenderScriptProcessor(javaProject, mGenFolder); + mProcessors.add(renderScriptProcessor); mDerivedProgressMonitor = new DerivedProgressMonitor(mGenFolder); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerDeltaVisitor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerDeltaVisitor.java index f7365e5..6660cd2 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerDeltaVisitor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerDeltaVisitor.java @@ -18,8 +18,8 @@ package com.android.ide.eclipse.adt.internal.build.builders; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AndroidConstants; -import com.android.ide.eclipse.adt.internal.build.GeneratorDeltaVisitor; -import com.android.ide.eclipse.adt.internal.build.JavaGenerator; +import com.android.ide.eclipse.adt.internal.build.SourceChangeHandler; +import com.android.ide.eclipse.adt.internal.build.SourceProcessor; import com.android.ide.eclipse.adt.internal.build.Messages; import com.android.ide.eclipse.adt.internal.build.builders.BaseBuilder.BaseDeltaVisitor; import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.BuildVerbosity; @@ -91,21 +91,21 @@ class PreCompilerDeltaVisitor extends BaseDeltaVisitor implements IResourceDelta private List<IPath> mSourceFolders; private boolean mIsGenSourceFolder = false; - private final List<GeneratorDeltaVisitor> mGeneratorDeltaVisitors = - new ArrayList<GeneratorDeltaVisitor>(); + private final List<SourceChangeHandler> mSourceChangeHandlers = + new ArrayList<SourceChangeHandler>(); private IWorkspaceRoot mRoot; public PreCompilerDeltaVisitor(BaseBuilder builder, List<IPath> sourceFolders, - List<JavaGenerator> generators) { + List<SourceProcessor> processors) { super(builder); mSourceFolders = sourceFolders; mRoot = ResourcesPlugin.getWorkspace().getRoot(); - for (JavaGenerator generator : generators) { - GeneratorDeltaVisitor dv = generator.getDeltaVisitor(); - mGeneratorDeltaVisitors.add(dv); + for (SourceProcessor processor : processors) { + SourceChangeHandler handler = processor.getChangeHandler(); + mSourceChangeHandlers.add(handler); } } @@ -272,11 +272,11 @@ class PreCompilerDeltaVisitor extends BaseDeltaVisitor implements IResourceDelta // we want a warning outputWarning = true; } else { - // look to see if this file was generated by a generator. - for (GeneratorDeltaVisitor dv : mGeneratorDeltaVisitors) { - if (dv.handleGeneratedFile(file, kind)) { + // look to see if this file was generated by a processor. + for (SourceChangeHandler handler : mSourceChangeHandlers) { + if (handler.handleGeneratedFile(file, kind)) { outputWarning = true; - break; // there shouldn't be 2 generators that handle the same file. + break; // there shouldn't be 2 processors that handle the same file. } } } @@ -295,8 +295,8 @@ class PreCompilerDeltaVisitor extends BaseDeltaVisitor implements IResourceDelta } } else { // this is another source folder. - for (GeneratorDeltaVisitor dv : mGeneratorDeltaVisitors) { - dv.handleSourceFile(file, kind); + for (SourceChangeHandler handler : mSourceChangeHandlers) { + handler.handleSourceFile(file, kind); } } @@ -342,8 +342,8 @@ class PreCompilerDeltaVisitor extends BaseDeltaVisitor implements IResourceDelta mBuilder.getProject(), message); } - for (GeneratorDeltaVisitor dv : mGeneratorDeltaVisitors) { - dv.handleResourceFile((IFile)resource, kind); + for (SourceChangeHandler handler : mSourceChangeHandlers) { + handler.handleResourceFile((IFile)resource, kind); } if (AndroidConstants.EXT_XML.equalsIgnoreCase(ext)) { |