added generalized constructor to StubBasedPsiElementBase to allow inheriting from...
authornik <Nikolay.Chashnikov@jetbrains.com>
Wed, 24 Jun 2015 08:08:35 +0000 (11:08 +0300)
committernik <Nikolay.Chashnikov@jetbrains.com>
Wed, 24 Jun 2015 08:08:55 +0000 (11:08 +0300)
platform/core-impl/src/com/intellij/extapi/psi/StubBasedPsiElementBase.java

index 2a421ff9a47d6f4f9976777287587a545183d751..fef796c3b17c2a89e662ac4e5ef704f8bc947231 100644 (file)
@@ -70,6 +70,24 @@ public class StubBasedPsiElementBase<T extends StubElement> extends ASTDelegateP
     myElementType = node.getElementType();
   }
 
+  /**
+   * This constructor is created to allow inheriting from this class in JVM languages which doesn't support multiple constructors (e.g. Scala).
+   * If your language does support multiple constructors use {@link #StubBasedPsiElementBase(StubElement, IStubElementType)} and
+   * {@link #StubBasedPsiElementBase(ASTNode)} instead.
+   */
+  public StubBasedPsiElementBase(T stub, IElementType nodeType, ASTNode node) {
+    if (stub != null) {
+      LOG.assertTrue(nodeType != null && node == null);
+      myStub = stub;
+      myElementType = nodeType;
+    }
+    else {
+      LOG.assertTrue(nodeType == null && node != null);
+      myNode = node;
+      myElementType = node.getElementType();
+    }
+  }
+
   @Override
   @NotNull
   public ASTNode getNode() {