選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

CodeSnippetSkeleton.java 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*******************************************************************************
  2. * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Common Public License v0.5
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/cpl-v05.html
  7. *
  8. * Contributors:
  9. * IBM Corporation - initial API and implementation
  10. ******************************************************************************/
  11. package org.eclipse.jdt.internal.eval;
  12. import org.eclipse.jdt.internal.compiler.env.IBinaryField;
  13. import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
  14. import org.eclipse.jdt.internal.compiler.env.IBinaryNestedType;
  15. import org.eclipse.jdt.internal.compiler.env.IBinaryType;
  16. import org.eclipse.jdt.internal.compiler.env.IConstants;
  17. import org.eclipse.jdt.internal.compiler.util.CharOperation;
  18. /**
  19. * The skeleton of the class 'org.eclipse.jdt.internal.eval.target.CodeSnippet'
  20. * used at compile time. Note that the method run() is declared to
  21. * throw Throwable so that the user can write a code snipet that
  22. * throws checked exceptio without having to catch those.
  23. */
  24. public class CodeSnippetSkeleton implements IBinaryType, EvaluationConstants {
  25. IBinaryMethod[] methods = new IBinaryMethod[] {
  26. new BinaryMethodSkeleton(
  27. "<init>".toCharArray(), //$NON-NLS-1$
  28. "()V".toCharArray(), //$NON-NLS-1$
  29. new char[][] {},
  30. true
  31. ),
  32. new BinaryMethodSkeleton(
  33. "run".toCharArray(), //$NON-NLS-1$
  34. "()V".toCharArray(), //$NON-NLS-1$
  35. new char[][] {"java/lang/Throwable".toCharArray()}, //$NON-NLS-1$
  36. false
  37. ),
  38. new BinaryMethodSkeleton(
  39. "setResult".toCharArray(), //$NON-NLS-1$
  40. "(Ljava/lang/Object;Ljava/lang/Class;)V".toCharArray(), //$NON-NLS-1$
  41. new char[][] {},
  42. false
  43. )
  44. };
  45. public class BinaryMethodSkeleton implements IBinaryMethod {
  46. char[][] exceptionTypeNames;
  47. char[] methodDescriptor;
  48. char[] selector;
  49. boolean isConstructor;
  50. public BinaryMethodSkeleton(char[] selector, char[] methodDescriptor, char[][] exceptionTypeNames, boolean isConstructor) {
  51. this.selector = selector;
  52. this.methodDescriptor = methodDescriptor;
  53. this.exceptionTypeNames = exceptionTypeNames;
  54. this.isConstructor = isConstructor;
  55. }
  56. public char[][] getExceptionTypeNames() {
  57. return this.exceptionTypeNames;
  58. }
  59. public char[] getMethodDescriptor() {
  60. return this.methodDescriptor;
  61. }
  62. public int getModifiers() {
  63. return IConstants.AccPublic;
  64. }
  65. public char[] getSelector() {
  66. return this.selector;
  67. }
  68. public boolean isClinit() {
  69. return false;
  70. }
  71. public boolean isConstructor() {
  72. return this.isConstructor;
  73. }
  74. /**
  75. * @see IGenericMethod#getArgumentNames()
  76. */
  77. public char[][] getArgumentNames() {
  78. return null;
  79. }
  80. }
  81. /**
  82. * CodeSnippetSkeleton constructor comment.
  83. */
  84. public CodeSnippetSkeleton() {
  85. super();
  86. }
  87. public char[] getEnclosingTypeName() {
  88. return null;
  89. }
  90. public IBinaryField[] getFields() {
  91. return null;
  92. }
  93. public char[] getFileName() {
  94. return CharOperation.concat(CODE_SNIPPET_NAME, ".java".toCharArray()); //$NON-NLS-1$
  95. }
  96. public char[][] getInterfaceNames() {
  97. return null;
  98. }
  99. public IBinaryNestedType[] getMemberTypes() {
  100. return null;
  101. }
  102. public IBinaryMethod[] getMethods() {
  103. return this.methods;
  104. }
  105. public int getModifiers() {
  106. return IConstants.AccPublic;
  107. }
  108. public char[] getName() {
  109. return CODE_SNIPPET_NAME;
  110. }
  111. public char[] getSuperclassName() {
  112. return null;
  113. }
  114. public boolean isAnonymous() {
  115. return false;
  116. }
  117. public boolean isBinaryType() {
  118. return true;
  119. }
  120. public boolean isClass() {
  121. return true;
  122. }
  123. public boolean isInterface() {
  124. return false;
  125. }
  126. public boolean isLocal() {
  127. return false;
  128. }
  129. public boolean isMember() {
  130. return false;
  131. }
  132. public char[] sourceFileName() {
  133. return null;
  134. }
  135. }