org.eclipse.mylyn.java.ui_3.7.1.v20120425-0100

16:46:45.308 INFO  jd.cli.Main - Decompiling org.eclipse.mylyn.java.ui_3.7.1.v20120425-0100.jar
package org.eclipse.mylyn.internal.java.ui;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.ui.actions.SelectionConverter;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.context.core.AbstractContextStructureBridge;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionContextManager;
import org.eclipse.mylyn.context.core.IInteractionElement;
import org.eclipse.mylyn.context.ui.AbstractContextUiBridge;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.Page;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;

public class JavaUiBridge
  extends AbstractContextUiBridge
{
  public void open(IInteractionElement node)
  {
    IJavaElement javaElement = JavaCore.create(node.getHandleIdentifier());
    if ((javaElement == null) || (!javaElement.exists())) {
      return;
    }
    try
    {
      IEditorPart part = JavaUI.openInEditor(javaElement);
      JavaUI.revealInEditor(part, javaElement);
    }
    catch (PartInitException e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.java.ui", NLS.bind(
        "Failed to open editor for: {0}", node.getHandleIdentifier()), e));
    }
    catch (JavaModelException e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.java.ui", NLS.bind(
        "Failed to open editor for: {0}", node.getHandleIdentifier()), e));
    }
  }
  
  public void close(IInteractionElement node)
  {
    try
    {
      IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
      if (page != null)
      {
        List<IEditorReference> toClose = new ArrayList(4);
        IEditorReference[] arrayOfIEditorReference;
        int j = (arrayOfIEditorReference = page.getEditorReferences()).length;
        for (int i = 0; i < j; i++)
        {
          IEditorReference reference = arrayOfIEditorReference[i];
          try
          {
            IJavaElement input = (IJavaElement)reference.getEditorInput().getAdapter(IJavaElement.class);
            if ((input != null) && (node.getHandleIdentifier().equals(input.getHandleIdentifier()))) {
              toClose.add(reference);
            }
          }
          catch (PartInitException localPartInitException) {}
        }
        if (toClose.size() > 0) {
          page.closeEditors((IEditorReference[])toClose.toArray(new IEditorReference[toClose.size()]), true);
        }
      }
    }
    catch (Throwable t)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.java.ui", "Could not auto close editor", t));
    }
  }
  
  public boolean acceptsEditor(IEditorPart editorPart)
  {
    return editorPart instanceof JavaEditor;
  }
  
  public IInteractionElement getElement(IEditorInput input)
  {
    Object adapter = input.getAdapter(IJavaElement.class);
    if ((adapter instanceof IJavaElement))
    {
      IJavaElement javaElement = (IJavaElement)adapter;
      String handle = ContextCore.getStructureBridge(javaElement).getHandleIdentifier(javaElement);
      return ContextCore.getContextManager().getElement(handle);
    }
    return null;
  }
  
  public List<TreeViewer> getContentOutlineViewers(IEditorPart editorPart)
  {
    if (editorPart == null) {
      return null;
    }
    List<TreeViewer> viewers = new ArrayList();
    Object out = editorPart.getAdapter(IContentOutlinePage.class);
    if ((out instanceof Page))
    {
      Page page = (Page)out;
      if (page.getControl() != null)
      {
        IWorkbenchSite site = page.getSite();
        if (site != null)
        {
          ISelectionProvider provider = site.getSelectionProvider();
          if ((provider instanceof TreeViewer)) {
            viewers.add((TreeViewer)provider);
          }
        }
      }
    }
    return viewers;
  }
  
  public Object getObjectForTextSelection(TextSelection selection, IEditorPart editor)
  {
    if ((editor instanceof JavaEditor))
    {
      TextSelection textSelection = selection;
      try
      {
        if (selection != null) {
          return SelectionConverter.resolveEnclosingElement((JavaEditor)editor, textSelection);
        }
        Object element = ((JavaEditor)editor).getEditorInput().getAdapter(IJavaElement.class);
        if ((element instanceof IJavaElement)) {
          return element;
        }
      }
      catch (JavaModelException localJavaModelException) {}
    }
    return null;
  }
  
  public String getContentType()
  {
    return "java";
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.java.ui.JavaUiBridge
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.java.ui.junit;

import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
import org.eclipse.debug.ui.CommonTab;
import org.eclipse.debug.ui.EnvironmentTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaArgumentsTab;
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaClasspathTab;
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaJRETab;

public class TaskContextJUnitTabGroup
  extends AbstractLaunchConfigurationTabGroup
{
  public void createTabs(ILaunchConfigurationDialog dialog, String mode)
  {
    ILaunchConfigurationTab[] tabs = { new TaskContextJUnitMainTab(false), 
      new JavaArgumentsTab(), new JavaClasspathTab(), new JavaJRETab(), new SourceLookupTab(), 
      new EnvironmentTab(), new CommonTab() };
    setTabs(tabs);
  }
  
  public void setDefaults(ILaunchConfigurationWorkingCopy config)
  {
    super.setDefaults(config);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.java.ui.junit.TaskContextJUnitTabGroup
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.java.ui.junit;

import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.junit.launcher.TestKindRegistry;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.context.core.AbstractContextStructureBridge;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionContext;
import org.eclipse.mylyn.context.core.IInteractionContextManager;
import org.eclipse.mylyn.context.core.IInteractionElement;
import org.eclipse.mylyn.context.core.IInteractionRelation;

public class InteractionContextTestUtil
{
  public static void setupTestConfiguration(Set<IType> contextTestCases, ILaunchConfiguration configuration, IProgressMonitor pm)
    throws CoreException
  {
    String testKindId = "org.eclipse.jdt.junit.loader.junit3";
    
    IJavaProject javaProject = null;
    for (IType type : contextTestCases)
    {
      IProjectNature nature = type.getJavaProject().getProject().getNature("org.eclipse.pde.PluginNature");
      if (nature != null) {
        javaProject = type.getJavaProject();
      }
    }
    ILaunchConfigurationWorkingCopy workingCopy = configuration.getWorkingCopy();
    if (javaProject != null) {
      workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, javaProject.getElementName());
    }
    if (contextTestCases.size() > 0)
    {
      testKindId = TestKindRegistry.getContainerTestKindId((IJavaElement)contextTestCases.iterator().next());
      workingCopy.setAttribute("org.eclipse.jdt.junit.TEST_KIND", testKindId);
    }
    workingCopy.doSave();
  }
  
  public static Set<IType> getTestCasesInContext()
  {
    Set<IType> testTypes = new HashSet();
    List<IInteractionElement> interesting = ContextCore.getContextManager().getActiveContext().getInteresting();
    AbstractContextStructureBridge bridge = ContextCore.getStructureBridge("java");
    try
    {
      for (IInteractionElement element : interesting) {
        if (element.getContentType().equals("java"))
        {
          Object javaElement = bridge.getObjectForHandle(element.getHandleIdentifier());
          if ((javaElement instanceof IType))
          {
            IType type = (IType)javaElement;
            if (isTestType(type)) {
              testTypes.add(type);
            }
          }
          for (IInteractionRelation relation : element.getRelations()) {
            if (relation.getRelationshipHandle().equals("org.eclipse.mylyn.java.relation.junitreferences"))
            {
              IInteractionElement target = relation.getTarget();
              Object targetObject = bridge.getObjectForHandle(target.getHandleIdentifier());
              if ((targetObject instanceof IMethod))
              {
                IMethod testMethod = (IMethod)targetObject;
                if (isTestType((IType)testMethod.getParent())) {
                  testTypes.add((IType)testMethod.getParent());
                }
              }
            }
          }
        }
      }
    }
    catch (Exception e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.java.ui", "Could not add all test types", e));
    }
    return testTypes;
  }
  
  public static boolean isTestType(IType type)
  {
    try
    {
      if (Flags.isAbstract(type.getFlags())) {
        return false;
      }
    }
    catch (JavaModelException localJavaModelException1)
    {
      return false;
    }
    try
    {
      ITypeHierarchy hierarchy = type.newSupertypeHierarchy(null);
      IType[] supertypes = hierarchy.getAllSuperclasses(type);
      IType[] arrayOfIType1;
      int j = (arrayOfIType1 = supertypes).length;
      for (int i = 0; i < j; i++)
      {
        IType supertype = arrayOfIType1[i];
        if (supertype.getFullyQualifiedName().equals("junit.framework.TestCase")) {
          return true;
        }
      }
    }
    catch (JavaModelException localJavaModelException2) {}
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.java.ui.junit.InteractionContextTestUtil
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.java.ui.junit;

import java.util.Iterator;
import java.util.Set;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationTab;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.mylyn.internal.java.ui.JavaUiBridgePlugin;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

public class TaskContextJUnitMainTab
  extends JUnitLaunchConfigurationTab
{
  private boolean isPdeMode = false;
  private final Image image;
  
  public TaskContextJUnitMainTab(boolean isPdeMode)
  {
    this.isPdeMode = isPdeMode;
    image = JavaUiBridgePlugin.getImageDescriptor("icons/etool16/junit-tab.gif").createImage();
  }
  
  public boolean isValid(ILaunchConfiguration config)
  {
    return true;
  }
  
  public void createControl(Composite parent)
  {
    Composite comp = new Composite(parent, 0);
    setControl(comp);
    
    GridLayout topLayout = new GridLayout();
    numColumns = 3;
    comp.setLayout(topLayout);
    
    new Label(comp, 0);
    Label label = new Label(comp, 0);
    GridData gd = new GridData();
    horizontalSpan = 3;
    label.setLayoutData(gd);
    
    label.setText(Messages.TaskContextJUnitMainTab_SUBCLASSES_OF_TESTCASE_AUTOMATICALLY_ADD_TO_SUITE);
  }
  
  public void performApply(ILaunchConfigurationWorkingCopy config)
  {
    if (!isPdeMode)
    {
      Set<IType> types = InteractionContextTestUtil.getTestCasesInContext();
      if (!types.isEmpty())
      {
        IType firstType = (IType)types.iterator().next();
        String projectName = firstType.getJavaProject().getElementName();
        config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
      }
    }
  }
  
  public void setDefaults(ILaunchConfigurationWorkingCopy config) {}
  
  public void initializeFrom(ILaunchConfiguration config) {}
  
  public String getName()
  {
    return "JUnit";
  }
  
  public Image getImage()
  {
    return image;
  }
  
  public void dispose()
  {
    super.dispose();
    if ((image != null) && (!image.isDisposed())) {
      image.dispose();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.java.ui.junit.TaskContextJUnitMainTab
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.java.ui.junit;

import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;

class TaskContextJUnitLaunchConfiguration$1
  implements Runnable
{
  TaskContextJUnitLaunchConfiguration$1(TaskContextJUnitLaunchConfiguration paramTaskContextJUnitLaunchConfiguration) {}
  
  public void run()
  {
    MessageDialog.openInformation(Display.getCurrent().getActiveShell(), 
      Messages.TaskContextJUnitLaunchConfiguration_Context_Test_Suite, 
      Messages.TaskContextJUnitLaunchConfiguration_No_test_types_found_in_the_active_task_context);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.java.ui.junit.TaskContextJUnitLaunchConfiguration.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.java.ui.junit;

import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;

public class TaskContextJUnitLaunchConfiguration
  extends JUnitLaunchConfigurationDelegate
{
  protected IMember[] evaluateTests(ILaunchConfiguration configuration, IProgressMonitor monitor)
    throws CoreException
  {
    Set<IType> contextTestCases = InteractionContextTestUtil.getTestCasesInContext();
    InteractionContextTestUtil.setupTestConfiguration(contextTestCases, configuration, monitor);
    if (contextTestCases.isEmpty()) {
      PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
      {
        public void run()
        {
          MessageDialog.openInformation(Display.getCurrent().getActiveShell(), 
            Messages.TaskContextJUnitLaunchConfiguration_Context_Test_Suite, 
            Messages.TaskContextJUnitLaunchConfiguration_No_test_types_found_in_the_active_task_context);
        }
      });
    }
    return (IMember[])contextTestCases.toArray(new IMember[contextTestCases.size()]);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.java.ui.junit.TaskContextJUnitLaunchConfiguration
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.java.ui.junit;

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.java.ui.junit.messages";
  public static String TaskContextJUnitLaunchConfiguration_Context_Test_Suite;
  public static String TaskContextJUnitLaunchConfiguration_No_test_types_found_in_the_active_task_context;
  public static String TaskContextJUnitMainTab_SUBCLASSES_OF_TESTCASE_AUTOMATICALLY_ADD_TO_SUITE;
  
  static {}
  
  public static void reloadMessages()
  {
    NLS.initializeMessages("org.eclipse.mylyn.internal.java.ui.junit.messages", Messages.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.java.ui.junit.Messages
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.java.ui;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.eclipse.core.internal.resources.Marker;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IImportDeclaration;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IParent;
import org.eclipse.jdt.core.ISourceReference;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.core.JarEntryFile;
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
import org.eclipse.jdt.internal.ui.packageview.ClassPathContainer.RequiredProjectWrapper;
import org.eclipse.jdt.internal.ui.packageview.PackageFragmentRootContainer;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.context.core.AbstractContextStructureBridge;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IDegreeOfInterest;
import org.eclipse.mylyn.context.core.IInteractionContextManager;
import org.eclipse.mylyn.context.core.IInteractionElement;
import org.eclipse.ui.internal.WorkingSet;
import org.eclipse.ui.views.markers.internal.ConcreteMarker;

public class JavaStructureBridge
  extends AbstractContextStructureBridge
{
  public static final String CONTENT_TYPE = "java";
  
  public String getContentType()
  {
    return "java";
  }
  
  public Object getAdaptedParent(Object object)
  {
    if ((object instanceof IFile))
    {
      IFile file = (IFile)object;
      return JavaCore.create(file.getParent());
    }
    return super.getAdaptedParent(object);
  }
  
  public String getParentHandle(String handle)
  {
    IJavaElement javaElement = (IJavaElement)getObjectForHandle(handle);
    if ((javaElement != null) && (javaElement.getParent() != null)) {
      return getHandleIdentifier(javaElement.getParent());
    }
    return null;
  }
  
  public List<String> getChildHandles(String handle)
  {
    Object object = getObjectForHandle(handle);
    if ((object instanceof IJavaElement))
    {
      IJavaElement element = (IJavaElement)object;
      if ((element instanceof IParent))
      {
        IParent parent = (IParent)element;
        try
        {
          IJavaElement[] children = parent.getChildren();
          List<String> childHandles = new ArrayList();
          IJavaElement[] arrayOfIJavaElement1;
          int j = (arrayOfIJavaElement1 = children).length;
          for (int i = 0; i < j; i++)
          {
            IJavaElement element2 = arrayOfIJavaElement1[i];
            String childHandle = getHandleIdentifier(element2);
            if (childHandle != null) {
              childHandles.add(childHandle);
            }
          }
          AbstractContextStructureBridge parentBridge = ContextCore.getStructureBridge(parentContentType);
          if ((parentBridge != null) && ("resource".equals(parentBridge.getContentType())) && 
            (element.getElementType() < 7))
          {
            Object resourceChildren = parentBridge.getChildHandles(handle);
            if (!((List)resourceChildren).isEmpty()) {
              childHandles.addAll((Collection)resourceChildren);
            }
          }
          return childHandles;
        }
        catch (JavaModelException localJavaModelException)
        {
          AbstractContextStructureBridge parentBridge = ContextCore.getStructureBridge("resource");
          return parentBridge.getChildHandles(handle);
        }
        catch (Exception e)
        {
          StatusHandler.log(new Status(4, "org.eclipse.mylyn.java.ui", "Could not get children", 
            e));
        }
      }
    }
    return Collections.emptyList();
  }
  
  public Object getObjectForHandle(String handle)
  {
    try
    {
      return JavaCore.create(handle);
    }
    catch (Throwable t)
    {
      StatusHandler.log(new Status(2, "org.eclipse.mylyn.java.ui", 
        "Could not create java element for handle: " + handle, t));
    }
    return null;
  }
  
  public String getHandleIdentifier(Object object)
  {
    if ((object instanceof IJavaElement)) {
      return ((IJavaElement)object).getHandleIdentifier();
    }
    if ((object instanceof IAdaptable))
    {
      Object adapter = ((IAdaptable)object).getAdapter(IJavaElement.class);
      if ((adapter instanceof IJavaElement)) {
        return ((IJavaElement)adapter).getHandleIdentifier();
      }
    }
    else if (isWtpClass(object))
    {
      return getWtpElementHandle(object);
    }
    return null;
  }
  
  private String getWtpElementHandle(Object object)
  {
    Class<?> objectClass = object.getClass();
    try
    {
      Method getProjectMethod = objectClass.getMethod("getProject", new Class[0]);
      Object javaProject = getProjectMethod.invoke(object, new Object[0]);
      if ((javaProject instanceof IJavaProject)) {
        return ((IJavaElement)javaProject).getHandleIdentifier();
      }
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    return null;
  }
  
  private boolean isWtpClass(Object object)
  {
    try
    {
      return (object != null) && (object.getClass().getSimpleName().equals("CompressedJavaProject"));
    }
    catch (Throwable localThrowable) {}
    return false;
  }
  
  public String getLabel(Object object)
  {
    if ((object instanceof IJavaElement)) {
      return ((IJavaElement)object).getElementName();
    }
    return "";
  }
  
  public boolean canBeLandmark(String handle)
  {
    IJavaElement element = (IJavaElement)getObjectForHandle(handle);
    if ((((element instanceof IMember)) || ((element instanceof IType))) && (element.exists())) {
      return true;
    }
    return false;
  }
  
  public boolean acceptsObject(Object object)
  {
    if ((object instanceof IResource))
    {
      Object adapter = ((IResource)object).getAdapter(IJavaElement.class);
      return adapter instanceof IJavaElement;
    }
    boolean accepts = ((object instanceof IJavaElement)) || ((object instanceof PackageFragmentRootContainer)) || 
      ((object instanceof ClassPathContainer.RequiredProjectWrapper)) || ((object instanceof JarEntryFile)) || 
      ((object instanceof IPackageFragment)) || ((object instanceof WorkingSet)) || (isWtpClass(object));
    
    return accepts;
  }
  
  public boolean canFilter(Object object)
  {
    if ((object instanceof ClassPathContainer.RequiredProjectWrapper)) {
      return true;
    }
    Object localObject1;
    int j;
    int i;
    if ((object instanceof PackageFragmentRootContainer))
    {
      PackageFragmentRootContainer container = (PackageFragmentRootContainer)object;
      
      Object[] children = container.getChildren();
      j = (localObject1 = children).length;
      for (i = 0; i < j; i++)
      {
        Object element2 = localObject1[i];
        if ((element2 instanceof JarPackageFragmentRoot))
        {
          JarPackageFragmentRoot element = (JarPackageFragmentRoot)element2;
          IInteractionElement node = ContextCore.getContextManager()
            .getElement(element.getHandleIdentifier());
          if ((node != null) && (node.getInterest().isInteresting())) {
            return false;
          }
        }
      }
    }
    else if ((object instanceof WorkingSet))
    {
      try
      {
        WorkingSet workingSet = (WorkingSet)object;
        IAdaptable[] elements = workingSet.getElements();
        j = (localObject1 = elements).length;
        for (i = 0; i < j; i++)
        {
          IAdaptable adaptable = localObject1[i];
          IInteractionElement interactionElement = ContextCore.getContextManager().getElement(
            getHandleIdentifier(adaptable));
          if ((interactionElement != null) && (interactionElement.getInterest().isInteresting())) {
            return false;
          }
        }
      }
      catch (Exception e)
      {
        e.printStackTrace();
        return false;
      }
    }
    return true;
  }
  
  public boolean isDocument(String handle)
  {
    IJavaElement element = (IJavaElement)getObjectForHandle(handle);
    return ((element instanceof ICompilationUnit)) || ((element instanceof IClassFile));
  }
  
  public String getHandleForOffsetInObject(Object object, int offset)
  {
    IMarker marker;
    if ((object instanceof ConcreteMarker))
    {
      marker = ((ConcreteMarker)object).getMarker();
    }
    else
    {
      IMarker marker;
      if ((object instanceof Marker)) {
        marker = (Marker)object;
      } else {
        return null;
      }
    }
    try
    {
      ICompilationUnit compilationUnit = null;
      IResource resource = marker.getResource();
      if ((resource instanceof IFile))
      {
        IFile file = (IFile)resource;
        if (file.getFileExtension().equals("java")) {
          compilationUnit = JavaCore.createCompilationUnitFrom(file);
        } else {
          return null;
        }
      }
      if (compilationUnit != null)
      {
        int charStart = 0;
        Object attribute = Integer.valueOf(marker.getAttribute("charStart", 0));
        if ((attribute instanceof Integer)) {
          charStart = ((Integer)attribute).intValue();
        }
        IJavaElement javaElement = null;
        if (charStart != -1)
        {
          javaElement = compilationUnit.getElementAt(charStart);
        }
        else
        {
          int lineNumber = 0;
          Object lineNumberAttribute = Integer.valueOf(marker.getAttribute("lineNumber", 0));
          if ((lineNumberAttribute instanceof Integer)) {
            lineNumber = ((Integer)lineNumberAttribute).intValue();
          }
          if (lineNumber != -1) {
            javaElement = compilationUnit;
          }
        }
        if (javaElement != null)
        {
          if ((javaElement instanceof IImportDeclaration)) {
            javaElement = javaElement.getParent().getParent();
          }
          return javaElement.getHandleIdentifier();
        }
        return null;
      }
      return null;
    }
    catch (JavaModelException ex)
    {
      if (!ex.isDoesNotExist()) {
        ExceptionHandler.handle(ex, "error", "could not find java element");
      }
      return null;
    }
    catch (Throwable t)
    {
      IMarker marker;
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.java.ui", "Could not find element for: " + 
        marker, t));
    }
    return null;
  }
  
  public String getContentType(String elementHandle)
  {
    return getContentType();
  }
  
  public boolean containsProblem(IInteractionElement node)
  {
    try
    {
      IJavaElement element = (IJavaElement)getObjectForHandle(node.getHandleIdentifier());
      switch (element.getElementType())
      {
      case 2: 
      case 3: 
        return getErrorTicksFromMarkers(element.getResource(), 2, null);
      case 4: 
      case 5: 
      case 6: 
        return getErrorTicksFromMarkers(element.getResource(), 1, null);
      case 7: 
      case 8: 
      case 9: 
      case 10: 
      case 11: 
      case 12: 
      case 13: 
      case 14: 
        ICompilationUnit cu = (ICompilationUnit)element.getAncestor(5);
        if (cu != null) {
          return getErrorTicksFromMarkers(element.getResource(), 1, null);
        }
        break;
      }
    }
    catch (CoreException localCoreException) {}
    return false;
  }
  
  private boolean getErrorTicksFromMarkers(IResource res, int depth, ISourceReference sourceElement)
    throws CoreException
  {
    if ((res == null) || (!res.isAccessible())) {
      return false;
    }
    IMarker[] markers = res.findMarkers("org.eclipse.core.resources.problemmarker", true, depth);
    if (markers != null)
    {
      IMarker[] arrayOfIMarker1;
      int j = (arrayOfIMarker1 = markers).length;
      for (int i = 0; i < j; i++)
      {
        IMarker curr = arrayOfIMarker1[i];
        if (sourceElement == null)
        {
          int priority = curr.getAttribute("severity", -1);
          if (priority == 2) {
            return true;
          }
        }
      }
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.java.ui.JavaStructureBridge
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.java.ui;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.mylyn.context.core.IInteractionContext;

public class JavaStackTraceContextComputationStrategy
  extends AbstractJavaContextComputationStrategy
{
  private static final String PACKAGE_PART = "([a-z][a-z0-9]*)";
  private static final String CLASS_PART = "[A-Za-z][a-zA-Z0-9_$]*";
  private static final String FQN_PART = "((([a-z][a-z0-9]*)\\.)+[A-Za-z][a-zA-Z0-9_$]*)";
  private static final Pattern STACK_TRACE_PATTERN = Pattern.compile("\\s*((((Caused by:\\s+)|(at\\s+))?((([a-z][a-z0-9]*)\\.)+[A-Za-z][a-zA-Z0-9_$]*)((:\\s+\\w.*)|(\\.((\\<(?:cl)?init\\>)|([a-zA-Z0-9_$]+))\\(.*?\\)))?)|(\\.\\.\\.\\s\\d+\\smore))");
  private final SortedSet<String> filteredPrefixes = new TreeSet(
    Arrays.asList(new String[] { "java", "javax", "junit.framework", "sun.reflect" }));
  
  public static class Element
  {
    String fqn;
    String methodName;
    
    public Element(String fqn, String methodName)
    {
      Assert.isNotNull(fqn);
      this.fqn = fqn;
      this.methodName = methodName;
    }
    
    public Element() {}
    
    public String toString()
    {
      StringBuilder builder = new StringBuilder();
      builder.append("Element [fqn=");
      builder.append(fqn);
      builder.append(", methodName=");
      builder.append(methodName);
      builder.append("]");
      return builder.toString();
    }
    
    public int hashCode()
    {
      int result = 1;
      result = 31 * result + (fqn == null ? 0 : fqn.hashCode());
      result = 31 * result + (methodName == null ? 0 : methodName.hashCode());
      return result;
    }
    
    public boolean equals(Object obj)
    {
      if (this == obj) {
        return true;
      }
      if (obj == null) {
        return false;
      }
      if (getClass() != obj.getClass()) {
        return false;
      }
      Element other = (Element)obj;
      if (fqn == null)
      {
        if (fqn != null) {
          return false;
        }
      }
      else if (!fqn.equals(fqn)) {
        return false;
      }
      if (methodName == null)
      {
        if (methodName != null) {
          return false;
        }
      }
      else if (!methodName.equals(methodName)) {
        return false;
      }
      return true;
    }
  }
  
  private final int maxElements = 10;
  
  public List<Object> computeContext(IInteractionContext context, IAdaptable input, IProgressMonitor monitor)
  {
    String text = getText(input);
    if (text != null) {
      return computeContext(text, monitor);
    }
    return Collections.emptyList();
  }
  
  private String getText(IAdaptable input)
  {
    String text = (String)input.getAdapter(String.class);
    if (text != null) {
      return text;
    }
    return null;
  }
  
  /* Error */
  public List<Object> computeContext(String description, IProgressMonitor monitor)
  {
    // Byte code:
    //   0: aload_2
    //   1: invokestatic 250	org/eclipse/core/runtime/SubMonitor:convert	(Lorg/eclipse/core/runtime/IProgressMonitor;)Lorg/eclipse/core/runtime/SubMonitor;
    //   4: astore_3
    //   5: aload_0
    //   6: aload_1
    //   7: invokevirtual 253	org/eclipse/mylyn/internal/java/ui/JavaStackTraceContextComputationStrategy:computeElements	(Ljava/lang/String;)Ljava/util/List;
    //   10: astore 4
    //   12: aload 4
    //   14: invokeinterface 262 1 0
    //   19: ifne +265 -> 284
    //   22: aload_3
    //   23: getstatic 231	org/eclipse/mylyn/internal/java/ui/Messages:JavaStackTraceContextComputationStrategy_Finding_Java_Context_Element_Progress_Label	Ljava/lang/String;
    //   26: aload 4
    //   28: invokeinterface 261 1 0
    //   33: invokevirtual 249	org/eclipse/core/runtime/SubMonitor:beginTask	(Ljava/lang/String;I)V
    //   36: new 112	java/util/ArrayList
    //   39: dup
    //   40: invokespecial 237	java/util/ArrayList:<init>	()V
    //   43: astore 5
    //   45: aload 4
    //   47: invokeinterface 264 1 0
    //   52: astore 7
    //   54: goto +200 -> 254
    //   57: aload 7
    //   59: invokeinterface 260 1 0
    //   64: checkcast 129	org/eclipse/mylyn/internal/java/ui/JavaStackTraceContextComputationStrategy$Element
    //   67: astore 6
    //   69: aload_3
    //   70: invokevirtual 247	org/eclipse/core/runtime/SubMonitor:isCanceled	()Z
    //   73: ifeq +6 -> 79
    //   76: goto +200 -> 276
    //   79: aload_0
    //   80: getfield 227	org/eclipse/mylyn/internal/java/ui/JavaStackTraceContextComputationStrategy:filteredPrefixes	Ljava/util/SortedSet;
    //   83: aload 6
    //   85: getfield 229	org/eclipse/mylyn/internal/java/ui/JavaStackTraceContextComputationStrategy$Element:fqn	Ljava/lang/String;
    //   88: invokeinterface 267 2 0
    //   93: astore 8
    //   95: aload 8
    //   97: invokeinterface 265 1 0
    //   102: ifne +24 -> 126
    //   105: aload 6
    //   107: getfield 229	org/eclipse/mylyn/internal/java/ui/JavaStackTraceContextComputationStrategy$Element:fqn	Ljava/lang/String;
    //   110: aload 8
    //   112: invokeinterface 266 1 0
    //   117: checkcast 6	java/lang/String
    //   120: invokevirtual 236	java/lang/String:startsWith	(Ljava/lang/String;)Z
    //   123: ifne +126 -> 249
    //   126: aload_0
    //   127: aload 6
    //   129: getfield 229	org/eclipse/mylyn/internal/java/ui/JavaStackTraceContextComputationStrategy$Element:fqn	Ljava/lang/String;
    //   132: invokevirtual 254	org/eclipse/mylyn/internal/java/ui/JavaStackTraceContextComputationStrategy:findTypeInWorkspace	(Ljava/lang/String;)Lorg/eclipse/jdt/core/IType;
    //   135: astore 9
    //   137: aload 9
    //   139: ifnull +110 -> 249
    //   142: aload 5
    //   144: aload 9
    //   146: invokeinterface 263 2 0
    //   151: pop
    //   152: aload 6
    //   154: getfield 230	org/eclipse/mylyn/internal/java/ui/JavaStackTraceContextComputationStrategy$Element:methodName	Ljava/lang/String;
    //   157: ifnull +92 -> 249
    //   160: aload 9
    //   162: invokeinterface 271 1 0
    //   167: astore 10
    //   169: aload 10
    //   171: dup
    //   172: astore 14
    //   174: arraylength
    //   175: istore 13
    //   177: iconst_0
    //   178: istore 12
    //   180: goto +41 -> 221
    //   183: aload 14
    //   185: iload 12
    //   187: aaload
    //   188: astore 11
    //   190: aload 11
    //   192: invokeinterface 270 1 0
    //   197: aload 6
    //   199: getfield 230	org/eclipse/mylyn/internal/java/ui/JavaStackTraceContextComputationStrategy$Element:methodName	Ljava/lang/String;
    //   202: invokevirtual 235	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   205: ifeq +13 -> 218
    //   208: aload 5
    //   210: aload 11
    //   212: invokeinterface 263 2 0
    //   217: pop
    //   218: iinc 12 1
    //   221: iload 12
    //   223: iload 13
    //   225: if_icmplt -42 -> 183
    //   228: goto +21 -> 249
    //   231: astore 9
    //   233: invokestatic 258	org/eclipse/mylyn/internal/java/ui/JavaUiBridgePlugin:getDefault	()Lorg/eclipse/mylyn/internal/java/ui/JavaUiBridgePlugin;
    //   236: invokevirtual 257	org/eclipse/mylyn/internal/java/ui/JavaUiBridgePlugin:getLog	()Lorg/eclipse/core/runtime/ILog;
    //   239: aload 9
    //   241: invokevirtual 245	org/eclipse/core/runtime/CoreException:getStatus	()Lorg/eclipse/core/runtime/IStatus;
    //   244: invokeinterface 269 2 0
    //   249: aload_3
    //   250: iconst_1
    //   251: invokevirtual 248	org/eclipse/core/runtime/SubMonitor:worked	(I)V
    //   254: aload 7
    //   256: invokeinterface 259 1 0
    //   261: ifne -204 -> 57
    //   264: goto +12 -> 276
    //   267: astore 15
    //   269: aload_3
    //   270: invokevirtual 246	org/eclipse/core/runtime/SubMonitor:done	()V
    //   273: aload 15
    //   275: athrow
    //   276: aload_3
    //   277: invokevirtual 246	org/eclipse/core/runtime/SubMonitor:done	()V
    //   280: aload 5
    //   282: areturn
    //   283: pop
    //   284: invokestatic 239	java/util/Collections:emptyList	()Ljava/util/List;
    //   287: areturn
    // Line number table:
    //   Java source line #142	-> byte code offset #0
    //   Java source line #144	-> byte code offset #5
    //   Java source line #145	-> byte code offset #12
    //   Java source line #147	-> byte code offset #22
    //   Java source line #148	-> byte code offset #23
    //   Java source line #149	-> byte code offset #26
    //   Java source line #147	-> byte code offset #33
    //   Java source line #151	-> byte code offset #36
    //   Java source line #153	-> byte code offset #45
    //   Java source line #154	-> byte code offset #69
    //   Java source line #155	-> byte code offset #76
    //   Java source line #158	-> byte code offset #79
    //   Java source line #159	-> byte code offset #95
    //   Java source line #161	-> byte code offset #126
    //   Java source line #162	-> byte code offset #137
    //   Java source line #163	-> byte code offset #142
    //   Java source line #164	-> byte code offset #152
    //   Java source line #165	-> byte code offset #160
    //   Java source line #166	-> byte code offset #169
    //   Java source line #167	-> byte co
1 2 3 4 5

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd