You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AjCompilerOptions.java 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /* *******************************************************************
  2. * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Common Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/cpl-v10.html
  8. *
  9. * Contributors:
  10. * PARC initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.ajdt.internal.core.builder;
  13. import java.util.Map;
  14. import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode;
  15. import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
  16. /**
  17. * Compiler options used by Eclipse integration (AJDT)
  18. */
  19. public class AjCompilerOptions extends CompilerOptions {
  20. // AspectJ Lint options
  21. public static final String OPTION_ReportInvalidAbsoluteTypeName = "org.aspectj.ajdt.core.compiler.lint.InvalidAbsoluteTypeName";
  22. public static final String OPTION_ReportInvalidWildcardTypeName = "org.aspectj.ajdt.core.compiler.lint.WildcardTypeName";
  23. public static final String OPTION_ReportUnresolvableMember = "org.aspectj.ajdt.core.compiler.lint.UnresolvableMember";
  24. public static final String OPTION_ReportTypeNotExposedToWeaver = "org.aspectj.ajdt.core.compiler.lint.TypeNotExposedToWeaver";
  25. public static final String OPTION_ReportShadowNotInStructure = "org.aspectj.ajdt.core.compiler.lint.ShadowNotInStructure";
  26. public static final String OPTION_ReportUnmatchedSuperTypeInCall = "org.aspectj.ajdt.core.compiler.list.UnmatchedSuperTypeInCall";
  27. public static final String OPTION_ReportCannotImplementLazyTJP = "org.aspectj.ajdt.core.compiler.lint.CannotImplementLazyTJP";
  28. public static final String OPTION_ReportNeedSerialVersionUIDField = "org.aspectj.ajdt.core.compiler.lint.NeedSerialVersionUIDField";
  29. public static final String OPTION_ReportIncompatibleSerialVersion = "org.aspectj.ajdt.core.compiler.lint.BrokeSerialVersionCompatibility";
  30. // General AspectJ Compiler options (excludes paths etc, these are handled separately)
  31. public static final String OPTION_NoWeave = "org.aspectj.ajdt.core.compiler.weaver.NoWeave";
  32. public static final String OPTION_XSerializableAspects = "org.aspectj.ajdt.core.compiler.weaver.XSerializableAspects";
  33. public static final String OPTION_XLazyThisJoinPoint = "org.aspectj.ajdt.core.compiler.weaver.XLazyThisJoinPoint";
  34. public static final String OPTION_XNoInline = "org.aspectj.ajdt.core.compiler.weaver.XNoInline";
  35. public static final String OPTION_XNotReweavable = "org.aspectj.ajdt.core.compiler.weaver.XNotReweavable";
  36. public static final String OPTION_XHasMember = "org.aspectj.ajdt.core.compiler.weaver.XHasMember";
  37. public static final String OPTION_XdevPinpoint = "org.aspectj.ajdt.core.compiler.weaver.XdevPinpoint";
  38. // these next four not exposed by IDEs
  39. public static final String OPTION_XDevNoAtAspectJProcessing = "org.aspectj.ajdt.core.compiler.ast.NoAtAspectJProcessing";
  40. public static final String OPTION_GenerateModel = "org.aspectj.ajdt.core.compiler.model.GenerateModel";
  41. public static final String OPTION_GenerateJavaDocsInModel = "org.aspectj.ajdt.core.compiler.model.GenerateJavaDocsInModel";
  42. public static final String OPTION_Emacssym = "org.aspectj.ajdt.core.compiler.model.Emacssym";
  43. // constants for irritant levels
  44. public static final long InvalidAbsoluteTypeName = ASTNode.Bit45L;
  45. public static final long InvalidWildCardTypeName = ASTNode.Bit46L;
  46. public static final long UnresolvableMember = ASTNode.Bit47L;
  47. public static final long TypeNotExposedToWeaver = ASTNode.Bit48L;
  48. public static final long ShadowNotInStructure = ASTNode.Bit49L;
  49. public static final long UnmatchedSuperTypeInCall = ASTNode.Bit50L;
  50. public static final long CannotImplementLazyTJP = ASTNode.Bit51L;
  51. public static final long NeedSerialVersionUIDField = ASTNode.Bit52L;
  52. public static final long IncompatibleSerialVersion = ASTNode.Bit53L;
  53. public boolean noWeave = false;
  54. public boolean xSerializableAspects = false;
  55. public boolean xLazyThisJoinPoint = false;
  56. public boolean xNoInline = false;
  57. public boolean xNotReweavable = false;
  58. public boolean xHasMember = false;
  59. public boolean xdevPinpoint = false;
  60. public boolean showWeavingInformation = false;
  61. // If true - autoboxing behaves differently ...
  62. public boolean behaveInJava5Way = false;
  63. // these next four not exposed by IDEs
  64. public boolean generateModel = false;
  65. public boolean generateJavaDocsInModel = false;
  66. public boolean generateEmacsSymFiles = false;
  67. public boolean noAtAspectJProcessing = false;
  68. public boolean proceedOnError = false;
  69. /**
  70. * Initializing the compiler options with defaults
  71. */
  72. public AjCompilerOptions(){
  73. super();
  74. setAspectJWarningDefaults();
  75. }
  76. /**
  77. * Initializing the compiler options with external settings
  78. * @param settings
  79. */
  80. public AjCompilerOptions(Map settings){
  81. setAspectJWarningDefaults();
  82. if (settings == null) return;
  83. set(settings);
  84. }
  85. /* (non-Javadoc)
  86. * @see org.eclipse.jdt.internal.compiler.impl.CompilerOptions#getMap()
  87. */
  88. public Map getMap() {
  89. Map map = super.getMap();
  90. // now add AspectJ additional options
  91. map.put(OPTION_ReportInvalidAbsoluteTypeName,getSeverityString(InvalidAbsoluteTypeName));
  92. map.put(OPTION_ReportInvalidWildcardTypeName,getSeverityString(InvalidWildCardTypeName));
  93. map.put(OPTION_ReportUnresolvableMember,getSeverityString(UnresolvableMember));
  94. map.put(OPTION_ReportTypeNotExposedToWeaver,getSeverityString(TypeNotExposedToWeaver));
  95. map.put(OPTION_ReportShadowNotInStructure,getSeverityString(ShadowNotInStructure));
  96. map.put(OPTION_ReportUnmatchedSuperTypeInCall,getSeverityString(UnmatchedSuperTypeInCall));
  97. map.put(OPTION_ReportCannotImplementLazyTJP,getSeverityString(CannotImplementLazyTJP));
  98. map.put(OPTION_ReportNeedSerialVersionUIDField,getSeverityString(NeedSerialVersionUIDField));
  99. map.put(OPTION_ReportIncompatibleSerialVersion,getSeverityString(IncompatibleSerialVersion));
  100. map.put(OPTION_NoWeave, this.noWeave ? ENABLED : DISABLED);
  101. map.put(OPTION_XSerializableAspects,this.xSerializableAspects ? ENABLED : DISABLED);
  102. map.put(OPTION_XLazyThisJoinPoint,this.xLazyThisJoinPoint ? ENABLED : DISABLED);
  103. map.put(OPTION_XNoInline,this.xNoInline ? ENABLED : DISABLED);
  104. map.put(OPTION_XNotReweavable,this.xNotReweavable ? ENABLED : DISABLED);
  105. map.put(OPTION_XHasMember, this.xHasMember ? ENABLED : DISABLED);
  106. map.put(OPTION_XdevPinpoint, this.xdevPinpoint ? ENABLED : DISABLED);
  107. map.put(OPTION_GenerateModel,this.generateModel ? ENABLED : DISABLED);
  108. map.put(OPTION_GenerateJavaDocsInModel,this.generateJavaDocsInModel ? ENABLED : DISABLED);
  109. map.put(OPTION_Emacssym,this.generateEmacsSymFiles ? ENABLED : DISABLED);
  110. map.put(OPTION_XDevNoAtAspectJProcessing,this.noAtAspectJProcessing ? ENABLED : DISABLED);
  111. return map;
  112. }
  113. /* (non-Javadoc)
  114. * @see org.eclipse.jdt.internal.compiler.impl.CompilerOptions#set(java.util.Map)
  115. */
  116. public void set(Map optionsMap) {
  117. super.set(optionsMap);
  118. Object optionValue;
  119. if ((optionValue = optionsMap.get(OPTION_ReportInvalidAbsoluteTypeName)) != null) updateSeverity(InvalidAbsoluteTypeName, optionValue);
  120. if ((optionValue = optionsMap.get(OPTION_ReportInvalidWildcardTypeName)) != null) updateSeverity(InvalidWildCardTypeName, optionValue);
  121. if ((optionValue = optionsMap.get(OPTION_ReportUnresolvableMember)) != null) updateSeverity(UnresolvableMember, optionValue);
  122. if ((optionValue = optionsMap.get(OPTION_ReportTypeNotExposedToWeaver)) != null) updateSeverity(TypeNotExposedToWeaver, optionValue);
  123. if ((optionValue = optionsMap.get(OPTION_ReportShadowNotInStructure)) != null) updateSeverity(ShadowNotInStructure, optionValue);
  124. if ((optionValue = optionsMap.get(OPTION_ReportUnmatchedSuperTypeInCall)) != null) updateSeverity(UnmatchedSuperTypeInCall, optionValue);
  125. if ((optionValue = optionsMap.get(OPTION_ReportCannotImplementLazyTJP)) != null) updateSeverity(CannotImplementLazyTJP, optionValue);
  126. if ((optionValue = optionsMap.get(OPTION_ReportNeedSerialVersionUIDField)) != null) updateSeverity(NeedSerialVersionUIDField, optionValue);
  127. if ((optionValue = optionsMap.get(OPTION_ReportIncompatibleSerialVersion)) != null) updateSeverity(IncompatibleSerialVersion, optionValue);
  128. if ((optionValue = optionsMap.get(OPTION_NoWeave)) != null) {
  129. if (ENABLED.equals(optionValue)) {
  130. this.noWeave = true;
  131. } else if (DISABLED.equals(optionValue)) {
  132. this.noWeave = false;
  133. }
  134. }
  135. if ((optionValue = optionsMap.get(OPTION_XSerializableAspects)) != null) {
  136. if (ENABLED.equals(optionValue)) {
  137. this.xSerializableAspects = true;
  138. } else if (DISABLED.equals(optionValue)) {
  139. this.xSerializableAspects = false;
  140. }
  141. }
  142. if ((optionValue = optionsMap.get(OPTION_XLazyThisJoinPoint)) != null) {
  143. if (ENABLED.equals(optionValue)) {
  144. this.xLazyThisJoinPoint = true;
  145. } else if (DISABLED.equals(optionValue)) {
  146. this.xLazyThisJoinPoint = false;
  147. }
  148. }
  149. if ((optionValue = optionsMap.get(OPTION_XNoInline)) != null) {
  150. if (ENABLED.equals(optionValue)) {
  151. this.xNoInline = true;
  152. } else if (DISABLED.equals(optionValue)) {
  153. this.xNoInline = false;
  154. }
  155. }
  156. if ((optionValue = optionsMap.get(OPTION_XNotReweavable)) != null) {
  157. if (ENABLED.equals(optionValue)) {
  158. this.xNotReweavable = true;
  159. } else if (DISABLED.equals(optionValue)) {
  160. this.xNotReweavable = false;
  161. }
  162. }
  163. /*
  164. if ((optionValue = optionsMap.get(OPTION_XReweavableCompress)) != null) {
  165. if (ENABLED.equals(optionValue)) {
  166. this.xReweavableCompress = true;
  167. } else if (DISABLED.equals(optionValue)) {
  168. this.xReweavableCompress = false;
  169. }
  170. }
  171. */
  172. if ((optionValue = optionsMap.get(OPTION_XHasMember)) != null) {
  173. if (ENABLED.equals(optionValue)) {
  174. this.xHasMember = true;
  175. } else if (DISABLED.equals(optionValue)) {
  176. this.xHasMember = false;
  177. }
  178. }
  179. if ((optionValue = optionsMap.get(OPTION_XdevPinpoint)) != null) {
  180. if (ENABLED.equals(optionValue)) {
  181. this.xdevPinpoint = true;
  182. } else if (DISABLED.equals(optionValue)) {
  183. this.xdevPinpoint = false;
  184. }
  185. }
  186. if ((optionValue = optionsMap.get(OPTION_GenerateModel)) != null) {
  187. if (ENABLED.equals(optionValue)) {
  188. this.generateModel = true;
  189. } else if (DISABLED.equals(optionValue)) {
  190. this.generateModel = false;
  191. }
  192. }
  193. if ((optionValue = optionsMap.get(OPTION_GenerateJavaDocsInModel)) != null) {
  194. if (ENABLED.equals(optionValue)) {
  195. this.generateJavaDocsInModel = true;
  196. } else if (DISABLED.equals(optionValue)) {
  197. this.generateJavaDocsInModel = false;
  198. }
  199. }
  200. if ((optionValue = optionsMap.get(OPTION_Emacssym)) != null) {
  201. if (ENABLED.equals(optionValue)) {
  202. this.generateEmacsSymFiles = true;
  203. } else if (DISABLED.equals(optionValue)) {
  204. this.generateEmacsSymFiles = false;
  205. }
  206. }
  207. if ((optionValue = optionsMap.get(OPTION_XDevNoAtAspectJProcessing)) != null) {
  208. if (ENABLED.equals(optionValue)) {
  209. this.noAtAspectJProcessing = true;
  210. } else if (DISABLED.equals(optionValue)) {
  211. this.noAtAspectJProcessing = false;
  212. }
  213. }
  214. }
  215. /**
  216. * Add these warnings to the default set...
  217. */
  218. private void setAspectJWarningDefaults() {
  219. super.warningThreshold =
  220. super.warningThreshold |
  221. InvalidAbsoluteTypeName |
  222. UnresolvableMember |
  223. TypeNotExposedToWeaver |
  224. UnmatchedSuperTypeInCall |
  225. CannotImplementLazyTJP;
  226. }
  227. /* (non-Javadoc)
  228. * @see java.lang.Object#toString()
  229. */
  230. public String toString() {
  231. StringBuffer buf = new StringBuffer( super.toString() );
  232. // now add AspectJ additional options
  233. buf.append("\n\tAspectJ Specific Options:");
  234. buf.append("\n\t- no weave: ").append(this.noWeave ? ENABLED : DISABLED); //$NON-NLS-1$
  235. buf.append("\n\t- no inline (X option): ").append(this.xNoInline ? ENABLED : DISABLED); //$NON-NLS-1$
  236. buf.append("\n\t- generate serializable aspects (X option): ").append(this.xSerializableAspects ? ENABLED : DISABLED); //$NON-NLS-1$
  237. buf.append("\n\t- lazy thisJoinPoint (X option): ").append(this.xLazyThisJoinPoint ? ENABLED : DISABLED); //$NON-NLS-1$
  238. buf.append("\n\t- generate non-reweavable class files (X option): ").append(this.xNotReweavable ? ENABLED : DISABLED); //$NON-NLS-1$
  239. buf.append("\n\t- has member support (X option): ").append(this.xHasMember ? ENABLED : DISABLED); //$NON-NLS-1$
  240. buf.append("\n\t- generate AJDE model: ").append(this.generateModel ? ENABLED : DISABLED); //$NON-NLS-1$
  241. buf.append("\n\t- generate Javadocs in AJDE model: ").append(this.generateJavaDocsInModel ? ENABLED : DISABLED); //$NON-NLS-1$
  242. buf.append("\n\t- generate Emacs symbol files: ").append(this.generateEmacsSymFiles ? ENABLED : DISABLED); //$NON-NLS-1$
  243. buf.append("\n\t- suppress @AspectJ processing: ").append(this.noAtAspectJProcessing ? ENABLED : DISABLED); //$NON-NLS-1$
  244. buf.append("\n\t- invalid absolute type name (XLint): ").append(getSeverityString(InvalidAbsoluteTypeName)); //$NON-NLS-1$
  245. buf.append("\n\t- invalid wildcard type name (XLint): ").append(getSeverityString(InvalidWildCardTypeName)); //$NON-NLS-1$
  246. buf.append("\n\t- unresolvable member (XLint): ").append(getSeverityString(UnresolvableMember)); //$NON-NLS-1$
  247. buf.append("\n\t- type not exposed to weaver (XLint): ").append(getSeverityString(TypeNotExposedToWeaver)); //$NON-NLS-1$
  248. buf.append("\n\t- shadow not in structure (XLint): ").append(getSeverityString(ShadowNotInStructure)); //$NON-NLS-1$
  249. buf.append("\n\t- unmatched super type in call (XLint): ").append(getSeverityString(UnmatchedSuperTypeInCall)); //$NON-NLS-1$
  250. buf.append("\n\t- cannot implement lazy thisJoinPoint (XLint): ").append(getSeverityString(CannotImplementLazyTJP)); //$NON-NLS-1$
  251. buf.append("\n\t- need serialVersionUID field (XLint): ").append(getSeverityString(NeedSerialVersionUIDField)); //$NON-NLS-1$
  252. buf.append("\n\t- incompatible serial version (XLint): ").append(getSeverityString(IncompatibleSerialVersion)); //$NON-NLS-1$
  253. return buf.toString();
  254. }
  255. }