author | alundblad |
Tue, 22 Apr 2014 16:51:10 +0200 | |
changeset 24067 | 76e7b6bbbd85 |
child 26098 | 32588700060b |
permissions | -rw-r--r-- |
24067
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
1 |
/* |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
4 |
* |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
10 |
* |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
15 |
* accompanied this code). |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
16 |
* |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
20 |
* |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
23 |
* questions. |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
24 |
*/ |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
25 |
|
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
26 |
package com.sun.tools.sjavac.options; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
27 |
|
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
28 |
import java.nio.file.Path; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
29 |
import java.util.List; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
30 |
import java.util.Map; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
31 |
import java.util.Set; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
32 |
|
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
33 |
import com.sun.tools.sjavac.Module; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
34 |
import com.sun.tools.sjavac.ProblemException; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
35 |
import com.sun.tools.sjavac.Source; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
36 |
|
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
37 |
/** |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
38 |
* Represents a directory to be used for input to sjavac. (For instance a |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
39 |
* sourcepath or classpath.) |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
40 |
*/ |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
41 |
public class SourceLocation { |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
42 |
|
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
43 |
// Path to the root directory |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
44 |
private Path path; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
45 |
|
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
46 |
// Package include / exclude patterns and file includes / excludes. |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
47 |
List<String> includes, excludes, includedFiles, excludedFiles; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
48 |
|
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
49 |
public SourceLocation(Path path, |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
50 |
List<String> includes, |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
51 |
List<String> excludes, |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
52 |
List<String> includedFiles, |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
53 |
List<String> excludedFiles) { |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
54 |
this.path = path; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
55 |
this.includes = includes; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
56 |
this.excludes = excludes; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
57 |
this.includedFiles = includedFiles; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
58 |
this.excludedFiles = excludedFiles; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
59 |
} |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
60 |
|
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
61 |
|
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
62 |
/** |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
63 |
* Finds all files with the given suffix that pass the include / exclude |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
64 |
* filters in this source location. |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
65 |
* |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
66 |
* @param suffixes The set of suffixes to search for |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
67 |
* @param foundFiles The map in which to store the found files |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
68 |
* @param foundModules The map in which to store the found modules |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
69 |
* @param currentModule The current module |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
70 |
* @param permitSourcesInDefaultPackage true if sources in default package |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
71 |
* are to be permitted |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
72 |
* @param inLinksrc true if in link source |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
73 |
*/ |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
74 |
public void findSourceFiles(Set<String> suffixes, |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
75 |
Map<String, Source> foundFiles, |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
76 |
Map<String, Module> foundModules, |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
77 |
Module currentModule, |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
78 |
boolean permitSourcesInDefaultPackage, |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
79 |
boolean inLinksrc) { |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
80 |
try { |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
81 |
Source.scanRoot(path.toFile(), suffixes, excludes, includes, |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
82 |
excludedFiles, includedFiles, foundFiles, foundModules, |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
83 |
currentModule, permitSourcesInDefaultPackage, false, |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
84 |
inLinksrc); |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
85 |
} catch (ProblemException e) { |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
86 |
e.printStackTrace(); |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
87 |
} |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
88 |
} |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
89 |
|
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
90 |
/** Get the root directory of this source location */ |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
91 |
public Path getPath() { |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
92 |
return path; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
93 |
} |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
94 |
|
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
95 |
/** Get the package include patterns */ |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
96 |
public List<String> getIncludes() { |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
97 |
return includes; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
98 |
} |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
99 |
|
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
100 |
/** Get the package exclude patterns */ |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
101 |
public List<String> getExcludes() { |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
102 |
return excludes; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
103 |
} |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
104 |
|
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
105 |
/** Get the file include patterns */ |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
106 |
public List<String> getIncludedFiles() { |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
107 |
return includedFiles; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
108 |
} |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
109 |
|
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
110 |
/** Get the file exclude patterns */ |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
111 |
public List<String> getExcludedFiles() { |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
112 |
return excludedFiles; |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
113 |
} |
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
114 |
|
76e7b6bbbd85
8035063: Option handling in sjavac needs to be rewritten
alundblad
parents:
diff
changeset
|
115 |
} |