You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2016/12/17 10:28:47 UTC
[71/81] [abbrv] zest-java git commit: ZEST-195, ZEST-201 ;
Rename of everything else from zest to polygene.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/psi/PsiClassUtil.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/psi/PsiClassUtil.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/psi/PsiClassUtil.java
deleted file mode 100644
index 1f7dbb2..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/psi/PsiClassUtil.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.common.psi;
-
-import com.intellij.psi.*;
-import com.intellij.psi.search.GlobalSearchScope;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.lang.reflect.InvocationHandler;
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.apache.polygene.ide.plugin.idea.common.psi.search.GlobalSearchScopeUtil.determineSearchScope;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class PsiClassUtil
-{
- @Nullable
- public static PsiClass getPSIClass( @NotNull PsiElement element )
- {
- if( element instanceof PsiClass )
- {
- return (PsiClass) element;
- }
-
- if( element instanceof PsiTypeElement )
- {
- PsiTypeElement psiTypeElement = (PsiTypeElement) element;
- PsiJavaCodeReferenceElement componentRef = psiTypeElement.getInnermostComponentReferenceElement();
- if( componentRef == null )
- {
- return null;
- }
-
- return (PsiClass) componentRef.resolve();
- }
-
- PsiElement context = element.getContext();
- if( context instanceof PsiClass )
- {
- return (PsiClass) context;
- }
-
- return null;
- }
-
- @NotNull
- public static Set<PsiClass> getExtends( @NotNull PsiClass psiClass )
- {
- HashSet<PsiClass> extendsClasses = new HashSet<PsiClass>();
- PsiClassType[] extendsClassTypes = psiClass.getExtendsListTypes();
- for( PsiClassType extendClassType : extendsClassTypes )
- {
- PsiClass extendClass = extendClassType.resolve();
- if( extendClass != null )
- {
- extendsClasses.add( extendClass );
- }
- }
-
- return extendsClasses;
- }
-
- /**
- * Returns all extends of the specified {@code psiClass}.
- *
- * @param psiClass class to process.
- * @return all extends of the specified {@code psiClass}.
- * @since 0.1
- */
- @NotNull
- public static Set<PsiClass> getExtendsDeep( @NotNull PsiClass psiClass )
- {
- HashSet<PsiClass> extendsClasses = new HashSet<PsiClass>();
- PsiClassType[] extendsClassTypes = psiClass.getExtendsListTypes();
- for( PsiClassType extendClassType : extendsClassTypes )
- {
- PsiClass extendClass = extendClassType.resolve();
- if( extendClass != null )
- {
- extendsClasses.add( extendClass );
- extendsClasses.addAll( getExtendsDeep( extendClass ) );
- }
- }
-
- return extendsClasses;
- }
-
- /**
- * @param psiClass Psi class to check.
- * @return {@code true} if psi class implements {@code InvocationHandler}, {@code false} otherwise.
- * @see InvocationHandler
- */
- public static boolean isImplementsInvocationHandler( @NotNull PsiClass psiClass )
- {
- if( psiClass.isInterface() )
- {
- return false;
- }
-
- GlobalSearchScope searchScope = determineSearchScope( psiClass );
- assert searchScope != null;
-
- JavaPsiFacade psiFacade = JavaPsiFacade.getInstance( psiClass.getProject() );
- PsiClass invocationHandler = psiFacade.findClass( "java.lang.reflect.InvocationHandler", searchScope );
- assert invocationHandler != null;
-
- return psiClass.isInheritor( invocationHandler, true );
- }
-
- private PsiClassUtil()
- {
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/psi/search/GlobalSearchScopeUtil.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/psi/search/GlobalSearchScopeUtil.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/psi/search/GlobalSearchScopeUtil.java
deleted file mode 100644
index 4beda1f..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/psi/search/GlobalSearchScopeUtil.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.common.psi.search;
-
-import com.intellij.openapi.module.Module;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.roots.ProjectRootManager;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.search.GlobalSearchScope;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import static com.intellij.openapi.module.ModuleUtil.findModuleForPsiElement;
-import static org.apache.polygene.ide.plugin.idea.common.vfs.VirtualFileUtil.getVirtualFile;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public class GlobalSearchScopeUtil
-{
- /**
- * Determine search scope given a psi element.
- *
- * @param psiElement context.
- * @return Search scope given psi class.
- * @since 0.1
- */
- @Nullable
- public static GlobalSearchScope determineSearchScope( @NotNull PsiElement psiElement )
- {
- VirtualFile classVirtualFile = getVirtualFile( psiElement );
- if( classVirtualFile == null )
- {
- return null;
- }
-
- Module module = findModuleForPsiElement( psiElement );
- if( module == null )
- {
- return null;
- }
-
- Project project = psiElement.getProject();
- ProjectRootManager projectRootManager = ProjectRootManager.getInstance( project );
- boolean includeTestClasses = projectRootManager.getFileIndex().isInTestSourceContent( classVirtualFile );
- return module.getModuleWithDependenciesAndLibrariesScope( includeTestClasses );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/resource/PolygeneResourceBundle.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/resource/PolygeneResourceBundle.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/resource/PolygeneResourceBundle.java
deleted file mode 100644
index c5f29b4..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/resource/PolygeneResourceBundle.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.common.resource;
-
-import com.intellij.CommonBundle;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.PropertyKey;
-
-import java.lang.ref.Reference;
-import java.lang.ref.SoftReference;
-import java.util.ResourceBundle;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class PolygeneResourceBundle
-{
-
- @NonNls
- private static final String RESOURCE_BUNDLE_NAME = "org.apache.polygene.ide.plugin.idea.common.resource.PolygeneResourceBundle";
-
- private static Reference<ResourceBundle> BUNDLE_REF;
-
- private PolygeneResourceBundle()
- {
- }
-
- public static String message( @PropertyKey( resourceBundle = RESOURCE_BUNDLE_NAME ) String key,
- Object... params )
- {
- ResourceBundle resourceBundle = getBundle();
- return CommonBundle.message( resourceBundle, key, params );
- }
-
- private static ResourceBundle getBundle()
- {
- ResourceBundle bundle = null;
- if( BUNDLE_REF != null )
- {
- bundle = BUNDLE_REF.get();
- }
-
- if( bundle == null )
- {
- bundle = ResourceBundle.getBundle( PolygeneResourceBundle.class.getName() );
- BUNDLE_REF = new SoftReference<ResourceBundle>( bundle );
- }
-
- return bundle;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/vfs/VirtualFileUtil.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/vfs/VirtualFileUtil.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/vfs/VirtualFileUtil.java
deleted file mode 100644
index d5b95b6..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/vfs/VirtualFileUtil.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.common.vfs;
-
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.PsiFileSystemItem;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class VirtualFileUtil
-{
- /**
- * @param element element to process.
- * @return The containing virtual file of the element.
- * @since 0.1
- */
- @Nullable
- public static VirtualFile getVirtualFile( @NotNull PsiElement element )
- {
- if( element instanceof PsiFileSystemItem )
- {
- PsiFileSystemItem fileSystemItem = (PsiFileSystemItem) element;
- return fileSystemItem.getVirtualFile();
- }
-
- // If it's not a file system, assume that this is an element within a file
- PsiFile containingFile = element.getContainingFile();
- if( containingFile == null )
- {
- return null;
- }
-
- VirtualFile virtualFile = containingFile.getVirtualFile();
- if( virtualFile != null )
- {
- return virtualFile;
- }
-
- PsiFile originalFile = containingFile.getOriginalFile();
- if( originalFile == null )
- {
- return null;
- }
-
- return originalFile.getVirtualFile();
- }
-
- private VirtualFileUtil()
- {
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/actions/create/CreateConcernFromMixinTypeOrCompositeAction.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/actions/create/CreateConcernFromMixinTypeOrCompositeAction.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/actions/create/CreateConcernFromMixinTypeOrCompositeAction.java
deleted file mode 100644
index b6abdfb..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/actions/create/CreateConcernFromMixinTypeOrCompositeAction.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.concerns.actions.create;
-
-import com.intellij.psi.PsiDirectory;
-import com.intellij.psi.PsiElement;
-import org.jetbrains.annotations.NotNull;
-import org.apache.polygene.ide.plugin.idea.common.actions.AbstractCreateElementActionBase;
-
-/**
- * @author edward.yakop@gmail.com
- */
-public class CreateConcernFromMixinTypeOrCompositeAction extends AbstractCreateElementActionBase
-{
- public CreateConcernFromMixinTypeOrCompositeAction()
- {
- super( "TODO", "TODO" );
- }
-
- protected String getCommandName()
- {
- return "CreateConcernFromMixinTypeOrCompositeAction";
- }
-
- protected String getActionName( PsiDirectory directory, String newName )
- {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- protected String getDialogPrompt()
- {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- protected String getDialogTitle()
- {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- @NotNull
- protected PsiElement[] create( String newName, PsiDirectory directory )
- throws Exception
- {
- return new PsiElement[0]; //To change body of implemented methods use File | Settings | File Templates.
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/actions/create/inPackage/CreateConcernOfInPackageAction.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/actions/create/inPackage/CreateConcernOfInPackageAction.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/actions/create/inPackage/CreateConcernOfInPackageAction.java
deleted file mode 100644
index 402df3e..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/actions/create/inPackage/CreateConcernOfInPackageAction.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.concerns.actions.create.inPackage;
-
-import com.intellij.ide.actions.CreateInPackageActionBase;
-import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.Messages;
-import com.intellij.psi.JavaDirectoryService;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiDirectory;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NotNull;
-
-import static com.intellij.openapi.actionSystem.DataKeys.PROJECT;
-import static com.intellij.openapi.actionSystem.DataKeys.PSI_ELEMENT;
-import static com.intellij.util.Icons.CLASS_ICON;
-import static org.apache.polygene.ide.plugin.idea.common.psi.search.GlobalSearchScopeUtil.determineSearchScope;
-import static org.apache.polygene.ide.plugin.idea.common.resource.PolygeneResourceBundle.message;
-import static org.apache.polygene.ide.plugin.idea.concerns.common.PolygeneConcernConstants.TEMPLATE_GENERIC_CONCERN_OF;
-import static org.apache.polygene.ide.plugin.idea.concerns.common.PolygeneConcernUtil.getConcernOfClass;
-
-/**
- * JAVADOC: Non generic concern
- *
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public class CreateConcernOfInPackageAction extends CreateInPackageActionBase
-{
- protected CreateConcernOfInPackageAction()
- {
- super( message( "createConcernOfInPackage.menu.action.text" ),
- message( "createConcernOfInPackage.menu.action.description" ),
- CLASS_ICON );
- }
-
- @Override
- protected final boolean isAvailable( DataContext dataContext )
- {
- boolean isAvailable = super.isAvailable( dataContext );
- if( !isAvailable )
- {
- return false;
- }
-
- PsiElement psiElement = PSI_ELEMENT.getData( dataContext );
- if( psiElement == null )
- {
- return false;
- }
-
- GlobalSearchScope searchScope = determineSearchScope( psiElement );
- if( searchScope == null )
- {
- return false;
- }
-
- Project project = PROJECT.getData( dataContext );
- PsiClass psiClass = getConcernOfClass( project, searchScope );
- return psiClass != null;
- }
-
- @NotNull
- protected final PsiElement[] invokeDialog( Project project, PsiDirectory directory )
- {
- MyInputValidator validator = new MyInputValidator( project, directory );
- Messages.showInputDialog( project, message( "createConcernOfInPackage.dlg.prompt" ),
- message( "createConcernOfInPackage.dlg.title" ),
- Messages.getQuestionIcon(), "", validator );
- return validator.getCreatedElements();
- }
-
- protected final String getCommandName()
- {
- return message( "createConcernOfInPackage.command.name" );
- }
-
- protected final String getErrorTitle()
- {
- return message( "createConcernOfInPackage.error.title" );
- }
-
- protected final String getActionName( PsiDirectory directory, String newName )
- {
- return message( "createConcernOfInPackage.progress.text", newName );
- }
-
- protected final void doCheckCreate( final PsiDirectory dir, final String className )
- throws IncorrectOperationException
- {
- JavaDirectoryService javaDirectoryService = JavaDirectoryService.getInstance();
- javaDirectoryService.checkCreateClass( dir, className );
- }
-
- @NotNull
- protected PsiClass doCreate( final PsiDirectory dir, final String className )
- throws IncorrectOperationException
- {
- JavaDirectoryService javaDirectoryService = JavaDirectoryService.getInstance();
- return javaDirectoryService.createClass( dir, className, TEMPLATE_GENERIC_CONCERN_OF );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/common/PolygeneConcernConstants.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/common/PolygeneConcernConstants.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/common/PolygeneConcernConstants.java
deleted file mode 100644
index 0bbe3a1..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/common/PolygeneConcernConstants.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.concerns.common;
-
-import org.jetbrains.annotations.NonNls;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class PolygeneConcernConstants
-{
- public static final String QUALIFIED_NAME_CONCERNS = "org.apache.polygene.api.concern.Concerns";
-
- public static final String QUALIFIED_NAME_CONCERN_OF = "org.apache.polygene.api.concern.ConcernOf";
- public static final String QUALIFIED_NAME_GENERIC_CONCERN = "org.apache.polygene.api.concern.GenericConcern";
-
- @NonNls
- public static final String TEMPLATE_GENERIC_CONCERN_OF = "GenericConcernOf.java";
-
- private PolygeneConcernConstants()
- {
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/common/PolygeneConcernUtil.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/common/PolygeneConcernUtil.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/common/PolygeneConcernUtil.java
deleted file mode 100644
index 4499143..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/common/PolygeneConcernUtil.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.concerns.common;
-
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.JavaCodeStyleManager;
-import com.intellij.psi.search.GlobalSearchScope;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.List;
-
-import static com.intellij.codeInsight.AnnotationUtil.findAnnotation;
-import static java.util.Collections.emptyList;
-import static org.apache.polygene.ide.plugin.idea.common.psi.PsiAnnotationUtil.getAnnotationDefaultParameterValue;
-import static org.apache.polygene.ide.plugin.idea.common.psi.PsiAnnotationUtil.getClassReference;
-import static org.apache.polygene.ide.plugin.idea.common.psi.PsiClassUtil.getPSIClass;
-import static org.apache.polygene.ide.plugin.idea.common.psi.search.GlobalSearchScopeUtil.determineSearchScope;
-import static org.apache.polygene.ide.plugin.idea.concerns.common.PolygeneConcernConstants.*;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class PolygeneConcernUtil
-{
-
-
- /**
- * @param searchContext Search context.
- * @return {@code GenericConcern} psi class if found, {@code null} otherwise.
- * @since 0.1
- */
- @Nullable
- public static PsiClass getGenericConcernClass( @NotNull PsiElement searchContext )
- {
- Project project = searchContext.getProject();
- GlobalSearchScope searchScope = determineSearchScope( searchContext );
- return getGenericConcernClass( project, searchScope );
- }
-
- /**
- * @param project project.
- * @param scope search scope.
- * @return {@code GenericConcern} psi class if found, {@code null} otherwise.
- * @since 0.1
- */
- @Nullable
- public static PsiClass getGenericConcernClass( @NotNull Project project,
- @Nullable GlobalSearchScope scope )
- {
- JavaPsiFacade psiFacade = JavaPsiFacade.getInstance( project );
- return scope != null ? psiFacade.findClass( QUALIFIED_NAME_GENERIC_CONCERN, scope ) : null;
- }
-
- @Nullable
- public static PsiClass getConcernOfClass( @NotNull PsiElement searchContext )
- {
- Project project = searchContext.getProject();
- GlobalSearchScope searchScope = determineSearchScope( searchContext );
- return getConcernOfClass( project, searchScope );
- }
-
- @Nullable
- public static PsiClass getConcernOfClass( @NotNull Project project,
- @Nullable GlobalSearchScope scope )
- {
- JavaPsiFacade psiFacade = JavaPsiFacade.getInstance( project );
- return scope != null ? psiFacade.findClass( QUALIFIED_NAME_CONCERN_OF, scope ) : null;
- }
-
- @Nullable
- public static PsiAnnotation getConcernsAnnotation( @NotNull PsiElement element )
- {
- PsiClass psiClass = getPSIClass( element );
- return findAnnotation( psiClass, QUALIFIED_NAME_CONCERNS );
- }
-
- @NotNull
- public static PsiAnnotation addOrReplaceConcernAnnotation( @NotNull PsiModifierListOwner modifierListOwner,
- @NotNull PsiClass concernClassToAdd )
- {
- Project project = modifierListOwner.getProject();
- JavaPsiFacade psiFacade = JavaPsiFacade.getInstance( project );
- PsiElementFactory factory = psiFacade.getElementFactory();
- PsiAnnotation existingConcernsAnnotation = findAnnotation( modifierListOwner, QUALIFIED_NAME_CONCERNS );
-
- boolean isReplace = false;
- PsiAnnotation newConcernsAnnotation;
- if( existingConcernsAnnotation != null )
- {
- // Check duplicate
- List<PsiAnnotationMemberValue> concernsValues = getConcernsAnnotationValue( existingConcernsAnnotation );
- for( PsiAnnotationMemberValue concernValue : concernsValues )
- {
- PsiJavaCodeReferenceElement concernClassReference = getConcernClassReference( concernValue );
- if( concernClassReference == null )
- {
- continue;
- }
-
- PsiElement concernClass = concernClassReference.resolve();
- if( concernClassToAdd.equals( concernClass ) )
- {
- return existingConcernsAnnotation;
- }
- }
-
- isReplace = true;
- }
-
- String concernAnnotationText = createConcernAnnotationText( existingConcernsAnnotation, concernClassToAdd );
- newConcernsAnnotation =
- factory.createAnnotationFromText( concernAnnotationText, modifierListOwner );
-
- if( isReplace )
- {
- // Replace @Concerns instead
- existingConcernsAnnotation.replace( newConcernsAnnotation );
- }
- else
- {
- // @Concerns doesn't exists, add it as first child
- PsiModifierList modifierList = modifierListOwner.getModifierList();
- modifierList.addBefore( newConcernsAnnotation, modifierList.getFirstChild() );
- }
-
- // Shorten all class references if possible
- JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance( project );
- codeStyleManager.shortenClassReferences( newConcernsAnnotation );
-
- return newConcernsAnnotation;
- }
-
- @NotNull
- private static String createConcernAnnotationText( @Nullable PsiAnnotation concernAnnotationBase,
- @NotNull PsiClass concernClassToAdd )
- {
- StringBuilder annotationTextBuilder = new StringBuilder();
- annotationTextBuilder.append( "@" ).append( QUALIFIED_NAME_CONCERNS ).append( "( {" );
- List<PsiAnnotationMemberValue> concernsAnnotationValue = getConcernsAnnotationValue( concernAnnotationBase );
- for( PsiAnnotationMemberValue concernValue : concernsAnnotationValue )
- {
- annotationTextBuilder.append( concernValue.getText() ).append( ", " );
- }
- annotationTextBuilder.append( concernClassToAdd.getQualifiedName() ).append( ".class" );
- annotationTextBuilder.append( "} )" );
- return annotationTextBuilder.toString();
- }
-
- @NotNull
- public static List<PsiAnnotationMemberValue> getConcernsAnnotationValue( @Nullable PsiAnnotation concernsAnnotation )
- {
- if( concernsAnnotation == null )
- {
- return emptyList();
- }
-
- String concernsQualifiedName = concernsAnnotation.getQualifiedName();
- if( !QUALIFIED_NAME_CONCERNS.equals( concernsQualifiedName ) )
- {
- return emptyList();
- }
-
- return getAnnotationDefaultParameterValue( concernsAnnotation );
- }
-
- @Nullable
- public static PsiJavaCodeReferenceElement getConcernClassReference( @NotNull PsiAnnotationMemberValue value )
- {
- return getClassReference( value );
- }
-
- /**
- * @param psiClass psi class to check.
- * @return {@code true} if {@code psiClass} extends {@code ConcernOf}, {@code false} if {@code psiClass} does
- * not extends {@code ConcernOf} or {@code ConcernOf} is not found.
- * @since 0.1
- */
- public static boolean isAConcern( @NotNull PsiClass psiClass )
- {
- if( psiClass.isInterface() )
- {
- return false;
- }
-
- PsiClass concernOfClass = getConcernOfClass( psiClass );
- return concernOfClass != null && psiClass.isInheritor( concernOfClass, true );
- }
-
- /**
- * @param psiClass psi class to check.
- * @return {@code true} if {@code psiClass} extends {@code GenericConcern}, {@code false} if {@code psiClass} does
- * not extends {@code GenericConcern} or {@code GenericConcern} is not found.
- * @since 0.1
- */
- public static boolean isAGenericConcern( @NotNull PsiClass psiClass )
- {
- if( psiClass.isInterface() )
- {
- return false;
- }
-
- PsiClass genericConcern = getGenericConcernClass( psiClass );
- return genericConcern != null && psiClass.isInheritor( genericConcern, true );
- }
-
- private PolygeneConcernUtil()
- {
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/inspections/ConcernsAnnotationDeclaredCorrectlyInspection.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/inspections/ConcernsAnnotationDeclaredCorrectlyInspection.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/inspections/ConcernsAnnotationDeclaredCorrectlyInspection.java
deleted file mode 100644
index 4549efe..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/inspections/ConcernsAnnotationDeclaredCorrectlyInspection.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.concerns.inspections;
-
-import com.intellij.codeInspection.InspectionManager;
-import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiAnnotation;
-import com.intellij.psi.PsiAnnotationMemberValue;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiJavaCodeReferenceElement;
-import com.intellij.psi.search.GlobalSearchScope;
-import org.jetbrains.annotations.NotNull;
-import org.apache.polygene.ide.plugin.idea.common.inspections.AbstractFix;
-import org.apache.polygene.ide.plugin.idea.common.inspections.AbstractInspection;
-import org.apache.polygene.ide.plugin.idea.common.resource.PolygeneResourceBundle;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import static com.intellij.codeInspection.ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
-import static org.apache.polygene.ide.plugin.idea.common.psi.search.GlobalSearchScopeUtil.determineSearchScope;
-import static org.apache.polygene.ide.plugin.idea.common.resource.PolygeneResourceBundle.message;
-import static org.apache.polygene.ide.plugin.idea.concerns.common.PolygeneConcernUtil.*;
-
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class ConcernsAnnotationDeclaredCorrectlyInspection extends AbstractInspection
-{
- @NotNull
- protected final String resourceBundlePrefixId()
- {
- return "concerns.annotation.declared.correctly";
- }
-
- @NotNull
- public final String getShortName()
- {
- return "ConcernsAnnotationDeclaredCorrectlyInspection";
- }
-
- @Override
- public final ProblemDescriptor[] checkClass( @NotNull PsiClass psiClass,
- @NotNull InspectionManager manager,
- boolean isOnTheFly )
- {
- // If class does not have @Concerns, ignore
- PsiAnnotation concernsAnnotation = getConcernsAnnotation( psiClass );
- if( concernsAnnotation == null )
- {
- return null;
- }
-
- // If @Concerns declared in class, suggest remove @Concerns annotation
- if( !psiClass.isInterface() )
- {
- String message = message( "concerns.annotation.declared.correctly.error.annotation.declared.in.class" );
- RemoveConcernsAnnotationFix fix = new RemoveConcernsAnnotationFix( concernsAnnotation );
- ProblemDescriptor problemDescriptor = manager.createProblemDescriptor( concernsAnnotation, message, fix,
- GENERIC_ERROR_OR_WARNING );
- return new ProblemDescriptor[]{ problemDescriptor };
- }
-
- // If @Concerns annotation is empty, ignore
- List<PsiAnnotationMemberValue> concernsAnnotationValue = getConcernsAnnotationValue( concernsAnnotation );
- if( concernsAnnotationValue.isEmpty() )
- {
- return null;
- }
-
- // If ConcernOfClass is not resolved, ignore
- Project project = psiClass.getProject();
- GlobalSearchScope searchScope = determineSearchScope( psiClass );
- PsiClass concernOfClass = getConcernOfClass( project, searchScope );
- if( concernOfClass == null )
- {
- return null;
- }
-
- List<ProblemDescriptor> problems = new LinkedList<ProblemDescriptor>();
- for( PsiAnnotationMemberValue concernClassAnnotationValue : concernsAnnotationValue )
- {
- PsiJavaCodeReferenceElement concernClassReference = getConcernClassReference( concernClassAnnotationValue );
-
- // If it's not a class reference, ignore
- if( concernClassReference == null )
- {
- continue;
- }
-
- // If class reference can't be resolved, ignore
- PsiClass concernClass = (PsiClass) concernClassReference.resolve();
- if( concernClass == null )
- {
- continue;
- }
-
- // If concern class does not inherit concern class, suggest remove that reference.
- if( !concernClass.isInheritor( concernOfClass, true ) )
- {
- String message = PolygeneResourceBundle.message(
- "concerns.annotation.declared.correctly.error.concern.class.does.not.extend.ConcernOf",
- concernClass.getQualifiedName()
- );
-
- RemoveInvalidConcernClassReferenceFix fix = new RemoveInvalidConcernClassReferenceFix(
- concernClassAnnotationValue, concernClassReference
- );
- ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
- concernClassAnnotationValue, message, fix, GENERIC_ERROR_OR_WARNING );
- problems.add( problemDescriptor );
- }
- else
- {
- // TODO: Test whether it is a generic concern
- // TODO: Test whether it is a specific concern
- }
- }
-
- return problems.toArray( new ProblemDescriptor[problems.size()] );
- }
-
- private static class RemoveConcernsAnnotationFix extends AbstractFix
- {
- private final PsiAnnotation annotationToRemove;
-
- private RemoveConcernsAnnotationFix( @NotNull PsiAnnotation annotationToRemove )
- {
- super( message( "concerns.annotation.declared.correctly.fix.remove.annotation" ) );
- this.annotationToRemove = annotationToRemove;
- }
-
- public final void applyFix( @NotNull Project project, @NotNull ProblemDescriptor descriptor )
- {
- annotationToRemove.delete();
- }
- }
-
- private static class RemoveInvalidConcernClassReferenceFix extends AbstractFix
- {
- private final PsiAnnotationMemberValue concernClassAnnotationValue;
-
- public RemoveInvalidConcernClassReferenceFix( @NotNull PsiAnnotationMemberValue annotationValueToRemove,
- @NotNull PsiJavaCodeReferenceElement concernClassReference )
- {
- super( message( "concerns.annotation.declared.correctly.fix.remove.concern.class.reference",
- concernClassReference.getQualifiedName() ) );
- this.concernClassAnnotationValue = annotationValueToRemove;
- }
-
- public final void applyFix( @NotNull Project project, @NotNull ProblemDescriptor descriptor )
- {
- concernClassAnnotationValue.delete();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/intentions/add/AddConcernOnType.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/intentions/add/AddConcernOnType.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/intentions/add/AddConcernOnType.java
deleted file mode 100644
index 5dc21bf..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/concerns/intentions/add/AddConcernOnType.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.concerns.intentions.add;
-
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.PsiMethod;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.util.Processor;
-import com.intellij.util.Query;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.apache.polygene.ide.plugin.idea.common.intentions.AbstractIntention;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static com.intellij.psi.search.searches.ClassInheritorsSearch.search;
-import static java.util.Collections.emptyList;
-import static org.apache.polygene.ide.plugin.idea.common.psi.search.GlobalSearchScopeUtil.determineSearchScope;
-import static org.apache.polygene.ide.plugin.idea.concerns.common.PolygeneConcernUtil.addOrReplaceConcernAnnotation;
-import static org.apache.polygene.ide.plugin.idea.concerns.common.PolygeneConcernUtil.getConcernOfClass;
-
-/**
- * JAVADOC: This is disabled in PolygeneApplicationComponent.
- *
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class AddConcernOnType
- extends AbstractIntention
-{
- protected boolean isIntentionValidFor( PsiElement element )
- {
- if( !( element instanceof PsiClass ) )
- {
- return false;
- }
-
- // If it's not interface, ignore it
- PsiClass psiClass = (PsiClass) element;
- if( !psiClass.isInterface() )
- {
- return false;
- }
-
- // Is @Concerns accesible within module
- GlobalSearchScope searchScope = determineSearchScope( psiClass );
- PsiClass concernOfClass = getConcernOfClass( psiClass.getProject(), searchScope );
- return concernOfClass != null;
- }
-
- protected final String resourceBundlePrefixId()
- {
- return "add.concern";
- }
-
- @Override
- public boolean isAvailable( @NotNull Project project, Editor editor, @Nullable PsiElement element )
- {
- while( element != null )
- {
- if( element instanceof PsiFile ||
- element instanceof PsiMethod )
- {
- break;
- }
-
- if( isIntentionValidFor( element ) )
- {
- return true;
- }
-
- element = element.getParent();
- }
-
- return false;
- }
-
- @SuppressWarnings( "unchecked" )
- protected void processIntention( @NotNull Project project, @NotNull Editor editor, @NotNull PsiElement element )
- {
- PsiClass psiClass = (PsiClass) element;
- List<PsiClass> concernCandidates = findConcernsCandidates( psiClass );
- if( concernCandidates.size() == 1 )
- {
- PsiClass concernCandidate = concernCandidates.get( 0 );
- addOrReplaceConcernAnnotation( psiClass, concernCandidate );
- }
- }
-
- private static List<PsiClass> findConcernsCandidates( final @NotNull PsiClass classToCheck )
- {
- GlobalSearchScope searchScope = determineSearchScope( classToCheck );
- PsiClass concernOfClass = getConcernOfClass( classToCheck.getProject(), searchScope );
- if( concernOfClass == null )
- {
- return emptyList();
- }
-
- Query<PsiClass> psiClassQuery = search( concernOfClass, searchScope, true, false );
- final List<PsiClass> concernCandidates = new ArrayList<PsiClass>();
- psiClassQuery.forEach( new Processor<PsiClass>()
- {
- public boolean process( PsiClass psiClass )
- {
- // TODO: Ideally search for all "extends" as well
- boolean isInheritor = psiClass.isInheritor( classToCheck, true );
- if( isInheritor )
- {
- concernCandidates.add( psiClass );
- }
-
- return true;
- }
- } );
-
- return concernCandidates;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/common/inspections/AbstractInjectionAnnotationDeclarationOnFieldAndConstructorInspection.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/common/inspections/AbstractInjectionAnnotationDeclarationOnFieldAndConstructorInspection.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/common/inspections/AbstractInjectionAnnotationDeclarationOnFieldAndConstructorInspection.java
deleted file mode 100644
index 4b4bb9c..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/common/inspections/AbstractInjectionAnnotationDeclarationOnFieldAndConstructorInspection.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.injections.common.inspections;
-
-import com.intellij.codeInspection.InspectionManager;
-import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.psi.PsiAnnotation;
-import com.intellij.psi.PsiMethod;
-import com.intellij.psi.PsiParameter;
-import com.intellij.psi.PsiParameterList;
-import org.jetbrains.annotations.NotNull;
-import org.apache.polygene.ide.plugin.idea.common.inspections.AbstractFix;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import static com.intellij.codeInspection.ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
-import static java.util.Arrays.asList;
-
-/**
- * {@code AbstractInjectionAnnotationDeclarationOnFieldAndConstructorInspection} is a helper method to check whether
- * injection annotation are declared in either constructor or non static field.
- *
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public abstract class AbstractInjectionAnnotationDeclarationOnFieldAndConstructorInspection
- extends AbstractInjectionAnnotationDeclarationOnFieldInspection
-{
- @Override
- public final ProblemDescriptor[] checkMethod( @NotNull PsiMethod method,
- @NotNull InspectionManager manager,
- boolean isOnTheFly )
- {
- PsiParameterList parameterList = method.getParameterList();
- PsiParameter[] parameters = parameterList.getParameters();
- if( method.isConstructor() )
- {
- List<ProblemDescriptor> problems = new LinkedList<ProblemDescriptor>();
- for( PsiParameter parameter : parameters )
- {
- PsiAnnotation annotation = getAnnotationToCheck( parameter );
- if( annotation != null )
- {
- ProblemDescriptor[] descriptors =
- verifyAnnotationDeclaredCorrectly( parameter, annotation, manager );
- if( descriptors != null )
- {
- problems.addAll( asList( descriptors ) );
- }
- }
- }
-
- return problems.toArray( new ProblemDescriptor[problems.size()] );
- }
- else
- {
- List<ProblemDescriptor> problems = new LinkedList<ProblemDescriptor>();
- for( PsiParameter parameter : parameters )
- {
- PsiAnnotation annotationToCheck = getAnnotationToCheck( parameter );
- if( annotationToCheck != null )
- {
- String message = getInjectionAnnotationValidDeclarationMessage();
- AbstractFix removeAnnotationFix = createRemoveAnnotationFix( annotationToCheck );
- ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
- annotationToCheck, message, removeAnnotationFix, GENERIC_ERROR_OR_WARNING
- );
- problems.add( problemDescriptor );
- }
- }
-
- return problems.toArray( new ProblemDescriptor[problems.size()] );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/common/inspections/AbstractInjectionAnnotationDeclarationOnFieldInspection.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/common/inspections/AbstractInjectionAnnotationDeclarationOnFieldInspection.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/common/inspections/AbstractInjectionAnnotationDeclarationOnFieldInspection.java
deleted file mode 100644
index f93f396..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/common/inspections/AbstractInjectionAnnotationDeclarationOnFieldInspection.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.injections.common.inspections;
-
-import com.intellij.codeInspection.InspectionManager;
-import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiAnnotation;
-import com.intellij.psi.PsiField;
-import com.intellij.psi.PsiModifierList;
-import com.intellij.psi.PsiVariable;
-import org.apache.polygene.ide.plugin.idea.common.resource.PolygeneResourceBundle;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.apache.polygene.ide.plugin.idea.common.inspections.AbstractFix;
-import org.apache.polygene.ide.plugin.idea.common.inspections.AbstractInspection;
-
-import static com.intellij.codeInsight.AnnotationUtil.findAnnotation;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public abstract class AbstractInjectionAnnotationDeclarationOnFieldInspection extends AbstractInspection
-{
- /**
- * @return Remove annotation message fix.
- * @since 0.1
- */
- @NotNull
- protected abstract String getRemoveAnnotationMessageFix();
-
- /**
- * @return Annotation to check qualified name.
- * @since 0.1
- */
- @NotNull
- protected abstract String getAnnotationToCheckQualifiedName();
-
- /**
- * Verified that {@link #getAnnotationToCheck(com.intellij.psi.PsiVariable)} is declared correctly.
- *
- * @param psiVariable Variable to check. This could be class field member or constructor parameter.
- * @param annotationToCheck annotation declared at variable to check.
- * @param manager Inspection manager to use to create problem descriptor.
- * @return {@code null} if annotation is declared correctly, otherwise an array of problem descriptor.
- * @since 0.1
- */
- @Nullable
- protected abstract ProblemDescriptor[] verifyAnnotationDeclaredCorrectly( @NotNull PsiVariable psiVariable,
- @NotNull PsiAnnotation annotationToCheck,
- @NotNull InspectionManager manager );
-
- @Override
- public final ProblemDescriptor[] checkField( @NotNull PsiField field,
- @NotNull InspectionManager manager,
- boolean isOnTheFly )
- {
- PsiAnnotation annotationToCheck = getAnnotationToCheck( field );
- if( annotationToCheck == null )
- {
- return null;
- }
-
- PsiModifierList modifierList = field.getModifierList();
- if( modifierList != null )
- {
- if( modifierList.hasModifierProperty( com.intellij.psi.PsiModifier.STATIC ) )
- {
- String message = getInjectionAnnotationValidDeclarationMessage();
- AbstractFix removeAnnotationFix = createRemoveAnnotationFix( annotationToCheck );
- ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
- annotationToCheck, message, removeAnnotationFix, com.intellij.codeInspection.ProblemHighlightType.GENERIC_ERROR_OR_WARNING
- );
-
- return new ProblemDescriptor[]{ problemDescriptor };
- }
- }
-
- return verifyAnnotationDeclaredCorrectly( field, annotationToCheck, manager );
- }
-
- /**
- * @param variable variable to check.
- * @return Annotation to check.
- * @see #getAnnotationToCheckQualifiedName()
- * @since 0.1
- */
- @Nullable
- protected final PsiAnnotation getAnnotationToCheck( @NotNull PsiVariable variable )
- {
- String annotationQualifiedName = getAnnotationToCheckQualifiedName();
- return findAnnotation( variable, annotationQualifiedName );
- }
-
- @NotNull protected String getInjectionAnnotationValidDeclarationMessage()
- {
- String annotationQualifiedName = getAnnotationToCheckQualifiedName();
- return PolygeneResourceBundle.message( "abstract.injection.annotation.declaration.inspection.error.annotation.not.declared.correctly",
- annotationQualifiedName );
- }
-
- @NotNull
- protected final AbstractFix createRemoveAnnotationFix( @NotNull PsiAnnotation annotationToRemove )
- {
- String fixMessage = getRemoveAnnotationMessageFix();
- return new RemoveAnnotationFix( fixMessage, annotationToRemove );
- }
-
- private static class RemoveAnnotationFix extends AbstractFix
- {
- private final PsiAnnotation annotationToRemove;
-
- public RemoveAnnotationFix( @NotNull String fixMessage, @NotNull PsiAnnotation annotationToRemove )
- {
- super( fixMessage );
- this.annotationToRemove = annotationToRemove;
- }
-
- public final void applyFix( @NotNull Project project, @NotNull ProblemDescriptor descriptor )
- {
- annotationToRemove.delete();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/invocation/common/PolygeneInvocationAnnotationConstants.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/invocation/common/PolygeneInvocationAnnotationConstants.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/invocation/common/PolygeneInvocationAnnotationConstants.java
deleted file mode 100644
index 25c1267..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/invocation/common/PolygeneInvocationAnnotationConstants.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.injections.invocation.common;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class PolygeneInvocationAnnotationConstants
-{
- public static final String QUALIFIED_NAME_INVOCATION_ANNOTATION = "org.apache.polygene.api.injection.scope.Invocation";
-
- private PolygeneInvocationAnnotationConstants()
- {
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/invocation/common/PolygeneInvocationAnnotationUtil.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/invocation/common/PolygeneInvocationAnnotationUtil.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/invocation/common/PolygeneInvocationAnnotationUtil.java
deleted file mode 100644
index 334918d..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/invocation/common/PolygeneInvocationAnnotationUtil.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.injections.invocation.common;
-
-import com.intellij.psi.*;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import static com.intellij.codeInsight.AnnotationUtil.findAnnotation;
-import static com.intellij.psi.PsiModifier.STATIC;
-import static org.apache.polygene.ide.plugin.idea.common.psi.PsiClassUtil.getPSIClass;
-import static org.apache.polygene.ide.plugin.idea.injections.invocation.common.PolygeneInvocationAnnotationConstants.QUALIFIED_NAME_INVOCATION_ANNOTATION;
-import static org.apache.polygene.ide.plugin.idea.injections.invocation.common.PolygeneInvocationAnnotationUtil.InvocationAnnotationDeclarationValidationResult.*;
-import static org.apache.polygene.ide.plugin.idea.injections.structure.common.PolygeneStructureAnnotationUtil.isInjecteableByStructureAnnotation;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class PolygeneInvocationAnnotationUtil
-{
- /**
- * Returns {@code @Invocation} annotation if exists.
- *
- * @param modifierListOwner modifier list owner to process.
- * @return {@code @Invocation} annotation if exists, {@code null} otherwise.
- * @since 0.1
- */
- @Nullable
- public static PsiAnnotation getInvocationAnnotation( @NotNull PsiModifierListOwner modifierListOwner )
- {
- return findAnnotation( modifierListOwner, QUALIFIED_NAME_INVOCATION_ANNOTATION );
- }
-
- /**
- * @param psiClass psi class to check.
- * @return {@code true} if the specified psiClass is injectable by invocation annotation, {@code false} otherwise.
- */
- public static boolean isInjectableByInvocationAnnotation( @NotNull PsiClass psiClass )
- {
- if( psiClass.isAnnotationType() )
- {
- return true;
- }
-
- String classQualifiedName = psiClass.getQualifiedName();
- return "java.lang.reflect.Method".equals( classQualifiedName ) ||
- "java.lang.reflect.AnnotatedElement".equals( classQualifiedName );
- }
-
- /**
- * Validates whether the variable has {@code @Invocation} annotation declared correctly.
- *
- * @param variable variable to check.
- * @return Look at {@link InvocationAnnotationDeclarationValidationResult}.
- * @since 0.1
- */
- @NotNull
- public static InvocationAnnotationDeclarationValidationResult isValidInvocationAnnotationDeclaration(
- @NotNull PsiVariable variable )
- {
- PsiAnnotation invocationAnnotation = getInvocationAnnotation( variable );
- if( invocationAnnotation == null )
- {
- return invalidInvocationAnnotationNotDeclared;
- }
-
- PsiModifierList modifierList = variable.getModifierList();
- if( modifierList != null )
- {
- if( modifierList.hasModifierProperty( STATIC ) )
- {
- return invalidDeclaredOnStaticVariable;
- }
- }
-
- // TODO: Check whether variable is either an instance of java.lang.reflect.Method or
- // java.lang.reflect.AnnotatedElement or Annotation
- PsiTypeElement typeElement = variable.getTypeElement();
- if( typeElement != null )
- {
- PsiClass psiClass = getPSIClass( typeElement );
- if( psiClass != null )
- {
- if( !isInjectableByInvocationAnnotation( psiClass ) )
- {
- // Can't be type that is injected by @Structure
- if( isInjecteableByStructureAnnotation( variable ) )
- {
- return invalidTypeIsInjectedViaStructureAnnotation;
- }
-
- return invalidType;
- }
- }
- }
-
- return valid;
- }
-
- public enum InvocationAnnotationDeclarationValidationResult
- {
- invalidInvocationAnnotationNotDeclared,
- invalidDeclaredOnStaticVariable,
- invalidTypeIsInjectedViaStructureAnnotation,
- invalidType,
- valid,
- }
-
- private PolygeneInvocationAnnotationUtil()
- {
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/invocation/inspections/InvocationAnnotationDeclaredCorrectlyInspection.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/invocation/inspections/InvocationAnnotationDeclaredCorrectlyInspection.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/invocation/inspections/InvocationAnnotationDeclaredCorrectlyInspection.java
deleted file mode 100644
index e8dc1d4..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/invocation/inspections/InvocationAnnotationDeclaredCorrectlyInspection.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.injections.invocation.inspections;
-
-import com.intellij.codeInspection.InspectionManager;
-import com.intellij.codeInspection.LocalQuickFix;
-import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.psi.PsiAnnotation;
-import com.intellij.psi.PsiVariable;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.apache.polygene.ide.plugin.idea.injections.common.inspections.AbstractInjectionAnnotationDeclarationOnFieldAndConstructorInspection;
-import org.apache.polygene.ide.plugin.idea.injections.structure.common.ReplaceWithStructureAnnotation;
-
-import static com.intellij.codeInspection.ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
-import static org.apache.polygene.ide.plugin.idea.common.resource.PolygeneResourceBundle.message;
-import static org.apache.polygene.ide.plugin.idea.injections.invocation.common.PolygeneInvocationAnnotationConstants.QUALIFIED_NAME_INVOCATION_ANNOTATION;
-import static org.apache.polygene.ide.plugin.idea.injections.invocation.common.PolygeneInvocationAnnotationUtil.InvocationAnnotationDeclarationValidationResult;
-import static org.apache.polygene.ide.plugin.idea.injections.invocation.common.PolygeneInvocationAnnotationUtil.isValidInvocationAnnotationDeclaration;
-import static org.apache.polygene.ide.plugin.idea.injections.structure.common.PolygeneStructureAnnotationUtil.getStructureAnnotation;
-
-/**
- * {@code InvocationAnnotationDeclaredCorrectlyInspection} validates {@code @Invocation} injection annotation
- * declaration.
- *
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public class InvocationAnnotationDeclaredCorrectlyInspection
- extends AbstractInjectionAnnotationDeclarationOnFieldAndConstructorInspection
-{
- @NotNull
- protected final String resourceBundlePrefixId()
- {
- return "injections.invocation.annotation.declared.correctly";
- }
-
- @NotNull
- public final String getShortName()
- {
- return "InvocationAnnotationDeclaredCorrectlyInspection";
- }
-
- @NotNull
- protected final String getRemoveAnnotationMessageFix()
- {
- return message( "injections.invocation.annotation.declared.correctly.fix.remove.annotation" );
- }
-
- @NotNull
- protected final String getAnnotationToCheckQualifiedName()
- {
- return QUALIFIED_NAME_INVOCATION_ANNOTATION;
- }
-
- @Nullable
- protected final ProblemDescriptor[] verifyAnnotationDeclaredCorrectly( @NotNull PsiVariable psiVariable,
- @NotNull PsiAnnotation invocationAnnotation,
- @NotNull InspectionManager manager )
- {
- LocalQuickFix fix = null;
- String message = null;
-
- String variableTypeQualifiedName = psiVariable.getType().getCanonicalText();
-
- InvocationAnnotationDeclarationValidationResult validationResult =
- isValidInvocationAnnotationDeclaration( psiVariable );
- switch( validationResult )
- {
- case invalidTypeIsInjectedViaStructureAnnotation:
- if( getStructureAnnotation( psiVariable ) == null )
- {
- fix = new ReplaceWithStructureAnnotation(
- message( "injections.invocation.annotation.declared.correctly.fix.replace.with.structure.annotation" ),
- invocationAnnotation );
- }
- message = message(
- "injections.invocation.annotation.declared.correctly.error.type.is.injected.by.structure",
- variableTypeQualifiedName
- );
- break;
-
- case invalidType:
- message = message( "injections.invocation.annotation.declared.correctly.error.type.is.not.injectable",
- variableTypeQualifiedName );
- break;
- }
-
- // If it's not an error, return null
- if( message == null )
- {
- return null;
- }
-
- // If Fix not defined, by default we remove it.
- if( fix == null )
- {
- fix = createRemoveAnnotationFix( invocationAnnotation );
- }
-
- ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
- invocationAnnotation, message, fix, GENERIC_ERROR_OR_WARNING );
- return new ProblemDescriptor[]{ problemDescriptor };
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/service/common/PolygeneServiceAnnotationConstants.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/service/common/PolygeneServiceAnnotationConstants.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/service/common/PolygeneServiceAnnotationConstants.java
deleted file mode 100644
index 5a95513..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/service/common/PolygeneServiceAnnotationConstants.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.injections.service.common;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class PolygeneServiceAnnotationConstants
-{
- public static final String QUALIFIED_NAME_SERVICE_ANNOTATION = "org.apache.polygene.api.injection.scope.Service";
-
- private PolygeneServiceAnnotationConstants()
- {
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/service/common/PolygeneServiceAnnotationUtil.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/service/common/PolygeneServiceAnnotationUtil.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/service/common/PolygeneServiceAnnotationUtil.java
deleted file mode 100644
index 962c1bb..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/service/common/PolygeneServiceAnnotationUtil.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.injections.service.common;
-
-import com.intellij.psi.PsiAnnotation;
-import com.intellij.psi.PsiModifierList;
-import com.intellij.psi.PsiModifierListOwner;
-import com.intellij.psi.PsiVariable;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import static com.intellij.codeInsight.AnnotationUtil.findAnnotation;
-import static com.intellij.psi.PsiModifier.STATIC;
-import static org.apache.polygene.ide.plugin.idea.injections.service.common.PolygeneServiceAnnotationConstants.QUALIFIED_NAME_SERVICE_ANNOTATION;
-import static org.apache.polygene.ide.plugin.idea.injections.service.common.PolygeneServiceAnnotationUtil.ServiceAnnotationDeclarationValidationResult.*;
-import static org.apache.polygene.ide.plugin.idea.injections.structure.common.PolygeneStructureAnnotationUtil.isInjecteableByStructureAnnotation;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class PolygeneServiceAnnotationUtil
-{
- /**
- * Returns {@code @Service} annotation if exists.
- *
- * @param modifierListOwner modifier list owner to process.
- * @return {@code @Service} annotation if exists, {@code null} otherwise.
- * @since 0.1
- */
- @Nullable
- public static PsiAnnotation getServiceAnnotation( @NotNull PsiModifierListOwner modifierListOwner )
- {
- return findAnnotation( modifierListOwner, QUALIFIED_NAME_SERVICE_ANNOTATION );
- }
-
- /**
- * Validates whether the variable has {@code @Service} annotation declared correctly.
- *
- * @param variable variable to check.
- * @return Look at {@link ServiceAnnotationDeclarationValidationResult}.
- * @since 0.1
- */
- @NotNull
- public static ServiceAnnotationDeclarationValidationResult isValidServiceAnnotationDeclaration(
- @NotNull PsiVariable variable )
- {
- PsiAnnotation serviceAnnotation = getServiceAnnotation( variable );
- if( serviceAnnotation == null )
- {
- return invalidServiceAnnotationNotDeclared;
- }
-
- PsiModifierList modifierList = variable.getModifierList();
- if( modifierList != null )
- {
- if( modifierList.hasModifierProperty( STATIC ) )
- {
- return invalidDeclaredOnStaticVariable;
- }
- }
-
- // Can't be type that is injected by @Structure
- if( isInjecteableByStructureAnnotation( variable ) )
- {
- return invalidTypeIsInjectedViaStructureAnnotation;
- }
-
- return valid;
- }
-
- public enum ServiceAnnotationDeclarationValidationResult
- {
- invalidServiceAnnotationNotDeclared,
- invalidDeclaredOnStaticVariable,
- invalidTypeIsInjectedViaStructureAnnotation,
- valid,
- }
-
- private PolygeneServiceAnnotationUtil()
- {
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/service/inspections/ServiceAnnotationDeclaredCorrectlyInspection.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/service/inspections/ServiceAnnotationDeclaredCorrectlyInspection.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/service/inspections/ServiceAnnotationDeclaredCorrectlyInspection.java
deleted file mode 100644
index afc43f1..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/service/inspections/ServiceAnnotationDeclaredCorrectlyInspection.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.injections.service.inspections;
-
-import com.intellij.codeInspection.InspectionManager;
-import com.intellij.codeInspection.LocalQuickFix;
-import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.psi.PsiAnnotation;
-import com.intellij.psi.PsiVariable;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.apache.polygene.ide.plugin.idea.injections.common.inspections.AbstractInjectionAnnotationDeclarationOnFieldAndConstructorInspection;
-import org.apache.polygene.ide.plugin.idea.injections.structure.common.ReplaceWithStructureAnnotation;
-
-import static com.intellij.codeInspection.ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
-import static org.apache.polygene.ide.plugin.idea.common.resource.PolygeneResourceBundle.message;
-import static org.apache.polygene.ide.plugin.idea.injections.service.common.PolygeneServiceAnnotationConstants.QUALIFIED_NAME_SERVICE_ANNOTATION;
-import static org.apache.polygene.ide.plugin.idea.injections.service.common.PolygeneServiceAnnotationUtil.ServiceAnnotationDeclarationValidationResult;
-import static org.apache.polygene.ide.plugin.idea.injections.service.common.PolygeneServiceAnnotationUtil.isValidServiceAnnotationDeclaration;
-import static org.apache.polygene.ide.plugin.idea.injections.structure.common.PolygeneStructureAnnotationUtil.getStructureAnnotation;
-
-/**
- * {@code ServiceAnnotationDeclaredCorrectly} validates {@code @Service} injection annotation declaration.
- *
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public class ServiceAnnotationDeclaredCorrectlyInspection
- extends AbstractInjectionAnnotationDeclarationOnFieldAndConstructorInspection
-{
- @NotNull
- protected final String resourceBundlePrefixId()
- {
- return "injections.service.annotation.declared.correctly";
- }
-
- @NotNull
- public final String getShortName()
- {
- return "ServiceAnnotationDeclaredCorrectlyInspection";
- }
-
- @NotNull
- protected final String getRemoveAnnotationMessageFix()
- {
- return message( "injections.service.annotation.declared.correctly.fix.remove.annotation" );
- }
-
- @NotNull
- protected final String getAnnotationToCheckQualifiedName()
- {
- return QUALIFIED_NAME_SERVICE_ANNOTATION;
- }
-
- @Nullable
- protected final ProblemDescriptor[] verifyAnnotationDeclaredCorrectly( @NotNull PsiVariable psiVariable,
- @NotNull PsiAnnotation serviceAnnotation,
- @NotNull InspectionManager manager )
- {
- ServiceAnnotationDeclarationValidationResult annotationCheck =
- isValidServiceAnnotationDeclaration( psiVariable );
- String message = null;
- LocalQuickFix fix = null;
- switch( annotationCheck )
- {
- case invalidTypeIsInjectedViaStructureAnnotation:
- if( getStructureAnnotation( psiVariable ) == null )
- {
- fix = new ReplaceWithStructureAnnotation(
- message( "injections.service.annotation.declared.correctly.fix.replace.with.structure.annotation" ),
- serviceAnnotation );
- }
- message = message(
- "injections.service.annotation.declared.correctly.error.type.is.injected.by.structure",
- psiVariable.getType().getCanonicalText()
- );
- break;
- }
-
- // If it's not an error, return null
- if( message == null )
- {
- return null;
- }
-
- // Default behavior to remove @Service annotation
- if( fix == null )
- {
- fix = createRemoveAnnotationFix( serviceAnnotation );
- }
-
- ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
- serviceAnnotation, message, fix, GENERIC_ERROR_OR_WARNING );
- return new ProblemDescriptor[]{ problemDescriptor };
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/structure/common/PolygeneStructureAnnotationConstants.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/structure/common/PolygeneStructureAnnotationConstants.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/structure/common/PolygeneStructureAnnotationConstants.java
deleted file mode 100644
index 2a5d3bf..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/structure/common/PolygeneStructureAnnotationConstants.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.polygene.ide.plugin.idea.injections.structure.common;
-
-import static java.util.Arrays.sort;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class PolygeneStructureAnnotationConstants
-{
- public static final String QUALIFIED_NAME_STRUCTURE_ANNOTATION = "org.apache.polygene.api.injection.scope.Structure";
-
- public static final String[] VALID_STRUCTURE_INJECTION_TYPE;
-
- static
- {
- VALID_STRUCTURE_INJECTION_TYPE = new String[]
- {
- "org.apache.polygene.composite.CompositeBuilderFactory",
- "org.apache.polygene.object.ObjectBuilderFactory",
- "org.apache.polygene.entity.UnitOfWorkFactory",
- "org.apache.polygene.service.ServiceFinder",
- "org.apache.polygene.structure.Module",
- "org.apache.polygene.structure.Layer",
- "org.apache.polygene.structure.Application",
- "org.apache.polygene.api.PolygeneAPI",
- "org.apache.polygene.spi.PolygeneSPI"
- };
- sort( VALID_STRUCTURE_INJECTION_TYPE );
- }
-
- private PolygeneStructureAnnotationConstants()
- {
- }
-}