本文整理匯總了Java中org.eclipse.jdt.core.JavaModelException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java JavaModelException.printStackTrace方法的具體用法?Java JavaModelException.printStackTrace怎麽用?Java JavaModelException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.JavaModelException
的用法示例。
在下文中一共展示了JavaModelException.printStackTrace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: collectAllCompilationUnits
import org.eclipse.jdt.core.JavaModelException; //導入方法依賴的package包/類
/**
* Collects all compilation units within the project.
* @return the collection of the compilation units
*/
public static List<ICompilationUnit> collectAllCompilationUnits() {
List<ICompilationUnit> units = new ArrayList<ICompilationUnit>();
try {
IProject[] projects = getWorkspace().getRoot().getProjects();
for (int i = 0; i < projects.length; i++) {
IJavaProject project = (IJavaProject)JavaCore.create((IProject)projects[i]);
IPackageFragment[] packages = project.getPackageFragments();
for (int j = 0; j < packages.length; j++) {
ICompilationUnit[] cus = packages[j].getCompilationUnits();
for (int k = 0; k < cus.length; k++) {
IResource res = cus[k].getResource();
if (res.getType() == IResource.FILE) {
String name = cus[k].getPath().toString();
if (name.endsWith(".java")) {
units.add(cus[k]);
}
}
}
}
}
} catch (JavaModelException e) {
e.printStackTrace();
}
return units;
}
示例2: execute
import org.eclipse.jdt.core.JavaModelException; //導入方法依賴的package包/類
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
final ICompilationUnit icu = JavaUI.getWorkingCopyManager().getWorkingCopy(editorPart.getEditorInput());
try {
final IType type = icu.getTypes()[0];
final List<Field> fields = new ArrayList<>();
for (final IField field : type.getFields()) {
final String fieldName = field.getElementName();
final String fieldType = Signature.getSignatureSimpleName(field.getTypeSignature());
fields.add(new Field(fieldName, fieldType));
}
new WizardDialog(HandlerUtil.getActiveShell(event), new BuilderGeneratorWizard(icu, fields)).open();
}
catch (final JavaModelException e) {
e.printStackTrace();
}
return null;
}
示例3: getInstanceMethods
import org.eclipse.jdt.core.JavaModelException; //導入方法依賴的package包/類
public List<IMethod> getInstanceMethods() {
if(jType == null)
return Collections.emptyList();
try {
List<IMethod> list = new ArrayList<>();
IMethod[] methods = jType.getMethods();
for(IMethod m : methods)
if(!m.isConstructor() && !Flags.isStatic(m.getFlags()) && isMethodVisible(m))
list.add(m);
return list;
} catch (JavaModelException e) {
e.printStackTrace();
return Collections.emptyList();
}
// return info.getMethods(EnumSet.of(VisibilityInfo.PUBLIC));
}
示例4: isMethodVisible
import org.eclipse.jdt.core.JavaModelException; //導入方法依賴的package包/類
private boolean isMethodVisible(IMethod m) {
try {
int f = m.getFlags();
return extension.includeMethod(m.getElementName()) && !jType.isMember() && isVisibleMember(m);
// (
// !jType.isMember() && jType.getPackageFragment().isDefaultPackage() &&
// (Flags.isPackageDefault(f) || Flags.isProtected(f) || Flags.isPublic(f))
// ||
// Flags.isPublic(f)
// );
}
catch (JavaModelException e) {
e.printStackTrace();
return false;
}
}
示例5: addRefCombovalues
import org.eclipse.jdt.core.JavaModelException; //導入方法依賴的package包/類
private void addRefCombovalues(Combo combo, String paramType) {
if(!PrimitiveType.isPrimitiveSig(paramType)) {
combo.add("null");
IType owner = (IType) method.getParent();
try {
IField[] fields = owner.getFields();
for(IField f : fields)
if(Flags.isStatic(f.getFlags()) && f.getTypeSignature().equals(paramType))
combo.add(f.getElementName());
} catch (JavaModelException e1) {
e1.printStackTrace();
}
}
}
示例6: getInvocationExpression
import org.eclipse.jdt.core.JavaModelException; //導入方法依賴的package包/類
public String getInvocationExpression() {
String[] values = getValues();
String[] parameterTypes = method.getParameterTypes();
for(int i = 0; i < values.length; i++) {
String pType = Signature.getSignatureSimpleName(parameterTypes[i]);
values[i] = convertForTypedInvocation(values[i], pType);
}
try {
return (method.isConstructor() ? "new " + method.getElementName() : methodName) + "(" + String.join(", ", values) + ")";
} catch (JavaModelException e) {
e.printStackTrace();
return null;
}
}
示例7: setMethod
import org.eclipse.jdt.core.JavaModelException; //導入方法依賴的package包/類
public void setMethod(IMethod method, InvocationAction a) {
String key = null;
try {
IType type = (IType) method.getParent();
key = type.getFullyQualifiedName() + "|" + method.getElementName() + method.getSignature();
} catch (JavaModelException e) {
e.printStackTrace();
}
if(key != null) {
StaticInvocationWidget2 inv = invWidgetsMap.get(key);
if(inv == null) {
inv = new StaticInvocationWidget2(this, null, method, a);
invWidgetsMap.put(key, inv);
}
inv.refreshItems();
layout.topControl = inv;
layout();
}
}
示例8: setMethod
import org.eclipse.jdt.core.JavaModelException; //導入方法依賴的package包/類
public void setMethod(IFile file, IMethod method, InvocationAction a) {
String key = null;
try {
IType type = (IType) method.getParent();
key = type.getFullyQualifiedName() + "|" + method.getElementName() + method.getSignature();
} catch (JavaModelException e) {
e.printStackTrace();
}
if(key != null) {
StaticInvocationWidget inv = invWidgetsMap.get(key);
if(inv == null) {
inv = new StaticInvocationWidget(this, file, method, a);
invWidgetsMap.put(key, inv);
}
inv.refreshItems(file);
layout.topControl = inv;
layout();
}
}
示例9: addCombovalues
import org.eclipse.jdt.core.JavaModelException; //導入方法依賴的package包/類
private void addCombovalues(Combo combo, String paramType) {
if(!PrimitiveType.isPrimitiveSig(paramType)) {
String sel = combo.getText();
combo.removeAll();
combo.add("null");
IType owner = (IType) method.getParent();
try {
IField[] fields = owner.getFields();
for(IField f : fields)
if(Flags.isStatic(f.getFlags()) && f.getTypeSignature().equals(paramType))
combo.add(f.getElementName());
} catch (JavaModelException e1) {
e1.printStackTrace();
}
if(sel.isEmpty())
combo.select(0);
else
combo.setText(sel);
}
}
示例10: generateBuilder
import org.eclipse.jdt.core.JavaModelException; //導入方法依賴的package包/類
private void generateBuilder() {
try {
final IType type = this.icu.getTypes()[0];
final String className = type.getElementName();
final List<Field> fields = this.mainPage.getFields();
final int[] mandatoryIndexs = this.mainPage.getSelectedFields();
final List<Field> mandatoryFields = getMandatoryField(fields, mandatoryIndexs);
final List<Field> optionalFields = getOptionalFields(fields, mandatoryIndexs);
// -- Create Constructor builder
type.createMethod(BuildersGeneratorUtil.generateBuilderConstructor(className, fields), null, false, null);
// -- Create static builder method start point
type.createMethod(BuildersGeneratorUtil.generateStartPoint(mandatoryFields), null, false, null);
// -- Builder
type.createType(BuildersGeneratorUtil.generateBuilderImpl(className, mandatoryFields, optionalFields), null,
true, null);
// -- Builder interface for optional and mandatory fields
if (mandatoryFields != null && mandatoryFields.size() != 0) {
type.createType(BuildersGeneratorUtil.generateMandatoryFieldInterface(mandatoryFields), null, false, null);
}
type.createType(BuildersGeneratorUtil.generateBuildInterface(className, optionalFields), null, false, null);
}
catch (final JavaModelException e) {
e.printStackTrace();
}
}
示例11: getOutputLocation
import org.eclipse.jdt.core.JavaModelException; //導入方法依賴的package包/類
@SuppressWarnings("unused")
private String getOutputLocation(IJavaProject project) {
String outputLocation = "";
IPath path;
try {
path = project.getOutputLocation();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IFolder folder = root.getFolder(path);
outputLocation = folder.getLocation().toOSString();
} catch (JavaModelException e) {
e.printStackTrace();
}
return outputLocation;
}
示例12: typeToClass
import org.eclipse.jdt.core.JavaModelException; //導入方法依賴的package包/類
/**
* transform the <code>IType</code> to <code>Class</code>
*
* @param type <code>IType</code>
* @return <code>Class</code>
* @throws ClassNotFoundException
* @throws MalformedURLException
*/
public static Class<?> typeToClass(IType type) throws CoreException,
ClassNotFoundException,MalformedURLException {
try {
if (null != type && (type.isClass() || type.isInterface())) {
String className = type.getFullyQualifiedName('$');
return loadClass(type.getJavaProject(), className);
}
} catch (JavaModelException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
return null;
}
示例13: accept
import org.eclipse.jdt.core.JavaModelException; //導入方法依賴的package包/類
@Override
public boolean accept(IType objectType) {
try {
IType[] superInterfaces = objectType.newSupertypeHierarchy(null).getAllSuperInterfaces(objectType);
for(IType t : superInterfaces)
if(t.getFullyQualifiedName().equals(Collection.class.getName()))
return true;
return false;
} catch (JavaModelException e) {
e.printStackTrace();
return false;
}
}
示例14: StaticInvocationWidget
import org.eclipse.jdt.core.JavaModelException; //導入方法依賴的package包/類
public StaticInvocationWidget(Composite parent, InvokeDialog invokeDialog, IMethod method, InvocationAction action) {
super(parent, SWT.NONE);
this.invokeDialog = invokeDialog;
this.method = method;
setLayout(rowLayout);
methodName = method.getElementName();
parameterTypes = method.getParameterTypes();
Label label = new Label(this, SWT.NONE);
FontManager.setFont(label, PandionJConstants.VAR_FONT_SIZE);
label.setText(method.getElementName() + " (");
paramBoxes = new Combo[method.getNumberOfParameters()];
String[] parameterNames = null;
try {
parameterNames = method.getParameterNames();
} catch (JavaModelException e1) {
e1.printStackTrace();
}
for(int i = 0; i < parameterTypes.length; i++) {
if(i != 0) {
Label comma = new Label(this, SWT.NONE);
FontManager.setFont(comma, PandionJConstants.VAR_FONT_SIZE);
comma.setText(", ");
}
paramBoxes[i] = createCombo(invokeDialog, parameterNames[i], parameterTypes[i]);
}
Label close = new Label(this, SWT.NONE);
FontManager.setFont(close, PandionJConstants.VAR_FONT_SIZE);
close.setText(")");
addCacheValues(paramBoxes);
checkValidity();
}
示例15: getMethodKey
import org.eclipse.jdt.core.JavaModelException; //導入方法依賴的package包/類
private String getMethodKey(IMethod method) {
try {
IType type = (IType) method.getParent();
return type.getFullyQualifiedName() + "|" + method.getElementName() + method.getSignature();
} catch (JavaModelException e) {
e.printStackTrace();
return null;
}
}