Top level function names restricted? - ceylon

Normally Ceylon loves when a file name corresponds with the name of the (only) class that gets declared in that file.
When I try to follow the same pattern with a top level function, the IDE barks at me. Example:
File structure:
utils/
file/
package.json
stringFromFile.ceylon
module.ceylon
package.ceylon
The content of the file stringFromFile.ceylon:
String|Null stringFromFile() {
return null
}
The error message produced by the IDE is: "duplicate declaration. The name stringFromFile is not unique in this scope". This message occurs when the cursor hovers over the function name declaration of 'stringFromFile'.
This declaration of stringFromFile is the only one in the code base (as revealed by a global search). The only "overlapping" name is the name of the containing file. Why are these two names not allowed to overlap?

Restarting the IntelliJ IDE will solve the problem.

Related

Interpret error from testbench after sending in an XSLT processed document

I am wondering how to read and interpret below error line from a suppliers test bench. My understanding is that the supplier run default configuration.
My assumptions:
<Q{.../2017-09-30}disposition-of-results>
...is referring to a element with namespace.
The Q is for QName the date is for the namespace path and "disposition-of-results" is element name.
The error complaints about that content model does not allow 2 defined elements to come one after another?
Something wrong detected at line -1 of file Xxx. In content of element <xbrl>: The content model does not allow element <Q{.../2017-09-30}disposition-of-results> to appear immediately after element <Q{.../2017-09-30}Sales>. The following elements would be valid here: xbrli:unit, link:footnoteLink, xbrli:context, xbrli:tuple, xbrli:item (or nothing).

How to create new phpDoc annotations in PhpStorm 8

I searched via Google but couldn't find an answer to this. PhpStorm has many built in annotations for code completion but many are missing as well. I am pretty sure there is a way to create new annotations but couldn't find it anywhere within the settings. Or maybe it is an XML file somewhere. NetBeans has support for this feature.
In other words, how can I create new phpDoc annotations for completion in phpStorm 8 like #usesDefaultClass for phpUnit.
I have found this answer here: http://blog.jetbrains.com/webide/2013/02/phpdoc_and_code_templates/
Hope this will help you
PhpDoc Templates
PhpDoc templates are located under Settings | File Templates | Includes. Currently there are three templates named PHP Class Doc Comment, PHP Function Doc Comment and PHP Field Doc Comment. Any of these can be included into other templates via the #parse directive. For example, we can modify the original class template (Templates | PHP Class) to also include the class PHP Doc when a class is generated:
<?php
#parse("PHP File Header.php")
...
#parse("PHP Class Doc Comment")
class ${NAME} {
}
The same templates are used when:
A new PHP Doc comment is generated after we type /** and press Enter before a class, function (method) or class field.
We invoke Code | Generate | PHPDoc blocks or use the Add PHP Doc quick-fix for the inspection Missing PHP Doc.
Below is a list of variables that can be used in PHP Doc templates:
${NAME}
The element (class, function, field) name.
${NAMESPACE}
The name of the namespace the element belongs to without any leading or trailing backslashes, for example Core\Widgets. The variable value is empty if the element doesn’t belong to any namespace. A check like `#if (${NAMESPACE})` ... is possible.
${CLASS_NAME}
Contains a class name for class methods and fields. Will be empty for functions that do not belong to any class.
${TYPE_HINT}
For functions (methods), contains the return type of the function (method). For fields, evaluates to the field’s type if it can be found, for example, from a default value. Will be empty if the type cannot be retrieved from the code.
${STATIC}
Takes the value of “static” if the function or field is static, otherwise, an empty string. We can use this variable with the condition `#if (${STATIC})` ... to generate something specific for static class members.
${CARET}
Marks the position where the editor caret should be placed after the comment is added. Note: Works only if the comment is added after we type “/**” and hit Enter. Should be placed inside the comment, not on the first line /** or on the last line */. In all other cases the caret marker will be ignored.
${PARAM_DOC}
A generated PHP Doc fragment containing function (method) parameters in the form: “* #param type $name“. For example, if the function signature is foo ($x, $y), it will evaluate to:
#param $x
#param $y
${THROWS_DOC}
A generated PHP Doc fragment containing exceptions thrown from function (method) body in the form * #throws ExceptionName. One exception per line/#throws tag. For example:
#throws DOMException
#throws HttpException
Code Templates for Overridden/Implemented Methods
The following templates can be found under Settings | File Templates | Code: PHP Implemented Method Body and PHP Overridden Method Body. There are few parameters, considering that in most cases we will need either a simple call to a parent method or just our own comment (some version of TODO perhaps):
${NAME}
Method name.
${PARAM_LIST}
A comma-separated list of parameters. For example, if the original method signature is foo(Bar $bar, $y), the variable will take the value “$bar, $x” which can be used in a call to the parent method as `${NAME}(${PARAM_LIST})`”
${RETURN}
Either “return” or an empty string.
A Dollar Sign Variable: ${DS}
Solves the problem of putting a dollar sign $ anywhere within the template. Actually, the dollar sign is used both in PHP and in Velocity template engine taking care of code generation behind the scenes. So whenever we need a dollar sign, just use ${DS} as its equivalent. For example, if we want $this->foo() to be generated, we need to put ${DS}this->foo(). This may not look perfect but guarantees that there will be no conflicts.

