-
Notifications
You must be signed in to change notification settings - Fork 354
Remove ES5 IntelliSense Option #1255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f1f0c89
7aadd85
fe5700b
e4c20e3
116f216
e3bf5ae
bc5800d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1075,41 +1075,6 @@ CollectingErrorSink errorSink | |
| ) { | ||
| // There are some scenarios during ES6 Mode where a textview is still opened using NodeLS. | ||
| // In these cases, we do not properly parse ES6 syntax, and therefore do not want to display errors. | ||
| if (NodejsPackage.Instance.IntellisenseOptionsPage.AnalysisLevel == AnalysisLevel.Preview) { | ||
| return; | ||
| } | ||
|
|
||
| // Update the warn-on-launch state for this entry | ||
| bool changed = false; | ||
| lock (_hasParseErrors) { | ||
| if (errorSink.Errors.Any() ? _hasParseErrors.Add(entry) : _hasParseErrors.Remove(entry)) { | ||
| changed = true; | ||
| } | ||
| } | ||
| if (changed) { | ||
| OnShouldWarnOnLaunchChanged(entry); | ||
| } | ||
|
|
||
| var f = new TaskProviderItemFactory(snapshot); | ||
|
|
||
| // Update the parser warnings/errors | ||
| if (errorSink.Warnings.Any() || errorSink.Errors.Any()) { | ||
| TaskProvider.ReplaceItems( | ||
| entry, | ||
| ParserTaskMoniker, | ||
| errorSink.Warnings | ||
| .Where(ShouldIncludeWarning) | ||
| .Select(er => f.FromParseWarning(er)) | ||
| .Concat(errorSink.Errors.Select(er => f.FromParseError(er))) | ||
| .ToList() | ||
| ); | ||
| } else { | ||
| TaskProvider.Clear(entry, ParserTaskMoniker); | ||
| } | ||
| #if FALSE | ||
| // Add a handler for the next complete analysis | ||
| _unresolvedSquiggles.ListenForNextNewAnalysis(entry as IJsProjectEntry); | ||
| #endif | ||
| } | ||
|
|
||
| private bool ShouldIncludeWarning(ErrorResult error) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I would prefer to remove just this, and remove everything below in a separate, more focused change, when we remove the analyzer altogether
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean remove the entire If block? This code is unreachable after this change if we keep the current logic. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,7 +93,9 @@ namespace Microsoft.NodejsTools { | |
| [ProvideLanguageEditorOptionPage(typeof(NodejsFormattingSpacingOptionsPage), NodejsConstants.Nodejs, "Formatting", "Spacing", "3042")] | ||
| [ProvideLanguageEditorOptionPage(typeof(NodejsFormattingBracesOptionsPage), NodejsConstants.Nodejs, "Formatting", "Braces", "3043")] | ||
| [ProvideLanguageEditorOptionPage(typeof(NodejsFormattingGeneralOptionsPage), NodejsConstants.Nodejs, "Formatting", "General", "3044")] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eventually we should remove Node.js formatting options pages as well when TS uses JS, rather than TS to back their editor. Worth adding an item to track.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opened #1258 to track this. |
||
| #if DEV14 | ||
| [ProvideLanguageEditorOptionPage(typeof(NodejsIntellisenseOptionsPage), NodejsConstants.Nodejs, "IntelliSense", "", "3048")] | ||
| #endif | ||
| [ProvideLanguageEditorOptionPage(typeof(NodejsAdvancedEditorOptionsPage), NodejsConstants.Nodejs, "Advanced", "", "3050")] | ||
| [ProvideCodeExpansions(Guids.NodejsLanguageInfoString, false, 106, "Nodejs", @"Snippets\%LCID%\SnippetsIndex.xml", @"Snippets\%LCID%\Nodejs\")] | ||
| [ProvideCodeExpansionPath("Nodejs", "Test", @"Snippets\%LCID%\Test\")] | ||
|
|
@@ -241,10 +243,6 @@ protected override void Initialize() { | |
|
|
||
| MakeDebuggerContextAvailable(); | ||
|
|
||
| IntellisenseOptionsPage.AnalysisLogMaximumChanged += IntellisenseOptionsPage_AnalysisLogMaximumChanged; | ||
| IntellisenseOptionsPage.AnalysisLevelChanged += IntellisenseOptionsPageAnalysisLevelChanged; | ||
| IntellisenseOptionsPage.SaveToDiskChanged += IntellisenseOptionsPageSaveToDiskChanged; | ||
|
|
||
| InitializeLogging(); | ||
|
|
||
| InitializeTelemetry(); | ||
|
|
@@ -282,19 +280,12 @@ private void SubscribeToVsCommandEvents( | |
| _subscribedCommandEvents.Add(targetEvent); | ||
| } | ||
|
|
||
|
|
||
| private void IntellisenseOptionsPage_AnalysisLogMaximumChanged(object sender, EventArgs e) { | ||
| if (_analyzer != null) { | ||
| _analyzer.MaxLogLength = IntellisenseOptionsPage.AnalysisLogMax; | ||
| } | ||
| } | ||
|
|
||
| private void InitializeLogging() { | ||
| _logger = new NodejsToolsLogger(ComponentModel.GetExtensions<INodejsToolsLogger>().ToArray()); | ||
|
|
||
| // log interesting stats on startup | ||
| _logger.LogEvent(NodejsToolsLogEvent.SurveyNewsFrequency, GeneralOptionsPage.SurveyNewsCheck); | ||
| _logger.LogEvent(NodejsToolsLogEvent.AnalysisLevel, IntellisenseOptionsPage.AnalysisLevel); | ||
| _logger.LogEvent(NodejsToolsLogEvent.AnalysisLevel, AnalysisLevel.Preview); | ||
| } | ||
|
|
||
| private void InitializeTelemetry() { | ||
|
|
@@ -603,31 +594,12 @@ internal VsProjectAnalyzer DefaultAnalyzer { | |
| if (_analyzer == null) { | ||
| _analyzer = CreateLooseVsProjectAnalyzer(); | ||
| LogLooseFileAnalysisLevel(); | ||
| _analyzer.MaxLogLength = IntellisenseOptionsPage.AnalysisLogMax; | ||
| _analyzer.MaxLogLength = 100; | ||
| } | ||
| return _analyzer; | ||
| } | ||
| } | ||
|
|
||
| private void IntellisenseOptionsPageSaveToDiskChanged(object sender, EventArgs e) { | ||
| if (_analyzer != null) { | ||
| _analyzer.SaveToDisk = IntellisenseOptionsPage.SaveToDisk; | ||
| } | ||
| } | ||
|
|
||
| private void IntellisenseOptionsPageAnalysisLevelChanged(object sender, EventArgs e) { | ||
| if (_analyzer != null) { | ||
| var analyzer = CreateLooseVsProjectAnalyzer(); | ||
| analyzer.SwitchAnalyzers(_analyzer); | ||
| if (_analyzer.RemoveUser()) { | ||
| _analyzer.Dispose(); | ||
| } | ||
| _analyzer = analyzer; | ||
| LogLooseFileAnalysisLevel(); | ||
| } | ||
| TelemetryLogger.LogAnalysisLevelChanged(IntellisenseOptionsPage.AnalysisLevel); | ||
| } | ||
|
|
||
| private VsProjectAnalyzer CreateLooseVsProjectAnalyzer() { | ||
| // In ES6 IntelliSense mode, rather than overriding the default JS editor, | ||
| // we throw to Salsa. If Salsa detects that it's not operating within the Node.js project context, | ||
|
|
@@ -639,7 +611,7 @@ private VsProjectAnalyzer CreateLooseVsProjectAnalyzer() { | |
| // we do not throw to Salsa from the REPL window. However, in order to provide a workable editing | ||
| // experience within the REPL context, we initialize the loose analyzer with Quick IntelliSense | ||
| // during ES6 mode. | ||
| var analysisLevel = IntellisenseOptionsPage.AnalysisLevel == AnalysisLevel.Preview ? AnalysisLevel.NodeLsMedium : IntellisenseOptionsPage.AnalysisLevel; | ||
| var analysisLevel = AnalysisLevel.NodeLsMedium; | ||
| return new VsProjectAnalyzer(analysisLevel, false); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -544,7 +544,7 @@ private int OpenWithNodejsEditor(uint selectionItemId) { | |
| var properties = GetExtensionObject(_innerVsHierarchy, selectionItemId).Properties; | ||
| try { | ||
| var itemType = properties.Item("ItemType").Value; | ||
| ourEditor = (string)itemType == ProjectFileConstants.Compile && !IsES6IntellisensePreview() ? Guids.NodejsEditorFactory : Guid.Empty; | ||
| ourEditor = Guid.Empty; | ||
| } catch (ArgumentException) { | ||
| // no item type, file is excluded from project. | ||
| ourEditor = Guids.NodejsEditorFactory; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also remove the itemType assignment, otherwise we might still fall back to NodejsEditorFactory. With these changes, it may also be helpful to place a TODO or track in some other way because much of this logic is actually unnecessary since we are always using the default editor
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've got another change that builds on this one to remove the node editors entirely (you can still reach them using |
||
|
|
@@ -572,11 +572,6 @@ out frame | |
| return hr; | ||
| } | ||
|
|
||
| private bool IsES6IntellisensePreview() { | ||
| // If the analysis level is set to preview then use the TypeScript language service for node.js | ||
| return NodejsPackage.Instance.IntellisenseOptionsPage.AnalysisLevel == Options.AnalysisLevel.Preview; | ||
| } | ||
|
|
||
| #region IVsProject Members | ||
|
|
||
| public int AddItem(uint itemidLoc, VSADDITEMOPERATION dwAddItemOperation, string pszItemName, uint cFilesToOpen, string[] rgpszFilesToOpen, IntPtr hwndDlgOwner, VSADDRESULT[] pResult) { | ||
|
|
@@ -600,7 +595,7 @@ public int AddItem(uint itemidLoc, VSADDITEMOPERATION dwAddItemOperation, string | |
| } | ||
|
|
||
| if (!isClientCode && _innerProject3 != null && IsJavaScriptFile(pszItemName)) { | ||
| Guid ourEditor = IsES6IntellisensePreview() ? Guid.Empty : typeof(NodejsEditorFactory).GUID; | ||
| Guid ourEditor = Guid.Empty; | ||
| Guid view = Guid.Empty; | ||
| return _innerProject3.AddItemWithSpecific( | ||
| itemidLoc, | ||
|
|
@@ -640,7 +635,7 @@ public int IsDocumentInProject(string pszMkDocument, out int pfFound, VSDOCUMENT | |
| public int OpenItem(uint itemid, ref Guid rguidLogicalView, IntPtr punkDocDataExisting, out IVsWindowFrame ppWindowFrame) { | ||
| if (_innerProject3 != null && IsJavaScriptFile(GetItemName(_innerVsHierarchy, itemid))) { | ||
| // force .js files opened w/o an editor type to be opened w/ our editor factory. | ||
| Guid guid = IsES6IntellisensePreview() ? Guid.Empty : typeof(NodejsEditorFactory).GUID; | ||
| Guid guid = Guid.Empty; | ||
| Guid view = Guid.Empty; | ||
| int hr = _innerProject3.OpenItemWithSpecific( | ||
| itemid, | ||
|
|
@@ -675,7 +670,7 @@ public int ReopenItem(uint itemid, ref Guid rguidEditorType, string pszPhysicalV | |
| // force .js files opened w/o an editor type to be opened w/ our editor factory. | ||
| // If the item type of this file is not compile, we don't actually want to open with Nodejs and should instead use the default. | ||
| var itemType = GetExtensionObject(_innerVsHierarchy, itemid).Properties.Item("ItemType").Value; | ||
| Guid guid = (string)itemType == ProjectFileConstants.Compile && !IsES6IntellisensePreview() ? Guids.NodejsEditorFactory : Guid.Empty; | ||
| Guid guid = Guid.Empty; | ||
|
|
||
| return _innerProject3.ReopenItem( | ||
| itemid, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still should check for VSConstants.VSSt2KCmdID.COMPLETEWORD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OnlyTabOrEnterToCommitdefaults to true in my understanding, which would make this(VSConstants.VSStd2KCmdID)nCmdID == VSConstants.VSStd2KCmdID.COMPLETEWORD && !true. Is that not correct?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, that's actually correct - parsed it wrong at first 😃