Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2008 Google Inc.
*
* 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.google.gwt.dev.cfg;
import com.google.gwt.core.ext.Linker;
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.core.ext.linker.LinkerOrder;
import com.google.gwt.core.ext.linker.LinkerOrder.Order;
import com.google.gwt.core.ext.typeinfo.TypeOracle;
import com.google.gwt.dev.CompilerContext;
import com.google.gwt.dev.javac.CompilationProblemReporter;
import com.google.gwt.dev.javac.CompilationState;
import com.google.gwt.dev.javac.CompilationStateBuilder;
import com.google.gwt.dev.resource.Resource;
import com.google.gwt.dev.resource.ResourceOracle;
import com.google.gwt.dev.resource.impl.DefaultFilters;
import com.google.gwt.dev.resource.impl.PathPrefix;
import com.google.gwt.dev.resource.impl.PathPrefixSet;
import com.google.gwt.dev.resource.impl.ResourceFilter;
import com.google.gwt.dev.resource.impl.ResourceOracleImpl;
import com.google.gwt.dev.util.Empty;
import com.google.gwt.dev.util.Util;
import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger;
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger.Event;
import com.google.gwt.dev.util.transitiveclosure.TransitiveClosureSolver;
import com.google.gwt.thirdparty.guava.common.base.Charsets;
import com.google.gwt.thirdparty.guava.common.base.Objects;
import com.google.gwt.thirdparty.guava.common.base.Preconditions;
import com.google.gwt.thirdparty.guava.common.base.Predicates;
import com.google.gwt.thirdparty.guava.common.collect.ArrayListMultimap;
import com.google.gwt.thirdparty.guava.common.collect.ImmutableList;
import com.google.gwt.thirdparty.guava.common.collect.Iterators;
import com.google.gwt.thirdparty.guava.common.collect.LinkedHashMultimap;
import com.google.gwt.thirdparty.guava.common.collect.ListMultimap;
import com.google.gwt.thirdparty.guava.common.collect.Lists;
import com.google.gwt.thirdparty.guava.common.collect.Maps;
import com.google.gwt.thirdparty.guava.common.collect.Queues;
import com.google.gwt.thirdparty.guava.common.collect.Sets;
import java.io.File;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Set;
/**
* Represents a module specification. In principle, this could be built without
* XML for unit tests.
*/
public class ModuleDef implements DepsInfoProvider {
/**
* Marks a module in a way that can be used to calculate the effective bounds of a library module
* in a module tree.
*/
public enum ModuleType {
/**
* A module that acts as just a bundle of source code to be included in a referencing library.
* The contained code may form circular references with other source within the contiguous chunk
* of modules made up of a library and it's subtree of filesets. As a result a fileset can not
* be compiled on it's own and must be compiled as part of a library.
*/
FILESET,
/**
* The default type of module. Libraries should be independently compilable and are expected to
* explicitly declare all of their immediate dependencies and include paths and none of their
* contained source should be part of a circular reference with any source outside the effective
* bounds of the library.
*/
LIBRARY
}
/**
* When walking a module tree of mixed library and fileset modules, attributes are accumulated and
* stored. But when compiling separately, some attributes should only be collected from the
* effective target module. AttributeSource is used to classify these "in target module" and "out
* of target module" times.
*/
private enum AttributeSource {
EXTERNAL_LIBRARY, TARGET_LIBRARY
}
/**
* Encapsulates two String names which conceptually represent the starting and ending points of a
* path.
*
* For example in the following module dependency path ["com.acme.MyApp",
* "com.acme.widgets.Widgets", "com.google.gwt.user.User"] the fromName is "com.acme.MyApp" and
* the toName is "com.google.gwt.user.User" and together they form a PathEndNames instance.
*
* The purpose of the class is to serve as a key by which to lookup the fileset path that connects
* two libraries. It makes it possible to insert fileset entries into a circular module reference
* report.
*/
private static class LibraryDependencyEdge {
private String fromName;
private String toName;
public LibraryDependencyEdge(String fromName, String toName) {
this.fromName = fromName;
this.toName = toName;
}
@Override
public boolean equals(Object object) {
if (object instanceof LibraryDependencyEdge) {
LibraryDependencyEdge that = (LibraryDependencyEdge) object;
return Objects.equal(this.fromName, that.fromName)
&& Objects.equal(this.toName, that.toName);
}
return false;
}
@Override
public int hashCode() {
return Objects.hashCode(fromName, toName);
}
}
private static final ResourceFilter NON_JAVA_RESOURCES = new ResourceFilter() {
@Override
public boolean allows(String path) {
return !path.endsWith(".java") && !path.endsWith(".class");
}
};
private static final Comparator> REV_NAME_CMP =
new Comparator>() {
@Override
public int compare(Map.Entry entry1, Map.Entry entry2) {
String key1 = entry1.getKey();
String key2 = entry2.getKey();
// intentionally reversed
return key2.compareTo(key1);
}
};
public static boolean isValidModuleName(String moduleName) {
// Check for an empty string between two periods.
if (moduleName.contains("..")) {
return false;
}
// Insure the package name components are a valid Java ident.
String[] parts = moduleName.split("\\.");
for (int i = 0; i < parts.length - 1; i++) {
String part = parts[i];
if (!Util.isValidJavaIdent(part)) {
return false;
}
}
return true;
}
private static LinkedList createExtendedCopy(LinkedList list,
String extendingElement) {
LinkedList extendedCopy = Lists.newLinkedList(list);
extendedCopy.add(extendingElement);
return extendedCopy;
}
/**
* All resources found on the public path, specified by directives in
* modules (or the implicit ./public directory). Marked 'lazy' because it does not
* start searching for resources until a query is made.
*/
protected ResourceOracleImpl lazyPublicOracle;
private final Set activeLinkers = new LinkedHashSet();
private String activePrimaryLinker;
/**
* A set of URLs for .gwtar files found on the classpath that correspond
* to .gwt.xml files loaded as a part of this module's nested load.
*
* @see com.google.gwt.dev.CompileModule
*/
private final List archiveURLs = new ArrayList();
private boolean collapseAllProperties;
/**
* Used to keep track of the current category of attribute source. When the attribute source is
* TARGET_LIBRARY all attributes are accumulated but when it is EXTERNAL_LIBRARY there are some
* attributes that are not collected.
*/
private Deque currentAttributeSource = Lists.newLinkedList();
private final DefaultFilters defaultFilters;
private TransitiveClosureSolver depsTransitiveClosureSolver;
/**
* The canonical module names of dependency library modules per depending library module.
*/
private LinkedHashMultimap directDepModuleNamesByModuleName =
LinkedHashMultimap.create();
private final List entryPointTypeNames = new ArrayList();
/**
* Names of free-standing compilable library modules that are depended upon by this module.
*/
private final Set externalLibraryCanonicalModuleNames = Sets.newLinkedHashSet();
/**
* A stack that keeps track of the type of the current module in the enterModule/exitModule tree.
*/
private final Deque currentModuleType = Lists.newLinkedList();
/**
* A stack that keeps track of the name of the current module in the enterModule/exitModule tree.
*/
private final Deque currentLibraryModuleNames = Lists.newLinkedList();
/**
* Records the canonical module names for filesets.
*/
private Set filesetModuleNames = Sets.newHashSet();
/**
* A mapping from a pair of starting and ending module names of a path to the ordered list of
* names of fileset modules that connect those end points. The mapping allows one to discover what
* path of filesets are connecting a pair of libraries when those libraries do not directly depend
* on one another. Multiple paths may exist; this map contains only one of them.
*/
private ListMultimap filesetPathPerEdge =
ArrayListMultimap.create();
private final Set gwtXmlFiles = new HashSet();
private final Set inheritedModules = new HashSet();
/**
* Contains files other than .java and .class files (such as CSS and PNG files) from either the
* source or resource paths.
*/
private ResourceOracleImpl lazyResourcesOracle;
/**
* Contains all files from the source path, specified by