Debian Codegraph @

src/com/google/javascript/jscomp/AnonymousFunctionNamingPolicy.java

raw symbols SCIP
1 /*
2 * Copyright 2009 The Closure Compiler Authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package com.google.javascript.jscomp;
18
19 /**
20 * Strategies for how to do naming of anonymous functions that occur as
21 * r-values in assignments and variable declarations.
22 */
23 public enum AnonymousFunctionNamingPolicy {
24
25 /** Don't give anonymous functions names */
26 OFF(null),
27
28 /**
29 * Generates names that are based on the left-hand side of the assignment.
30 * Runs after variable and property renaming, so that the generated names
31 * will be short and obfuscated.
32 * @see NameAnonymousFunctions
33 */
34 UNMAPPED(new char[] { NameAnonymousFunctions.DELIMITER }),
35
36 /**
37 * Generates short unique names and provides a mapping from them back to a
38 * more meaningful name that's based on the left-hand side of the
39 * assignment.
40 * @see NameAnonymousFunctionsMapped
41 */
42 MAPPED(new char[] { NameAnonymousFunctionsMapped.PREFIX }),
43 ;
44
45 private final char[] reservedCharacters;
46
47 AnonymousFunctionNamingPolicy(char[] reservedCharacters) {
48 this.reservedCharacters = reservedCharacters;
49 }
50
51 /**
52 * Gets characters that are reserved for use in anonymous function names and
53 * can't be used in variable or property names.
54 * @return reserved characters or null if no characters are reserved
55 */
56 public char[] getReservedCharacters() {
57 // TODO(user) - for MAPPED, only the first character is reserved which
58 // can be used to further optimize
59 return reservedCharacters;
60 }
61 }