org.eclipse.cdt.codan.ui.cxx_2.0.0.201202111925

16:41:36.555 INFO  jd.cli.Main - Decompiling org.eclipse.cdt.codan.ui.cxx_2.0.0.201202111925.jar
package org.eclipse.cdt.codan.ui;

import org.eclipse.cdt.codan.core.CodanRuntime;
import org.eclipse.cdt.codan.core.model.ICheckersRegistry;
import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.core.model.IProblemProfile;
import org.eclipse.cdt.codan.internal.core.model.CodanProblemMarker;
import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.ui.CDTUITools;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;

public abstract class AbstractCodanCMarkerResolution
  implements ICodanMarkerResolution
{
  private boolean codanProblem;
  
  public int getOffset(IMarker marker, IDocument doc)
  {
    int charStart = marker.getAttribute("charStart", -1);
    int position;
    if (charStart > 0)
    {
      position = charStart;
    }
    else
    {
      int line = marker.getAttribute("lineNumber", -1) - 1;
      try
      {
        position = doc.getLineOffset(line);
      }
      catch (BadLocationException localBadLocationException)
      {
        int position;
        return -1;
      }
    }
    int position;
    return position;
  }
  
  public boolean isCodanProblem()
  {
    return codanProblem;
  }
  
  public String getProblemArgument(IMarker marker, int index)
  {
    return CodanProblemMarker.getProblemArgument(marker, index);
  }
  
  public void run(IMarker marker)
  {
    IDocument doc = openDocument(marker);
    if (doc != null)
    {
      codanProblem = (getProblemId(marker) != null);
      apply(marker, doc);
    }
  }
  
  public abstract void apply(IMarker paramIMarker, IDocument paramIDocument);
  
  public boolean isApplicable(IMarker marker)
  {
    return true;
  }
  
  protected IEditorPart openEditor(IMarker marker)
  {
    try
    {
      editorPart = CodanEditorUtility.openInEditor(marker);
    }
    catch (PartInitException e)
    {
      IEditorPart editorPart;
      CodanUIActivator.log(e);
      return null;
    }
    IEditorPart editorPart;
    return editorPart;
  }
  
  protected IDocument openDocument(IMarker marker)
  {
    return openDocument(openEditor(marker));
  }
  
  protected IDocument openDocument(IEditorPart editorPart)
  {
    if ((editorPart instanceof ITextEditor))
    {
      ITextEditor editor = (ITextEditor)editorPart;
      IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
      return doc;
    }
    return null;
  }
  
  protected ITranslationUnit getTranslationUnitViaEditor(IMarker marker)
  {
    ITranslationUnit tu = (ITranslationUnit)CDTUITools.getEditorInputCElement(openEditor(marker).getEditorInput());
    return tu;
  }
  
  protected ITranslationUnit getTranslationUnitViaWorkspace(IMarker marker)
  {
    IPath path = marker.getResource().getFullPath();
    IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
    ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(file);
    return tu;
  }
  
  protected IASTName getASTNameFromMarker(IMarker marker, IASTTranslationUnit ast)
  {
    int charStart = marker.getAttribute("charStart", -1);
    int length = marker.getAttribute("charEnd", -1) - charStart;
    return getASTNameFromPositions(ast, charStart, length);
  }
  
  protected IASTName getASTNameFromPositions(IASTTranslationUnit ast, int charStart, int length)
  {
    IASTName name = ast.getNodeSelector(null).findEnclosingName(charStart, length);
    return name;
  }
  
  protected IIndex getIndexFromMarker(IMarker marker)
    throws CoreException
  {
    IProject project = marker.getResource().getProject();
    ICProject cProject = CoreModel.getDefault().create(project);
    IIndex index = CCorePlugin.getIndexManager().getIndex(cProject);
    return index;
  }
  
  public String getProblemId(IMarker marker)
  {
    return CodanProblemMarker.getProblemId(marker);
  }
  
  public IProblem getProblem(IMarker marker)
  {
    IPath path = marker.getResource().getFullPath();
    IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
    if (file == null) {
      return null;
    }
    IProblemProfile profile = CodanRuntime.getInstance().getCheckersRegistry().getResourceProfile(file);
    String id = getProblemId(marker);
    return profile.findProblem(id);
  }
  
  public String getProblemMessage(IMarker marker)
  {
    return CodanProblemMarker.getMessage(marker);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.cdt.codan.ui.AbstractCodanCMarkerResolution
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.cdt.codan.ui;

import org.eclipse.cdt.codan.internal.ui.cxx.Activator;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.FindReplaceDocumentAdapter;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.ui.IEditorPart;

public abstract class AbstractAstRewriteQuickFix
  extends AbstractCodanCMarkerResolution
{
  private IDocument document;
  
  public void apply(IMarker marker, IDocument document)
  {
    try
    {
      this.document = document;
      openEditor(marker).doSave(new NullProgressMonitor());
      try
      {
        index = getIndexFromMarker(marker);
      }
      catch (CoreException e)
      {
        IIndex index;
        Activator.log(e); return;
      }
      IIndex index;
      try
      {
        index.acquireReadLock();
      }
      catch (InterruptedException localInterruptedException)
      {
        return;
      }
      try
      {
        modifyAST(index, marker);
      }
      finally
      {
        index.releaseReadLock();
      }
    }
    catch (Exception e)
    {
      Activator.log(e);
    }
  }
  
  public abstract void modifyAST(IIndex paramIIndex, IMarker paramIMarker);
  
  public IDocument getDocument()
  {
    return document;
  }
  
  public IASTName getAstNameFromProblemArgument(IMarker marker, IASTTranslationUnit ast, int argumentIndex)
  {
    IASTName astName = null;
    int pos = getOffset(marker, getDocument());
    String name = null;
    try
    {
      name = getProblemArgument(marker, argumentIndex);
    }
    catch (Exception localException)
    {
      return null;
    }
    if (name == null) {
      return null;
    }
    FindReplaceDocumentAdapter dad = new FindReplaceDocumentAdapter(getDocument());
    try
    {
      region = dad.find(pos, name, 
        true, true, 
        true, false);
    }
    catch (BadLocationException localBadLocationException)
    {
      IRegion region;
      return null;
    }
    IRegion region;
    astName = getASTNameFromPositions(ast, region.getOffset(), region.getLength());
    return astName;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.cdt.codan.ui.AbstractAstRewriteQuickFix
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.cdt.codan.internal.ui.cxx;

import org.eclipse.cdt.codan.core.cxx.internal.model.CxxCodanReconciler;
import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.texteditor.ITextEditor;

public class CodanCReconciler
  implements ICReconcilingListener
{
  private CxxCodanReconciler reconsiler = new CxxCodanReconciler();
  
  void install(ITextEditor editor)
  {
    if ((editor instanceof CEditor))
    {
      initialize();
      ((CEditor)editor).addReconcileListener(this);
    }
  }
  
  void uninstall(ITextEditor editor)
  {
    if ((editor instanceof CEditor))
    {
      initialize();
      ((CEditor)editor).removeReconcileListener(this);
    }
  }
  
  private void initialize() {}
  
  public void aboutToBeReconciled() {}
  
  public void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor)
  {
    if (ast == null) {
      return;
    }
    ITranslationUnit tu = ast.getOriginatingTranslationUnit();
    if (tu == null) {
      return;
    }
    IResource resource = tu.getResource();
    if (resource == null) {
      return;
    }
    IProject project = resource.getProject();
    IPreferenceStore store = CodanUIActivator.getDefault().getPreferenceStore(project);
    if (store.getBoolean("inEditor")) {
      reconsiler.reconciledAst(ast, resource, progressMonitor);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.cdt.codan.internal.ui.cxx.CodanCReconciler
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.cdt.codan.internal.ui.cxx;

import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IPartListener2;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.ITextEditor;

public class Startup
  implements IStartup
{
  public void earlyStartup()
  {
    registerListeners();
  }
  
  private void registerListeners()
  {
    final IWorkbench workbench = PlatformUI.getWorkbench();
    workbench.getDisplay().asyncExec(new Runnable()
    {
      public void run()
      {
        IWorkbenchWindow active = workbench.getActiveWorkbenchWindow();
        IWorkbenchPage page = active.getActivePage();
        IPartListener2 partListener = new IPartListener2()
        {
          CodanCReconciler reconsiler = new CodanCReconciler();
          
          public void partActivated(IWorkbenchPartReference partRef) {}
          
          public void partDeactivated(IWorkbenchPartReference partRef) {}
          
          public void partOpened(IWorkbenchPartReference partRef)
          {
            IWorkbenchPart editor = partRef.getPart(false);
            if ((editor instanceof ITextEditor)) {
              reconsiler.install((ITextEditor)editor);
            }
          }
          
          public void partHidden(IWorkbenchPartReference partRef) {}
          
          public void partVisible(IWorkbenchPartReference partRef) {}
          
          public void partClosed(IWorkbenchPartReference partRef)
          {
            IWorkbenchPart part = partRef.getPart(false);
            if ((part instanceof ITextEditor)) {
              reconsiler.uninstall((ITextEditor)part);
            }
          }
          
          public void partBroughtToTop(IWorkbenchPartReference partRef) {}
          
          public void partInputChanged(IWorkbenchPartReference partRef) {}
        };
        page.addPartListener(partListener);
        
        IEditorReference[] editorReferences = page.getEditorReferences();
        for (int i = 0; i < editorReferences.length; i++)
        {
          IEditorReference ref = editorReferences[i];
          partListener.partOpened(ref);
        }
      }
    });
  }
}

/* Location:
 * Qualified Name:     org.eclipse.cdt.codan.internal.ui.cxx.Startup
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.cdt.codan.internal.ui.cxx;

import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IPartListener2;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.texteditor.ITextEditor;

class Startup$1
  implements Runnable
{
  Startup$1(Startup paramStartup, IWorkbench paramIWorkbench) {}
  
  public void run()
  {
    IWorkbenchWindow active = val$workbench.getActiveWorkbenchWindow();
    IWorkbenchPage page = active.getActivePage();
    IPartListener2 partListener = new IPartListener2()
    {
      CodanCReconciler reconsiler = new CodanCReconciler();
      
      public void partActivated(IWorkbenchPartReference partRef) {}
      
      public void partDeactivated(IWorkbenchPartReference partRef) {}
      
      public void partOpened(IWorkbenchPartReference partRef)
      {
        IWorkbenchPart editor = partRef.getPart(false);
        if ((editor instanceof ITextEditor)) {
          reconsiler.install((ITextEditor)editor);
        }
      }
      
      public void partHidden(IWorkbenchPartReference partRef) {}
      
      public void partVisible(IWorkbenchPartReference partRef) {}
      
      public void partClosed(IWorkbenchPartReference partRef)
      {
        IWorkbenchPart part = partRef.getPart(false);
        if ((part instanceof ITextEditor)) {
          reconsiler.uninstall((ITextEditor)part);
        }
      }
      
      public void partBroughtToTop(IWorkbenchPartReference partRef) {}
      
      public void partInputChanged(IWorkbenchPartReference partRef) {}
    };
    page.addPartListener(partListener);
    
    IEditorReference[] editorReferences = page.getEditorReferences();
    for (int i = 0; i < editorReferences.length; i++)
    {
      IEditorReference ref = editorReferences[i];
      partListener.partOpened(ref);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.cdt.codan.internal.ui.cxx.Startup.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.cdt.codan.internal.ui.cxx;

import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
import org.eclipse.cdt.ui.text.ICCompletionProposal;
import org.eclipse.cdt.ui.text.IInvocationContext;
import org.eclipse.cdt.ui.text.IProblemLocation;
import org.eclipse.cdt.ui.text.IQuickFixProcessor;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;

public abstract class AbstractCodanCQuickFixProcessor
  implements IQuickFixProcessor
{
  public boolean hasCorrections(ITranslationUnit unit, int problemId)
  {
    return problemId == 42;
  }
  
  public ICCompletionProposal[] getCorrections(IInvocationContext context, IProblemLocation[] locations)
    throws CoreException
  {
    if ((locations == null) || (locations.length == 0)) {
      return null;
    }
    IProblemLocation loc = locations[0];
    IPath location = context.getTranslationUnit().getLocation();
    IFile astFile = ResourceLookup.selectFileForLocation(location, context.getTranslationUnit().getCProject().getProject());
    IMarker[] markers = astFile.findMarkers(loc.getMarkerType(), false, 1);
    for (int i = 0; i < markers.length; i++)
    {
      IMarker m = markers[i];
      int start = m.getAttribute("charStart", -1);
      if (start == loc.getOffset())
      {
        String id = m.getAttribute("id", "");
        return getCorrections(context, id, m);
      }
    }
    return null;
  }
  
  public int getOffset(IMarker marker, IDocument doc)
  {
    int charStart = marker.getAttribute("charStart", -1);
    int position;
    if (charStart > 0)
    {
      position = charStart;
    }
    else
    {
      int line = marker.getAttribute("lineNumber", -1) - 1;
      try
      {
        position = doc.getLineOffset(line);
      }
      catch (BadLocationException localBadLocationException)
      {
        int position;
        return -1;
      }
    }
    int position;
    return position;
  }
  
  public abstract ICCompletionProposal[] getCorrections(IInvocationContext paramIInvocationContext, String paramString, IMarker paramIMarker);
}

/* Location:
 * Qualified Name:     org.eclipse.cdt.codan.internal.ui.cxx.AbstractCodanCQuickFixProcessor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.cdt.codan.internal.ui.cxx;

import org.eclipse.ui.IPartListener2;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.texteditor.ITextEditor;

class Startup$1$1
  implements IPartListener2
{
  CodanCReconciler reconsiler = new CodanCReconciler();
  
  Startup$1$1(Startup.1 param1) {}
  
  public void partActivated(IWorkbenchPartReference partRef) {}
  
  public void partDeactivated(IWorkbenchPartReference partRef) {}
  
  public void partOpened(IWorkbenchPartReference partRef)
  {
    IWorkbenchPart editor = partRef.getPart(false);
    if ((editor instanceof ITextEditor)) {
      reconsiler.install((ITextEditor)editor);
    }
  }
  
  public void partHidden(IWorkbenchPartReference partRef) {}
  
  public void partVisible(IWorkbenchPartReference partRef) {}
  
  public void partClosed(IWorkbenchPartReference partRef)
  {
    IWorkbenchPart part = partRef.getPart(false);
    if ((part instanceof ITextEditor)) {
      reconsiler.uninstall((ITextEditor)part);
    }
  }
  
  public void partBroughtToTop(IWorkbenchPartReference partRef) {}
  
  public void partInputChanged(IWorkbenchPartReference partRef) {}
}

/* Location:
 * Qualified Name:     org.eclipse.cdt.codan.internal.ui.cxx.Startup.1.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.cdt.codan.internal.ui.cxx;

import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

public class Activator
  extends AbstractUIPlugin
{
  public static final String PLUGIN_ID = "org.eclipse.cdt.codan.internal.ui.cxx";
  private static Activator plugin;
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    plugin = this;
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    plugin = null;
    super.stop(context);
  }
  
  public static Activator getDefault()
  {
    return plugin;
  }
  
  public static void log(IStatus status)
  {
    getDefault().getLog().log(status);
  }
  
  public static void log(Throwable e)
  {
    log(new Status(4, "org.eclipse.cdt.codan.internal.ui.cxx", 1, "Internal Error", e));
  }
  
  public static void log(String message)
  {
    log(new Status(4, "org.eclipse.cdt.codan.internal.ui.cxx", 1, message, null));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.cdt.codan.internal.ui.cxx.Activator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
1

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-2019. Infinite Loop Ltd