Setting breakpoints at methods of inner and anonymous classes in JDB

I'm attempting to operate JDB programmatically. Unlike any sane debugger, JDB refers to the source code using class names instead of source file names. I'm assuming it's related to having the bytecode stored in multiple .class files instead of a single file(you would expect compilation with the -g flag to produce some reference to the source files, but making things easy is not the Java way...)
When JDB refers to classes I can usually do some string manipulations and look at the source file names to figure out which source file declares the relevant class. When I need to supply a class name for a breakpoint, I can read the file to get the package name, use the file name as the class name and generate the full class name that way. These two cases I got them working.
The problem starts with inner classes and anonymous classes. They reside in their own class files, and their names are mangled versions of the class that contains them. To set a breakpoint there I need the mangled name.
For example - this is Main.java(+line numbers):
1: public class Main{
2: public static void main(String[] args){
3: new Object(){
4: #Override public String toString(){
5: System.out.println("hi");
6: return "";
7: }
8: }.toString();
9: }
10:}
I compile it using javac -g Main.java and got Main.class and Main$1.class. I'm running jdb:
Initializing jdb ...
> stop on Main.main
Deferring breakpoint Main.main.
It will be set after the class is loaded.
> run Main
run Main
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
>
VM Started: Set deferred breakpoint Main.main
Breakpoint hit: "thread=main", Main.main(), line=3 bci=0
3 new Object(){
(I needed that part to load Main.class - otherwise I would simply get "It will be set after the class is loaded." for all the breakpoint setting attempts.)
If I set a breakpoint for line 8 it works properly:
main[1] stop at Main:8
Set breakpoint Main:8
If I set a breakpoint for line 5 - which is part of the anonymous class - I get an error:
main[1] stop at Main:5
Unable to set breakpoint Main:5 : No code at line 5 in Main
Line 5 clearly contains code - the problem is that the code is not compiled into Main.class - it's compiled into Main$1.class, so I need to write instead:
main[1] stop at Main$1:5
Deferring breakpoint Main$1:5.
It will be set after the class is loaded.
Now, the way Java splits the bytecode into .class files is deterministic, and in this simple example it's easy to figure out what goes where - when you examine it with human eyes - but I need a way to figure the mangled class names programmatically(with VimScript) for real world source files. Trying to syntactically analyze the source file and figure out which is what is too complex a task - there ought to be a simpler way.
Maybe extract that information from the .class files, or question JDB about it, or even make JDB use source file names like any sane debugger for any sane language...
I just had the same problem. As a quickfix I just grepped for the class name (Object in your case) in all the Main$[x].class.
If you find many of them you have to use the index of the order they appear in the source file.

Error #2136: swf contains invalid data

public function starttank(event:MouseEvent):void
{
var Tankdrive:TankDrive = new TankDrive();
Tankdrive.tankstart();
}
It's saying that something in that function contains invalid data.
I have no idea what it is, i checked TankDrive and tankstart(); and both are correct, tankstart() is a public function...
I'm stumped...
EDIT: Error:
Error #2136: The SWF file file:///C|/Users/BigRed/Desktop/TankDrive/TankDrive.swf contains invalid data.
at mainmenu/starttank()
That's the error...
And above the starttank() function is still the same...
Ok, I looked over the files.
I'm puzzled by what you are trying to do.
Your Document class is TankDrive, and it creates an instance of mainmenu, which create ANOTHER instance of TankDrive when you click a button. Which is not what I think you want to do, or you think it's allowing you to access your document class. -- it's not. It's attempting to create a whole new instance of your game.
In short, your design is not making sense, and it's also causing a conflict with the document class resulting in that error.
The quick solution is to NOT have your EventListener & handler for the click in the mainmenu class, and then call the tankstart() method of your document class instead of attempting to create a new instance of TankDrive.
First move that listener into the document class and modify like this :
main.enterTank.addEventListener(MouseEvent.CLICK, starttank);
and then move your handler to the TankDrive class and modify as follows :
public function starttank(event:MouseEvent):void
{
tankstart();
}
This is not the only way to do this, and not really the way that I would do it. But I think that discussion is beyond the scope of this question.
If you want you can contact me at prototype.in.training#gmail.com for more details on that.
The problem is that you have an instance name that's also a class name (and the compiler has assumed that you meant to reference the latter). You probably meant to call your TankDrive variable 'tankDrive', so changing your code snippet to the following will probably help:
public function starttank(event:MouseEvent):void
{
var tankdrive:TankDrive = new TankDrive();
tankdrive.tankstart();
}
It's common and recommended to start all public variable names with a lower case letter, private variables with an underscore, and class names with a capital, though this isn't enforced by the language itself, so this kind of thing can happen.
Here are some guides on conventional variable and function naming that can help you keep track of what each of your vars and functions are supposed to do:
http://www.adobe.com/devnet/actionscript/learning/as3-fundamentals/variables.html
http://www.adobe.com/devnet/actionscript/learning/as3-fundamentals/functions.html
Good luck!

1067: Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObject

So for instance, I've got three .as files called 'Helicopter.as, Game.as, Blue.as'
and I also have a .fla file called Helicopter.fla (These files are all suppose to link together, to make the helicopter game) . In the Game.as file, I have the following;
if (blue1.hitTestObject(Helicopter))
{
trace("YOU HIT THE BLOCK!");
Helicopter.x = 76;
Helicopter.y = 217;
}
I have drawn the so called 'Helicopter'^ using API in a different file called Helicopter.as using this code;
graphics.beginFill(0x00FF00);
graphics.drawCircle(0, 60, 35);
graphics.endFill();
However, I originally had the "Helicopter' symbol drawn in the Helicopter.fla file (which I've now deleted), and now that I've drawn the 'Helicopter' using API, I get this error;
''1067: Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObject.''
Flash doesn't recognise the original Helicopter symbol (in the Helicopter.fla file, because I deleted it). But I want the system to detect the 'circle' drawn using API (In the Helicopter.as file). And I have no idea how to how to name the API drawn circle 'Helicopter', thus I'm getting an error. So how do I name the API circle to 'Helicopter', so the Game.as file recognises it. If you have no idea what I'm talking about, then don't worry, because I don't know too. Thank you. If you want, I can paste all the code I've done so far.
Helicopter is a class not a variable, therefore you cannot assign Helicopter.x. You need to create a variable var heli:Helicopter = new Helicopter(); and use heli.x
it also could be that you're not following the programming standards, and Helicopter is in fact a variable and not a Class, though the error seems to indicate otherwise.