Java Code Examples for com.intellij.util.ReflectionUtil#getDeclaredMethod()

The following examples show how to use com.intellij.util.ReflectionUtil#getDeclaredMethod() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AndroidModuleLibraryManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void init41(@Nullable ProgressIndicator indicator) {
  boolean finished = false;
  try {
    //ProjectManagerImpl.initProject(path, this, true, null, null);
    Method method = ReflectionUtil
      .getDeclaredMethod(ProjectManagerImpl.class, "initProject", Path.class, ProjectImpl.class, boolean.class, Project.class,
                         ProgressIndicator.class);
    assert (method != null);
    try {
      method.invoke(null, path, this, true, null, null);
    }
    catch (IllegalAccessException | InvocationTargetException e) {
      throw new RuntimeException(e);
    }
    finished = true;
  }
  finally {
    if (!finished) {
      TransactionGuard.submitTransaction(this, () -> WriteAction.run(() -> Disposer.dispose(this)));
    }
  }
}
 
Example 2
Source File: AndroidModuleLibraryManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void initPre41(@Nullable ProgressIndicator indicator) {
  boolean finished = false;
  try {
    //registerComponents();
    Method method = ReflectionUtil.getDeclaredMethod(ProjectImpl.class, "registerComponents");
    assert (method != null);
    try {
      method.invoke(this);
    }
    catch (IllegalAccessException | InvocationTargetException e) {
      throw new RuntimeException(e);
    }
    getStateStore().setPath(path, true, null);
    super.init(indicator);
    finished = true;
  }
  finally {
    if (!finished) {
      TransactionGuard.submitTransaction(this, () -> WriteAction.run(() -> Disposer.dispose(this)));
    }
  }
}
 
Example 3
Source File: AndroidModuleLibraryManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void init41(@Nullable ProgressIndicator indicator) {
  boolean finished = false;
  try {
    //ProjectManagerImpl.initProject(path, this, true, null, null);
    Method method = ReflectionUtil
      .getDeclaredMethod(ProjectManagerImpl.class, "initProject", Path.class, ProjectImpl.class, boolean.class, Project.class,
                         ProgressIndicator.class);
    assert (method != null);
    try {
      method.invoke(null, path, this, true, null, null);
    }
    catch (IllegalAccessException | InvocationTargetException e) {
      throw new RuntimeException(e);
    }
    finished = true;
  }
  finally {
    if (!finished) {
      TransactionGuard.submitTransaction(this, () -> WriteAction.run(() -> Disposer.dispose(this)));
    }
  }
}
 
Example 4
Source File: AndroidModuleLibraryManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void initPre41(@Nullable ProgressIndicator indicator) {
  boolean finished = false;
  try {
    //registerComponents();
    Method method = ReflectionUtil.getDeclaredMethod(ProjectImpl.class, "registerComponents");
    assert (method != null);
    try {
      method.invoke(this);
    }
    catch (IllegalAccessException | InvocationTargetException e) {
      throw new RuntimeException(e);
    }
    getStateStore().setPath(path, true, null);
    super.init(indicator);
    finished = true;
  }
  finally {
    if (!finished) {
      TransactionGuard.submitTransaction(this, () -> WriteAction.run(() -> Disposer.dispose(this)));
    }
  }
}
 
Example 5
Source File: FontLayoutService.java    From consulo with Apache License 2.0 5 votes vote down vote up
private DefaultFontLayoutService() {
  myHandleCharWidthMethod = ReflectionUtil.getDeclaredMethod(FontDesignMetrics.class, "handleCharWidth", int.class);
  if (myHandleCharWidthMethod == null) {
    LOG.warn("Couldn't access FontDesignMetrics.handleCharWidth method");
  }
  myGetLatinCharWidthMethod = ReflectionUtil.getDeclaredMethod(FontDesignMetrics.class, "getLatinCharWidth", char.class);
  if (myGetLatinCharWidthMethod == null) {
    LOG.warn("Couldn't access FontDesignMetrics.getLatinCharWidth method");
  }
}
 
Example 6
Source File: ClipboardSynchronizer.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Quickly checks availability of data in X11 clipboard selection.
 *
 * @return null if is unable to check; empty list if clipboard owner doesn't respond timely;
 * collection of available data flavors otherwise.
 */
@Nullable
private static Collection<DataFlavor> checkContentsQuick() {
  final Clipboard clipboard = getClipboard();
  if (clipboard == null) return null;
  final Class<? extends Clipboard> aClass = clipboard.getClass();
  if (!"sun.awt.X11.XClipboard".equals(aClass.getName())) return null;

  final Method getClipboardFormats = ReflectionUtil.getDeclaredMethod(aClass, "getClipboardFormats");
  if (getClipboardFormats == null) return null;

  final String timeout = System.getProperty(DATA_TRANSFER_TIMEOUT_PROPERTY);
  System.setProperty(DATA_TRANSFER_TIMEOUT_PROPERTY, SHORT_TIMEOUT);

  try {
    final long[] formats = (long[])getClipboardFormats.invoke(clipboard);
    if (formats == null || formats.length == 0) {
      return Collections.emptySet();
    }
    @SuppressWarnings({"unchecked"}) final Set<DataFlavor> set = DataTransferer.getInstance().getFlavorsForFormats(formats, FLAVOR_MAP).keySet();
    return set;
  }
  catch (IllegalAccessException | IllegalArgumentException ignore) {
  }
  catch (InvocationTargetException e) {
    final Throwable cause = e.getCause();
    if (cause instanceof IllegalStateException) {
      throw (IllegalStateException)cause;
    }
  }
  finally {
    System.setProperty(DATA_TRANSFER_TIMEOUT_PROPERTY, timeout);
  }

  return null;
}