/** Replies the label provider. * * @return the label provider. */ protected PackageExplorerLabelProvider getLabelProvider() { try { return (PackageExplorerLabelProvider) this.reflect.get(this, "fLabelProvider"); //$NON-NLS-1$ } catch (SecurityException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { throw new Error(e); } }
/** * Sets the given value on an the receivers's accessible field with the given name. * * @param receiver the receiver, never <code>null</code> * @param fieldName the field's name, never <code>null</code> * @param value the value to set * * @throws NoSuchFieldException see {@link Class#getField(String)} * @throws SecurityException see {@link Class#getField(String)} * @throws IllegalAccessException see {@link Field#set(Object, Object)} * @throws IllegalArgumentException see {@link Field#set(Object, Object)} */ public void set(Object receiver, String fieldName, /* @Nullable */ Object value) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { Preconditions.checkNotNull(receiver,"receiver"); Preconditions.checkNotNull(fieldName,"fieldName"); Class<? extends Object> clazz = receiver.getClass(); Field f = getDeclaredField(clazz, fieldName); if (!f.isAccessible()) f.setAccessible(true); f.set(receiver, value); }
private boolean isCompatible(Method candidate, String featureName, Object... args) { if (!candidate.getName().equals(featureName)) return false; if (candidate.getParameterTypes().length != args.length) return false; for (int i = 0; i< candidate.getParameterTypes().length; i++) { Object param = args[i]; Class<?> class1 = candidate.getParameterTypes()[i]; if (class1.isPrimitive()) class1 = wrapperTypeFor(class1); if (param != null && !class1.isInstance(param)) return false; } return true; }
public void assertExpressionTypeIsResolved(final XExpression expression, final IResolvedTypes types) { try { final Object internalTypes = this._reflectExtensions.invoke(types, "delegate"); TypeData _switchResult = null; boolean _matched = false; TypeData _xifexpression = null; if ((delegate instanceof RootResolvedTypes)) { Object _invoke = this._reflectExtensions.invoke(delegate, "getTypeData", expression, Boolean.FALSE); _xifexpression = ((TypeData) _invoke); Object _invoke = this._reflectExtensions.invoke(internalTypes, "getTypeData", expression, Boolean.FALSE); _switchResult = ((TypeData) _invoke);
do { for (Method candidate : clazz.getDeclaredMethods()) { if (candidate != null && !candidate.isBridge() && isCompatible(candidate, methodName, arguments)) { if (compatible != null) throw new IllegalStateException("Ambiguous methods to invoke. Both "+compatible+" and "+candidate+" would be compatible choices.");
/** * Constructor. * * @param reflect the reflection utilities. * @param builder the builder. */ @Inject public SARLPackageExplorerPart(ReflectExtensions reflect, IPackageExplorerLabelProviderBuilder builder) { this.reflect = reflect; this.packageExplorerLabelProviderProvider = builder; // // Trick for overriding the dialog settings with nicer default values. // final IDialogSettings dialogSettings = getDialogSettings(); try { this.reflect.set(this, "fShowLibrariesNode", //$NON-NLS-1$ dialogSettings.get(TAG_GROUP_LIBRARIES) == null ? DEFAULT_SHOW_LIBRARIES : dialogSettings.getBoolean(TAG_GROUP_LIBRARIES)); try { this.reflect.set(this, "fIsCurrentLayoutFlat", //$NON-NLS-1$ dialogSettings.getInt(TAG_LAYOUT) == FLAT_LAYOUT); } catch (NumberFormatException e) { this.reflect.set(this, "fIsCurrentLayoutFlat", DEFAULT_SHOW_FLAT); //$NON-NLS-1$ } } catch (SecurityException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { throw new Error(e); } }
private String getBootClassPath() throws MojoExecutionException { final Toolchain toolchain = this.toolchainManager.getToolchainFromBuildContext("jdk", this.mavenHelper.getSession()); //$NON-NLS-1$ if (toolchain instanceof JavaToolchain && toolchain instanceof ToolchainPrivate) { final JavaToolchain javaToolChain = (JavaToolchain) toolchain; final ToolchainPrivate privateJavaToolChain = (ToolchainPrivate) toolchain; getLog().info(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_5, javaToolChain)); String[] includes = {"jre/lib/*", "jre/lib/ext/*", "jre/lib/endorsed/*"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ String[] excludes = new String[0]; final Xpp3Dom config = (Xpp3Dom) privateJavaToolChain.getModel().getConfiguration(); if (config != null) { final Xpp3Dom bootClassPath = config.getChild("bootClassPath"); //$NON-NLS-1$ if (bootClassPath != null) { final Xpp3Dom includeParent = bootClassPath.getChild("includes"); //$NON-NLS-1$ if (includeParent != null) { includes = getValues(includeParent.getChildren("include")); //$NON-NLS-1$ } final Xpp3Dom excludeParent = bootClassPath.getChild("excludes"); //$NON-NLS-1$ if (excludeParent != null) { excludes = getValues(excludeParent.getChildren("exclude")); //$NON-NLS-1$ } } } try { return scanBootclasspath(Objects.toString(this.reflect.invoke(javaToolChain, "getJavaHome")), includes, excludes); //$NON-NLS-1$ } catch (Exception e) { throw new MojoExecutionException(e.getLocalizedMessage(), e); } } return ""; //$NON-NLS-1$ }
do { for (Method candidate : clazz.getDeclaredMethods()) { if (candidate != null && !candidate.isBridge() && isCompatible(candidate, methodName, arguments)) { if (compatible != null) throw new IllegalStateException("Ambiguous methods to invoke. Both "+compatible+" and "+candidate+" would be compatible choices.");
/** Reset the label provider for using the SARL one. */ protected void internalResetLabelProvider() { try { final PackageExplorerLabelProvider provider = createLabelProvider(); this.reflect.set(this, "fLabelProvider", provider); //$NON-NLS-1$ provider.setIsFlatLayout(isFlatLayout()); final DecoratingJavaLabelProvider decoratingProvider = new DecoratingJavaLabelProvider( provider, false, isFlatLayout()); this.reflect.set(this, "fDecoratingLabelProvider", decoratingProvider); //$NON-NLS-1$ getViewer().setLabelProvider(decoratingProvider); } catch (SecurityException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { throw new Error(e); } }
return scanBootclasspath(Objects.toString(this.reflect.invoke(javaToolChain, "getJavaHome")), includes, excludes); //$NON-NLS-1$ } catch (Exception e) { throw new IOException(e.getLocalizedMessage(), e);
/** Replies the viewer. * * @return the viewer. */ protected ProblemTreeViewer getViewer() { try { return (ProblemTreeViewer) this.reflect.get(this, "fViewer"); //$NON-NLS-1$ } catch (SecurityException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { throw new Error(e); } }
/** * Retrieves the value of the given accessible field of the given receiver. * * @param receiver the container of the field, not <code>null</code> * @param fieldName the field's name, not <code>null</code> * @return the value of the field * * @throws NoSuchFieldException see {@link Class#getField(String)} * @throws SecurityException see {@link Class#getField(String)} * @throws IllegalAccessException see {@link Field#get(Object)} * @throws IllegalArgumentException see {@link Field#get(Object)} */ @SuppressWarnings("unchecked") /* @Nullable */ public <T> T get(Object receiver, String fieldName) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { Preconditions.checkNotNull(receiver,"receiver"); Preconditions.checkNotNull(fieldName,"fieldName"); Class<? extends Object> clazz = receiver.getClass(); Field f = getDeclaredField(clazz, fieldName); if (!f.isAccessible()) f.setAccessible(true); return (T) f.get(receiver); }
private boolean isCompatible(Method candidate, String featureName, Object... args) { if (!candidate.getName().equals(featureName)) return false; if (candidate.getParameterTypes().length != args.length) return false; for (int i = 0; i< candidate.getParameterTypes().length; i++) { Object param = args[i]; Class<?> class1 = candidate.getParameterTypes()[i]; if (class1.isPrimitive()) class1 = wrapperTypeFor(class1); if (param != null && !class1.isInstance(param)) return false; } return true; }
/** Replies the label provider. * * @return the label provider. */ protected PackageExplorerContentProvider getContentProvider() { try { return (PackageExplorerContentProvider) this.reflect.get(this, "fContentProvider"); //$NON-NLS-1$ } catch (SecurityException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { throw new Error(e); } }
/** * Sets the given value on an the receivers's accessible field with the given name. * * @param receiver the receiver, never <code>null</code> * @param fieldName the field's name, never <code>null</code> * @param value the value to set * * @throws NoSuchFieldException see {@link Class#getField(String)} * @throws SecurityException see {@link Class#getField(String)} * @throws IllegalAccessException see {@link Field#set(Object, Object)} * @throws IllegalArgumentException see {@link Field#set(Object, Object)} */ public void set(Object receiver, String fieldName, /* @Nullable */ Object value) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { Preconditions.checkNotNull(receiver,"receiver"); Preconditions.checkNotNull(fieldName,"fieldName"); Class<? extends Object> clazz = receiver.getClass(); Field f = getDeclaredField(clazz, fieldName); if (!f.isAccessible()) f.setAccessible(true); f.set(receiver, value); }
if (!operation.getTypeParameters().isEmpty()) { this.reflect.invoke(this, "appendTypeParameters", appendable, operation, type); //$NON-NLS-1$ returnType, newHashSet(operation.getExceptions())); this.reflect.invoke(this, "closeBlock", appendable); //$NON-NLS-1$ } catch (Exception exception) { throw new RuntimeException(exception);
/** Replies the data that describe the package. * * @return the package data. */ protected JarPackageData getJarPackageData() { try { return (JarPackageData) this.reflect.get(this, "fJarPackage"); //$NON-NLS-1$ } catch (Exception e) { throw new RuntimeException(e); } }
/** * Retrieves the value of the given accessible field of the given receiver. * * @param receiver the container of the field, not <code>null</code> * @param fieldName the field's name, not <code>null</code> * @return the value of the field * * @throws NoSuchFieldException see {@link Class#getField(String)} * @throws SecurityException see {@link Class#getField(String)} * @throws IllegalAccessException see {@link Field#get(Object)} * @throws IllegalArgumentException see {@link Field#get(Object)} */ @SuppressWarnings("unchecked") /* @Nullable */ public <T> T get(Object receiver, String fieldName) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { Preconditions.checkNotNull(receiver,"receiver"); Preconditions.checkNotNull(fieldName,"fieldName"); Class<? extends Object> clazz = receiver.getClass(); Field f = getDeclaredField(clazz, fieldName); if (!f.isAccessible()) f.setAccessible(true); return (T) f.get(receiver); }
/** Replies the structured selection. * * @return the selection. */ protected IStructuredSelection getStructuredSelection() { try { return (IStructuredSelection) this.reflect.get(this, "fSelection"); //$NON-NLS-1$ } catch (Exception e) { throw new RuntimeException(e); } }