Typescript refactoring (class renaming) issue in Webstorm 9 - refactoring

Any workaround for the following Typescript imported class name refactoring issue? The preview window does show the correct references to be refactored, however, when refactoring takes place, only the import statement is refactored.
1) File: animal.ts
class Animal {
// ...
}
export = Animal;
2) File: main.ts
import X = require("animal");
var dog = new X(); // refactoring origin: trying to refactor X to Y
The error happens when I try to refactor (Shift+F6) Animal in main.ts: the preview window does show both references ("import X..." and "... new X"), but refactoring only renames the import statement.
Version tested: Webstorm 9.0.2 on Windows 7 64-bit

It's a bug. Please vote for WEB-14009

Related

Binding in Xamarin ambiguous between the following methods or properties in openCV

I have an Android Studio app that uses openCV and runs just fine.
It uses a couple of libraries that have been written specifically for the project. They work fine within the project as mentioned.
I am now trying to get this into an .aar and use that in an Xamarin project.
The .aar files have been created and as far as I can tell nothing out of the ordinary there.
I set up a simple Xamarin project to then create a DLL as per various articles one being this ;
https://learn.microsoft.com/en-us/xamarin/android/platform/binding-java-library/binding-an-aar
My problem is when building the dll, I am getting the following error and just cannot understand why nor what it really mean. More particularly it seems it is coming from openCV ?
The call is ambiguous between the following methods or properties:
'CameraBridgeViewBase.SetCvCameraViewListener(CameraBridgeViewBase.ICvCameraViewListener)'
and
'CameraBridgeViewBase.SetCvCameraViewListener(CameraBridgeViewBase.ICvCameraViewListener2)'
in
\verifytest\obj\Debug\generated\src\Org.Opencv.Android.CameraBridgeViewBase.cs
An example of my Android app code which I built the .aar from is as follows ;
import org.opencv.android.Utils;
import org.opencv.core.Mat;
import org.opencv.core.MatOfRect;
import org.opencv.imgproc.Imgproc;
if (SelfiePage.mFaceDetector.confirmFace(mGray)) {
MatOfRect roiRegionMat = new MatOfRect();
SelfiePage.mFaceDetector.getRoi(roiRegionMat);
org.opencv.core.Rect roiRegion[] = roiRegionMat.toArray();
if (roiRegion.length > 0) {
mbHasFace = true;
org.opencv.core.Rect roi = roiRegion[0];
mFaceRect.set(1.f * roi.x / mGray.width() * width, 1.f * roi.y / mGray.height() * height, 1.f * (roi.x + roi.width) / mGray.width()
* width, 1.f * (roi.y + roi.height) / mGray.height() * height);
And this is the code (in openCV) (Org.Opencv.Android.CameraBridgeViewBase.cs) that the VS error is referring to ;
public event EventHandler<global::Org.Opencv.Android.CameraBridgeViewBase.CameraViewStartedEventArgs> CameraViewStarted {
add {
global::Java.Interop.EventHelper.AddEventHandler<global::Org.Opencv.Android.CameraBridgeViewBase.ICvCameraViewListener, global::Org.Opencv.Android.CameraBridgeViewBase.ICvCameraViewListenerImplementor>(
ref weak_implementor_SetCvCameraViewListener,
__CreateICvCameraViewListenerImplementor,
SetCvCameraViewListener,
__h => __h.OnCameraViewStartedHandler += value);
}
remove {
global::Java.Interop.EventHelper.RemoveEventHandler<global::Org.Opencv.Android.CameraBridgeViewBase.ICvCameraViewListener, global::Org.Opencv.Android.CameraBridgeViewBase.ICvCameraViewListenerImplementor>(
ref weak_implementor_SetCvCameraViewListener,
I really can't understand what is going on.
Thanks

qtcreator does not autocomplete when structure bindings is used?

I seem to have an issue with qtcreator not autocompleting my code, which is getting pretty annoying.
Currently is it not able to autocomplete when i try to use structure bindings in for loops like this..
std::vector<pair<string,AudioFile<double>>> list_of_files;
// Some init of list_of_file
for (const auto& [name,file]: this->list_of_files) // red line under this.. does seem to like structure bindings?
{
file.printSummary(); // qtcreator don't offer any autocomplete options?
}
qtcreator basically complains about everything about the code posted above..
But when I write it like this:
for (int i = 0 ; i <list_of_file.size() ; i++) // No red lines under this..
{
list_of_files[i].second.printSummary() // Autocompletes without any problems.
}
qtcreator does not complain about this code, and seem to autocomplete it just fine.. So why is it causing so many problems with c++17 style?
Any fixes for this?
A temporary solution for this seem to be something like this - which autocompletions does not complain about, and seem to suit my definition of (readability):
for ( const auto &elements : this->list_of_files)
{
auto name = std::get<0>(elements);
auto file = std::get<1>(elements);
}

SWIFT XCODE error

I am a complete beginner in coding. I managed to get some working code in Playground but once I moved to building a project nothing worked.
This is for OS X.
I have used the following simple lines of code in Playground and AppDelegate contexts. It runs and outputs to the console without error in Playground but returns an error in AppDelegate.swift - Expected declaration for the " for num in availcrop" line with a red arrow under the f in for.
var availcrop = [0, 1, 2, 3, 4, 5, 6, 7]
for num in availcrop
{
var ran = 1000+randInt(2000)
availcrop[num] = ran
println(availcrop[num])
}
- the println is not planned for the project. Just in the Playground for testing
Both have imported Cocoa. One runs and the other crashes. In Playground the array name avail crop is blue implying it is recognised I suppose. In the AppDelegate.swift it remains grey.
Once you're dealing with classes and objects, code generally needs to be inside some method so that it can be invoked by name.
Try:
func printRandoms {
// Your code here
}

How do I prevent ⌘L from selecting the line indentation in Sublime Text 2?

Disclaimer: I'm very new to both ST2 and coding.
Running Mac OSX.
I am trying to find a way to get the ⌘L command to NOT select:
The next line
Indentations
Here's an example:
I found a partial answer to this question on Stack overflow already:
ST2 Keymap: Args for "expand_selection"
That solves the problem of NOT selecting the next line, but indentations are still a bother. That solution is enabled in the GIF I linked.
I feel stumped.
You can use the following as a plugin. Note this will not select the next line if the cursor is at the end like the other post, but that isn't the behavior I would expect. You can modify this so it will do that if you want.
import sublime
import sublime_plugin
class TrimmedLineSelect(sublime_plugin.TextCommand):
def run(self, edit):
line_regions = []
new_line_regions = []
view = self.view
cursors = view.sel()
for cursor in cursors:
line_regions.append(view.line(cursor))
for region in line_regions:
line_content = view.substr(region)
full_length = len(line_content)
stripped_length = len(line_content.lstrip())
num_removed = full_length - stripped_length
new_region = sublime.Region(region.begin() + num_removed, region.end())
new_line_regions.append(new_region)
view.sel().clear()
for region in new_line_regions:
view.sel().add(region)
The command will be trimmed_line_select

Broken toggle-comment in Textmate

I'm having a problem with the Toggle Comment command ("Comment Line / Selection") in TextMate for Actionscript 2 (I know, I know). I've tried completely stripping the language set down to isolate the issue, and tried walking through the Ruby, both to no avail. My issue is that the command insists on using block comments for comment toggling (⌘ + /) and doesn't respect when I add a preferences file to change TM_COMMENT_MODE. I even tried using this simple preference:
{ shellVariables = (
{ name = 'TM_COMMENT_START';
value = '// ';
},
);
}
but no luck. I'm hoping that someone who speaks Ruby much better than myself (ie. at all) can find a simple fix for this. You can reproduce in any (recent) install of TextMate by creating a new actionscript 2 file and trying to ⌘ + / a section of code (or even a line). Contrast to a JS file which will use a line comment. Copy the "Comments" snippet from JavaScript to Actionscript bundles, and the problem will persist.
Thanks!
In your ActionScript Bundle, add a Preference called "Comments". In the editor part, add:
{ shellVariables = (
{ name = 'TM_COMMENT_START';
value = '// ';
},
{ name = 'TM_COMMENT_DISABLE_INDENT';
value = 'YES';
},
{ name = 'TM_COMMENT_START_2';
value = '/* ';
},
{ name = 'TM_COMMENT_END_2';
value = '*/';
},
);
}
and finally at the bottom, set the scope selector to: scope.actionscript.2
Here is an image of what mine looks like
be sure to use the Reload Bundles menu item after you've made these changes.

Resources