Ignore:
Timestamp:
03/23/12 20:31:53 (13 years ago)
Author:
masberg
Message:

The ProblemHover? class is severely broken and non-functional. As a first step, we fix all the warnings in the file, but it should probably be removed from trunk. If someone wants to work on this, it should take place on a branch and merged to trunk when ready.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/org.modelica.mdt.ui/src/org/modelica/mdt/ui/hover/ProblemHover.java

    r694 r1438  
    1111package org.modelica.mdt.ui.hover;
    1212
    13 import java.util.ArrayList;
    14 import java.util.Collections;
    15 import java.util.HashMap;
    16 import java.util.Map;
    17 
    18 import org.eclipse.swt.SWT;
    19 import org.eclipse.swt.widgets.Shell;
    20 
    21 import org.eclipse.core.resources.IFile;
    22 import org.eclipse.core.resources.IMarker;
    23 import org.eclipse.core.resources.IResource;
    24 
    25 import org.eclipse.jface.action.Action;
    2613import org.eclipse.jface.action.ToolBarManager;
    27 import org.eclipse.jface.dialogs.MessageDialog;
    2814
    2915import org.eclipse.jface.text.IInformationControl;
     
    3218import org.eclipse.jface.text.contentassist.ICompletionProposal;
    3319import org.eclipse.jface.text.source.Annotation;
    34 import org.eclipse.jface.text.source.IAnnotationModel;
    35 import org.eclipse.jface.text.source.ISourceViewer;
    36 
    37 import org.eclipse.ui.IEditorInput;
    38 import org.eclipse.ui.PlatformUI;
    39 import org.eclipse.ui.dialogs.PreferencesUtil;
    4020
    4121import org.eclipse.ui.texteditor.MarkerAnnotation;
    42 import org.eclipse.ui.texteditor.spelling.SpellingAnnotation;
    43 import org.modelica.mdt.core.IModelicaElement;
    44 import org.modelica.mdt.core.IModelicaFolder;
    45 import org.modelica.mdt.core.IModelicaProject;
    46 import org.modelica.mdt.core.IModelicaSourceFile;
    47 import org.modelica.mdt.core.compiler.IProblem;
    48 import org.modelica.mdt.internal.core.ModelicaFolder;
    49 import org.modelica.mdt.internal.core.ModelicaSourceFile;
    50 import org.modelica.mdt.ui.editor.EditorUtility;
    51 import org.modelica.mdt.ui.text.modelica.IProblemLocation;
    5222
    5323/**
     
    6535    protected static class ProblemInfo extends AnnotationInfo {
    6636
    67         private static final ICompletionProposal[] NO_PROPOSALS= new ICompletionProposal[0];
     37        private static final ICompletionProposal[] NO_PROPOSALS = new ICompletionProposal[0];
    6838
    6939        public ProblemInfo(Annotation annotation, Position position, ITextViewer textViewer) {
     
    7545         */
    7646        public ICompletionProposal[] getCompletionProposals() {
    77 
    78             if (annotation instanceof MarkerAnnotation)
     47            if (annotation instanceof MarkerAnnotation) {
    7948                return getMarkerAnnotationFixes((MarkerAnnotation) annotation);
     49            }
    8050
    8151            return NO_PROPOSALS;
    8252        }
    8353
    84 
    85         private static boolean hasProblem(IProblem[] problems, IProblemLocation location) {
    86 //          for (int i= 0; i < problems.length; i++) {
    87 //              IProblem problem= problems[i];
    88 //              if (problem.getID() == location.getProblemId() && problem.getSourceStart() == location.getOffset())
    89 //                  return true;
    90 //          }
    91             return false;
    92         }
    93 
    9454        private ICompletionProposal[] getMarkerAnnotationFixes(MarkerAnnotation markerAnnotation) {
    95             if (markerAnnotation.isQuickFixableStateSet() && !markerAnnotation.isQuickFixable())
    96                 return NO_PROPOSALS;
    97 
    98             IMarker marker= markerAnnotation.getMarker();
    99 
    100             IModelicaSourceFile cu= getCompilationUnit(marker);
    101             if (cu == null)
    102                 return NO_PROPOSALS;
    103 
    104 //          IEditorInput input= EditorUtility.getEditorInput(cu);
    105 //          if (input == null)
    106 //              return NO_PROPOSALS;
    107 
    108             IAnnotationModel model= ((ISourceViewer)viewer).getAnnotationModel();
    109             if (model == null)
    110                 return NO_PROPOSALS;
    111 
    112             ISourceViewer sourceViewer= null;
    113             if (viewer instanceof ISourceViewer)
    114                 sourceViewer= (ISourceViewer) viewer;
    115 
    116             ArrayList proposals= new ArrayList();
    117             return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
    118         }
    119 
    120         private static IModelicaSourceFile getCompilationUnit(IMarker marker) {
    121             IResource res= marker.getResource();
    122             if (res instanceof IFile && res.isAccessible()) {
    123                 IModelicaElement element= new ModelicaSourceFile((ModelicaFolder)res.getParent(), (IFile)res);
    124                 if (element instanceof IModelicaSourceFile)
    125                     return (IModelicaSourceFile) element;
    126             }
    127             return null;
     55            return NO_PROPOSALS;
    12856        }
    12957
     
    13462            super.fillToolBar(manager, infoControl);
    13563        }
    136 
    13764    }
    13865
Note: See TracChangeset for help on using the changeset viewer.