forked from google/bamboo-soy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Partly fixes google#172
- Loading branch information
Alexander Pavlov
committed
Dec 20, 2019
1 parent
cc62277
commit 227f22f
Showing
27 changed files
with
1,065 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/main/java/com/google/bamboo/soy/elements/AtStateElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2017 Google Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.bamboo.soy.elements; | ||
|
||
import com.google.bamboo.soy.lang.Parameter; | ||
import com.google.bamboo.soy.lang.StateVariable; | ||
import com.google.bamboo.soy.parser.SoyParamDefinitionIdentifier; | ||
import com.google.bamboo.soy.parser.SoyTypeExpression; | ||
import com.google.bamboo.soy.parser.SoyTypes; | ||
import com.google.bamboo.soy.stubs.AtParamStub; | ||
import com.google.bamboo.soy.stubs.AtStateStub; | ||
import com.intellij.psi.PsiElement; | ||
import com.intellij.psi.PsiNamedElement; | ||
import com.intellij.psi.StubBasedPsiElement; | ||
import com.intellij.util.IncorrectOperationException; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public interface AtStateElement extends StubBasedPsiElement<AtStateStub>, PsiNamedElement, | ||
TagElement { | ||
|
||
@Nullable | ||
SoyParamDefinitionIdentifier getParamDefinitionIdentifier(); | ||
|
||
@Nullable | ||
SoyTypeExpression getTypeExpression(); | ||
|
||
default PsiElement setName(@NotNull String s) throws IncorrectOperationException { | ||
return null; | ||
} | ||
|
||
@NotNull | ||
default String getType() { | ||
if (getStub() != null) { | ||
return getStub().type; | ||
} | ||
if (getTypeExpression() != null) { | ||
return getTypeExpression().getText(); | ||
} | ||
return ""; | ||
} | ||
|
||
default StateVariable toStateVariable() { | ||
return this.getParamDefinitionIdentifier() == null | ||
? null | ||
: new StateVariable(getName(), getType(), this.getParamDefinitionIdentifier()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/main/java/com/google/bamboo/soy/elements/impl/AtStateMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright 2017 Google Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.bamboo.soy.elements.impl; | ||
|
||
import com.google.bamboo.soy.elements.AtParamElement; | ||
import com.google.bamboo.soy.elements.AtStateElement; | ||
import com.google.bamboo.soy.parser.SoyParamDefinitionIdentifier; | ||
import com.google.bamboo.soy.parser.SoyTypeExpression; | ||
import com.google.bamboo.soy.stubs.AtParamStub; | ||
import com.google.bamboo.soy.stubs.AtStateStub; | ||
import com.intellij.lang.ASTNode; | ||
import com.intellij.psi.stubs.IStubElementType; | ||
import com.intellij.psi.tree.IElementType; | ||
import com.intellij.psi.util.PsiTreeUtil; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public abstract class AtStateMixin extends SoyStubBasedPsiElementBase<AtStateStub> | ||
implements AtStateElement { | ||
|
||
public AtStateMixin(AtStateStub stub, IStubElementType type) { | ||
super(stub, type); | ||
} | ||
|
||
public AtStateMixin(ASTNode node) { | ||
super(node); | ||
} | ||
|
||
public AtStateMixin(AtStateStub stub, IElementType type, ASTNode node) { | ||
super(stub, type, node); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String getName() { | ||
if (getStub() != null) { | ||
return getStub().getName(); | ||
} | ||
if (getParamDefinitionIdentifier() != null) { | ||
return getParamDefinitionIdentifier().getName(); | ||
} | ||
return ""; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public SoyParamDefinitionIdentifier getParamDefinitionIdentifier() { | ||
return PsiTreeUtil.getChildOfType(this, SoyParamDefinitionIdentifier.class); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public SoyTypeExpression getTypeExpression() { | ||
return PsiTreeUtil.getChildOfType(this, SoyTypeExpression.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.