OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012, the Dart project authors. | 2 * Copyright (c) 2012, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
(...skipping 14 matching lines...) Expand all Loading... |
25 import com.google.dart.engine.ast.visitor.NodeLocator; | 25 import com.google.dart.engine.ast.visitor.NodeLocator; |
26 import com.google.dart.engine.context.AnalysisContext; | 26 import com.google.dart.engine.context.AnalysisContext; |
27 import com.google.dart.engine.element.CompilationUnitElement; | 27 import com.google.dart.engine.element.CompilationUnitElement; |
28 import com.google.dart.engine.index.Index; | 28 import com.google.dart.engine.index.Index; |
29 import com.google.dart.engine.search.SearchEngine; | 29 import com.google.dart.engine.search.SearchEngine; |
30 import com.google.dart.engine.search.SearchEngineFactory; | 30 import com.google.dart.engine.search.SearchEngineFactory; |
31 import com.google.dart.engine.services.assist.AssistContext; | 31 import com.google.dart.engine.services.assist.AssistContext; |
32 import com.google.dart.engine.source.FileBasedSource; | 32 import com.google.dart.engine.source.FileBasedSource; |
33 import com.google.dart.engine.source.Source; | 33 import com.google.dart.engine.source.Source; |
34 import com.google.dart.engine.utilities.source.SourceRange; | 34 import com.google.dart.engine.utilities.source.SourceRange; |
| 35 import com.google.dart.server.Outline; |
35 import com.google.dart.tools.core.DartCore; | 36 import com.google.dart.tools.core.DartCore; |
36 import com.google.dart.tools.core.DartCoreDebug; | 37 import com.google.dart.tools.core.DartCoreDebug; |
37 import com.google.dart.tools.core.MessageConsole; | 38 import com.google.dart.tools.core.MessageConsole; |
| 39 import com.google.dart.tools.core.analysis.model.AnalysisServerData; |
| 40 import com.google.dart.tools.core.analysis.model.AnalysisServerOutlineListener; |
38 import com.google.dart.tools.core.analysis.model.Project; | 41 import com.google.dart.tools.core.analysis.model.Project; |
39 import com.google.dart.tools.core.analysis.model.ProjectManager; | 42 import com.google.dart.tools.core.analysis.model.ProjectManager; |
40 import com.google.dart.tools.core.formatter.DefaultCodeFormatterConstants; | 43 import com.google.dart.tools.core.formatter.DefaultCodeFormatterConstants; |
41 import com.google.dart.tools.core.model.CompilationUnit; | 44 import com.google.dart.tools.core.model.CompilationUnit; |
42 import com.google.dart.tools.core.model.DartElement; | 45 import com.google.dart.tools.core.model.DartElement; |
43 import com.google.dart.tools.core.model.DartModelException; | 46 import com.google.dart.tools.core.model.DartModelException; |
44 import com.google.dart.tools.core.model.SourceReference; | 47 import com.google.dart.tools.core.model.SourceReference; |
45 import com.google.dart.tools.core.utilities.general.SourceRangeFactory; | 48 import com.google.dart.tools.core.utilities.general.SourceRangeFactory; |
46 import com.google.dart.tools.internal.corext.refactoring.util.ExecutionUtils; | 49 import com.google.dart.tools.internal.corext.refactoring.util.ExecutionUtils; |
47 import com.google.dart.tools.internal.corext.refactoring.util.RunnableEx; | 50 import com.google.dart.tools.internal.corext.refactoring.util.RunnableEx; |
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1707 | 1710 |
1708 /** Preference key for matching brackets */ | 1711 /** Preference key for matching brackets */ |
1709 protected final static String MATCHING_BRACKETS = PreferenceConstants.EDITOR_M
ATCHING_BRACKETS; | 1712 protected final static String MATCHING_BRACKETS = PreferenceConstants.EDITOR_M
ATCHING_BRACKETS; |
1710 | 1713 |
1711 /** Preference key for matching brackets color */ | 1714 /** Preference key for matching brackets color */ |
1712 protected final static String MATCHING_BRACKETS_COLOR = PreferenceConstants.ED
ITOR_MATCHING_BRACKETS_COLOR; | 1715 protected final static String MATCHING_BRACKETS_COLOR = PreferenceConstants.ED
ITOR_MATCHING_BRACKETS_COLOR; |
1713 | 1716 |
1714 protected final static char[] BRACKETS = {'{', '}', '(', ')', '[', ']', '<', '
>'}; | 1717 protected final static char[] BRACKETS = {'{', '}', '(', ')', '[', ']', '<', '
>'}; |
1715 | 1718 |
1716 /** The outline page */ | 1719 /** The outline page */ |
1717 protected DartOutlinePage fOutlinePage; | 1720 protected DartOutlinePage fOutlinePage_OLD; |
| 1721 |
| 1722 /** The outline page */ |
| 1723 protected DartOutlinePage_NEW fOutlinePage_NEW; |
| 1724 |
| 1725 private AnalysisServerOutlineListener analysisServerOutlineListener = new Anal
ysisServerOutlineListener() { |
| 1726 @Override |
| 1727 public void computedOutline(String contextId, Source source, final Outline o
utline) { |
| 1728 if (fOutlinePage_NEW != null) { |
| 1729 Display.getDefault().asyncExec(new Runnable() { |
| 1730 @Override |
| 1731 public void run() { |
| 1732 fOutlinePage_NEW.setInput(outline); |
| 1733 } |
| 1734 }); |
| 1735 } |
| 1736 } |
| 1737 }; |
1718 | 1738 |
1719 /** Outliner context menu Id */ | 1739 /** Outliner context menu Id */ |
1720 protected String fOutlinerContextMenuId; | 1740 protected String fOutlinerContextMenuId; |
1721 /** | 1741 /** |
1722 * The editor selection changed listener. | 1742 * The editor selection changed listener. |
1723 */ | 1743 */ |
1724 private EditorSelectionChangedListener fEditorSelectionChangedListener; | 1744 private EditorSelectionChangedListener fEditorSelectionChangedListener; |
1725 /** The editor's bracket matcher */ | 1745 /** The editor's bracket matcher */ |
1726 protected DartPairMatcher fBracketMatcher = new DartPairMatcher(BRACKETS); | 1746 protected DartPairMatcher fBracketMatcher = new DartPairMatcher(BRACKETS); |
1727 | 1747 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1925 } | 1945 } |
1926 // OK, schedule selection update | 1946 // OK, schedule selection update |
1927 resolvedUnit = unit; | 1947 resolvedUnit = unit; |
1928 ExecutionUtils.runLogAsync(new RunnableEx() { | 1948 ExecutionUtils.runLogAsync(new RunnableEx() { |
1929 @Override | 1949 @Override |
1930 public void run() { | 1950 public void run() { |
1931 if (isDisposed()) { | 1951 if (isDisposed()) { |
1932 return; | 1952 return; |
1933 } | 1953 } |
1934 // update Outline | 1954 // update Outline |
1935 if (resolvedUnit != null && fOutlinePage != null) { | 1955 if (resolvedUnit != null && fOutlinePage_OLD != null) { |
1936 if (fOutlinePage != null) { | 1956 if (fOutlinePage_OLD != null) { |
1937 fOutlinePage.setInput(resolvedUnit); | 1957 fOutlinePage_OLD.setInput(resolvedUnit); |
1938 } | 1958 } |
1939 applySelectionToOutline(); | 1959 applySelectionToOutline(); |
1940 } | 1960 } |
1941 // update selection listeners | 1961 // update selection listeners |
1942 fireDartSelectionListeners(); | 1962 fireDartSelectionListeners(); |
1943 // update occurrences | 1963 // update occurrences |
1944 fForcedMarkOccurrencesSelection = getSelectionProvider().getSelection(); | 1964 fForcedMarkOccurrencesSelection = getSelectionProvider().getSelection(); |
1945 updateOccurrenceAnnotations((ITextSelection) fForcedMarkOccurrencesSelec
tion, resolvedUnit); | 1965 updateOccurrenceAnnotations((ITextSelection) fForcedMarkOccurrencesSelec
tion, resolvedUnit); |
1946 } | 1966 } |
1947 }); | 1967 }); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1994 if (isSemanticHighlightingEnabled()) { | 2014 if (isSemanticHighlightingEnabled()) { |
1995 installSemanticHighlighting(); | 2015 installSemanticHighlighting(); |
1996 } | 2016 } |
1997 | 2017 |
1998 PlatformUI.getWorkbench().addWindowListener(fActivationListener); | 2018 PlatformUI.getWorkbench().addWindowListener(fActivationListener); |
1999 } | 2019 } |
2000 | 2020 |
2001 @Override | 2021 @Override |
2002 public void dispose() { | 2022 public void dispose() { |
2003 if (DartCoreDebug.ENABLE_ANALYSIS_SERVER) { | 2023 if (DartCoreDebug.ENABLE_ANALYSIS_SERVER) { |
2004 DartCore.getAnalysisServerData().unsubscribeNavigation( | 2024 AnalysisServerData analysisServerData = DartCore.getAnalysisServerData(); |
2005 getInputAnalysisContextId(), | 2025 String contextId = getInputAnalysisContextId(); |
2006 getInputSource()); | 2026 Source source = getInputSource(); |
| 2027 if (contextId != null && source != null) { |
| 2028 analysisServerData.unsubscribeNavigation(contextId, source); |
| 2029 analysisServerData.unsubscribeOutline(contextId, source, analysisServerO
utlineListener); |
| 2030 } |
2007 } | 2031 } |
2008 | 2032 |
2009 DartX.todo("folding"); | 2033 DartX.todo("folding"); |
2010 if (fProjectionModelUpdater != null) { | 2034 if (fProjectionModelUpdater != null) { |
2011 fProjectionModelUpdater.uninstall(); | 2035 fProjectionModelUpdater.uninstall(); |
2012 fProjectionModelUpdater = null; | 2036 fProjectionModelUpdater = null; |
2013 } | 2037 } |
2014 | 2038 |
2015 if (fProjectionSupport != null) { | 2039 if (fProjectionSupport != null) { |
2016 fProjectionSupport.dispose(); | 2040 fProjectionSupport.dispose(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2135 } | 2159 } |
2136 } | 2160 } |
2137 } | 2161 } |
2138 | 2162 |
2139 @SuppressWarnings("rawtypes") | 2163 @SuppressWarnings("rawtypes") |
2140 @Override | 2164 @Override |
2141 public Object getAdapter(Class required) { | 2165 public Object getAdapter(Class required) { |
2142 | 2166 |
2143 DartX.todo("outline"); | 2167 DartX.todo("outline"); |
2144 if (IContentOutlinePage.class.equals(required)) { | 2168 if (IContentOutlinePage.class.equals(required)) { |
2145 if (fOutlinePage == null) { | 2169 if (DartCoreDebug.ENABLE_ANALYSIS_SERVER) { |
2146 fOutlinePage = createOutlinePage(); | 2170 if (fOutlinePage_NEW == null) { |
| 2171 fOutlinePage_NEW = createOutlinePage_NEW(); |
| 2172 } |
| 2173 return fOutlinePage_NEW; |
| 2174 } else { |
| 2175 if (fOutlinePage_OLD == null) { |
| 2176 fOutlinePage_OLD = createOutlinePage_OLD(); |
| 2177 } |
| 2178 return fOutlinePage_OLD; |
2147 } | 2179 } |
2148 return fOutlinePage; | |
2149 } | 2180 } |
2150 | 2181 |
2151 if (IEncodingSupport.class.equals(required)) { | 2182 if (IEncodingSupport.class.equals(required)) { |
2152 return fEncodingSupport; | 2183 return fEncodingSupport; |
2153 } | 2184 } |
2154 | 2185 |
2155 if (required == IShowInTargetList.class) { | 2186 if (required == IShowInTargetList.class) { |
2156 return new IShowInTargetList() { | 2187 return new IShowInTargetList() { |
2157 @Override | 2188 @Override |
2158 public String[] getShowInTargetIds() { | 2189 public String[] getShowInTargetIds() { |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2497 return widget.isVisible(); | 2528 return widget.isVisible(); |
2498 } | 2529 } |
2499 } | 2530 } |
2500 return false; | 2531 return false; |
2501 } | 2532 } |
2502 | 2533 |
2503 /** | 2534 /** |
2504 * Informs the editor that its outliner has been closed. | 2535 * Informs the editor that its outliner has been closed. |
2505 */ | 2536 */ |
2506 public void outlinePageClosed() { | 2537 public void outlinePageClosed() { |
2507 if (fOutlinePage != null) { | 2538 if (DartCoreDebug.ENABLE_ANALYSIS_SERVER) { |
2508 fOutlinePage = null; | 2539 if (fOutlinePage_NEW != null) { |
2509 resetHighlightRange(); | 2540 fOutlinePage_NEW = null; |
| 2541 resetHighlightRange(); |
| 2542 } |
| 2543 } else { |
| 2544 if (fOutlinePage_OLD != null) { |
| 2545 fOutlinePage_OLD = null; |
| 2546 resetHighlightRange(); |
| 2547 } |
2510 } | 2548 } |
2511 } | 2549 } |
2512 | 2550 |
2513 public void removeDartSelectionListener(ISelectionChangedListener listener) { | 2551 public void removeDartSelectionListener(ISelectionChangedListener listener) { |
2514 dartSelectionListeners.remove(listener); | 2552 dartSelectionListeners.remove(listener); |
2515 } | 2553 } |
2516 | 2554 |
2517 /** | 2555 /** |
2518 * Resets the foldings structure according to the folding preferences. | 2556 * Resets the foldings structure according to the folding preferences. |
2519 */ | 2557 */ |
(...skipping 15 matching lines...) Expand all Loading... |
2535 int length = element.getDisplayName().length(); | 2573 int length = element.getDisplayName().length(); |
2536 selectAndReveal(offset, length); | 2574 selectAndReveal(offset, length); |
2537 } | 2575 } |
2538 | 2576 |
2539 public void setPreferences(IPreferenceStore store) { | 2577 public void setPreferences(IPreferenceStore store) { |
2540 uninstallSemanticHighlighting(); | 2578 uninstallSemanticHighlighting(); |
2541 super.setPreferenceStore(store); | 2579 super.setPreferenceStore(store); |
2542 installSemanticHighlighting(); | 2580 installSemanticHighlighting(); |
2543 } | 2581 } |
2544 | 2582 |
2545 public void setSelection(LightNodeElement element, boolean moveCursor) { | 2583 public void setSelection_NEW(Outline element, boolean moveCursor) { |
| 2584 // validate Outline |
| 2585 if (element == null) { |
| 2586 return; |
| 2587 } |
| 2588 // prepare range |
| 2589 int offset = element.getOffset(); |
| 2590 int length = element.getLength(); |
| 2591 // prepare ISourceViewer |
| 2592 ISourceViewer sourceViewer = getSourceViewer(); |
| 2593 if (sourceViewer == null) { |
| 2594 return; |
| 2595 } |
| 2596 // highlight range (not selection - just highlighting on left editor band) |
| 2597 if (offset < 0) { |
| 2598 return; |
| 2599 } |
| 2600 setHighlightRange(offset, length, moveCursor); |
| 2601 // do we want to change selection? |
| 2602 if (!moveCursor) { |
| 2603 return; |
| 2604 } |
| 2605 // prepare StyledText |
| 2606 StyledText textWidget = sourceViewer.getTextWidget(); |
| 2607 if (textWidget == null) { |
| 2608 return; |
| 2609 } |
| 2610 // set selection in StyledText |
| 2611 try { |
| 2612 textWidget.setRedraw(false); |
| 2613 sourceViewer.revealRange(offset, length); |
| 2614 sourceViewer.setSelectedRange(offset, length); |
| 2615 fForcedMarkOccurrencesSelection = getSelectionProvider().getSelection(); |
| 2616 updateOccurrenceAnnotations((ITextSelection) fForcedMarkOccurrencesSelecti
on, getInputUnit()); |
| 2617 } finally { |
| 2618 textWidget.setRedraw(true); |
| 2619 } |
| 2620 } |
| 2621 |
| 2622 public void setSelection_OLD(LightNodeElement element, boolean moveCursor) { |
2546 // validate LightNodeElement | 2623 // validate LightNodeElement |
2547 if (element == null) { | 2624 if (element == null) { |
2548 return; | 2625 return; |
2549 } | 2626 } |
2550 // prepare range | 2627 // prepare range |
2551 int offset = element.getNameOffset(); | 2628 int offset = element.getNameOffset(); |
2552 int length = element.getNameLength(); | 2629 int length = element.getNameLength(); |
2553 // prepare ISourceViewer | 2630 // prepare ISourceViewer |
2554 ISourceViewer sourceViewer = getSourceViewer(); | 2631 ISourceViewer sourceViewer = getSourceViewer(); |
2555 if (sourceViewer == null) { | 2632 if (sourceViewer == null) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2589 // TODO(scheglov) | 2666 // TODO(scheglov) |
2590 // synchronizeOutlinePage(computeHighlightRangeSourceElement()); | 2667 // synchronizeOutlinePage(computeHighlightRangeSourceElement()); |
2591 } | 2668 } |
2592 | 2669 |
2593 public void updatedTitleImage(Image image) { | 2670 public void updatedTitleImage(Image image) { |
2594 setTitleImage(image); | 2671 setTitleImage(image); |
2595 } | 2672 } |
2596 | 2673 |
2597 @Override | 2674 @Override |
2598 protected void adjustHighlightRange(int offset, int length) { | 2675 protected void adjustHighlightRange(int offset, int length) { |
2599 Object element = getElementAt(offset, false); | 2676 if (DartCoreDebug.ENABLE_ANALYSIS_SERVER) { |
| 2677 if (fOutlinePage_NEW != null) { |
| 2678 fOutlinePage_NEW.select(offset); |
| 2679 } |
| 2680 } else { |
| 2681 Object element = getElementAt(offset, false); |
2600 | 2682 |
2601 if (element instanceof LightNodeElement) { | 2683 if (element instanceof LightNodeElement) { |
2602 LightNodeElement sourceElement = (LightNodeElement) element; | 2684 LightNodeElement sourceElement = (LightNodeElement) element; |
2603 int elementOffset = sourceElement.getNameOffset(); | 2685 int elementOffset = sourceElement.getNameOffset(); |
2604 int elementLength = sourceElement.getNameLength(); | 2686 int elementLength = sourceElement.getNameLength(); |
2605 | 2687 |
2606 ISourceViewer viewer = getSourceViewer(); | 2688 ISourceViewer viewer = getSourceViewer(); |
2607 if (viewer instanceof ITextViewerExtension5) { | 2689 if (viewer instanceof ITextViewerExtension5) { |
2608 ITextViewerExtension5 extension = (ITextViewerExtension5) viewer; | 2690 ITextViewerExtension5 extension = (ITextViewerExtension5) viewer; |
2609 extension.exposeModelRange(new Region(elementOffset, elementLength)); | 2691 extension.exposeModelRange(new Region(elementOffset, elementLength)); |
2610 } | 2692 } |
2611 | 2693 |
2612 setHighlightRange(elementOffset, elementLength, true); | 2694 setHighlightRange(elementOffset, elementLength, true); |
2613 if (fOutlinePage != null) { | 2695 if (fOutlinePage_OLD != null) { |
2614 fOutlinePage.select((LightNodeElement) element); | 2696 fOutlinePage_OLD.select((LightNodeElement) element); |
| 2697 } |
2615 } | 2698 } |
2616 } | 2699 } |
2617 | 2700 |
2618 ISourceViewer viewer = getSourceViewer(); | 2701 ISourceViewer viewer = getSourceViewer(); |
2619 if (viewer instanceof ITextViewerExtension5) { | 2702 if (viewer instanceof ITextViewerExtension5) { |
2620 ITextViewerExtension5 extension = (ITextViewerExtension5) viewer; | 2703 ITextViewerExtension5 extension = (ITextViewerExtension5) viewer; |
2621 extension.exposeModelRange(new Region(offset, length)); | 2704 extension.exposeModelRange(new Region(offset, length)); |
2622 } else { | 2705 } else { |
2623 resetHighlightRange(); | 2706 resetHighlightRange(); |
2624 } | 2707 } |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3006 action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT
); | 3089 action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT
); |
3007 setAction(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT, action); | 3090 setAction(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT, action); |
3008 textWidget.setKeyBinding(SWT.CTRL | SWT.SHIFT | SWT.ARROW_RIGHT, SWT.NULL); | 3091 textWidget.setKeyBinding(SWT.CTRL | SWT.SHIFT | SWT.ARROW_RIGHT, SWT.NULL); |
3009 } | 3092 } |
3010 | 3093 |
3011 /** | 3094 /** |
3012 * Creates the outline page used with this editor. | 3095 * Creates the outline page used with this editor. |
3013 * | 3096 * |
3014 * @return the created Dart outline page | 3097 * @return the created Dart outline page |
3015 */ | 3098 */ |
3016 protected DartOutlinePage createOutlinePage() { | 3099 protected DartOutlinePage_NEW createOutlinePage_NEW() { |
3017 DartOutlinePage page = new DartOutlinePage(fOutlinerContextMenuId, this); | 3100 DartOutlinePage_NEW page = new DartOutlinePage_NEW(fOutlinerContextMenuId, t
his); |
3018 setOutlinePageInput(page, getEditorInput()); | 3101 setOutlinePageInput_NEW(page, getEditorInput()); |
3019 return page; | 3102 return page; |
3020 } | 3103 } |
3021 | 3104 |
| 3105 /** |
| 3106 * Creates the outline page used with this editor. |
| 3107 * |
| 3108 * @return the created Dart outline page |
| 3109 */ |
| 3110 protected DartOutlinePage createOutlinePage_OLD() { |
| 3111 DartOutlinePage page = new DartOutlinePage(fOutlinerContextMenuId, this); |
| 3112 setOutlinePageInput_OLD(page, getEditorInput()); |
| 3113 return page; |
| 3114 } |
| 3115 |
3022 @Override | 3116 @Override |
3023 protected final ISourceViewer createSourceViewer(Composite parent, IVerticalRu
ler verticalRuler, | 3117 protected final ISourceViewer createSourceViewer(Composite parent, IVerticalRu
ler verticalRuler, |
3024 int styles) { | 3118 int styles) { |
3025 | 3119 |
3026 IPreferenceStore store = getPreferenceStore(); | 3120 IPreferenceStore store = getPreferenceStore(); |
3027 final ISourceViewer viewer = createDartSourceViewer( | 3121 final ISourceViewer viewer = createDartSourceViewer( |
3028 parent, | 3122 parent, |
3029 verticalRuler, | 3123 verticalRuler, |
3030 getOverviewRuler(), | 3124 getOverviewRuler(), |
3031 isOverviewRulerVisible(), | 3125 isOverviewRulerVisible(), |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3101 | 3195 |
3102 EditorUtility.addGTKPasteHack(viewer); | 3196 EditorUtility.addGTKPasteHack(viewer); |
3103 | 3197 |
3104 return viewer; | 3198 return viewer; |
3105 } | 3199 } |
3106 | 3200 |
3107 protected void doSelectionChanged(ISelection selection) { | 3201 protected void doSelectionChanged(ISelection selection) { |
3108 if (selection instanceof IStructuredSelection) { | 3202 if (selection instanceof IStructuredSelection) { |
3109 IStructuredSelection structuredSelection = (IStructuredSelection) selectio
n; | 3203 IStructuredSelection structuredSelection = (IStructuredSelection) selectio
n; |
3110 for (Object selectionObject : structuredSelection.toList()) { | 3204 for (Object selectionObject : structuredSelection.toList()) { |
3111 if (selectionObject instanceof LightNodeElement) { | 3205 if (DartCoreDebug.ENABLE_ANALYSIS_SERVER) { |
3112 setSelection((LightNodeElement) selectionObject, !isActivePart()); | 3206 if (selectionObject instanceof Outline) { |
3113 break; | 3207 setSelection_NEW((Outline) selectionObject, !isActivePart()); |
| 3208 break; |
| 3209 } |
| 3210 } else { |
| 3211 if (selectionObject instanceof LightNodeElement) { |
| 3212 setSelection_OLD((LightNodeElement) selectionObject, !isActivePart()
); |
| 3213 break; |
| 3214 } |
3114 } | 3215 } |
3115 } | 3216 } |
3116 } | 3217 } |
3117 } | 3218 } |
3118 | 3219 |
3119 @Override | 3220 @Override |
3120 protected void doSetInput(IEditorInput input) throws CoreException { | 3221 protected void doSetInput(IEditorInput input) throws CoreException { |
3121 AnalysisContext sdkContext = DartCore.getProjectManager().getSdkContext(); | 3222 AnalysisContext sdkContext = DartCore.getProjectManager().getSdkContext(); |
3122 if (input instanceof IFileEditorInput) { | 3223 if (input instanceof IFileEditorInput) { |
3123 IFileEditorInput fileInput = (IFileEditorInput) input; | 3224 IFileEditorInput fileInput = (IFileEditorInput) input; |
3124 inputResourceFile = fileInput.getFile(); | 3225 inputResourceFile = fileInput.getFile(); |
3125 } else if (input instanceof IURIEditorInput) { | 3226 } else if (input instanceof IURIEditorInput) { |
3126 IURIEditorInput uriInput = (IURIEditorInput) input; | 3227 IURIEditorInput uriInput = (IURIEditorInput) input; |
3127 URI uri = uriInput.getURI(); | 3228 URI uri = uriInput.getURI(); |
3128 if (uri != null && uri.getScheme().equals("file") && uri.isAbsolute()) { | 3229 if (uri != null && uri.getScheme().equals("file") && uri.isAbsolute()) { |
3129 try { | 3230 try { |
3130 inputJavaFile = new File(uri); | 3231 inputJavaFile = new File(uri); |
3131 } catch (Throwable e) { | 3232 } catch (Throwable e) { |
3132 } | 3233 } |
3133 } | 3234 } |
3134 } | 3235 } |
3135 | 3236 |
3136 if (DartCoreDebug.ENABLE_ANALYSIS_SERVER) { | 3237 if (DartCoreDebug.ENABLE_ANALYSIS_SERVER) { |
3137 DartCore.getAnalysisServerData().subscribeNavigation( | 3238 AnalysisServerData analysisServerData = DartCore.getAnalysisServerData(); |
3138 getInputAnalysisContextId(), | 3239 String contextId = getInputAnalysisContextId(); |
3139 getInputSource()); | 3240 Source source = getInputSource(); |
| 3241 if (contextId != null && source != null) { |
| 3242 analysisServerData.subscribeNavigation(contextId, source); |
| 3243 } |
3140 } | 3244 } |
3141 | 3245 |
3142 ISourceViewer sourceViewer = getSourceViewer(); | 3246 ISourceViewer sourceViewer = getSourceViewer(); |
3143 if (!(sourceViewer instanceof ISourceViewerExtension2)) { | 3247 if (!(sourceViewer instanceof ISourceViewerExtension2)) { |
3144 setPreferenceStore(createCombinedPreferenceStore(input)); | 3248 setPreferenceStore(createCombinedPreferenceStore(input)); |
3145 internalDoSetInput(input); | 3249 internalDoSetInput(input); |
3146 return; | 3250 return; |
3147 } | 3251 } |
3148 | 3252 |
3149 // uninstall & unregister preference store listener | 3253 // uninstall & unregister preference store listener |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3831 fOpenEditorActionGroup.fillContextMenu(menu); | 3935 fOpenEditorActionGroup.fillContextMenu(menu); |
3832 fOpenEditorActionGroup.setContext(null); | 3936 fOpenEditorActionGroup.setContext(null); |
3833 } | 3937 } |
3834 | 3938 |
3835 /** | 3939 /** |
3836 * Sets the input of the editor's outline page. | 3940 * Sets the input of the editor's outline page. |
3837 * | 3941 * |
3838 * @param page the Dart outline page | 3942 * @param page the Dart outline page |
3839 * @param input the editor input | 3943 * @param input the editor input |
3840 */ | 3944 */ |
3841 protected void setOutlinePageInput(DartOutlinePage page, IEditorInput input) { | 3945 protected void setOutlinePageInput_NEW(DartOutlinePage_NEW page, IEditorInput
input) { |
3842 if (page == null) { | 3946 if (page == null) { |
3843 return; | 3947 return; |
3844 } | 3948 } |
| 3949 AnalysisServerData analysisServerData = DartCore.getAnalysisServerData(); |
| 3950 String contextId = getInputAnalysisContextId(); |
| 3951 Source source = getInputSource(); |
| 3952 if (contextId != null && source != null) { |
| 3953 analysisServerData.subscribeOutline(contextId, source, analysisServerOutli
neListener); |
| 3954 } |
| 3955 } |
| 3956 |
| 3957 /** |
| 3958 * Sets the input of the editor's outline page. |
| 3959 * |
| 3960 * @param page the Dart outline page |
| 3961 * @param input the editor input |
| 3962 */ |
| 3963 protected void setOutlinePageInput_OLD(DartOutlinePage page, IEditorInput inpu
t) { |
| 3964 if (page == null) { |
| 3965 return; |
| 3966 } |
3845 page.setInput(resolvedUnit); | 3967 page.setInput(resolvedUnit); |
3846 } | 3968 } |
3847 | 3969 |
3848 /** | 3970 /** |
3849 * Sets the outliner's context menu ID. | 3971 * Sets the outliner's context menu ID. |
3850 * | 3972 * |
3851 * @param menuId the menu ID | 3973 * @param menuId the menu ID |
3852 */ | 3974 */ |
3853 protected void setOutlinerContextMenuId(String menuId) { | 3975 protected void setOutlinerContextMenuId(String menuId) { |
3854 fOutlinerContextMenuId = menuId; | 3976 fOutlinerContextMenuId = menuId; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4021 | 4143 |
4022 /** | 4144 /** |
4023 * Synchronizes the outliner selection with the given element position in the
editor. | 4145 * Synchronizes the outliner selection with the given element position in the
editor. |
4024 * | 4146 * |
4025 * @param element the Dart element to select | 4147 * @param element the Dart element to select |
4026 * @param checkIfOutlinePageActive <code>true</code> if check for active outli
ne page needs to be | 4148 * @param checkIfOutlinePageActive <code>true</code> if check for active outli
ne page needs to be |
4027 * done | 4149 * done |
4028 */ | 4150 */ |
4029 protected void synchronizeOutlinePage(Object /* ASTNode */element, | 4151 protected void synchronizeOutlinePage(Object /* ASTNode */element, |
4030 boolean checkIfOutlinePageActive) { | 4152 boolean checkIfOutlinePageActive) { |
4031 if (fOutlinePage != null && element != null | 4153 if (fOutlinePage_OLD != null && element != null |
4032 && !(checkIfOutlinePageActive && isOutlinePageActive())) { | 4154 && !(checkIfOutlinePageActive && isOutlinePageActive())) { |
4033 // TODO(scheglov) | 4155 // TODO(scheglov) |
4034 // ((DartOutlinePage) fOutlinePage).select((LightNodeElement) element); | 4156 // ((DartOutlinePage) fOutlinePage).select((LightNodeElement) element); |
4035 // ((DartOutlinePage) fOutlinePage).setInput( | 4157 // ((DartOutlinePage) fOutlinePage).setInput( |
4036 // (com.google.dart.engine.ast.CompilationUnit) ((LightNodeElement) e
lement).getNode().getRoot(), | 4158 // (com.google.dart.engine.ast.CompilationUnit) ((LightNodeElement) e
lement).getNode().getRoot(), |
4037 // (LightNodeElement) element); | 4159 // (LightNodeElement) element); |
4038 } | 4160 } |
4039 } | 4161 } |
4040 | 4162 |
4041 protected void uninstallOccurrencesFinder() { | 4163 protected void uninstallOccurrencesFinder() { |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4334 if (unit == null) { | 4456 if (unit == null) { |
4335 return; | 4457 return; |
4336 } | 4458 } |
4337 // prepare selection | 4459 // prepare selection |
4338 ISelection selection = getSelectionProvider().getSelection(); | 4460 ISelection selection = getSelectionProvider().getSelection(); |
4339 if (!(selection instanceof TextSelection)) { | 4461 if (!(selection instanceof TextSelection)) { |
4340 return; | 4462 return; |
4341 } | 4463 } |
4342 int offset = ((TextSelection) selection).getOffset(); | 4464 int offset = ((TextSelection) selection).getOffset(); |
4343 // apply selected element | 4465 // apply selected element |
4344 LightNodeElement element = computeHighlightRangeSourceElement(resolvedUnit,
offset); | 4466 if (DartCoreDebug.ENABLE_ANALYSIS_SERVER) { |
4345 if (element != null && fOutlinePage != null) { | 4467 if (fOutlinePage_NEW != null) { |
4346 fOutlinePage.select(element); | 4468 fOutlinePage_NEW.select(offset); |
| 4469 } |
| 4470 } else { |
| 4471 LightNodeElement element = computeHighlightRangeSourceElement(resolvedUnit
, offset); |
| 4472 if (element != null && fOutlinePage_OLD != null) { |
| 4473 fOutlinePage_OLD.select(element); |
| 4474 } |
4347 } | 4475 } |
4348 } | 4476 } |
4349 | 4477 |
4350 /** | 4478 /** |
4351 * Creates and returns the preference store for this Dart editor with the give
n input. | 4479 * Creates and returns the preference store for this Dart editor with the give
n input. |
4352 * | 4480 * |
4353 * @param input The editor input for which to create the preference store | 4481 * @param input The editor input for which to create the preference store |
4354 * @return the preference store for this editor | 4482 * @return the preference store for this editor |
4355 */ | 4483 */ |
4356 private IPreferenceStore createCombinedPreferenceStore(IEditorInput input) { | 4484 private IPreferenceStore createCombinedPreferenceStore(IEditorInput input) { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4531 if (reconciler != null) { | 4659 if (reconciler != null) { |
4532 reconciler.install(dartSourceViewer); | 4660 reconciler.install(dartSourceViewer); |
4533 dartSourceViewer.setReconciler(reconciler); | 4661 dartSourceViewer.setReconciler(reconciler); |
4534 } | 4662 } |
4535 } | 4663 } |
4536 | 4664 |
4537 if (fEncodingSupport != null) { | 4665 if (fEncodingSupport != null) { |
4538 fEncodingSupport.reset(); | 4666 fEncodingSupport.reset(); |
4539 } | 4667 } |
4540 | 4668 |
4541 setOutlinePageInput(fOutlinePage, input); | 4669 if (DartCoreDebug.ENABLE_ANALYSIS_SERVER) { |
| 4670 setOutlinePageInput_NEW(fOutlinePage_NEW, input); |
| 4671 } else { |
| 4672 setOutlinePageInput_OLD(fOutlinePage_OLD, input); |
| 4673 } |
4542 | 4674 |
4543 if (isShowingOverrideIndicators()) { | 4675 if (isShowingOverrideIndicators()) { |
4544 installOverrideIndicator(false); | 4676 installOverrideIndicator(false); |
4545 } | 4677 } |
4546 } | 4678 } |
4547 | 4679 |
4548 /* | 4680 /* |
4549 * Tells whether the content is editable. | 4681 * Tells whether the content is editable. |
4550 */ | 4682 */ |
4551 private boolean isContentEditable() { | 4683 private boolean isContentEditable() { |
4552 return inputResourceFile != null && !DartCore.isContainedInPackages(inputRes
ourceFile) | 4684 return inputResourceFile != null && !DartCore.isContainedInPackages(inputRes
ourceFile) |
4553 && !inputResourceFile.isReadOnly(); | 4685 && !inputResourceFile.isReadOnly(); |
4554 } | 4686 } |
4555 | 4687 |
4556 /** | 4688 /** |
4557 * @return {@code true} if this {@link DartEditor} was already disposed. | 4689 * @return {@code true} if this {@link DartEditor} was already disposed. |
4558 */ | 4690 */ |
4559 private boolean isDisposed() { | 4691 private boolean isDisposed() { |
4560 return getSourceViewer() == null; | 4692 return getSourceViewer() == null; |
4561 } | 4693 } |
4562 | 4694 |
4563 private boolean isEditorHoverProperty(String property) { | 4695 private boolean isEditorHoverProperty(String property) { |
4564 return PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS.equals(property); | 4696 return PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS.equals(property); |
4565 } | 4697 } |
4566 | 4698 |
4567 private boolean isOutlinePageActive() { | 4699 private boolean isOutlinePageActive() { |
4568 IWorkbenchPart part = getActivePart(); | 4700 IWorkbenchPart part = getActivePart(); |
4569 return part instanceof ContentOutline | 4701 if (DartCoreDebug.ENABLE_ANALYSIS_SERVER) { |
4570 && ((ContentOutline) part).getCurrentPage() == fOutlinePage; | 4702 return part instanceof ContentOutline |
| 4703 && ((ContentOutline) part).getCurrentPage() == fOutlinePage_NEW; |
| 4704 } else { |
| 4705 return part instanceof ContentOutline |
| 4706 && ((ContentOutline) part).getCurrentPage() == fOutlinePage_OLD; |
| 4707 } |
4571 } | 4708 } |
4572 | 4709 |
4573 private boolean isRemoveTrailingWhitespaceEnabled() { | 4710 private boolean isRemoveTrailingWhitespaceEnabled() { |
4574 return PreferenceConstants.getPreferenceStore().getBoolean( | 4711 return PreferenceConstants.getPreferenceStore().getBoolean( |
4575 PreferenceConstants.EDITOR_REMOVE_TRAILING_WS); | 4712 PreferenceConstants.EDITOR_REMOVE_TRAILING_WS); |
4576 } | 4713 } |
4577 | 4714 |
4578 /** | 4715 /** |
4579 * @return <code>true</code> if Semantic Highlighting is enabled. | 4716 * @return <code>true</code> if Semantic Highlighting is enabled. |
4580 */ | 4717 */ |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4640 textHover, | 4777 textHover, |
4641 t, | 4778 t, |
4642 ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK); | 4779 ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK); |
4643 } | 4780 } |
4644 } else { | 4781 } else { |
4645 sourceViewer.setTextHover(configuration.getTextHover(sourceViewer, t), t
); | 4782 sourceViewer.setTextHover(configuration.getTextHover(sourceViewer, t), t
); |
4646 } | 4783 } |
4647 } | 4784 } |
4648 } | 4785 } |
4649 } | 4786 } |
OLD | NEW |