diff options
author | mikaelpeltier <mikaelpeltier@google.com> | 2015-03-27 16:21:28 +0100 |
---|---|---|
committer | mikaelpeltier <mikaelpeltier@google.com> | 2015-04-07 17:15:10 +0200 |
commit | 81861fd04ba4863b321de26c0852575fa7f173c3 (patch) | |
tree | 702651c6eac7739264b78f64d9a7a136ed15eb4f /jack/tests | |
parent | bdbdeb2b2c143c8ff201058024bf77a78a425a80 (diff) | |
download | toolchain_jack-81861fd04ba4863b321de26c0852575fa7f173c3.tar.gz toolchain_jack-81861fd04ba4863b321de26c0852575fa7f173c3.tar.bz2 toolchain_jack-81861fd04ba4863b321de26c0852575fa7f173c3.zip |
Fix bug into Java parser
Bug: 19613702
Bug: 19910266
Change-Id: I6d2c7011ba92e0c0b6f97cd13264ef67a19700a3
Diffstat (limited to 'jack/tests')
-rw-r--r-- | jack/tests/com/android/jack/frontend/OrderedInputFilter.java | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/jack/tests/com/android/jack/frontend/OrderedInputFilter.java b/jack/tests/com/android/jack/frontend/OrderedInputFilter.java new file mode 100644 index 00000000..5d1be700 --- /dev/null +++ b/jack/tests/com/android/jack/frontend/OrderedInputFilter.java @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.frontend; + +import com.android.jack.Jack; +import com.android.jack.Options; +import com.android.jack.analysis.dependency.file.FileDependencies; +import com.android.jack.analysis.dependency.library.LibraryDependencies; +import com.android.jack.analysis.dependency.type.TypeDependencies; +import com.android.jack.incremental.CommonFilter; +import com.android.jack.incremental.InputFilter; +import com.android.jack.ir.ast.JSession; +import com.android.jack.library.InputLibrary; +import com.android.jack.library.OutputJackLibrary; +import com.android.sched.util.codec.ImplementationName; +import com.android.sched.util.config.Config; +import com.android.sched.util.config.ThreadConfig; +import com.android.sched.util.file.Directory; +import com.android.sched.util.file.FileOrDirectory; + +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +import javax.annotation.Nonnull; + +/** + * {@link InputFilter} that returns ordered inputs. + */ +@ImplementationName(iface = InputFilter.class, name = "ordered-filter") +public class OrderedInputFilter extends CommonFilter implements InputFilter { + + @Nonnull + private final Set<String> fileNamesToCompile; + + @Nonnull + private final Options options; + + @Nonnull + private final List<? extends InputLibrary> importedLibrariesFromCommandLine; + + @Nonnull + private final List<? extends InputLibrary> librariesOnClasspathFromCommandLine; + + public OrderedInputFilter(@Nonnull Options options) { + this.options = options; + this.fileNamesToCompile = getJavaFileNamesSpecifiedOnCommandLine(options); + JSession session = Jack.getSession(); + session.setFileDependencies(new FileDependencies()); + session.setTypeDependencies(new TypeDependencies()); + importedLibrariesFromCommandLine = ThreadConfig.get(Options.IMPORTED_LIBRARIES); + librariesOnClasspathFromCommandLine = getInputLibrariesFromFiles( + ThreadConfig.get(Options.CLASSPATH), + ThreadConfig.get(Jack.STRICT_CLASSPATH).booleanValue()); + + LibraryDependencies libraryDependencies = session.getLibraryDependencies(); + libraryDependencies.addImportedLibraries(importedLibrariesFromCommandLine); + libraryDependencies.addLibrariesOnClasspath(librariesOnClasspathFromCommandLine); + } + + @Override + @Nonnull + public Set<String> getFileNamesToCompile() { + return fileNamesToCompile; + } + + @Override + @Nonnull + public List<? extends InputLibrary> getClasspath() { + return librariesOnClasspathFromCommandLine; + } + + @Override + @Nonnull + public List<? extends InputLibrary> getImportedLibrary() { + return importedLibrariesFromCommandLine; + } + + @Override + @Nonnull + public OutputJackLibrary getOutputJackLibrary() { + return getOutputJackLibraryFromVfs(); + } + + @Override + @Nonnull + protected Set<String> getJavaFileNamesSpecifiedOnCommandLine(@Nonnull Options options) { + Config config = options.getConfig(); + final String extension = ".java"; + + Set<String> javaFileNames = new TreeSet<String>(); + for (FileOrDirectory file : config.get(Options.SOURCES)) { + if (file instanceof Directory) { + fillFiles(((Directory) file).getFile(), extension, javaFileNames); + } else if (file.getPath().endsWith(extension)) { + // File already checked by codec + javaFileNames.add(file.getPath()); + } + } + + return (javaFileNames); + } +} |