Changeset 1438 for trunk/org.modelica.mdt.ui/src/org/modelica
- Timestamp:
- 03/23/12 20:31:53 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/org.modelica.mdt.ui/src/org/modelica/mdt/ui/hover/ProblemHover.java
r694 r1438 11 11 package org.modelica.mdt.ui.hover; 12 12 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;26 13 import org.eclipse.jface.action.ToolBarManager; 27 import org.eclipse.jface.dialogs.MessageDialog;28 14 29 15 import org.eclipse.jface.text.IInformationControl; … … 32 18 import org.eclipse.jface.text.contentassist.ICompletionProposal; 33 19 import 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;40 20 41 21 import 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;52 22 53 23 /** … … 65 35 protected static class ProblemInfo extends AnnotationInfo { 66 36 67 private static final ICompletionProposal[] NO_PROPOSALS = new ICompletionProposal[0];37 private static final ICompletionProposal[] NO_PROPOSALS = new ICompletionProposal[0]; 68 38 69 39 public ProblemInfo(Annotation annotation, Position position, ITextViewer textViewer) { … … 75 45 */ 76 46 public ICompletionProposal[] getCompletionProposals() { 77 78 if (annotation instanceof MarkerAnnotation) 47 if (annotation instanceof MarkerAnnotation) { 79 48 return getMarkerAnnotationFixes((MarkerAnnotation) annotation); 49 } 80 50 81 51 return NO_PROPOSALS; 82 52 } 83 53 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 94 54 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; 128 56 } 129 57 … … 134 62 super.fillToolBar(manager, infoControl); 135 63 } 136 137 64 } 138 65
Note: See TracChangeset
for help on using the changeset viewer.